mm.physics.ansatze.PolyExpBase¶
- class mrmustard.physics.ansatze.PolyExpBase(mat, vec, array)[source]¶
Bases:
Ansatz
A family of Ansatze parametrized by a triple of a matrix, a vector and an array. For example, the Bargmann representation \(c\:\textrm{exp}(z A z / 2 + b z)\) is of this form (where
A
,b
,c
is the triple), or the Wigner representation (whereSigma
,mu
,1
is the triple).Note that this class is not initializable (despite having an initializer) because it does not implement all the abstract methods of
Ansatz
, and it is in fact more general. Concrete ansatze that inherit from this class need to implement__call__
,__mul__
and__matmul__
, which are representation-specific.Note that the arguments are expected to be batched, i.e. to have a batch dimension or to be an iterable. This is because this class also provides the linear superposition functionality by implementing the
__add__
method, which concatenates the batch dimensions.As this can blow up the number of terms in the representation, it is recommended to run the simplify() method after adding terms together, which combines together terms that have the same exponential part.
- Parameters:
mat (
Batch
[ndarray
[Tuple
[int
,int
],Union
[TypeVar
(R
,float16
,float32
,float64
),TypeVar
(C
,complex64
,complex128
),TypeVar
(Z
,int16
,int32
,int64
),TypeVar
(N
,uint16
,uint32
,uint64
)]]]) – the matrix-like datavec (
Batch
[ndarray
[Tuple
[int
],Union
[TypeVar
(R
,float16
,float32
,float64
),TypeVar
(C
,complex64
,complex128
),TypeVar
(Z
,int16
,int32
,int64
),TypeVar
(N
,uint16
,uint32
,uint64
)]]]) – the vector-like dataarray (
Batch
[ndarray
[Tuple
[int
,...
],Union
[TypeVar
(R
,float16
,float32
,float64
),TypeVar
(C
,complex64
,complex128
),TypeVar
(Z
,int16
,int32
,int64
),TypeVar
(N
,uint16
,uint32
,uint64
)]]]) – the array-like data
Attributes
Methods
__call__
(point)Evaluates this ansatz at a given point in the domain.
simplify
()Simplifies the representation by combining together terms that have the same exponential part, i.e. two terms along the batch are considered equal if their matrix and vector are equal.
A different implementation of
simplify
that orders the batch dimension first.- abstract __call__(point)¶
Evaluates this ansatz at a given point in the domain.
- Return type:
Union
[TypeVar
(R
,float16
,float32
,float64
),TypeVar
(C
,complex64
,complex128
),TypeVar
(Z
,int16
,int32
,int64
),TypeVar
(N
,uint16
,uint32
,uint64
)]
- simplify()[source]¶
Simplifies the representation by combining together terms that have the same exponential part, i.e. two terms along the batch are considered equal if their matrix and vector are equal. In this case only one is kept and the arrays are added.
Does not run if the representation has already been simplified, so it is safe to call.
- Return type:
None