Cytnx v0.7.4
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
cytnx::UniTensor Class Reference

An Enhanced tensor specifically designed for physical Tensor network simulation. More...

#include <UniTensor.hpp>

Public Member Functions

 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)
 
UniTensorset_name (const std::string &in)
 set the name of the UniTensor
 
UniTensorset_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.
 
UniTensorset_labels (const std::vector< cytnx_int64 > &new_labels)
 change a new label for bond with original label.
 
UniTensorset_rowrank (const cytnx_uint64 &new_rowrank)
 
template<class T >
Titem ()
 
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< Symmetrysyms () const
 
const boolis_braket_form () const
 
const std::vector< cytnx_int64 > & labels () const
 
const std::vector< Bond > & bonds () const
 
std::vector< Bond > & bonds ()
 
std::vector< cytnx_uint64shape () 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 >
Tat (const std::vector< cytnx_uint64 > &locator)
 
template<class T >
const Tat (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 Tensorget_block_ (const cytnx_uint64 &idx=0) const
 
Tensorget_block_ (const cytnx_uint64 &idx=0)
 
Tensorget_block_ (const std::vector< cytnx_int64 > &qnum, const bool &force=false)
 
Tensorget_block_ (const std::initializer_list< cytnx_int64 > &qnum, const bool &force=false)
 
const Tensorget_block_ (const std::vector< cytnx_int64 > &qnum, const bool &force=false) const
 
const Tensorget_block_ (const std::initializer_list< cytnx_int64 > &qnum, const bool &force=false) const
 
std::vector< Tensorget_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< BondgetTotalQnums (const bool physical=false) const
 
std::vector< std::vector< cytnx_int64 > > get_blocks_qnums () const
 
bool same_data (const UniTensor &rhs) const
 
UniTensorAdd_ (const UniTensor &rhs)
 
UniTensorMul_ (const UniTensor &rhs)
 
UniTensorSub_ (const UniTensor &rhs)
 
UniTensorDiv_ (const UniTensor &rhs)
 
UniTensorAdd_ (const Scalar &rhs)
 
UniTensorMul_ (const Scalar &rhs)
 
UniTensorSub_ (const Scalar &rhs)
 
UniTensorDiv_ (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
 
UniTensoroperator+= (const UniTensor &rhs)
 
UniTensoroperator-= (const UniTensor &rhs)
 
UniTensoroperator/= (const UniTensor &rhs)
 
UniTensoroperator*= (const UniTensor &rhs)
 
UniTensoroperator+= (const Scalar &rhs)
 
UniTensoroperator-= (const Scalar &rhs)
 
UniTensoroperator/= (const Scalar &rhs)
 
UniTensoroperator*= (const Scalar &rhs)
 
UniTensor Conj ()
 
UniTensorConj_ ()
 
UniTensor Transpose () const
 
UniTensorTranspose_ ()
 
UniTensor Trace (const cytnx_int64 &a=0, const cytnx_int64 &b=1, const bool &by_label=false) const
 
UniTensorTrace_ (const cytnx_int64 &a=0, const cytnx_int64 &b=1, const bool &by_label=false)
 
UniTensor Dagger () const
 
UniTensorDagger_ ()
 
UniTensortag ()
 
UniTensor Pow (const double &p) const
 
UniTensorPow_ (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
 
UniTensortruncate_ (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
 

Static Public Member Functions

static UniTensor Load (const std::string &fname)
 
static UniTensor Load (const char *fname)
 

Detailed Description

An Enhanced tensor specifically designed for physical Tensor network simulation.

Constructor & Destructor Documentation

◆ UniTensor() [1/2]

cytnx::UniTensor::UniTensor ( const Tensor in_tensor,
const cytnx_uint64 rowrank,
const bool is_diag = false 
)
inline

Initialize a UniTensor with cytnx::Tensor.

Parameters
in_tensora cytnx::Tensor
rowrankthe rowrank of the outcome UniTensor.

[Note]

  1. 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.
  2. The constructed UniTensor is always untagged.
  3. [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 "cytnx.hpp"
#include <iostream>
using namespace std;
using namespace cytnx;
int main(int argc, char* argv[]){
Tensor T = zeros({4,4});
UniTensor CyT = UniTensor(T,2); //create un-tagged CyTensor from Tensor
CyT.print_diagram();
cout << "before:" << endl;
cout << T << endl;
cout << CyT << endl;
//Note that it is a shared view, so a change to CyT will affect Tensor T.
CyT.at<cytnx_double>({0,0}) = 1.456;
cout << "after:" << endl;
cout << T << endl;
cout << CyT << endl;
//If we want a new instance of memery, use clone at initialize:
cout << "[non-share example]" << endl;
cout << "before:" << endl;
cout << T << endl;
CyT_nonshare.at<cytnx_double>({1,1}) = 2.345;
cout << "after" << endl;
cout << T << endl; // T is unchanged!
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) #create un-tagged UniTensor from Tensor
CyT.print_diagram()
print("before:")
print(T)
print(CyT)
#Note that it is a shared view, so a change to CyT will affect Tensor T.
CyT.set_elem([0,0],1.456)
print("after")
print(T)
print(CyT)
#If we want a new instance of memery, use clone at initialize:
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) # T is unchanged!
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 ]]




◆ UniTensor() [2/2]

cytnx::UniTensor::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 
)
inline

Initialize a UniTensor.

Parameters
bondsthe bond list. when init, each bond will be copy( not a shared view of bond object with input bond)
in_labelsthe labels for each rank(bond)
rowrankthe rank of physical row space.
dtypethe dtype of the UniTensor. It can be any type defined in cytnx::Type.
devicethe device that the UniTensor is put on. It can be any device defined in cytnx::Device.
is_diagif the constructed UniTensor is a diagonal UniTensor. This can only be assigned true when the UniTensor is square, untagged and rank-2 UniTensor.

[Note]

  1. the bonds cannot contain simutaneously untagged bond(s) and tagged bond(s)
  2. If the bonds are with symmetry (qnums), the symmetry types should be the same across all the bonds.

Member Function Documentation

◆ Add() [1/2]

UniTensor cytnx::UniTensor::Add ( const Scalar rhs) const

◆ Add() [2/2]

UniTensor cytnx::UniTensor::Add ( const UniTensor rhs) const

◆ Add_() [1/2]

UniTensor & cytnx::UniTensor::Add_ ( const Scalar rhs)
inline

◆ Add_() [2/2]

UniTensor & cytnx::UniTensor::Add_ ( const UniTensor rhs)
inline

◆ astype()

UniTensor cytnx::UniTensor::astype ( const unsigned int dtype) const
inline

◆ at() [1/4]

template<class T >
T & cytnx::UniTensor::at ( const std::vector< cytnx_uint64 > &  locator)
inline

◆ at() [2/4]

Scalar::Sproxy cytnx::UniTensor::at ( const std::vector< cytnx_uint64 > &  locator)
inline

◆ at() [3/4]

template<class T >
const T & cytnx::UniTensor::at ( const std::vector< cytnx_uint64 > &  locator) const
inline

◆ at() [4/4]

const Scalar::Sproxy cytnx::UniTensor::at ( const std::vector< cytnx_uint64 > &  locator) const
inline

◆ bonds() [1/2]

std::vector< Bond > & cytnx::UniTensor::bonds ( )
inline

◆ bonds() [2/2]

const std::vector< Bond > & cytnx::UniTensor::bonds ( ) const
inline

◆ clone()

UniTensor cytnx::UniTensor::clone ( ) const
inline

◆ combineBonds()

void cytnx::UniTensor::combineBonds ( const std::vector< cytnx_int64 > &  indicators,
const bool permute_back = true,
const bool by_label = true 
)
inline

◆ Conj()

UniTensor cytnx::UniTensor::Conj ( )
inline

◆ Conj_()

UniTensor & cytnx::UniTensor::Conj_ ( )
inline

◆ contiguous()

UniTensor cytnx::UniTensor::contiguous ( ) const
inline

◆ contiguous_()

void cytnx::UniTensor::contiguous_ ( )
inline

◆ contract()

UniTensor cytnx::UniTensor::contract ( const UniTensor inR,
const bool mv_elem_self = false,
const bool mv_elem_rhs = false 
) const
inline

◆ Dagger()

UniTensor cytnx::UniTensor::Dagger ( ) const
inline

◆ Dagger_()

UniTensor & cytnx::UniTensor::Dagger_ ( )
inline

◆ device()

int cytnx::UniTensor::device ( ) const
inline

◆ device_str()

std::string cytnx::UniTensor::device_str ( ) const
inline

◆ Div() [1/2]

UniTensor cytnx::UniTensor::Div ( const Scalar rhs) const

◆ Div() [2/2]

UniTensor cytnx::UniTensor::Div ( const UniTensor rhs) const

◆ Div_() [1/2]

UniTensor & cytnx::UniTensor::Div_ ( const Scalar rhs)
inline

◆ Div_() [2/2]

UniTensor & cytnx::UniTensor::Div_ ( const UniTensor rhs)
inline

◆ dtype()

unsigned int cytnx::UniTensor::dtype ( ) const
inline

◆ dtype_str()

std::string cytnx::UniTensor::dtype_str ( ) const
inline

◆ elem_exists()

bool cytnx::UniTensor::elem_exists ( const std::vector< cytnx_uint64 > &  locator) const
inline

◆ get()

UniTensor cytnx::UniTensor::get ( const std::vector< Accessor > &  accessors) const
inline

◆ get_block() [1/3]

Tensor cytnx::UniTensor::get_block ( const cytnx_uint64 idx = 0) const
inline

◆ get_block() [2/3]

Tensor cytnx::UniTensor::get_block ( const std::initializer_list< cytnx_int64 > &  qnum,
const bool force = false 
) const
inline

◆ get_block() [3/3]

Tensor cytnx::UniTensor::get_block ( const std::vector< cytnx_int64 > &  qnum,
const bool force = false 
) const
inline

◆ get_block_() [1/6]

Tensor & cytnx::UniTensor::get_block_ ( const cytnx_uint64 idx = 0)
inline

◆ get_block_() [2/6]

const Tensor & cytnx::UniTensor::get_block_ ( const cytnx_uint64 idx = 0) const
inline

◆ get_block_() [3/6]

Tensor & cytnx::UniTensor::get_block_ ( const std::initializer_list< cytnx_int64 > &  qnum,
const bool force = false 
)
inline

◆ get_block_() [4/6]

const Tensor & cytnx::UniTensor::get_block_ ( const std::initializer_list< cytnx_int64 > &  qnum,
const bool force = false 
) const
inline

◆ get_block_() [5/6]

Tensor & cytnx::UniTensor::get_block_ ( const std::vector< cytnx_int64 > &  qnum,
const bool force = false 
)
inline

◆ get_block_() [6/6]

const Tensor & cytnx::UniTensor::get_block_ ( const std::vector< cytnx_int64 > &  qnum,
const bool force = false 
) const
inline

◆ get_blocks()

std::vector< Tensor > cytnx::UniTensor::get_blocks ( ) const
inline

◆ get_blocks_() [1/2]

std::vector< Tensor > & cytnx::UniTensor::get_blocks_ ( const bool silent = false)
inline

◆ get_blocks_() [2/2]

const std::vector< Tensor > & cytnx::UniTensor::get_blocks_ ( const bool silent = false) const
inline

◆ get_blocks_qnums()

std::vector< std::vector< cytnx_int64 > > cytnx::UniTensor::get_blocks_qnums ( ) const
inline

◆ get_elem()

template<class T >
T cytnx::UniTensor::get_elem ( const std::vector< cytnx_uint64 > &  locator) const
inline

◆ getTotalQnums()

std::vector< Bond > cytnx::UniTensor::getTotalQnums ( const bool  physical = false) const
inline

◆ Init() [1/2]

void cytnx::UniTensor::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 
)
inline

