Macaulay2 » Documentation
Packages » SLPexpressions :: cCode
next | previous | forward | backward | up | index | toc

cCode -- generate C code for evaluating a straight-line program

Description

Generates C code for evaluating the straight-line program determined by the output expressions in terms of the specified input variables.

i1 : declareVariable \ {x,y}

o1 = {x, y}

o1 : List
i2 : f = (x+y)^2 - x*y

o2 = (((x + y) * (x + y)) + (-1 * (x * y)))

o2 : SumGate
i3 : cCode({x,y},{f})
void evaluate(const C* x, C* y) {
C X0 = x[0];
C X1 = x[1];
C G0 = X0 + X1;
C G1 = G0 * G0;
C C0 = -1;
C G2 = X0 * X1;
C G3 = C0 * G2;
C G4 = G1 + G3;
y[0] = X0;
y[1] = X1;
}

See also

Ways to use cCode:

  • cCode(GateMatrix,GateMatrix)
  • cCode(List,List)
  • cCode(GateMatrix,GateMatrix,File) (missing documentation)
  • cCode(List,List,File) (missing documentation)

For the programmer

The object cCode is a method function.


The source of this document is in SLPexpressions/doc.m2:151:0.