pygsti.baseobjs.basisconstructors.VectorBasisConstructor#
- class VectorBasisConstructor(longname, vectorgen_fn, labelgen_fn, real)#
Bases:
objectA factory class for constructing builtin basis types whose elements are vectors.
- Parameters:
longname (str) – The long name for the builtin basis.
vectorgen_fn (function) – A function that generates the vector elements for this basis given the vector dimension.
labelgen_fn (function) – A function that generates the element labels for this basis given the vector dimension.
real (bool) – Whether vectors expressed in this basis are required to have real components.
Create a new VectorBasisConstructor:
- Parameters:
longname (str) – The long name for the builtin basis.
vectorgen_fn (function) – A function that generates the vector elements for this basis given the vector dimension.
labelgen_fn (function) – A function that generates the element labels for this basis given the vector dimension.
real (bool) – Whether vectors expressed in this basis are required to have real components.
Methods
__init__(longname, vectorgen_fn, ...)Create a new VectorBasisConstructor:
constructor(dim, sparse)Get the elements of a basis to be constructed.
labeler(dim, sparse)Get the labels of a basis to be constructed.
sizes(dim, sparse)Get some relevant sizes/dimensions for constructing a basis.
- constructor(dim, sparse)#
Get the elements of a basis to be constructed.
- Parameters:
dim (int) – The vector-space dimension of the basis.
sparse (bool) – Whether the basis is sparse or not.
- Return type:
list of basis elements
- labeler(dim, sparse)#
Get the labels of a basis to be constructed.
- Parameters:
dim (int) – The vector-space dimension of the basis.
sparse (bool) – Whether the basis is sparse or not.
- Return type:
list of labels (strs)
- sizes(dim, sparse)#
Get some relevant sizes/dimensions for constructing a basis.
This function is needed for constructing Basis objects because these objects want to know the size & dimension of a basis without having to construct the (potentially large) set of elements.
- Parameters:
dim (int) – The vector-space dimension of the basis. e.g. 4 for a basis of 2x2 matrices and 2 for a basis of length=2 vectors.
sparse (bool) – Whether the basis is sparse or not.
- Returns:
nElements (int) – The number of elements in the basis.
dim (int) – The vector-space dimension of the basis.
elshape (tuple) – The shape of the elements that might be constructed (if constructor was called).