Unimodular Transformation - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : CodeTools : Program Analysis : Unimodular Transformation

CodeTools[ProgramAnalysis]

  

UnimodularTransformation

  

apply a unimodular transformation to a ForLoop

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

UnimodularTransformation(loop, M)

UnimodularTransformation(loop, M, newvars)

Parameters

loop

-

ForLoop

M

-

unimodular Matrix

newvars

-

(optional) list of symbols, names for the index variables in the returned ForLoop

Description

• 

This command applies a transformation to loop's index variables via the change of coordinates newvars=M·vars, where M is a unimodular matrix,  vars are the index variable(s) in loop, and newvars are the index variable(s) in the resulting transformed ForLoop.  The loop bounds and loop body in loop are updated according to this transformation.

• 

The Matrix M is a square matrix with integer entries whose determinant is +1 or -1.  It must have the same number of rows and columns as there are elements in loop:-variables.

• 

If the optional argument newvars is not supplied, the returned ForLoop will have the same names for its index variable(s) as the original loop, but with the transformation applied.  Otherwise, the returned loop's index variable(s) will have the names in newvars, ordered from the outermost to innermost loops.

Examples

withCodeToolsProgramAnalysis:

Create a ForLoop from the given procedure:

heateq := proc(A, m, n)
    local i1, j1;
    for i1 to m do
        for j1 from i1 + 1 to n do
            A[i1, j1] := A[i1 - 1, j1 - 1] + 2*A[i1 - 1, j1] + A[i1 - 1, j1 + 1] + 3:
        end do:
    end do:
end proc;

heateqprocA,m,nlocali1,j1;fori1tomdoforj1fromi1+1tondoA[i1,j1]A[i11,j11]+2*A[i11,j1]+A[i11,j1+1]+3end doend doend proc

(1)

loopCreateLoopheateq:

Create a unimodular matrix:

UMatrix1,2,2,3:LinearAlgebra:-DeterminantU

−1

(2)

Apply a unimodular transformation to loop so that the returned loop has index variables named i2 and j2:

transformed_loopUnimodularTransformationloop,U,i2,j2:GenerateProceduretransformed_loop

procA,m,nlocali2,j2;fori2from5tomin2*n+m,3*n1doforj2fromceilmax1/2+3/2*i2,2*i2ntofloormin3/2*i2+1/2*m,5/3*i21/3doA[−3*i2+2*j2,2*i2j2]A[−3*i2+2*j21,2*i2j21]+2*A[−3*i2+2*j21,2*i2j2]+A[−3*i2+2*j21,2*i2j2+1]+3end doend do;returnend proc

(3)

The inverse transformation can be applied to generate a ForLoop that is equivalent to the original procedure heateq :

transformed_backUnimodularTransformationtransformed_loop,U1,i1,j1:

GenerateProceduretransformed_back

procA,m,nlocali1,j1;fori1tominm,n1doforj1fromi1+1tondoA[i1,j1]A[i11,j11]+2*A[i11,j1]+A[i11,j1+1]+3end doend do;returnend proc

(4)

The final procedure has a different upper bound on the outer loop than the original, but the two procedures are equivalent.

Compatibility

• 

The CodeTools[ProgramAnalysis][UnimodularTransformation] 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][IterationSpace]

CodeTools[ProgramAnalysis]