◆ Init() [2/2]

void cytnx::UniTensor::Init ( const Tensor in_tensor,
const cytnx_uint64 rowrank,
const bool is_diag = false 
)
inline

◆ is_blockform()

bool cytnx::UniTensor::is_blockform ( ) const
inline

◆ is_braket_form()

const bool & cytnx::UniTensor::is_braket_form ( ) const
inline

◆ is_contiguous()

bool cytnx::UniTensor::is_contiguous ( ) const
inline

◆ is_diag()

bool cytnx::UniTensor::is_diag ( ) const
inline

◆ is_tag()

bool cytnx::UniTensor::is_tag ( ) const
inline

◆ item() [1/2]

template<class T >
T & cytnx::UniTensor::item ( )
inline

◆ item() [2/2]

Scalar::Sproxy cytnx::UniTensor::item ( ) const
inline

◆ labels()

const std::vector< cytnx_int64 > & cytnx::UniTensor::labels ( ) const
inline

◆ Load() [1/2]

UniTensor cytnx::UniTensor::Load ( const char fname)
static

◆ Load() [2/2]

UniTensor cytnx::UniTensor::Load ( const std::string &  fname)
static

◆ Mul() [1/2]

UniTensor cytnx::UniTensor::Mul ( const Scalar rhs) const

