next | previous | forward | backward | up | top | index | toc | Macaulay2 website
SLPexpressions :: evaluating gates

evaluating gates

The standard method value provides a way to evaluate Gates at particular inputs, provided in the form of a ValueHashTable. The results are cached, and thus are not recomputed when called again with the same Gate and ValueHashTable as inputs.

i1 : declareVariable X

o1 = X

o1 : InputGate
i2 : declareVariable Y

o2 = Y

o2 : InputGate
i3 : C = sumGate {X+Y,Y,X}

o3 = ((X + Y) + Y + X)

o3 : SumGate
i4 : D = productGate {X*Y,Y,C}

o4 = ((X * Y) * Y * ((X + Y) + Y + X))

o4 : ProductGate
i5 : h = valueHashTable({X,Y},{1,ii})

o5 = ValueHashTable{...2...}

o5 : ValueHashTable
i6 : v = value(D,h)

o6 = -2-2*ii

o6 : CC (of precision 53)
i7 : v == product{value(X*Y,h),value(Y,h),value(C,h)}

o7 = true

See also