symmray.flat.flat_vector

Block vector class with flat backend.

Classes

FlatVector

Class for storing block vectors with flat storage, e.g. for the

Module Contents

class symmray.flat.flat_vector.FlatVector(sectors, blocks)[source]

Bases: symmray.flat.flat_data_common.FlatCommon, symmray.vector_common.VectorCommon, symmray.common.SymmrayCommon

Class for storing block vectors with flat storage, e.g. for the singular- or eigen- values of a matrix.

This is equivalent to the diagonal of a zero charge abelian matrix.

Parameters:
  • sectors (array_like) – The vector of charges, with shape (num_blocks,).

  • blocks (array_like) – The stack of vectors, with shape (num_blocks, charge_subsize).

__slots__ = ('_blocks', '_sectors', 'backend')
classmethod from_blocks(blocks)[source]

Create a flat vector from a dictionary of blocks.

Parameters:

blocks (dict) – Dictionary mapping sector (charge) to block (array).

classmethod from_blockvector(blockvector)[source]

Create a flat backend vector from a sparse backend BlockVector.

Parameters:

blockvector (BlockVector) – The BlockVector to convert.

to_blockvector()[source]

Convert to a sparse backend BlockVector.

classmethod from_fill_fn(fill_fn, sectors, charge_size)[source]

Create a flat vector by filling blocks using a function that takes a shape and returns an array.

Parameters:
  • fill_fn (callable) – Function that takes a shape tuple and returns an array of that shape.

  • sectors (array_like or int or str) – The vector of charges, with shape (num_blocks,). If an integer is given, it is assumed to be Z{N} symmetry and the sectors are set to range(N). If a string is given, it is assumed to be of the form “ZN” for some integer N.

  • charge_size (int) – The size of each charge block.

  • like (str or array_like, optional)

classmethod rand(sectors, charge_size, dist='normal', seed=None, like='numpy')[source]
property size

The total size of all elements in the vector.

property shape: tuple[int, Ellipsis]

Get the effective shape of the vector.

copy(deep=False) FlatVector[source]
copy_with(sectors=None, blocks=None) FlatVector[source]

Create a copy of the vector with some attributes replaced. Note that checks are not performed on the new properties, this is intended for internal use.

modify(sectors=None, blocks=None)[source]

Modify the vector in place with some attributes replaced. Note that checks are not performed on the new properties, this is intended for internal use.

check()[source]
sort_stack(inplace=False)[source]

Sort the sectors and associated blocks in ascending order of charge.

_binary_blockwise_op(other, fn, missing=None, inplace=False)[source]
to_dense()[source]
__repr__()[source]