Canonicalization
            oqd_trical.light_matter.compiler.canonicalize
¶
    
            PruneOperator
¶
    
              Bases: RewriteRule
Prunes an Operator AST by removing zeros
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
                
            PruneZeroPowers
¶
    
              Bases: RewriteRule
Prunes a MathExpr AST by MathPow when base is zero
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
                
              
            OperatorDistributivity
¶
    
              Bases: RewriteRule
Implements distributivity of addition over multiplication, kronecker product and scalar multiplication
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
                
            OperatorAssociativity
¶
    
              Bases: RewriteRule
Implements associativity of addition, multiplication and kronecker product
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
                
            GatherCoefficient
¶
    
              Bases: RewriteRule
Gathers the coefficients of an operator into a single scalar multiplication for each term
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
                
            CoefficientDistributivity
¶
    
              Bases: RewriteRule
Implements distributivity of addition over multiplication on coefficient
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
                
            CoefficientAssociativity
¶
    
              Bases: RewriteRule
Implements associativity of addition, multiplication on coefficient
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
                
            ScaleTerms
¶
    
              Bases: RewriteRule
Adds a scalar multiplication for each term if it does not exist
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
                
            _CombineTermsHelper
¶
    
              Bases: RewriteRule
Helper for combining terms of the same operator by combining their coefficients
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
                
            CombineTerms
¶
    
              Bases: RewriteRule
Combines terms of the same operator by combining their coefficients
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
                
            PartitionMathExpr
¶
    
              Bases: RewriteRule
This separates real and complex portions of [MathExpr][oqd_core.interface.math.MathExpr] objects.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
                model
             | 
            
                  MathExpr
             | 
            
               The rule only acts on [  | 
            required | 
Returns:
| Name | Type | Description | 
|---|---|---|
model |             
                  MathExpr
             | 
            
               | 
          
Assumptions
[DistributeMathExpr][oqd_core.compiler.math.rules.DistributeMathExpr],
[ProperOrderMathExpr][oqd_core.compiler.math.rules.ProperOrderMathExpr]
Example
- MathStr(string = '1 + 1j + 2') => MathStr(string = '1 + 2 + 1j')
 - MathStr(string = '1 * 1j * 2') => MathStr(string = '1j * 1 * 2')
 
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
                
            canonicalize_math_factory()
¶
    Creates a new instance of the canonicalization pass for math expressions
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
              
            canonicalize_coefficient_factory()
¶
    Creates a new instance of the canonicalization pass for coefficients
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
              
            canonicalize_operator_factory()
¶
    Creates a new instance of the canonicalization pass for operators
Source code in src\oqd_trical\light_matter\compiler\canonicalize.py
              
            
            canonicalize_emulator_circuit_factory()
¶
    Creates a new instance of the canonicalization pass for AtomicEmulatorCircuit