CodeTools[ProgramAnalysis] - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : CodeTools : Program Analysis : CodeTools/ProgramAnalysis/IterationSpace

CodeTools[ProgramAnalysis]

  

IterationSpace

  

relations on the index variables of a ForLoop

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

IterationSpace(loop)

Parameters

loop

-

The ForLoop to be analyzed

Description

• 

This command computes the iteration space of the ForLoop loop, which is the set of values for the indices into the arrays over all iterations of loop.  This set is represented as the integer solutions to a list of non-strict inequalities.  The relations are written in terms of the loop's index variables and parameters.

• 

The returned system of inequalities has not been simplified and may represent an empty set for trivial loops.

Examples

withCodeTools[ProgramAnalysis]:

Example usage

Find the possible values of i,j used by the given nested loop, as encoded by a list of inequalities:

p1 := proc(a, b, n)
    local i, j;
    for i from 1 to min(n + 2, 10) do
        for j from i to n + 2 do
            a[i, j] := b[i + 1] + a[i - 1, j - 1]
        end do
    end do
end proc:
loop1 := CreateLoop(p1):
iteration_space1 := IterationSpace(loop1);

iteration_space11i,i10,in+2,ij,jn+2

(1)

Specifying a value for the parameter n, the integer solutions to the given list of inequalities can be computed:

iteration_space1_2subsn=2,iteration_space1:isolveconvertiteration_space1_2,set

i=1,j=1,i=1,j=2,i=1,j=3,i=1,j=4,i=2,j=4,i=3,j=4,i=4,j=4

(2)

These solutions correspond to the values of the loop variables for which the loop's statements will be executed.  Note that the order of solutions returned by isolve will not necessarily match the order of the loop's execution.

Trivial Loop with an Empty Iteration Space

The body of the following loop will never be executed:

p2 := proc(a)
    local i;
    for i from 2 to 1 do
        a[i] := a[i - 1]:
    end do
end proc:
loop2 := CreateLoop(p2):
iteration_space2 := IterationSpace(loop2);

iteration_space22i,i1

(3)

Its iteration space is a list of infeasible inequalities, i.e. there are no solutions for i:

simplex[feasible]iteration_space2

false

(4)

Compatibility

• 

The CodeTools[ProgramAnalysis][IterationSpace] command was introduced in Maple 2016.

• 

For more information on Maple 2016 changes, see Updates in Maple 2016.

See Also

CodeTools[ProgramAnalysis][CreateLoop]

CodeTools[ProgramAnalysis]

isolve

Optimization[LPSolve]

simplex[feasible]