|
| | UniTensor (const Tensor &in_tensor, const cytnx_uint64 &rowrank, const bool &is_diag=false) |
| | Initialize a UniTensor with cytnx::Tensor.
|
| |
| void | Init (const Tensor &in_tensor, const cytnx_uint64 &rowrank, const bool &is_diag=false) |
| |
| | UniTensor (const std::vector< Bond > &bonds, const std::vector< cytnx_int64 > &in_labels={}, const cytnx_int64 &rowrank=-1, const unsigned int &dtype=Type.Double, const int &device=Device.cpu, const bool &is_diag=false) |
| | Initialize a UniTensor.
|
| |
| void | Init (const std::vector< Bond > &bonds, const std::vector< cytnx_int64 > &in_labels={}, const cytnx_int64 &rowrank=-1, const unsigned int &dtype=Type.Double, const int &device=Device.cpu, const bool &is_diag=false) |
| |
| UniTensor & | set_name (const std::string &in) |
| | set the name of the UniTensor
|
| |
| UniTensor & | set_label (const cytnx_int64 &idx, const cytnx_int64 &new_label, const bool &by_label=false) |
| | set a new label for bond at the assigned index.
|
| |
| UniTensor & | set_labels (const std::vector< cytnx_int64 > &new_labels) |
| | change a new label for bond with original label.
|
| |
| UniTensor & | set_rowrank (const cytnx_uint64 &new_rowrank) |
| |
| template<class T > |
| T & | item () |
| |
| Scalar::Sproxy | item () const |
| |
| cytnx_uint64 | Nblocks () const |
| |
| cytnx_uint64 | rank () const |
| |
| cytnx_uint64 | rowrank () const |
| |
| unsigned int | dtype () const |
| |
| int | uten_type () const |
| |
| int | device () const |
| |
| std::string | name () const |
| |
| std::string | dtype_str () const |
| |
| std::string | device_str () const |
| |
| std::string | uten_type_str () const |
| |
| bool | is_contiguous () const |
| |
| bool | is_diag () const |
| |
| bool | is_tag () const |
| |
| std::vector< Symmetry > | syms () const |
| |
| const bool & | is_braket_form () const |
| |
| const std::vector< cytnx_int64 > & | labels () const |
| |
| const std::vector< Bond > & | bonds () const |
| |
| std::vector< Bond > & | bonds () |
| |
| std::vector< cytnx_uint64 > | shape () const |
| |
| bool | is_blockform () const |
| |
| void | to_ (const int &device) |
| |
| UniTensor | to (const int &device) const |
| |
| UniTensor | clone () const |
| |
| UniTensor | relabels (const std::vector< cytnx_int64 > &new_labels) const |
| |
| UniTensor | relabel (const cytnx_int64 &inx, const cytnx_int64 &new_label, const bool &by_label=false) const |
| |
| UniTensor | astype (const unsigned int &dtype) const |
| |
| UniTensor | permute (const std::vector< cytnx_int64 > &mapper, const cytnx_int64 &rowrank=-1, const bool &by_label=false) |
| |
| void | permute_ (const std::vector< cytnx_int64 > &mapper, const cytnx_int64 &rowrank=-1, const bool &by_label=false) |
| |
| UniTensor | contiguous () const |
| |
| void | contiguous_ () |
| |
| void | print_diagram (const bool &bond_info=false) |
| |
| template<class T > |
| T & | at (const std::vector< cytnx_uint64 > &locator) |
| |
| template<class T > |
| const T & | at (const std::vector< cytnx_uint64 > &locator) const |
| |
| const Scalar::Sproxy | at (const std::vector< cytnx_uint64 > &locator) const |
| |
| Scalar::Sproxy | at (const std::vector< cytnx_uint64 > &locator) |
| |
| Tensor | get_block (const cytnx_uint64 &idx=0) const |
| |
| Tensor | get_block (const std::vector< cytnx_int64 > &qnum, const bool &force=false) const |
| |
| Tensor | get_block (const std::initializer_list< cytnx_int64 > &qnum, const bool &force=false) const |
| |
| const Tensor & | get_block_ (const cytnx_uint64 &idx=0) const |
| |
| Tensor & | get_block_ (const cytnx_uint64 &idx=0) |
| |
| Tensor & | get_block_ (const std::vector< cytnx_int64 > &qnum, const bool &force=false) |
| |
| Tensor & | get_block_ (const std::initializer_list< cytnx_int64 > &qnum, const bool &force=false) |
| |
| const Tensor & | get_block_ (const std::vector< cytnx_int64 > &qnum, const bool &force=false) const |
| |
| const Tensor & | get_block_ (const std::initializer_list< cytnx_int64 > &qnum, const bool &force=false) const |
| |
| std::vector< Tensor > | get_blocks () const |
| |
| const std::vector< Tensor > & | get_blocks_ (const bool &silent=false) const |
| |
| std::vector< Tensor > & | get_blocks_ (const bool &silent=false) |
| |
| void | put_block (const Tensor &in, const cytnx_uint64 &idx=0) |
| |
| void | put_block (const Tensor &in, const std::vector< cytnx_int64 > &qnum, const bool &force) |
| |
| void | put_block_ (Tensor &in, const cytnx_uint64 &idx=0) |
| |
| void | put_block_ (Tensor &in, const std::vector< cytnx_int64 > &qnum, const bool &force) |
| |
| 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) |
| |
| void | reshape_ (const std::vector< cytnx_int64 > &new_shape, const cytnx_uint64 &rowrank=0) |
| |
| UniTensor | to_dense () |
| |
| void | to_dense_ () |
| |
| void | combineBonds (const std::vector< cytnx_int64 > &indicators, const bool &permute_back=true, const bool &by_label=true) |
| |
| UniTensor | contract (const UniTensor &inR, const bool &mv_elem_self=false, const bool &mv_elem_rhs=false) const |
| |
| std::vector< Bond > | getTotalQnums (const bool physical=false) const |
| |
| std::vector< std::vector< cytnx_int64 > > | get_blocks_qnums () const |
| |
| bool | same_data (const UniTensor &rhs) const |
| |
| UniTensor & | Add_ (const UniTensor &rhs) |
| |
| UniTensor & | Mul_ (const UniTensor &rhs) |
| |
| UniTensor & | Sub_ (const UniTensor &rhs) |
| |
| UniTensor & | Div_ (const UniTensor &rhs) |
| |
| UniTensor & | Add_ (const Scalar &rhs) |
| |
| UniTensor & | Mul_ (const Scalar &rhs) |
| |
| UniTensor & | Sub_ (const Scalar &rhs) |
| |
| UniTensor & | Div_ (const Scalar &rhs) |
| |
| UniTensor | Add (const UniTensor &rhs) const |
| |
| UniTensor | Add (const Scalar &rhs) const |
| |
| UniTensor | Mul (const UniTensor &rhs) const |
| |
| UniTensor | Mul (const Scalar &rhs) const |
| |
| UniTensor | Div (const UniTensor &rhs) const |
| |
| UniTensor | Div (const Scalar &rhs) const |
| |
| UniTensor | Sub (const UniTensor &rhs) const |
| |
| UniTensor | Sub (const Scalar &rhs) const |
| |
| Tensor | Norm () const |
| |
| UniTensor & | operator+= (const UniTensor &rhs) |
| |
| UniTensor & | operator-= (const UniTensor &rhs) |
| |
| UniTensor & | operator/= (const UniTensor &rhs) |
| |
| UniTensor & | operator*= (const UniTensor &rhs) |
| |
| UniTensor & | operator+= (const Scalar &rhs) |
| |
| UniTensor & | operator-= (const Scalar &rhs) |
| |
| UniTensor & | operator/= (const Scalar &rhs) |
| |
| UniTensor & | operator*= (const Scalar &rhs) |
| |
| UniTensor | Conj () |
| |
| UniTensor & | Conj_ () |
| |
| UniTensor | Transpose () const |
| |
| UniTensor & | Transpose_ () |
| |
| UniTensor | Trace (const cytnx_int64 &a=0, const cytnx_int64 &b=1, const bool &by_label=false) const |
| |
| UniTensor & | Trace_ (const cytnx_int64 &a=0, const cytnx_int64 &b=1, const bool &by_label=false) |
| |
| UniTensor | Dagger () const |
| |
| UniTensor & | Dagger_ () |
| |
| UniTensor & | tag () |
| |
| UniTensor | Pow (const double &p) const |
| |
| UniTensor & | Pow_ (const double &p) |
| |
| bool | elem_exists (const std::vector< cytnx_uint64 > &locator) const |
| |
| 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 |
| |
| void | Save (const char *fname) const |
| |
| UniTensor & | truncate_ (const cytnx_int64 &bond_idx, const cytnx_uint64 &dim, const bool &by_label=false) |
| |
| UniTensor | truncate (const cytnx_int64 &bond_idx, const cytnx_uint64 &dim, const bool &by_label=false) const |
| |
An Enhanced tensor specifically designed for physical Tensor network simulation.
Initialize a UniTensor with cytnx::Tensor.
- Parameters
-
[Note]
- The constructed UniTensor will have same rank as the input Tensor, with default labels, and a shared view (shared instance) of interal block as the input Tensor.
- The constructed UniTensor is always untagged.
- [Important] The internal block of UniTensor is a referece of input Tensor. That is, they share the same memory. All the change afterward on UniTensor block will change in input Tensor as well. Use Tensor.clone() if a shared view is not the case.
Example:
c++ API:
#include <iostream>
using namespace std;
return 0;
}
an tensor (multi-dimensional array)
Definition Tensor.hpp:333
An Enhanced tensor specifically designed for physical Tensor network simulation.
Definition UniTensor.hpp:1123
int device() const
Definition UniTensor.hpp:1302
Definition Accessor.hpp:12
double cytnx_double
Definition Type.hpp:20
Tensor zeros(const cytnx_uint64 &Nelem, const unsigned int &dtype=Type.Double, const int &device=Device.cpu)
create an rank-1 Tensor with all the elements are initialized with zero.
Definition Generator.cpp:10
output>
-----------------------
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 ]]
python API:
from cytnx import *
T = zeros([4,4])
CyT = UniTensor(T,2)
CyT.print_diagram()
print("before:")
print(T)
print(CyT)
CyT.set_elem([0,0],1.456)
print("after")
print(T)
print(CyT)
print("[non-share example]")
CyT_nonshare = UniTensor(T.clone(),2);
print("before:")
print(T)
print(CyT_nonshare)
CyT_nonshare.set_elem([1,1],2.345);
print("after")
print(T)
print(CyT_nonshare)
output>
-----------------------
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 ]]
change a new label for bond with original label.
- Parameters
-
| old_lbl | the original label of the bond that to be replaced. |
| new_label | the new label that is assign to replace the original label. |
[Note] the new assign label cannot be the same as the label of any other bonds in the UniTensor. ( cannot have duplicate labels )
set new labels for all the bonds.
- Parameters
-
| new_labels | the new labels for each bond. |
[Note] the new assign labels cannot have duplicate element(s), and should have the same size as the rank of UniTensor.