|
Cytnx v1.0.0
|
An Enhanced tensor specifically designed for physical Tensor network simulation. More...
#include <UniTensor.hpp>
Public Member Functions | |
| UniTensor (const Tensor &in_tensor, const bool &is_diag=false, const cytnx_int64 &rowrank=-1, const std::vector< std::string > &in_labels={}, const std::string &name="") | |
| Construct a UniTensor from a cytnx::Tensor. | |
| void | Init (const Tensor &in_tensor, const bool &is_diag=false, const cytnx_int64 &rowrank=-1, const std::vector< std::string > &in_labels={}, const std::string &name="") |
| Initialize a UniTensor from a cytnx::Tensor. | |
| UniTensor (const std::vector< Bond > &bonds, const std::vector< std::string > &in_labels={}, const cytnx_int64 &rowrank=-1, const unsigned int &dtype=Type.Double, const int &device=Device.cpu, const bool &is_diag=false, const std::string &name="") | |
| Construct a UniTensor. | |
| UniTensor & | Init (const std::vector< Bond > &bonds, const std::vector< std::string > &in_labels={}, const cytnx_int64 &rowrank=-1, const unsigned int &dtype=Type.Double, const int &device=Device.cpu, const bool &is_diag=false, const std::string &name="") |
| Initialize the UniTensor with the given arguments. | |
| UniTensor & | set_name_ (const std::string &in) |
| Set the name of a UniTensor, in-place. | |
| UniTensor & | set_name (const std::string &in) |
| UniTensor & | set_label_ (const cytnx_int64 &idx, const std::string &new_label) |
| Set a new label for bond at the assigned index, in-place. | |
| UniTensor & | set_label_ (const cytnx_int64 &idx, const char *new_label) |
| UniTensor & | set_label_ (const std::string &old_label, const std::string &new_label) |
| set a new label for bond to replace one of the current label, in-place. | |
| UniTensor & | set_label_ (const char *old_label, const std::string &new_label) |
| UniTensor & | set_label_ (const std::string &old_label, const char *new_label) |
| UniTensor & | set_label_ (const char *old_label, const char *new_label) |
| UniTensor & | set_label (const cytnx_int64 &idx, const std::string &new_label) |
| UniTensor & | set_label (const cytnx_int64 &idx, const char *new_label) |
| UniTensor & | set_label (const std::string &old_label, const std::string &new_label) |
| UniTensor & | set_label (const char *old_label, const std::string &new_label) |
| UniTensor & | set_label (const std::string &old_label, const char *new_label) |
| UniTensor & | set_label (const char *old_label, const char *new_label) |
| UniTensor & | set_labels (const std::vector< std::string > &new_labels) |
| UniTensor & | set_labels (const std::initializer_list< char * > &new_labels) |
| UniTensor & | set_rowrank_ (const cytnx_uint64 &new_rowrank) |
| Set the rowrank of the UniTensor. | |
| UniTensor | set_rowrank (const cytnx_uint64 &new_rowrank) const |
| template<class T > | |
| T & | item () |
| Scalar::Sproxy | item () const |
| cytnx_uint64 | Nblocks () const |
| Return the number of blocks in the UniTensor. | |
| cytnx_uint64 | rank () const |
| Return the rank of the UniTensor. | |
| cytnx_uint64 | rowrank () const |
| Return the row rank of the UniTensor. | |
| unsigned int | dtype () const |
| Return the data type of the UniTensor. | |
| int | uten_type () const |
| Return the UniTensor type (cytnx::UTenType) of the UniTensor. | |
| bool | is_void () const |
| Return whether the UniTensor is uninitialized. | |
| bool | is_scalar () const |
| whether the UniTensor is an initialized rank-0 scalar UniTensor | |
| cytnx_uint64 | size () const |
| Return the total number of logical elements in the UniTensor. | |
| bool | is_empty () const |
| whether the UniTensor is initialized and has no logical elements | |
| int | device () const |
| Return the device of the UniTensor. | |
| std::string | name () const |
| Return the name of the UniTensor. | |
| std::string | dtype_str () const |
| Return the data type of the UniTensor in 'string' form. | |
| std::string | device_str () const |
| Return the device of the UniTensor in 'string' form. | |
| std::string | uten_type_str () const |
| Return the UniTensor type (cytnx::UTenType) of the UniTensor in 'string' form. | |
| bool | is_contiguous () const |
| To tell whether the UniTensor is contiguous. | |
| bool | is_diag () const |
| To tell whether the UniTensor is in diagonal form. | |
| bool | is_tag () const |
| To tell whether the UniTensor is tagged. That is, all of the Bond in the UniTensor is directional (all of them are bondType.BD_KET or bondType.BD_BRA) | |
| std::vector< Symmetry > | syms () const |
| Return the symmetry type of the UniTensor. | |
| const bool & | is_braket_form () const |
| Check whether the UniTensor is in braket form. | |
| const std::vector< std::string > & | labels () const |
| Return the labels of the UniTensor. | |
| cytnx_int64 | get_index (std::string label) const |
| Get the index of an desired label string. | |
| const std::vector< Bond > & | bonds () const |
| Get the bonds of the UniTensor. | |
| const Bond & | bond_ (const cytnx_uint64 &idx) const |
| Bond & | bond_ (const cytnx_uint64 &idx) |
| const Bond & | bond_ (const std::string &label) const |
| Bond & | bond_ (const std::string &label) |
| Bond | bond (const cytnx_uint64 &idx) const |
| Bond | bond (const std::string &label) const |
| std::vector< cytnx_uint64 > | shape () const |
| Get the shape of the UniTensor. | |
| std::vector< bool > | signflip () const |
| Get the sign information of a fermionic UniTensor. | |
| bool | is_blockform () const |
| Check whether the UniTensor is in block form. | |
| UniTensor & | to_ (const int &device) |
| move the current UniTensor to the assigned device (inplace). | |
| UniTensor | to (const int &device) const |
| move the current UniTensor to the assigned device. | |
| UniTensor | clone () const |
| Clone (deep copy) the UniTensor. | |
| UniTensor & | relabel_ (const std::vector< std::string > &new_labels) |
| Set new labels for all the bonds. | |
| UniTensor & | relabels_ (const std::vector< std::string > &new_labels) |
| UniTensor | relabel (const std::vector< std::string > &new_labels) const |
| relabel all of the labels in UniTensor. | |
| UniTensor | relabels (const std::vector< std::string > &new_labels) const |
| UniTensor | relabel (const std::initializer_list< char * > &new_labels) const |
| relables all of the labels in UniTensor. | |
| UniTensor | relabels (const std::initializer_list< char * > &new_labels) const |
| UniTensor & | relabel_ (const std::initializer_list< char * > &new_labels) |
| UniTensor & | relabels_ (const std::initializer_list< char * > &new_labels) |
| UniTensor | relabel (const std::vector< std::string > &old_labels, const std::vector< std::string > &new_labels) const |
| replace part or all labels by given new labels for the bonds. | |
| UniTensor | relabels (const std::vector< std::string > &old_labels, const std::vector< std::string > &new_labels) const |
| UniTensor & | relabel_ (const std::vector< std::string > &old_labels, const std::vector< std::string > &new_labels) |
| relabel part or all of the labels in UniTensor by given new labels | |
| UniTensor & | relabels_ (const std::vector< std::string > &old_labels, const std::vector< std::string > &new_labels) |
| UniTensor | relabel (const std::initializer_list< char * > &old_labels, const std::initializer_list< char * > &new_labels) const |
| UniTensor | relabels (const std::initializer_list< char * > &old_labels, const std::initializer_list< char * > &new_labels) const |
| UniTensor & | relabel_ (const std::initializer_list< char * > &old_labels, const std::initializer_list< char * > &new_labels) |
| UniTensor & | relabels_ (const std::initializer_list< char * > &old_labels, const std::initializer_list< char * > &new_labels) |
| UniTensor | relabel (const cytnx_int64 &inx, const std::string &new_label) const |
| rebabel the legs in the UniTensor by given index. | |
| UniTensor & | relabel_ (const cytnx_int64 &inx, const std::string &new_label) |
| rebable the legs in the UniTensor by given index. | |
| UniTensor & | relabel_ (const std::string &old_label, const std::string &new_label) |
| relabel the legs in the UniTensor by a given label. | |
| UniTensor | relabel (const std::string &old_label, const std::string &new_label) const |
| relabel the legs in the UniTensor by a given label. | |
| UniTensor | astype (const unsigned int &dtype) const |
| Return a new UniTensor whose elements are casted to a different data type. | |
| UniTensor | permute (const std::vector< cytnx_int64 > &mapper, const cytnx_int64 &rowrank=-1) const |
| permute the legs of the UniTensor | |
| UniTensor | permute (const std::vector< std::string > &mapper, const cytnx_int64 &rowrank=-1) const |
| permute the legs of the UniTensor by labels | |
| UniTensor | permute (const std::initializer_list< char * > &mapper, const cytnx_int64 &rowrank=-1) const |
| UniTensor & | permute_ (const std::vector< cytnx_int64 > &mapper, const cytnx_int64 &rowrank=-1) |
| permute the legs of the UniTensor, inplacely. | |
| UniTensor & | permute_ (const std::vector< std::string > &mapper, const cytnx_int64 &rowrank=-1) |
| permute the legs of the UniTensor, inplacely. | |
| UniTensor | permute_nosignflip (const std::vector< cytnx_int64 > &mapper, const cytnx_int64 &rowrank=-1) const |
| permute the legs of the UniTensor without sign flips | |
| UniTensor | permute_nosignflip (const std::vector< std::string > &mapper, const cytnx_int64 &rowrank=-1) const |
| permute the legs of the UniTensor by labels without sign flips | |
| UniTensor | permute_nosignflip (const std::initializer_list< char * > &mapper, const cytnx_int64 &rowrank=-1) const |
| UniTensor & | permute_nosignflip_ (const std::vector< cytnx_int64 > &mapper, const cytnx_int64 &rowrank=-1) |
| permute the legs of the UniTensor without fermionic sign flips, inplacely. | |
| UniTensor & | permute_nosignflip_ (const std::vector< std::string > &mapper, const cytnx_int64 &rowrank=-1) |
| permute the legs of the UniTensor without fermionic sign flips, inplacely. | |
| UniTensor | twist (const std::string &label) const |
| Apply a twist (or braids/self-swap) operation to a given bond; No effect for bosonic tensors; for a fermionic tensor, this means that a signflip occurs for all blocks where the bond has odd fermion parity. | |
| UniTensor | twist (const cytnx_int64 &idx) const |
| Apply a twist (or braids/self-swap) operation to a given bond; No effect for bosonic tensors; for a fermionic tensor, this means that a signflip occurs for all blocks where the bond has odd fermion parity. | |
| UniTensor & | twist_ (const std::string &label) |
| Inline version. | |
| UniTensor & | twist_ (const cytnx_int64 &idx) |
| Inline version. | |
| UniTensor | fermion_twists () const |
| Apply twists to all right bonds (>= rowrank) with bond type BD_KET. | |
| UniTensor & | fermion_twists_ () |
| Inline version. | |
| UniTensor | contiguous () const |
| Make the UniTensor contiguous by coalescing the memory (storage). | |
| UniTensor & | contiguous_ () |
| Make the UniTensor contiguous by coalescing the memory (storage), inplacely. | |
| UniTensor | apply () const |
| Apply fermionic signflips to the UniTensor, such that all elements calling signflip() on the output tensor will result in all elements to be false. | |
| UniTensor & | apply_ () |
| Apply fermionic signflips to the UniTensor, inplacely. Subsequently, all elements returned by signflip() are false. | |
| void | print_diagram (const bool &bond_info=false) const |
| Plot the diagram of the UniTensor. | |
| void | print_blocks (const bool &full_info=true) const |
| Print all blocks of the UniTensor. | |
| void | print_block (const cytnx_int64 &idx, const bool &full_info=true) const |
| Print out the block of the UniTensor with a given block index number. | |
| UniTensor & | group_basis_ () |
| Group the same quantum number basis together. | |
| UniTensor | group_basis () const |
| template<class T > | |
| T & | at (const std::vector< cytnx_uint64 > &locator) |
| Get an element at a specific location. | |
| template<class T > | |
| const T & | at (const std::vector< cytnx_uint64 > &locator) const |
| Get an element at a specific location. | |
| template<class T > | |
| const T & | at (const std::vector< std::string > &labels, const std::vector< cytnx_uint64 > &locator) const |
| template<class T > | |
| T & | at (const std::vector< std::string > &labels, const std::vector< cytnx_uint64 > &locator) |
| const Scalar::Sproxy | at (const std::vector< cytnx_uint64 > &locator) const |
| Get an element at a specific location. | |
| Scalar::Sproxy | at (const std::vector< cytnx_uint64 > &locator) |
| Get an element at a specific location. | |
| Scalar::Sproxy | at (const std::vector< std::string > &labels, const std::vector< cytnx_uint64 > &locator) |
| const Scalar::Sproxy | at (const std::vector< std::string > &labels, const std::vector< cytnx_uint64 > &locator) const |
| Tensor | get_block (const cytnx_uint64 &idx=0) const |
| Get the block of the UniTensor for a given block index. | |
| Tensor | get_block (const std::vector< cytnx_int64 > &qidx, const bool &force=false) const |
| Get the block of the UniTensor for the given quantun indices. | |
| Tensor | get_block (const std::vector< std::string > &labels, const std::vector< cytnx_int64 > &qidx, const bool &force=false) const |
| Tensor | get_block (const std::initializer_list< cytnx_int64 > &qnum, const bool &force=false) const |
| Tensor | get_block (const std::vector< cytnx_uint64 > &qnum, const bool &force=false) const |
| Tensor | get_block (const std::vector< std::string > &labels, const std::vector< cytnx_uint64 > &qidx, const bool &force=false) const |
| const Tensor & | get_block_ (const cytnx_uint64 &idx=0) const |
| Get the shared view of the block for the given block index. | |
| Tensor & | get_block_ (const cytnx_uint64 &idx=0) |
| Tensor & | get_block_ (const std::vector< cytnx_int64 > &qidx, const bool &force=false) |
| Get the shared view of the block for the given quantum indices. | |
| Tensor | get_block_ (const std::vector< std::string > &labels, const std::vector< cytnx_int64 > &qidx, const bool &force=false) |
| Get the shared (data) view of the block for the given quantum indices on given labels. | |
| Tensor & | get_block_ (const std::initializer_list< cytnx_int64 > &qidx, const bool &force=false) |
| Tensor & | get_block_ (const std::vector< cytnx_uint64 > &qidx, const bool &force=false) |
| Tensor | get_block_ (const std::vector< std::string > &labels, const std::vector< cytnx_uint64 > &qidx, const bool &force=false) |
| const Tensor & | get_block_ (const std::vector< cytnx_int64 > &qidx, const bool &force=false) const |
| const Tensor & | get_block_ (const std::initializer_list< cytnx_int64 > &qidx, const bool &force=false) const |
| const Tensor & | get_block_ (const std::vector< cytnx_uint64 > &qidx, const bool &force=false) const |
| std::vector< Tensor > | get_blocks () const |
| Get all the blocks of the UniTensor. | |
| const std::vector< Tensor > & | get_blocks_ (const bool &silent=false) const |
| Get all the blocks of the UniTensor, inplacely. | |
| std::vector< Tensor > & | get_blocks_ (const bool &silent=false) |
| UniTensor & | put_block (const Tensor &in, const cytnx_uint64 &idx=0) |
| Put the block into the UniTensor with given index. | |
| UniTensor & | put_block (const Tensor &in, const cytnx_uint64 &idx, const bool &force) |
| UniTensor & | put_block (const Tensor &in_tens, const std::vector< cytnx_int64 > &qidx) |
| Put the block into the UniTensor with given quantum number. | |
| UniTensor & | put_block (const Tensor &in_tens, const std::vector< cytnx_int64 > &qidx, const bool &force) |
| UniTensor & | put_block (Tensor &in, const std::vector< std::string > &lbls, const std::vector< cytnx_int64 > &qidx) |
| Put the block into the UniTensor with given quantum indices, will copy the input tensor. | |
| UniTensor & | put_block (Tensor &in, const std::vector< std::string > &lbls, const std::vector< cytnx_int64 > &qidx, const bool &force) |
| UniTensor & | put_block_ (Tensor &in, const cytnx_uint64 &idx=0) |
| Put the block into the UniTensor with given index, inplacely. | |
| UniTensor & | put_block_ (Tensor &in, const std::vector< cytnx_int64 > &qidx) |
| Put the block into the UniTensor with given quantum indices, inplacely. | |
| UniTensor & | put_block_ (Tensor &in, const std::vector< cytnx_int64 > &qidx, const bool &force) |
| UniTensor & | put_block_ (Tensor &in, const std::vector< std::string > &lbls, const std::vector< cytnx_int64 > &qidx) |
| Put the block into the UniTensor with given quantum indices, inplacely. | |
| UniTensor & | put_block_ (Tensor &in, const std::vector< std::string > &lbls, const std::vector< cytnx_int64 > &qidx, const bool &force) |
| UniTensor | get (const std::vector< Accessor > &accessors) const |
| get elements using Accessor (C++ API) / slices (python API) | |
| UniTensor | operator[] (const std::vector< cytnx::Accessor > &accessors) const |
| get elements using Accessor (C++ API) / slices (python API) | |
| UniTensor | operator[] (const std::initializer_list< cytnx::Accessor > &accessors) const |
| UniTensor | operator[] (const std::vector< cytnx_int64 > &accessors) const |
| UniTensor | operator[] (const std::initializer_list< cytnx_int64 > &accessors) const |
| UniTensor & | set (const std::vector< Accessor > &accessors, const Tensor &rhs) |
| set elements using Accessor (C++ API) / slices (python API) | |
| UniTensor & | set (const std::vector< Accessor > &accessors, const UniTensor &rhs) |
| UniTensor | reshape (const std::vector< cytnx_int64 > &new_shape, const cytnx_uint64 &rowrank=0) |
| Reshape the UniTensor. | |
| UniTensor & | reshape_ (const std::vector< cytnx_int64 > &new_shape, const cytnx_uint64 &rowrank=0) |
| Reshape the UniTensor, inplacely. | |
| UniTensor | to_dense () |
| Convert the UniTensor to non-diagonal form. | |
| UniTensor & | to_dense_ () |
| Convert the UniTensor to non-diagonal form, inplacely. | |
| void | combineBonds (const std::vector< cytnx_int64 > &indicators, const bool &force, const bool &by_label) |
| void | combineBonds (const std::vector< std::string > &indicators, const bool &force=false) |
| void | combineBonds (const std::vector< cytnx_int64 > &indicators, const bool &force=false) |
| UniTensor & | combineBond_ (const std::vector< std::string > &indicators, const bool &force=false) |
| Combine the sevral bonds of the UniTensor, in-place. | |
| UniTensor | combineBond (const std::vector< std::string > &indicators, const bool &force=false) const |
| Combine the sevral bonds of the UniTensor, out-of-place. | |
| UniTensor | contract (const UniTensor &inR, const bool &mv_elem_self=false, const bool &mv_elem_rhs=false) const |
| Contract the UniTensor with common labels. | |
| bool | same_data (const UniTensor &rhs) const |
| Check whether the Blocks address are the same. | |
| UniTensor & | Add_ (const UniTensor &rhs) |
| The addition function of the UniTensor. | |
| UniTensor & | Mul_ (const UniTensor &rhs) |
| The multiplcation function of the UniTensor. | |
| UniTensor & | Sub_ (const UniTensor &rhs) |
| The subtraction function of the UniTensor. | |
| UniTensor & | Div_ (const UniTensor &rhs) |
| The division function of the UniTensor. | |
| UniTensor & | Add_ (const Scalar &rhs) |
| The addition function for a given scalar. | |
| UniTensor & | Mul_ (const Scalar &rhs) |
| The multiplication function for a given scalar. | |
| UniTensor & | Sub_ (const Scalar &rhs) |
| The subtraction function for a given scalar. | |
| UniTensor & | Div_ (const Scalar &rhs) |
| The division function for a given scalar. | |
| UniTensor | Add (const UniTensor &rhs) const |
| The addition function of the UniTensor. | |
| UniTensor | Add (const Scalar &rhs) const |
| The addition function for a given scalar. | |
| UniTensor | Mul (const UniTensor &rhs) const |
| The multiplication function of the UniTensor. | |
| UniTensor | Mul (const Scalar &rhs) const |
| The multiplication function for a given scalar. | |
| UniTensor | Div (const UniTensor &rhs) const |
| The division function of the UniTensor. | |
| UniTensor | Div (const Scalar &rhs) const |
| The division function for a given scalar. | |
| UniTensor | Sub (const UniTensor &rhs) const |
| The subtraction function of the UniTensor. | |
| UniTensor | Sub (const Scalar &rhs) const |
| The subtraction function for a given scalar. | |
| Tensor | Norm () const |
| Return the norm of the UniTensor. | |
| Scalar | norm () const |
| Return the norm of the UniTensor. | |
| UniTensor & | operator+= (const UniTensor &rhs) |
| The addition assignment operator of the UniTensor. | |
| UniTensor & | operator-= (const UniTensor &rhs) |
| The subtraction assignment operator of the UniTensor. | |
| UniTensor & | operator/= (const UniTensor &rhs) |
| The division assignment operator of the UniTensor. | |
| UniTensor & | operator*= (const UniTensor &rhs) |
| The multiplication assignment operator of the UniTensor. | |
| UniTensor & | operator+= (const Scalar &rhs) |
| The addition assignment operator for a given scalar. | |
| UniTensor & | operator-= (const Scalar &rhs) |
| The subtraction assignment operator for a given scalar. | |
| UniTensor & | operator/= (const Scalar &rhs) |
| The division assignment operator for a given scalar. | |
| UniTensor & | operator*= (const Scalar &rhs) |
| The multiplication assignment operator for a given scalar. | |
| UniTensor | Inv (double clip=-1.) const |
| Element-wise (pseudo-)inverse. | |
| UniTensor & | Inv_ (double clip=-1.) |
| Element-wise (pseudo-)inverse, inplacely. | |
| UniTensor | Conj () const |
| Apply complex conjugate on each entry of the UniTensor. | |
| UniTensor & | Conj_ () |
| Apply complex conjugate on each entry of the UniTensor. | |
| UniTensor | Transpose () const |
| Take the transpose of the UniTensor. | |
| UniTensor & | Transpose_ () |
| Take the transpose of the UniTensor, inplacely. | |
| UniTensor | normalize () const |
| normalize the current UniTensor instance with 2-norm. | |
| UniTensor & | normalize_ () |
| normalize the UniTensor, inplacely. | |
| UniTensor | Trace (const std::string &a, const std::string &b) const |
| Take the partial trace of the UniTensor. | |
| UniTensor | Trace (const cytnx_int64 &a=0, const cytnx_int64 &b=1) const |
| Take the partial trace of the UniTensor. | |
| UniTensor & | Trace_ (const std::string &a, const std::string &b) |
| Take the partial trace of the UniTensor, inplacely. | |
| UniTensor & | Trace_ (const cytnx_int64 &a=0, const cytnx_int64 &b=1) |
| Take the partial trace of the UniTensor, inplacely. | |
| UniTensor | Dagger () const |
| Take the conjugate transpose to the UniTensor. | |
| UniTensor & | Dagger_ () |
| Take the conjugate transpose to the UniTensor, inplacely. | |
| UniTensor & | tag_ () |
| Set the UniTensor as a tagged UniTensor, in-place. | |
| UniTensor & | tag () |
| UniTensor | Pow (const double &p) const |
Take the power p of all elements. | |
| UniTensor & | Pow_ (const double &p) |
Take the power p of all elements, inplacely. | |
| bool | elem_exists (const std::vector< cytnx_uint64 > &locator) const |
| Given the locator, check if the element exists. | |
| template<class T > | |
| T | get_elem (const std::vector< cytnx_uint64 > &locator) const |
| template<class T2 > | |
| UniTensor & | set_elem (const std::vector< cytnx_uint64 > &locator, const T2 &rc) |
| void | Save (const std::string &fname) const |
| save a UniTensor to file | |
| void | Save (const char *fname) const |
| save a UniTensor to file | |
| UniTensor & | truncate_ (const std::string &label, const cytnx_uint64 &dim) |
| truncate bond dimension of the UniTensor by the given bond label and dimension. | |
| UniTensor & | truncate_ (const cytnx_int64 &bond_idx, const cytnx_uint64 &dim) |
| truncate bond dimension of the UniTensor by the given bond index and dimension. | |
| UniTensor | truncate (const std::string &label, const cytnx_uint64 &dim) const |
| truncate bond dimension of the UniTensor by the given bond label and dimension. | |
| UniTensor | truncate (const cytnx_int64 &bond_idx, const cytnx_uint64 &dim) const |
| truncate bond dimension of the UniTensor by the given bond index and dimension. | |
| const std::vector< cytnx_uint64 > & | get_qindices (const cytnx_uint64 &bidx) const |
| get the q-indices on each leg for the [bidx]-th block | |
| std::vector< cytnx_uint64 > & | get_qindices (const cytnx_uint64 &bidx) |
| get the q-indices on each leg for the [bidx]-th block | |
| const vec2d< cytnx_uint64 > & | get_itoi () const |
| get the q-indices on each leg for all the blocks | |
| vec2d< cytnx_uint64 > & | get_itoi () |
| UniTensor & | convert_from_ (const UniTensor &rhs, bool force=false, cytnx_double tol=0.) |
| Copy data from a UniTensor of different type, in-place. | |
| UniTensor & | convert_from (const UniTensor &rhs, bool force=false, cytnx_double tol=0.) |
| UniTensor & | normal_ (const double &mean, const double &std, const unsigned int &seed=cytnx::random::__static_random_device()) |
| Generate a one-bond UniTensor with all elements are random numbers sampled from a normal (Gaussian) distribution, inplacely. | |
| UniTensor & | uniform_ (const double &low=0, const double &high=1, const unsigned int &seed=cytnx::random::__static_random_device()) |
| Generate a UniTensor with all elements are random numbers sampled from a uniform distribution, inplacely. | |
Static Public Member Functions | |
| static UniTensor | Load (const std::string &fname) |
| load a UniTensor from file | |
| static UniTensor | Load (const char *fname) |
| load a UniTensor from file | |
| static UniTensor | zeros (const std::vector< cytnx_uint64 > &shape, const std::vector< std::string > &in_labels={}, unsigned int dtype=Type.Double, int device=Device.cpu, const std::string &name="") |
| Generate a UniTensor with all elements set to zero. | |
| static UniTensor | zeros (std::initializer_list< cytnx_uint64 > shape, const std::vector< std::string > &in_labels={}, unsigned int dtype=Type.Double, int device=Device.cpu, const std::string &name="") |
| static UniTensor | identity (cytnx_uint64 dim, const std::vector< std::string > &in_labels={}, cytnx_bool is_diag=false, unsigned int dtype=Type.Double, int device=Device.cpu, const std::string &name="") |
| Generate an identity UniTensor with two bonds. | |
| static UniTensor | eye (cytnx_uint64 dim, const std::vector< std::string > &in_labels={}, cytnx_bool is_diag=false, unsigned int dtype=Type.Double, int device=Device.cpu, const std::string &name="") |
| Generate a 2-bond identity UniTensor. | |
| static UniTensor | ones (const std::vector< cytnx_uint64 > &shape, const std::vector< std::string > &in_labels={}, unsigned int dtype=Type.Double, int device=Device.cpu, const std::string &name="") |
| Generate a UniTensor with all elements set to one. | |
| static UniTensor | ones (std::initializer_list< cytnx_uint64 > shape, const std::vector< std::string > &in_labels={}, unsigned int dtype=Type.Double, int device=Device.cpu, const std::string &name="") |
| static UniTensor | arange (cytnx_int64 Nelem, const std::vector< std::string > &in_labels={}, const std::string &name="") |
| Create a rank-1 UniTensor with incremental unsigned integer elements in the range [0,Nelem). | |
| static UniTensor | arange (cytnx_double start, cytnx_double end, cytnx_double step=1, const std::vector< std::string > &in_labels={}, unsigned int dtype=Type.Double, int device=Device.cpu, const std::string &name="") |
Create a rank-1 UniTensor with incremental elements in the range [start,end) with given step-size step between elements. | |
| static UniTensor | linspace (cytnx_double start, cytnx_double end, cytnx_uint64 Nelem, bool endpoint=true, const std::vector< std::string > &in_labels={}, unsigned int dtype=Type.Double, int device=Device.cpu, const std::string &name="") |
| Generate a one-bond UniTensor with all elements are evenly spaced numbers over a specified interval. | |
| static UniTensor | normal (const cytnx_uint64 &Nelem, const double &mean, const double &std, const std::vector< std::string > &in_labels={}, const unsigned int &seed=cytnx::random::__static_random_device(), const unsigned int &dtype=Type.Double, const int &device=Device.cpu, const std::string &name="") |
| Generate a one-bond UniTensor with all elements are random numbers sampled from a normal (Gaussian) distribution. | |
| static UniTensor | normal (const std::vector< cytnx_uint64 > &shape, const double &mean, const double &std, const std::vector< std::string > &in_labels={}, const unsigned int &seed=cytnx::random::__static_random_device(), const unsigned int &dtype=Type.Double, const int &device=Device.cpu, const std::string &name="") |
| Generate a UniTensor with all elements are random numbers sampled from a normal (Gaussian) distribution. | |
| static UniTensor | uniform (const cytnx_uint64 &Nelem, const double &low, const double &high, const std::vector< std::string > &in_labels={}, const unsigned int &seed=cytnx::random::__static_random_device(), const unsigned int &dtype=Type.Double, const int &device=Device.cpu, const std::string &name="") |
| Generate a one-bond UniTensor with all elements are random numbers sampled from a uniform distribution. | |
| static UniTensor | uniform (const std::vector< cytnx_uint64 > &shape, const double &low, const double &high, const std::vector< std::string > &in_labels={}, const unsigned int &seed=cytnx::random::__static_random_device(), const unsigned int &dtype=Type.Double, const int &device=Device.cpu, const std::string &name="") |
| Generate a UniTensor with all elements are random numbers sampled from a uniform distribution. | |
An Enhanced tensor specifically designed for physical Tensor network simulation.
|
inlineexplicit |
Construct a UniTensor from a cytnx::Tensor.
| [in] | in_tensor | a cytnx::Tensor |
| [in] | is_diag | whether the input Tensor in_tensor is a diagonal Tensor; this requires the input in_tensor to be 1D. |
| [in] | rowrank | the rowrank of the resulting UniTensor |
-----------------------
tensor Name :
tensor Rank : 2
block_form : false
is_diag : False
on device : cytnx device: CPU
-------------
/ \
0 ____| 4 |
| |
1 ____| 4 |
\ /
-------------
before:
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
-------- start of print ---------
Tensor name:
Tensor name:
is_diag : False
contiguous : True
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
after:
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
-------- start of print ---------
Tensor name:
Tensor name:
is_diag : False
contiguous : True
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
[non-share example]
before:
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
-------- start of print ---------
Tensor name:
Tensor name:
is_diag : False
contiguous : True
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
after
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
-------- start of print ---------
Tensor name:
Tensor name:
is_diag : False
contiguous : True
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 2.34500e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
-----------------------
tensor Name :
tensor Rank : 2
block_form : false
is_diag : False
on device : cytnx device: CPU
--------
/ \
0 ____| 4 |
| |
1 ____| 4 |
\ /
--------
before:
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
-------- start of print ---------
Tensor name:
Tensor name:
is_diag : False
contiguous : True
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
after
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
-------- start of print ---------
Tensor name:
Tensor name:
is_diag : False
contiguous : True
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
[non-share example]
before:
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
-------- start of print ---------
Tensor name:
Tensor name:
is_diag : False
contiguous : True
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
after
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
-------- start of print ---------
Tensor name:
Tensor name:
is_diag : False
contiguous : True
Total elem: 16
type : Double (Float64)
cytnx device: CPU
Shape : (4,4)
[[1.45600e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 2.34500e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]
[0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 ]]
|
inline |
Construct a UniTensor.
| [in] | bonds | the bond list. Each bond will be deep copy( not a shared view of bond object with input bond) |
| [in] | in_labels | the labels for each rank(bond) |
| [in] | rowrank | the rank of physical row space. |
| [in] | dtype | the data type of the UniTensor. It can be any type defined in cytnx::Type. |
| [in] | device | the device that the UniTensor is put on. It can be any device defined in cytnx::Device. |
| [in] | is_diag | if the constructed UniTensor is a diagonal UniTensor. This can only be assigned true when the UniTensor is square and rank-2 UniTensor. The UniTensor must have one in-bond and one out-bond. |
The addition function for a given scalar.
Given the scalar rhs, it will perform the addition for each element in UniTensor with this scalar rhs.
| [in] | rhs | a scalar you want to add in the UniTensor. |
The addition function of the UniTensor.
This is addition function of the UniTensor. Given the UniTensor \( UT_2\) as the argument, it will return a new UniTensor
\[ UT = UT_{self} + UT_2 \]
Perform element-wise addition of two UniTensor.
| [in] | rhs | The UniTensor you want to add by. |
The addition function for a given scalar.
Given the Scalar rhs, it will perform the addition for each element in UniTensor with this Scalar rhs.
| [in] | rhs | a Scalar you want to add in the UniTensor. |
The addition function of the UniTensor.
This is addition function of the UniTensor. Given the UniTensor \( UT_2\) as the argument, it will return
\[ UT_{self} = UT_{self} + UT_2 \]
Perform element-wise addition of two UniTensor.
| [in] | rhs | The UniTensor you want to add by. |
|
inline |
Apply fermionic signflips to the UniTensor, such that all elements calling signflip() on the output tensor will result in all elements to be false.
|
inline |
Apply fermionic signflips to the UniTensor, inplacely. Subsequently, all elements returned by signflip() are false.
|
inlinestatic |
Create a rank-1 UniTensor with incremental elements in the range [start,end) with given step-size step between elements.
The elements are start, start + step, start + 2 * step, ... The last element is the largest one that is smaller than end.
| [in] | start | start value of the range. |
| [in] | end | end value of the range (exclusive). |
| [in] | step | step-size between subsequent elements in the range. |
| [in] | in_labels | the label of the UniTensor. |
| [in] | dtype | the data type of the UniTensor, see cytnx::Type for more information. |
| [in] | device | the device type of the UniTensor, see cytnx::Device for more information. |
| [in] | name | the name of the UniTensor. |
|
inlinestatic |
Create a rank-1 UniTensor with incremental unsigned integer elements in the range [0,Nelem).
The elements are 0, 1, 2, ..., Nelem - 1.
| [in] | Nelem | number of incremental elements. |
| [in] | in_labels | the label of the UniTensor. |
| [in] | name | the name of the UniTensor. |
|
inline |
Get an element at a specific location.
| [in] | locator | the location of the element we want to access. |
|
inline |
Get an element at a specific location.
see more information at user guide 6.3.5.
|
inline |
Get an element at a specific location.
| [in] | locator | the location of the element we want to access. |
|
inline |
Get an element at a specific location.
see more information at user guide 6.3.5.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the bonds of the UniTensor.
|
inline |
|
inline |
Combine the sevral bonds of the UniTensor, out-of-place.
| [in] | indicators | the labels of the legs you want to combine. |
| [in] | force | If force is true, it will combine the bonds anyway even the direction of the bonds are same. After combining, the direction of the bonds will be set as same as the first bond. |
indicators need to >= 2.
|
inline |
Combine the sevral bonds of the UniTensor, in-place.
| [in] | indicators | the labels of the legs you want to combine. |
| [in] | force | If force is true, it will combine the bonds anyway even the direction of the bonds are same. After combining, the direction of the bonds will be set as same as the first bond. |
indicators need to >= 2.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Make the UniTensor contiguous by coalescing the memory (storage).
|
inline |
Make the UniTensor contiguous by coalescing the memory (storage), inplacely.
|
inline |
Contract the UniTensor with common labels.
This function contract the UniTensor legs with common labels.
| [in] | inR | The UniTensor you want to contract with. |
| [in] | mv_elem_self | Whether the self UniTensor need to do contiguous() after the contraction. |
| [in] | mv_elem_rhs | Whether the rhs UniTensor inR need to do contiguous() after the contraction. |
|
inline |
|
inline |
Copy data from a UniTensor of different type, in-place.
For example, if uTB is a BlockUniTensor and uTD is a DenseUniTensor of the same shape, then uTD.convert_from_(uTB) makes uTD a sparse copy of uTB.
| [in] | rhs | the UniTensor to copy from |
| [in] | force | if true, the compatibility of the input and output tensor structure is not checked strictly; elements that do not exist in the output tensor are ignored in the input tensor, even if they are not zero or small. |
| [in] | tol | applies if a denser UniTensor is converted to a sparser tensor structure; if an element in the output tensor does not exist, the absolute value of the element in the input tensor has to be <= tol. Otherwise an error is thrown. This is overwritten by force = true. |
|
inline |
|
inline |
|
inline |
|
inline |
The division function for a given scalar.
Given the scalar rhs, it will perform the division for each element in UniTensor with this scalar rhs.
| [in] | rhs | a scalar you want to divide in the UniTensor. |
The division function of the UniTensor.
This is division function of the UniTensor. Given the UniTensor \( UT_2\) as the argument, it will return a new UniTensor
\[ UT = UT_{self} / UT_2 \]
Perform element-wise division of two UniTensor.
| [in] | rhs | the divisor |
The division function for a given scalar.
Given the scalar rhs, it will perform the division for each element in UniTensor with this scalar rhs.
| [in] | rhs | a scalar you want to divide in the UniTensor. |
The division function of the UniTensor.
This is division function of the UniTensor. Given the UniTensor \( UT_2\) as the argument, it will return
\[ UT_{self} = UT_{self} / UT_2 \]
Perform element-wise division of two UniTensor.
| [in] | rhs | the divisor |
|
inline |
|
inline |
Given the locator, check if the element exists.
| [in] | locator | the locator of the element. |
locator).exists().
|
inlinestatic |
Generate a 2-bond identity UniTensor.
| [in] | dim | the dimension of the diagnal. |
| [in] | in_labels | the two labels of the UniTensor. |
| [in] | is_diag | determine if the UniTensor is diagonal or not. Default is false. |
| [in] | dtype | the data type of the UniTensor, see cytnx::Type for more information. |
| [in] | device | the device type of the UniTensor, see cytnx::Device for more information. |
| [in] | name | the name of the UniTensor. |
|
inline |
Apply twists to all right bonds (>= rowrank) with bond type BD_KET.
For bosonic tensors, nothing changes. For fermions, this makes sure that bra- and ket-states can be contracted correctly. For example, a scalar product <A|B> between ket states A and B represented by fermionic tensors with incoming and outgoing legs, can be calculated correctly by contract(Adag.fermion_twists_(), B). This example asumes that Adag is the dagger of A and has rowrank=0, while B has maximal rowrank. Applying fermion_twists_ to B would have no effect in this case and is thus safe to do. Similarly, this can be applied to linear operators. If M is an operator, then its first rowrank indices correspond to ket bonds and are not affected by fermion_twists_. For the remaining bonds, a twist is applied if they are not of type BD_BRA. The combination of this method to bra states, ket states and linear operators in a Hilbert space, together with contractions, ensures that scalar products can be executed as desired.
|
inline |
Inline version.
get elements using Accessor (C++ API) / slices (python API)
| [in] | accessors | the Accessor (C++ API) / slices (python API) to get the elements. |
|
inline |
Get the block of the UniTensor for a given block index.
| [in] | idx | the index of the block we want to get |
|
inline |
Get the block of the UniTensor for the given quantun indices.
| [in] | qidx | input the quantum indices you want to get the corresponding block. |
| [in] | force | If force is true, it will return the tensor anyway (Even the corresponding block is empty, it will return void type tensor if force is set as true. Otherwise, it will trow the exception.) |
|
inline |
|
inline |
|
inline |
|
inline |
Get the shared view of the block for the given block index.
| [in] | idx | input the index you want to get the corresponding block |
|
inline |
Get the shared view of the block for the given quantum indices.
| [in] | qidx | input the quantum indices you want to get the corresponding block. |
| [in] | force | If force is true, it will return the tensor anyway (Even the corresponding block is empty, it will return void type tensor if force is set as true. Otherwise, it will trow the exception.) |
|
inline |
Get the shared (data) view of the block for the given quantum indices on given labels.
| [in] | labels | the labels of the bonds. |
| [in] | qidx | input the quantum indices you want to get the corresponding block. |
| [in] | force | If force is true, it will return the tensor anyway (Even the corresponding block is empty, it will return void type tensor if force is set as true. Otherwise, it will trow the exception.) |
qidx[i] qnum at Bond labels[i]. Also note that the return Tensor will have axes in the same order specified by labels.
|
inline |
|
inline |
Get all the blocks of the UniTensor.
get_blocks will return the blocks of the UniTensor. Furthermore,
For non-symmetric UniTensor, it will return the deep copy of blocks.
|
inline |
Get all the blocks of the UniTensor, inplacely.
| [in] | silent | whether need to print out the warning messages. |
|
inline |
|
inline |
Get the index of an desired label string.
| label | Label you want to find |
|
inline |
|
inline |
get the q-indices on each leg for all the blocks
|
inline |
get the q-indices on each leg for the [bidx]-th block
| bidx | the bidx-th block in current block list. |
|
inline |
get the q-indices on each leg for the [bidx]-th block
| bidx | the bidx-th block in current block list. |
|
inline |
|
inline |
|
inlinestatic |
Generate an identity UniTensor with two bonds.
| [in] | dim | the dimension of the diagnal. |
| [in] | in_labels | the two labels of the UniTensor. |
| [in] | is_diag | determine if the UniTensor is diagonal or not. Default is false. |
| [in] | dtype | the data type of the UniTensor, see cytnx::Type for more information. |
| [in] | device | the device type of the UniTensor, see cytnx::Device for more information. |
| [in] | name | the name of the UniTensor. |
|
inline |
Initialize the UniTensor with the given arguments.
This is the initial function of the UniTensor. If you want to initialize your UniTensor after declaring just a 'void' UniTensor. You can use this function to initialize it.
| [in] | bonds | the bond list. Each bond will be deep copy( not a shared view of bond object with input bond) |
| [in] | in_labels | the labels for each rank(bond) |
| [in] | rowrank | the rank of physical row space |
| [in] | dtype | the dtype of the UniTensor. It can be any type defined in cytnx::Type. |
| [in] | device | the device that the UniTensor is put on. It can be any device defined in cytnx::Device. |
| [in] | is_diag | if the constructed UniTensor is a diagonal UniTensor. This can only be assigned true when the UniTensor is square, untagged and rank-2 UniTensor. |
| [in] | name | user specified name of the UniTensor. |
bonds should be all symmetric or non-symmetric. You cannot mix them.
|
inline |
Initialize a UniTensor from a cytnx::Tensor.
| [in] | in_tensor | a cytnx::Tensor |
| [in] | is_diag | whether the input Tensor in_tensor is a diagonal Tensor. this requires the input in_tensor to be 1D. |
| [in] | rowrank | the rowrank of the resulting UniTensor. |
| [in] | name | user-specified name of the UniTensor. |
Element-wise (pseudo-)inverse.
This function performs an element-wise inverse with clip. If \( |T_\text{in}[i]| \le \mathrm{clip} \), then the new element is set to zero.
\[ T_\text{out}[i] = \left\{ \begin{array}{ll} 1/(T_\text{in}[i]) & \mathrm{if} \ |T_\text{in}[i]| > \mathrm{clip} \\ 0 & \mathrm{otherwise} \end{array} \right. \]
| [in] | clip | elmements with absolute value <= clip are set to zero, corresponding to the pseudo-inverse; default: -1 (no clipping) |
Element-wise (pseudo-)inverse, inplacely.
This function performs an element-wise inverse with clip. If \( |T_\text{in}[i]| \le \mathrm{clip} \), then the new element is set to zero.
\[ T_\text{in}[i] \rightarrow \left\{ \begin{array}{ll} 1/(T_\text{in}[i]) & \mathrm{if} \ |T_\text{in}[i]| > \mathrm{clip} \\ 0 & \mathrm{otherwise} \end{array} \right. \]
| [in] | clip | elmements with absolute value <= clip are set to zero, corresponding to the pseudo-inverse; default: -1 (no clipping) |
|
inline |
Check whether the UniTensor is in block form.
This function will check whether the UniTensor is in block form. That is, the uten_type() is UTenType::Block.
|
inline |
|
inline |
To tell whether the UniTensor is in diagonal form.
|
inline |
whether the UniTensor is initialized and has no logical elements
|
inline |
|
inline |
To tell whether the UniTensor is tagged. That is, all of the Bond in the UniTensor is directional (all of them are bondType.BD_KET or bondType.BD_BRA)
|
inline |
Return whether the UniTensor is uninitialized.
|
inline |
|
inline |
Return the labels of the UniTensor.
|
inlinestatic |
Generate a one-bond UniTensor with all elements are evenly spaced numbers over a specified interval.
Generate a UniTensor with all elements are evenly spaced numbers over a specified interval. The interval is [start, end] and the number of elements is Nelem.
| [in] | start | the start of the linspace. |
| [in] | end | the end of the linspace. |
| [in] | Nelem | the number of elements. |
| [in] | endpoint | if endpoint is true, the end of linspace is end, else the end of linspace is end - step. |
| [in] | in_labels | the labels of the UniTensor. |
| [in] | dtype | the data type of the UniTensor, see cytnx::Type for more information. |
| [in] | device | the device type of the UniTensor, see cytnx::Device for more information. |
| [in] | name | the name of the UniTensor. |
load a UniTensor from file
| [in] | fname | the file name |
load a UniTensor from file
| [in] | fname | the file name |
The multiplication function for a given scalar.
Given the scalar rhs, it will perform the multiplication for each element in UniTensor with this scalar rhs.
| [in] | rhs | a scalar you want to multiply in the UniTensor. |
The multiplication function of the UniTensor.
This is multiplication function of the UniTensor. Given the UniTensor \( UT_2\) as the argument, it will return a new UniTensor
\[ UT = UT_{self} \times UT_2 \]
Perform element-wise multiplcation of two UniTensor.
| [in] | rhs | The UniTensor you want to multiplicate by. |
The multiplication function for a given scalar.
Given the scalar rhs, it will perform the multiplication for each element in UniTensor with this scalar rhs.
| [in] | rhs | a scalar you want to multiplicate in the UniTensor. |
The multiplcation function of the UniTensor.
This is multiplcation function of the UniTensor. Given the UniTensor \( UT_2\) as the argument, it will return
\[ UT_{self} = UT_{self} \times UT_2 \]
Perform element-wise multiplication of two UniTensor.
| [in] | rhs | The UniTensor you want to multiplcate by. |
|
inline |
Return the name of the UniTensor.
|
inline |
Return the number of blocks in the UniTensor.
|
inline |
|
inline |
Return the norm of the UniTensor.
norm() return the 2-norm of the UniTensor \(UT\) as a Scalar carrying the UniTensor's own precision (Float for Float/ComplexFloat input, Double otherwise), so x /= x.norm() stays dtype-preserving rather than promoting a Float UniTensor to Double.
\[ ||UT||_2 \]
|
static |
Generate a one-bond UniTensor with all elements are random numbers sampled from a normal (Gaussian) distribution.
Generate a UniTensor with all elements are random numbers sampled from a normal (Gaussian) distribution. The mean is mean and the standard deviation is std.
| [in] | Nelem | the number of elements. |
| [in] | mean | the mean of the normal distribution. |
| [in] | std | the standard deviation of the normal distribution. |
| [in] | in_labels | the labels of the UniTensor. |
| [in] | seed | the seed of the random generator. |
| [in] | dtype | the data type of the UniTensor, see cytnx::Type for more information. |
| [in] | device | the device type of the UniTensor, see cytnx::Device for more information. |
| [in] | name | the name of the UniTensor. |
|
static |
Generate a UniTensor with all elements are random numbers sampled from a normal (Gaussian) distribution.
Generate a UniTensor with all elements are random numbers sampled from a normal (Gaussian) distribution. The mean is mean and the standard deviation is std.
| [in] | shape | the shape of the UniTensor. |
| [in] | mean | the mean of the normal distribution. |
| [in] | std | the standard deviation of the normal distribution. |
| [in] | in_labels | the labels of the UniTensor. |
| [in] | seed | the seed of the random generator. |
| [in] | dtype | the data type of the UniTensor, see cytnx::Type for more information. |
| [in] | device | the device type of the UniTensor, see cytnx::Device for more information. |
| [in] | name | the name of the UniTensor. |
| UniTensor & cytnx::UniTensor::normal_ | ( | const double & | mean, |
| const double & | std, | ||
| const unsigned int & | seed = cytnx::random::__static_random_device() |
||
| ) |
Generate a one-bond UniTensor with all elements are random numbers sampled from a normal (Gaussian) distribution, inplacely.
This function provides an inplacely way to generate a UniTensor with all elements are random numbers sampled from a normal (Gaussian) distribution. The mean is mean and the standard deviation is std.
| [in] | mean | the mean of the normal distribution. |
| [in] | std | the standard deviation of the normal distribution. |
| [in] | seed | the seed of the random generator. |
|
inline |
normalize the current UniTensor instance with 2-norm.
|
inline |
normalize the UniTensor, inplacely.
|
inlinestatic |
Generate a UniTensor with all elements set to one.
| [in] | shape | the shape of the UniTensor. |
| [in] | in_labels | the labels of the UniTensor. |
| [in] | dtype | the data type of the UniTensor, see cytnx::Type for more information. |
| [in] | device | the device type of the UniTensor, see cytnx::Device for more information. |
| [in] | name | the name of the UniTensor. |
|
inlinestatic |
|
inline |
The multiplication assignment operator for a given scalar.
Given the scalar rhs, it will perform the multiplication for each element in UniTensor with this scalar rhs.
| [in] | rhs | a scalar you want to multiply in the UniTensor. |
|
inline |
The multiplication assignment operator of the UniTensor.
This is multiplication assignment operator of the UniTensor. It will perform element-wise multiplication and return
\[ UT *= UT_R \]
| [in] | rhs | The UniTensor you want to multilicate by. |
|
inline |
The addition assignment operator for a given scalar.
Given the scalar rhs, it will perform the addition for each element in UniTensor with this scalar rhs.
| [in] | rhs | a scalar you want to add in the UniTensor. |
|
inline |
The addition assignment operator of the UniTensor.
This is addition assignment operator of the UniTensor. It will perform element-wise addition and return
\[ UT += UT_R \]
| [in] | rhs | The UniTensor you want to add by. |
|
inline |
The subtraction assignment operator for a given scalar.
Given the scalar rhs, it will perform the subtraction for each element in UniTensor with this scalar rhs.
| [in] | rhs | the subtrahend |
|
inline |
The subtraction assignment operator of the UniTensor.
This is subtraction assignment operator of the UniTensor. It will perform element-wise subtraction and return
\[ UT -= UT_R \]
| [in] | rhs | the subtrahend |
|
inline |
The division assignment operator for a given scalar.
Given the scalar rhs, it will perform the division for each element in UniTensor with this scalar rhs.
| [in] | rhs | the divisor |
|
inline |
The division assignment operator of the UniTensor.
This is division assignment operator of the UniTensor. It will perform element-wise division and return
\[ UT /= UT_R \]
| [in] | rhs | the divisor |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
permute the legs of the UniTensor, inplacely.
| [in] | mapper | the mapper of the permutation by labels |
| [in] | rowrank | the row rank after the permutation |
|
inline |
|
inline |
|
inline |
permute the legs of the UniTensor without sign flips
The indices are permuted, but no fermionic sign flips occur. Use with care! This is usually not intended, since fermionic permutations create sign flips! This should typically only be used to compare tensors in different sign conventions with each other.
| [in] | mapper | the mapper of the permutation by indices |
| [in] | rowrank | the new rowrank after the permutation |
|
inline |
permute the legs of the UniTensor by labels without sign flips
The indices are permuted, but no fermionic sign flips occur. Use with care! This is usually not intended, since fermionic permutations create sign flips! This should typically only be used to compare tensors in different sign conventions with each other.
| [in] | mapper | the mapper of the permutation by labels |
| [in] | rowrank | the row rank |
|
inline |
permute the legs of the UniTensor without fermionic sign flips, inplacely.
The indices are permuted, but no fermionic sign flips occur. Use with care! This is usually not intended, since fermionic permutations create sign flips! This should typically only be used to compare tensors in different sign conventions with each other.
| [in] | mapper | the mapper of the permutation by indices |
| [in] | rowrank | the row rank after the permutation |
|
inline |
permute the legs of the UniTensor without fermionic sign flips, inplacely.
The indices are permuted, but no fermionic sign flips occur. Use with care! This is usually not intended, since fermionic permutations create sign flips! This should typically only be used to compare tensors in different sign conventions with each other.
| [in] | mapper | the mapper of the permutation by labels |
| [in] | rowrank | the row rank after the permutation |
Take the power p of all elements.
\[ T_\text{out}[i] = (T_\text{in}[i])^p \]
| [in] | p | the power to take |
p must be an integer. p < 0 an inverse has to be taken. If elements could be zero (or close to it), use Inv(double clip) const for a pseudo-inverse instead. Take the power p of all elements, inplacely.
\[ T_\text{in}[i] \rightarrow (T_\text{in}[i])^p \]
| [in] | p | the power to take |
p must be an integer. p < 0 an inverse has to be taken. If elements could be zero (or close to it), use Inv_(double clip) for a pseudo-inverse instead.
|
inline |
Print out the block of the UniTensor with a given block index number.
| [in] | idx | the input index |
| [in] | full_info | whether need to print the full information of the block |
Print all blocks of the UniTensor.
| [in] | full_info | whether need to print the full information of the blocks |
|
inline |
|
inline |
Put the block into the UniTensor with given index.
| [in] | in | the block you want to put into UniTensor |
| [in] | in | the index of the UniTensor you want to put the block in in. |
|
inline |
Put the block into the UniTensor with given quantum number.
| [in] | in_tens | the block you want to put into UniTensor |
| [in] | qidx | the quantum indices of the UniTensor you want to put the block in_tens in. |
|
inline |
|
inline |
Put the block into the UniTensor with given quantum indices, will copy the input tensor.
|
inline |
|
inline |
Put the block into the UniTensor with given index, inplacely.
|
inline |
Put the block into the UniTensor with given quantum indices, inplacely.
|
inline |
|
inline |
Put the block into the UniTensor with given quantum indices, inplacely.
|
inline |
|
inline |
Return the rank of the UniTensor.
|
inline |
rebabel the legs in the UniTensor by given index.
This function will relabel the legs in the UniTensor by a given index. This function will return a new UniTensor with the new label, but the data is still shared with the original UniTensor (that is if you use same_data() to check, it will return true). Compared to set_label(), this function will return a new UniTensor object with different meta data.
| [in] | inx | a given index |
| [in] | new_label | the new label of the UniTensor in the index inx |
|
inline |
relables all of the labels in UniTensor.
|
inline |
relabel the legs in the UniTensor by a given label.
This function will relabel the legs in the UniTensor by a given label. This function will return a new UniTensor with the new label, but the data is still shared with the original UniTensor (that is if you use same_data() to check, it will return true). Compared to set_label(), this function will return a new UniTensor object with different meta data.
| [in] | old_label | original label you want to replace |
| [in] | new_label | the new label |
|
inline |
replace part or all labels by given new labels for the bonds.
| [in] | old_labels | the old labels for each bond. |
| [in] | new_labels | the new labels for each bond. |
|
inline |
|
inline |
Set new labels for all the bonds.
| [in] | new_labels | the new labels for each bond. |
|
inline |
relabel part or all of the labels in UniTensor by given new labels
| [in] | old_labels | the old labels for each bond. |
| [in] | new_labels | the new labels for each bond. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return the row rank of the UniTensor.
Check whether the Blocks address are the same.
save a UniTensor to file
Save a UniTensor to file. The file extension will be extended as '.cytnx'
| [in] | fname | the file name (exclude the file extension). |
save a UniTensor to file
Save a UniTensor to file. The file extension will be extended as '.cytnx'
| [in] | fname | the file name (exclude the file extension). |
|
inline |
set elements using Accessor (C++ API) / slices (python API)
| [in] | accessors | the Accessor (C++ API) / slices (python API) to set the elements. |
| [in] | rhs | the tensor containing the values to set. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Set a new label for bond at the assigned index, in-place.
| [in] | idx | the index of the bond. |
| [in] | new_label | the new label that is assign to the bond. |
|
inline |
set a new label for bond to replace one of the current label, in-place.
| [in] | old_label | the current label of the bond. |
| [in] | new_label | the new label that is assign to the bond. |
|
inline |
|
inline |
|
inline |
|
inline |
Get the shape of the UniTensor.
|
inline |
|
inline |
The subtraction function for a given scalar.
Given the scalar rhs, it will perform the subtraction for each element in UniTensor with this scalar rhs.
| [in] | rhs | the subtrahend |
The subtraction function of the UniTensor.
This is subtraction function of the UniTensor. Given the UniTensor \( UT_2\) as the argument, it will return a new UniTensor
\[ UT = UT_{self} - UT_2 \]
Perform element-wise subtraction of two UniTensor.
| [in] | rhs | the subtrahend |
The subtraction function for a given scalar.
Given the scalar rhs, it will perform the subtraction for each element in UniTensor with this scalar rhs.
| [in] | rhs | a scalar you want to subtract in the UniTensor. |
The subtraction function of the UniTensor.
This is subtraction function of the UniTensor. Given the UniTensor \( UT_2\) as the argument, it will return
\[ UT_{self} = UT_{self} - UT_2 \]
Perform element-wise subtraction of two UniTensor.
| [in] | rhs | the subtrahend |
|
inline |
|
inline |
|
inline |
Set the UniTensor as a tagged UniTensor, in-place.
This function will set the untagged UniTensor(all of the Bonds are BondType::BD_REG) ) to tagged UniTensor (all of the Bonds are BondType::BD_BRA or BondType::BD_KET). And it will change the UniTensor to bra-ket form. See is_braket_form() for more information.
move the current UniTensor to the assigned device.
| [in] | device | the device-id(cytnx::Device) that is moving to. It can by any device defined in cytnx::Device. |
move the current UniTensor to the assigned device (inplace).
| [in] | device | the device-id(cytnx::Device) that is moving to. It can by any device defined in cytnx::Device. |
|
inline |
Convert the UniTensor to non-diagonal form.
Converts a UniTensor with is_diag = true to one with is_diag = false by expanding each block into a (diagonal) matrix.
is_diag = false), the input is returned. So every manipulation on the returned tensor will change the input tensor. Call clone() on the result if an independent copy is required.
|
inline |
Convert the UniTensor to non-diagonal form, inplacely.
|
inline |
|
inline |
|
inline |
Take the transpose of the UniTensor.
This function takes the transpose of a UniTensor: 1) The order of the indices is inverted. 2) Incoming legs become outgoing ones, and vice versa. 3) The rowrank is set to rank - old rowrank, such that left indices become right indices and vice versa.
|
inline |
Take the transpose of the UniTensor, inplacely.
|
inline |
truncate bond dimension of the UniTensor by the given bond index and dimension.
| [in] | bond_idx | the bond index. |
| [in] | dim | the dimension to be truncated. |
|
inline |
truncate bond dimension of the UniTensor by the given bond label and dimension.
| [in] | label | the bond label. |
| [in] | dim | the dimension to be truncated. |
|
inline |
truncate bond dimension of the UniTensor by the given bond index and dimension.
| [in] | bond_idx | the bond index. |
| [in] | dim | the dimension to be truncated. |
|
inline |
truncate bond dimension of the UniTensor by the given bond label and dimension.
| [in] | label | the bond label. |
| [in] | dim | the dimension to be truncated. |
|
inline |
Apply a twist (or braids/self-swap) operation to a given bond; No effect for bosonic tensors; for a fermionic tensor, this means that a signflip occurs for all blocks where the bond has odd fermion parity.
| [in] | idx | bond index on which the twist shall be applied |
Apply a twist (or braids/self-swap) operation to a given bond; No effect for bosonic tensors; for a fermionic tensor, this means that a signflip occurs for all blocks where the bond has odd fermion parity.
| [in] | label | bond label on which the twist shall be applied |
|
inline |
Inline version.
| [in] | idx | bond index on which the twist shall be applied |
Inline version.
| [in] | label | bond label on which the twist shall be applied |
|
static |
Generate a one-bond UniTensor with all elements are random numbers sampled from a uniform distribution.
Generate a UniTensor with all elements are random numbers sampled from a uniform distribution. The low bound is low and the high bound is high.
| [in] | Nelem | the number of elements. |
| [in] | low | the low bound of the uniform distribution. |
| [in] | high | the high bound of the uniform distribution. |
| [in] | in_labels | the labels of the UniTensor. |
| [in] | seed | the seed of the random generator. |
| [in] | dtype | the data type of the UniTensor, see cytnx::Type for more information. |
| [in] | device | the device type of the UniTensor, see cytnx::Device for more information. |
| [in] | name | the name of the UniTensor. |
|
static |
Generate a UniTensor with all elements are random numbers sampled from a uniform distribution.
Generate a UniTensor with all elements are random numbers sampled from a uniform distribution. The low bound is low and the high bound is high.
| [in] | shape | the shape of the UniTensor. |
| [in] | low | the low bound of the uniform distribution. |
| [in] | high | the high bound of the uniform distribution. |
| [in] | in_labels | the labels of the UniTensor. |
| [in] | seed | the seed of the random generator. |
| [in] | dtype | the data type of the UniTensor, see cytnx::Type for more information. |
| [in] | device | the device type of the UniTensor, see cytnx::Device for more information. |
| [in] | name | the name of the UniTensor. |
Generate a UniTensor with all elements are random numbers sampled from a uniform distribution.
Generate a UniTensor with all elements are random numbers sampled from a uniform distribution. The low bound is low and the high bound is high.
| [in] | shape | the shape of the UniTensor. |
| [in] | low | the low bound of the uniform distribution. |
| [in] | high | the high bound of the uniform distribution. |
| [in] | in_labels | the labels of the UniTensor. |
| [in] | seed | the seed of the random generator. |
| [in] | dtype | the data type of the UniTensor, see cytnx::Type for more information. |
| [in] | device | the device type of the UniTensor, see cytnx::Device for more information. |
| [in] | name | the name of the UniTensor. |
| UniTensor & cytnx::UniTensor::uniform_ | ( | const double & | low = 0, |
| const double & | high = 1, |
||
| const unsigned int & | seed = cytnx::random::__static_random_device() |
||
| ) |
Generate a UniTensor with all elements are random numbers sampled from a uniform distribution, inplacely.
This function provides an inplacely way to generate a UniTensor with all elements are random numbers sampled from a uniform distribution. The low bound is low and the high bound is high.
| [in] | low | the low bound of the uniform distribution. |
| [in] | high | the high bound of the uniform distribution. |
| [in] | seed | the seed of the random generator. |
|
inline |
Return the UniTensor type (cytnx::UTenType) of the UniTensor.
The function return the UniTensor type of the UniTensor.
|
inline |
Return the UniTensor type (cytnx::UTenType) of the UniTensor in 'string' form.
|
inlinestatic |
Generate a UniTensor with all elements set to zero.
| [in] | shape | the shape of the UniTensor. |
| [in] | in_labels | the labels of the UniTensor. |
| [in] | dtype | the data type of the UniTensor, see cytnx::Type for more information. |
| [in] | device | the device type of the UniTensor, see cytnx::Device for more information. |
| [in] | name | the name of the UniTensor. |
|
inlinestatic |