|
Cytnx v0.9.1
|
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 with 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. | |
| void | 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 the UniTensor. | |
| UniTensor & | set_label (const cytnx_int64 &idx, const std::string &new_label) |
| Set a new label for bond at the assigned index. | |
| 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. | |
| 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) |
| Set new labels for all the bonds. | |
| UniTensor & | set_labels (const std::initializer_list< char * > &new_labels) |
| UniTensor & | set_rowrank (const cytnx_uint64 &new_rowrank) |
| Set the row rank of the UniTensor. | |
| 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. | |
| 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 lbl) const |
| Get the index of an desired label string. | |
| const std::vector< Bond > & | bonds () const |
| Get the bonds of the UniTensor. | |
| std::vector< Bond > & | bonds () |
| std::vector< cytnx_uint64 > | shape () const |
| Get the shape of the UniTensor. | |
| bool | is_blockform () const |
| Check whether the UniTensor is in block form. | |
| void | 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. | |
| void | relabels_ (const std::vector< std::string > &new_labels) const |
| Set new labels for all the bonds. | |
| UniTensor | relabels (const std::vector< std::string > &new_labels) const |
| rebables all of the labels in UniTensor. | |
| UniTensor | relabels (const std::initializer_list< char * > &new_lbls) const |
| void | relabels_ (const std::initializer_list< char * > &new_lbls) |
| UniTensor | relabel (const cytnx_int64 &inx, const std::string &new_label) const |
| rebable the lags in the UniTensor by given index. | |
| void | relabel_ (const cytnx_int64 &inx, const std::string &new_label) const |
| rebable the lags in the UniTensor by given index. | |
| void | relabel_ (const std::string &old_label, const std::string &new_label) const |
| relabel the lags in the UniTensor by a given label. | |
| UniTensor | relabel (const std::string &old_label, const std::string &new_label) const |
| relabel the lags in the UniTensor by a given label. | |
| UniTensor | astype (const unsigned int &dtype) const |
| Return a new UniTensor that cast to different data type. | |
| UniTensor | permute (const std::vector< cytnx_int64 > &mapper, const cytnx_int64 &rowrank=-1) const |
| permute the lags of the UniTensor | |
| UniTensor | permute (const std::vector< std::string > &mapper, const cytnx_int64 &rowrank=-1) const |
| permute the lags of the UniTensor by labels | |
| UniTensor | permute (const std::initializer_list< char * > &mapper, const cytnx_int64 &rowrank=-1) const |
| void | permute_ (const std::vector< cytnx_int64 > &mapper, const cytnx_int64 &rowrank=-1) |
| permute the lags of the UniTensor, inplacely. | |
| void | permute_ (const std::vector< std::string > &mapper, const cytnx_int64 &rowrank=-1) |
| permute the lags of the UniTensor, inplacely. | |
| UniTensor | contiguous () const |
| Make the UniTensor contiguous by coalescing the memory (storage). | |
| void | contiguous_ () |
| Make the UniTensor contiguous by coalescing the memory (storage), inplacely. | |
| void | print_diagram (const bool &bond_info=false) |
| Plot the diagram of the UniTensor. | |
| void | print_blocks (const bool &full_info=true) const |
| Print all of the blocks in the UniTensor. | |
| void | print_block (const cytnx_int64 &idx, const bool &full_info=true) const |
| Given a index and print out the corresponding block of the UniTensor. | |
| void | 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 specific location. | |
| template<class T > | |
| const T & | at (const std::vector< cytnx_uint64 > &locator) const |
| Get an element at specific location. | |
| const Scalar::Sproxy | at (const std::vector< cytnx_uint64 > &locator) const |
| Get an element at specific location. | |
| Scalar::Sproxy | at (const std::vector< cytnx_uint64 > &locator) |
| Get an element at specific location. | |
| Tensor | get_block (const cytnx_uint64 &idx=0) const |
| Get the block of the UniTensor for a given 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::initializer_list< cytnx_int64 > &qnum, const bool &force=false) const |
| Tensor | get_block (const std::vector< cytnx_uint64 > &qnum, const bool &force=false) const |
| const Tensor & | get_block_ (const cytnx_uint64 &idx=0) const |
| Get the shared view of block for the given 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 block for the given quantum indices. | |
| 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) |
| 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) |
| void | put_block (const Tensor &in, const cytnx_uint64 &idx=0) |
| Put the block into the UniTensor with given index. | |
| void | put_block (const Tensor &in_tens, const std::vector< cytnx_int64 > &qidx, const bool &force) |
| Put the block into the UniTensor with given quantum number. | |
| void | put_block_ (Tensor &in, const cytnx_uint64 &idx=0) |
| Put the block into the UniTensor with given index, inplacely. | |
| void | put_block_ (Tensor &in, const std::vector< cytnx_int64 > &qidx, const bool &force) |
| Put the block into the UniTensor with given quantum indices, inplacely. | |
| UniTensor | get (const std::vector< Accessor > &accessors) const |
| void | set (const std::vector< Accessor > &accessors, const Tensor &rhs) |
| UniTensor | reshape (const std::vector< cytnx_int64 > &new_shape, const cytnx_uint64 &rowrank=0) |
| Reshape the UniTensor. | |
| void | 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. | |
| void | 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) |
| Combine the sevral bonds of the UniTensor. | |
| void | combineBonds (const std::vector< cytnx_int64 > &indicators, const bool &force=false) |
| 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. | |
| 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 | Conj () |
| 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 trance to the UniTensor. | |
| UniTensor | Trace (const cytnx_int64 &a=0, const cytnx_int64 &b=1) const |
| Take the partial trance to the UniTensor. | |
| UniTensor & | Trace_ (const std::string &a, const std::string &b) |
| Take the partial trance to the UniTensor, inplacely. | |
| UniTensor & | Trace_ (const cytnx_int64 &a=0, const cytnx_int64 &b=1) |
| Take the partial trance to 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. | |
| UniTensor | Pow (const double &p) const |
| Power function. | |
| UniTensor & | Pow_ (const double &p) |
| Power function. | |
| bool | elem_exists (const std::vector< cytnx_uint64 > &locator) const |
| Geiven the locator, check if the element exists. | |
| template<class T > | |
| T | get_elem (const std::vector< cytnx_uint64 > &locator) const |
| template<class T2 > | |
| void | 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 () |
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 | |
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 will requires that the input of in_tensor to be 1D. |
| [in] | rowrank | the rowrank of the outcome 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.
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 |
Return a new UniTensor that cast to different data type.
| [in] | new_type | the new data type. It an be any type defined in cytnx::Type. |
new_type is same as dtype of the original UniTensor, return self.
|
inline |
Get an element at specific location.
| [in] | locator | the location of the element we want to access. |
|
inline |
Get an element at specific location.
see more information at user guide 6.3.5.
|
inline |
Get an element at specific location.
| [in] | locator | the location of the element we want to access. |
|
inline |
Get an element at specific location.
see more information at user guide 6.3.5.
|
inline |
Get the bonds of the UniTensor.
|
inline |
|
inline |
|
inline |
|
inline |
Combine the sevral bonds of the UniTensor.
| [in] | indicators | the labels of the lags 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 |
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 lags 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 |
|
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 |
|
inline |
Geiven the locator, check if the element exists.
| [in] | locator | the locator of the element. |
locator).exists().
|
inline |
|
inline |
|
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 |
Get the shared view of block for the given index.
| [in] | idx | input the index you want to get the corresponding block |
|
inline |
|
inline |
|
inline |
Get the shared view of 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 |
|
inline |
|
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 |
|
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.
| lbl | 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 |
|
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 with cytnx::Tensor.
| [in] | in_tensor | a cytnx::Tensor |
| [in] | is_diag | Whether the input Tensor in_tensor is a diagonal Tensor. This will requires that the input of in_tensor to be 1D. |
| [in] | rowrank | the rowrank of the outcome UniTensor. |
| [in] | name | user specified name of the UniTensor. |
|
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 |
|
inline |
To tell whether the UniTensor is in diagonal form.
|
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 |
|
inline |
|
inline |
Return the labels of the UniTensor.
|
static |
load a UniTensor from file
| [in] | fname | the file name |
|
static |
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 |
normalize the current UniTensor instance with 2-norm.
|
inline |
normalize the UniTensor, inplacely.
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. |
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. |
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. |
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. |
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 |
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 |
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 |
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 |
permute the lags of the UniTensor, inplacely.
| [in] | mapper | the mapper by labels |
| [in] | rowrank | the row rank after the permutation |
by_label will be deprecated!
|
inline |
permute the lags of the UniTensor, inplacely.
| [in] | mapper | the mapper by labels |
| [in] | rowrank | the row rank after the permutation |
| UniTensor cytnx::UniTensor::Pow | ( | const double & | p | ) | const |
| UniTensor & cytnx::UniTensor::Pow_ | ( | const double & | p | ) |
|
inline |
Given a index and print out the corresponding block of the UniTensor.
| [in] | idx | the input index |
| [in] | full_info | whether need to print the full information of the block |
|
inline |
Print all of the blocks in the UniTensor.
| [in] | full_info | whether need to print the full information of the blocks |
|
inline |
|
inline |
|
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. |
force will be deprecated soon!
|
inline |
Put the block into the UniTensor with given index, inplacely.
|
inline |
Put the block into the UniTensor with given quantum indices, inplacely.
force will be deprecated soon!
|
inline |
Return the rank of the UniTensor.
|
inline |
rebable the lags in the UniTensor by given index.
This function will relabel the lags 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). Compare 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 |
relabel the lags in the UniTensor by a given label.
This function will relabel the lags 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). Compare 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 |
|
inline |
|
inline |
|
inline |
rebables all of the labels in UniTensor.
|
inline |
|
inline |
Set new labels for all the bonds.
| [in] | new_labels | the new labels for each bond. |
|
inline |
|
inline |
|
inline |
Return the row rank of the UniTensor.
|
inline |
Check whether the Blocks address are the same.
| void cytnx::UniTensor::Save | ( | const char * | fname | ) | const |
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). |
| void cytnx::UniTensor::Save | ( | const std::string & | fname | ) | const |
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 |
|
inline |
|
inline |
|
inline |
|
inline |
Set a new label for bond at the assigned index.
| [in] | idx | the index of the bond. |
| [in] | new_label | the new label that is assign to the bond. |
|
inline |
|
inline |
set a new label for bond to replace one of the current label.
| [in] | old_label | the current label of the bond. |
| [in] | new_label | the new label that is assign to the bond. |
|
inline |
|
inline |
Set new labels for all the bonds.
| [in] | new_labels | the new labels for each bond. |
|
inline |
|
inline |
|
inline |
Get the shape of the UniTensor.
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 |
Set the UniTensor as a tagged UniTensor.
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.
|
inline |
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. |
|
inline |
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.
to_dense() convert the UniTensor from diagonal form to non-diagonal structure. That means input the UniTensor with is_diag = true to is_diag = false.
|
inline |
Convert the UniTensor to non-diagonal form, inplacely.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Take the transpose of the UniTensor.
This function will take the transpose of the UniTensor. If the UniTensor is tagged (i.e. the Bonds are directional), it will swap the direction of the Bonds but the rowrank will not change. If the UniTensor is untagged (i.e. the Bonds are BondType::BD_REG), it will change the rowrank to the opposite side.
|
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 |
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.