| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Circuit.Affine
Description
Definition of arithmetic circuits that only contain addition, scalar multiplications and constant gates, along with its direct evaluation and translation into affine maps.
Synopsis
- data AffineCircuit i f
- = Add (AffineCircuit i f) (AffineCircuit i f)
- | ScalarMul f (AffineCircuit i f)
- | ConstGate f
- | Var i
- collectInputsAffine :: Ord i => AffineCircuit i f -> [i]
- mapVarsAffine :: (i -> j) -> AffineCircuit i f -> AffineCircuit j f
- evalAffineCircuit :: Num f => (i -> vars -> Maybe f) -> vars -> AffineCircuit i f -> f
- affineCircuitToAffineMap :: (Num f, Ord i) => AffineCircuit i f -> (f, Map i f)
- evalAffineMap :: (Num f, Ord i) => (f, Map i f) -> Map i f -> f
- dotProduct :: (Num f, Ord i) => Map i f -> Map i f -> f
Documentation
data AffineCircuit i f Source #
Arithmetic circuits without multiplication, i.e. circuits describe affine transformations.
Constructors
| Add (AffineCircuit i f) (AffineCircuit i f) | |
| ScalarMul f (AffineCircuit i f) | |
| ConstGate f | |
| Var i |
Instances
collectInputsAffine :: Ord i => AffineCircuit i f -> [i] Source #
mapVarsAffine :: (i -> j) -> AffineCircuit i f -> AffineCircuit j f Source #
Apply mapping to variable names, i.e. rename variables. (Ideally the mapping is injective.)
Arguments
| :: Num f | |
| => (i -> vars -> Maybe f) | lookup function for variable mapping |
| -> vars | variables |
| -> AffineCircuit i f | circuit to evaluate |
| -> f |
Evaluate the arithmetic circuit without mul-gates on the given input. Variable map is assumed to have all the variables referred to in the circuit. Failed lookups are currently treated as 0.
affineCircuitToAffineMap Source #
Arguments
| :: (Num f, Ord i) | |
| => AffineCircuit i f | circuit to translate |
| -> (f, Map i f) | constant part and non-constant part |
Convert non-mul circuit to a vector representing the evaluation
function. We use a Map to represent the potentially sparse vector.
Arguments
| :: (Num f, Ord i) | |
| => (f, Map i f) | program split into constant and non-constant part |
| -> Map i f | input variables |
| -> f |
Evaluating the affine map representing the arithmetic circuit without mul-gates against inputs. If the input map does not have a variable that is referred to in the affine map, then it is treated as a 0.