◆ Mul() [2/2]

UniTensor cytnx::UniTensor::Mul ( const UniTensor rhs) const

◆ Mul_() [1/2]

UniTensor & cytnx::UniTensor::Mul_ ( const Scalar rhs)
inline

◆ Mul_() [2/2]

UniTensor & cytnx::UniTensor::Mul_ ( const UniTensor rhs)
inline

◆ name()

std::string cytnx::UniTensor::name ( ) const
inline

◆ Nblocks()

cytnx_uint64 cytnx::UniTensor::Nblocks ( ) const
inline

◆ Norm()

Tensor cytnx::UniTensor::Norm ( ) const
inline

◆ operator*=() [1/2]

◆ operator*=() [2/2]

◆ operator+=() [1/2]

◆ operator+=() [2/2]

◆ operator-=() [1/2]

◆ operator-=() [2/2]

◆ operator/=() [1/2]

◆ operator/=() [2/2]

◆ permute()

UniTensor cytnx::UniTensor::permute ( const std::vector< cytnx_int64 > &  mapper,
const cytnx_int64 rowrank = -1,
const bool by_label = false 
)
inline

◆ permute_()

void cytnx::UniTensor::permute_ ( const std::vector< cytnx_int64 > &  mapper,
const cytnx_int64 rowrank = -1,
const bool by_label = false 
)
inline

◆ Pow()

UniTensor cytnx::UniTensor::Pow ( const double p) const

◆ Pow_()

UniTensor & cytnx::UniTensor::Pow_ ( const double p)

◆ print_diagram()

void cytnx::UniTensor::print_diagram ( const bool bond_info = false)
inline

◆ put_block() [1/2]

void cytnx::UniTensor::put_block ( const Tensor in,
const cytnx_uint64 idx = 0 
)
inline

◆ put_block() [2/2]

void cytnx::UniTensor::put_block ( const Tensor in,
const std::vector< cytnx_int64 > &  qnum,
const bool force 
)
inline

◆ put_block_() [1/2]

void cytnx::UniTensor::put_block_ ( Tensor in,
const cytnx_uint64 idx = 0 
)
inline

◆ put_block_() [2/2]

void cytnx::UniTensor::put_block_ ( Tensor in,
const std::vector< cytnx_int64 > &  qnum,
const bool force 
)
inline

◆ rank()

cytnx_uint64 cytnx::UniTensor::rank ( ) const
inline

◆ relabel()

UniTensor cytnx::UniTensor::relabel ( const cytnx_int64 inx,
const cytnx_int64 new_label,
const bool by_label = false 
) const
inline

◆ relabels()

UniTensor cytnx::UniTensor::relabels ( const std::vector< cytnx_int64 > &  new_labels) const
inline

◆ reshape()

UniTensor cytnx::UniTensor::reshape ( const std::vector< cytnx_int64 > &  new_shape,
const cytnx_uint64 rowrank = 0 
)
inline

◆ reshape_()

void cytnx::UniTensor::reshape_ ( const std::vector< cytnx_int64 > &  new_shape,
const cytnx_uint64 rowrank = 0 
)
inline

◆ rowrank()

cytnx_uint64 cytnx::UniTensor::rowrank ( ) const
inline

◆ same_data()

bool cytnx::UniTensor::same_data ( const UniTensor rhs) const
inline

◆ Save() [1/2]

void cytnx::UniTensor::Save ( const char fname) const

◆ Save() [2/2]

void cytnx::UniTensor::Save ( const std::string &  fname) const

◆ set()

void cytnx::UniTensor::set ( const std::vector< Accessor > &  accessors,
const Tensor rhs 
)
inline

◆ set_elem()

template<class T2 >
void cytnx::UniTensor::set_elem ( const std::vector< cytnx_uint64 > &  locator,
const T2 rc 
)
inline

◆ set_label()

UniTensor & cytnx::UniTensor::set_label ( const cytnx_int64 idx,
const cytnx_int64 new_label,
const bool by_label = false 
)
inline

set a new label for bond at the assigned index.

Parameters
idxthe index of the bond.
new_labelthe new label that is assign to the bond.

[Note] the new assign label cannot be the same as the label of any other bonds in the UniTensor. ( cannot have duplicate labels )

◆ set_labels()

UniTensor & cytnx::UniTensor::set_labels ( const std::vector< cytnx_int64 > &  new_labels)
inline

change a new label for bond with original label.

Parameters
old_lblthe original label of the bond that to be replaced.
new_labelthe 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_labelsthe 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.

◆ set_name()

UniTensor & cytnx::UniTensor::set_name ( const std::string &  in)
inline

set the name of the UniTensor

Parameters
inthe name. It should be a string.

◆ set_rowrank()

UniTensor & cytnx::UniTensor::set_rowrank ( const cytnx_uint64 new_rowrank)
inline

◆ shape()

std::vector< cytnx_uint64 > cytnx::UniTensor::shape ( ) const
inline

◆ Sub() [1/2]

UniTensor cytnx::UniTensor::Sub ( const Scalar rhs) const

◆ Sub() [2/2]

UniTensor cytnx::UniTensor::Sub ( const UniTensor rhs) const

◆ Sub_() [1/2]

UniTensor & cytnx::UniTensor::Sub_ ( const Scalar rhs)
inline

◆ Sub_() [2/2]

UniTensor & cytnx::UniTensor::Sub_ ( const UniTensor rhs)
inline

◆ syms()

std::vector< Symmetry > cytnx::UniTensor::syms ( ) const
inline

◆ tag()

UniTensor & cytnx::UniTensor::tag ( )
inline

◆ to()

UniTensor cytnx::UniTensor::to ( const int device) const
inline

◆ to_()

void cytnx::UniTensor::to_ ( const int device)
inline

◆ to_dense()

UniTensor cytnx::UniTensor::to_dense ( )
inline

◆ to_dense_()

void cytnx::UniTensor::to_dense_ ( )
inline

◆ Trace()

UniTensor cytnx::UniTensor::Trace ( const cytnx_int64 a = 0,
const cytnx_int64 b = 1,
const bool by_label = false 
) const
inline

◆ Trace_()

UniTensor & cytnx::UniTensor::Trace_ ( const cytnx_int64 a = 0,
const cytnx_int64 b = 1,
const bool by_label = false 
)
inline

◆ Transpose()

UniTensor cytnx::UniTensor::Transpose ( ) const
inline

◆ Transpose_()

UniTensor & cytnx::UniTensor::Transpose_ ( )
inline

◆ truncate()

UniTensor cytnx::UniTensor::truncate ( const cytnx_int64 bond_idx,
const cytnx_uint64 dim,
const bool by_label = false 
) const
inline

◆ truncate_()

UniTensor & cytnx::UniTensor::truncate_ ( const cytnx_int64 bond_idx,
const cytnx_uint64 dim,
const bool by_label = false 
)
inline

◆ uten_type()

int cytnx::UniTensor::uten_type ( ) const
inline

◆ uten_type_str()

std::string cytnx::UniTensor::uten_type_str ( ) const
inline

The documentation for this class was generated from the following files: