Cytnx v0.9.1
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 bool &is_diag=false, const cytnx_int64 &rowrank=-1, 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::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.
 
 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, const std::string &name="")
 
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.
 
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, const std::string &name="")
 
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)
 
UniTensorset_label (const cytnx_int64 &idx, const cytnx_int64 &new_label)
 
UniTensorset_label (const cytnx_int64 &idx, const std::string &new_label)
 Set a new label for bond at the assigned index.
 
UniTensorset_label (const cytnx_int64 &idx, const char *new_label)
 
UniTensorset_label (const std::string &old_label, const std::string &new_label)
 set a new label for bond to replace one of the current label.
 
UniTensorset_label (const char *old_label, const std::string &new_label)
 
UniTensorset_label (const std::string &old_label, const char *new_label)
 
UniTensorset_label (const char *old_label, const char *new_label)
 
UniTensorset_labels (const std::vector< cytnx_int64 > &new_labels)
 change a new label for bond with original label.
 
UniTensorset_labels (const std::vector< std::string > &new_labels)
 Set new labels for all the bonds.
 
UniTensorset_labels (const std::initializer_list< char * > &new_labels)
 
UniTensorset_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 blocks' number.
 
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
 
std::vector< Symmetrysyms () const
 Return the symmetry type of the UniTensor.
 
const bool & is_braket_form () const
 
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_uint64shape () const
 Get the shape of the UniTensor.
 
bool is_blockform () const
 
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.
 
UniTensor relabels (const std::vector< cytnx_int64 > &new_labels) const
 
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
 
UniTensor relabel (const cytnx_int64 &inx, const cytnx_int64 &new_label, const bool &by_label=false) const
 
UniTensor relabel (const cytnx_int64 &inx, const std::string &new_label) const
 rebable the lags in the UniTensor by given index.
 
UniTensor relabel (const std::string &old_label, const std::string &new_label) const
 rebable 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 bool &by_label=false) 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, const bool &by_label=false)
 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_ ()
 
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
 
Scalar::Sproxy at (const std::vector< cytnx_uint64 > &locator)
 
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 > &qnum, const bool &force=false) const
 Get the block of the UniTensor for the given quantun number.
 
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 Tensorget_block_ (const cytnx_uint64 &idx=0) const
 Get the shared view of block for the given index.
 
Tensorget_block_ (const cytnx_uint64 &idx=0)
 
Tensorget_block_ (const std::vector< cytnx_int64 > &qnum, const bool &force=false)
 Get the shared view of block for the given quantum number.
 
Tensorget_block_ (const std::initializer_list< cytnx_int64 > &qnum, const bool &force=false)
 
Tensorget_block_ (const std::vector< cytnx_uint64 > &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
 
const Tensorget_block_ (const std::vector< cytnx_uint64 > &qnum, const bool &force=false) const
 
std::vector< Tensorget_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, const std::vector< cytnx_int64 > &qnum, 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 > &qnum, const bool &force)
 Put the block into the UniTensor with given quantum number, 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.
 
std::vector< BondgetTotalQnums (const bool physical=false) const
 Get the total quantum number of the UniTensor.
 
std::vector< std::vector< cytnx_int64 > > get_blocks_qnums () const
 
bool same_data (const UniTensor &rhs) const
 
UniTensorAdd_ (const UniTensor &rhs)
 The addition function of the UniTensor.
 
UniTensorMul_ (const UniTensor &rhs)
 The multiplcation function of the UniTensor.
 
UniTensorSub_ (const UniTensor &rhs)
 The subtraction function of the UniTensor.
 
UniTensorDiv_ (const UniTensor &rhs)
 The division function of the UniTensor.
 
UniTensorAdd_ (const Scalar &rhs)
 The addition function for a given scalar.
 
UniTensorMul_ (const Scalar &rhs)
 The multiplication function for a given scalar.
 
UniTensorSub_ (const Scalar &rhs)
 The subtraction function for a given scalar.
 
UniTensorDiv_ (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.
 
UniTensoroperator+= (const UniTensor &rhs)
 The addition assignment operator of the UniTensor.
 
UniTensoroperator-= (const UniTensor &rhs)
 The subtraction assignment operator of the UniTensor.
 
UniTensoroperator/= (const UniTensor &rhs)
 The division assignment operator of the UniTensor.
 
UniTensoroperator*= (const UniTensor &rhs)
 The multiplication assignment operator of the UniTensor.
 
UniTensoroperator+= (const Scalar &rhs)
 The addition assignment operator for a given scalar.
 
UniTensoroperator-= (const Scalar &rhs)
 The subtraction assignment operator for a given scalar.
 
UniTensoroperator/= (const Scalar &rhs)
 The division assignment operator for a given scalar.
 
UniTensoroperator*= (const Scalar &rhs)
 The multiplication assignment operator for a given scalar.
 
UniTensor Conj ()
 Apply complex conjugate on each entry of the UniTensor.
 
UniTensorConj_ ()
 Apply complex conjugate on each entry of the UniTensor.
 
UniTensor Transpose () const
 Take the transpose of the UniTensor.
 
UniTensorTranspose_ ()
 Take the transpose of the UniTensor, inplacely.
 
UniTensor normalize () const
 normalize the current UniTensor instance with 2-norm.
 
UniTensornormalize_ ()
 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 cytnx_int64 &a, const cytnx_int64 &b, const bool &by_label) const
 
UniTensorTrace_ (const std::string &a, const std::string &b)
 Take the partial trance to the UniTensor, inplacely.
 
UniTensorTrace_ (const cytnx_int64 &a=0, const cytnx_int64 &b=1)
 Take the partial trance to the UniTensor, inplacely.
 
UniTensorTrace_ (const cytnx_int64 &a, const cytnx_int64 &b, const bool &by_label)
 
UniTensor Dagger () const
 Take the conjugate transpose to the UniTensor.
 
UniTensorDagger_ ()
 Take the conjugate transpose to the UniTensor, inplacely.
 
UniTensortag ()
 
UniTensor Pow (const double &p) const
 Power function.
 
UniTensorPow_ (const double &p)
 Power function.
 
bool elem_exists (const std::vector< cytnx_uint64 > &locator) const
 
template<class 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
 
UniTensortruncate_ (const cytnx_int64 &bond_idx, const cytnx_uint64 &dim, const bool &by_label)
 
UniTensortruncate_ (const std::string &bond_idx, const cytnx_uint64 &dim)
 
UniTensortruncate_ (const cytnx_int64 &bond_idx, const cytnx_uint64 &dim)
 
UniTensor truncate (const cytnx_int64 &bond_idx, const cytnx_uint64 &dim, const bool &by_label) const
 
UniTensor truncate (const std::string &bond_idx, const cytnx_uint64 &dim) const
 
UniTensor truncate (const cytnx_int64 &bond_idx, const cytnx_uint64 &dim) const
 
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
 

Detailed Description

An Enhanced tensor specifically designed for physical Tensor network simulation.

Constructor & Destructor Documentation

◆ UniTensor() [1/3]

cytnx::UniTensor::UniTensor ( const Tensor in_tensor,
const bool &  is_diag = false,
const cytnx_int64 rowrank = -1,
const std::string &  name = "" 
)
inlineexplicit

Construct a UniTensor from a cytnx::Tensor.

Parameters
[in]in_tensora cytnx::Tensor
[in]is_diagWhther the current UniTensor is a diagonal Tensor. This will requires that the input of in_tensor to be 1D.
[in]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.
Attention
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, false, 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;
UniTensor CyT_nonshare = UniTensor(T.clone(), false, 2);
cout << "before:" << endl;
cout << T << endl;
cout << CyT_nonshare << endl;
CyT_nonshare.at<cytnx_double>({1, 1}) = 2.345;
cout << "after" << endl;
cout << T << endl; // T is unchanged!
cout << CyT_nonshare << endl;
return 0;
}
an tensor (multi-dimensional array)
Definition Tensor.hpp:345
T & at(const std::vector< cytnx_uint64 > &locator)
[C++ only] get an element at specific location.
Definition Tensor.hpp:1101
Tensor clone() const
return a clone of the current Tensor.
Definition Tensor.hpp:820
An Enhanced tensor specifically designed for physical Tensor network simulation.
Definition UniTensor.hpp:2449
T & at(const std::vector< cytnx_uint64 > &locator)
Get an element at specific location.
Definition UniTensor.hpp:3210
Definition Accessor.hpp:12
double cytnx_double
Definition Type.hpp:43
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:

import sys
from pathlib import Path
home = str(Path.home())
sys.path.append(home + '/Cytnx_lib')
from cytnx import *
T = zeros([4,4])
CyT = UniTensor(T,rowrank=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(),rowrank=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/3]

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

Construct a UniTensor.

Parameters
[in]bondsthe bond list. Each bond will be deep copy( not a shared view of bond object with input bond)
[in]in_labelsthe labels for each rank(bond)
[in]rowrankthe rank of physical row space.
[in]dtypethe data type of the UniTensor. It can be any type defined in cytnx::Type.
[in]devicethe device that the UniTensor is put on. It can be any device defined in cytnx::Device.
[in]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.
Precondition
  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.

◆ UniTensor() [3/3]

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,
const std::string &  name = "" 
)
inline
Deprecated:
This constructor (integer labels) is deprecated, use
UniTensor(const std::vector<Bond>&, const std::vector<std::string> &in_labels, const cytnx_int64 &rowrank, const unsigned int &dtype, const int &device, const bool &is_diag)
instread.

Member Function Documentation

◆ Add() [1/2]

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

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.

Parameters
[in]rhsa scalar you want to add in the UniTensor.
Returns
UniTensor
Note
Compare to Add_(const Scalar&), this function will create a new UniTensor.
See also
Add_(const Scalar&), Add_(const UniTensor&), Add(const UniTensor&)const, operator+=(const UniTensor&), operator+=(const Scalar&), operator+

◆ Add() [2/2]

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

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.

Parameters
[in]rhsThe UniTensor you want to add by.
Returns
UniTensor
Precondition
The two UniTensor need to have same structure.
Note
Compare to Add_(const UniTensor&), this function will create a new UniTensor.
See also
Add_(const UniTensor&), Add_(const Scalar&), Add(const Scalar&)const , operator+=(const UniTensor&), operator+=(const Scalar&), operator+

◆ Add_() [1/2]

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

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.

Parameters
[in]rhsa Scalar you want to add in the UniTensor.
Returns
UniTensor&
Note
Compare to Add(const Scalar&)const, this is an inplace function.
See also
Add_(const UniTensor&), Add(const UniTensor&)const, Add(const Scalar&)const , operator+=(const UniTensor&), operator+=(const Scalar&), operator+

◆ Add_() [2/2]

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

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.

Parameters
[in]rhsThe UniTensor you want to add by.
Returns
UniTensor&
Precondition
The two UniTensor need to have same structure.
Note
Compare to Add(const UniTensor&)const, this is an inplace function.
See also
Add_(const Scalar&), Add(const UniTensor&)const, Add(const Scalar&)const , operator+=(const UniTensor&), operator+=(const Scalar&), operator+

◆ astype()

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

Return a new UniTensor that cast to different data type.

Parameters
[in]new_typethe new data type. It an be any type defined in cytnx::Type.
Returns
UniTensor
Attention
If the new_type is same as dtype of the original UniTensor, return self.

◆ at() [1/4]

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

Get an element at specific location.

Parameters
[in]locatorthe location of the element we want to access.
Note
this API is only for C++.

◆ 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

Get an element at specific location.

Parameters
[in]locatorthe location of the element we want to access.
Note
this API is only for C++.

◆ 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
See also
bonds();

◆ bonds() [2/2]

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

Get the bonds of the UniTensor.

Returns
std::vector<Bond>

◆ clone()

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

Clone (deep copy) the UniTensor.

Returns
UniTensor

◆ combineBonds() [1/3]

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

◆ combineBonds() [2/3]

void cytnx::UniTensor::combineBonds ( const std::vector< cytnx_int64 > &  indicators,
const bool &  force = false 
)
inline

◆ combineBonds() [3/3]

void cytnx::UniTensor::combineBonds ( const std::vector< std::string > &  indicators,
const bool &  force = false 
)
inline

Combine the sevral bonds of the UniTensor.

Parameters
[in]indicatorsthe labels of the lags you want to combine.
[in]force
Precondition
  1. The size of indicators need to >= 2.
  2. The UniTensor cannot be diagonal form (that means is_diag is true.)

◆ Conj()

UniTensor cytnx::UniTensor::Conj ( )
inline

Apply complex conjugate on each entry of the UniTensor.

Conj() apply complex conjugate on each entry of the UniTensor.

Returns
UniTensor
Note
Compare to Conj_(), this fucntion will create a new object UniTensor.
See also
Conj_()

◆ Conj_()

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

Apply complex conjugate on each entry of the UniTensor.

Conj_() apply complex conjugate on each entry of the UniTensor, inplacely.

Returns
UniTensor
Note
Compare to Conj(), this fucntion is inplace function.
See also
Conj()

◆ contiguous()

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

Make the UniTensor contiguous by coalescing the memory (storage).

See also
contiguous_()

◆ contiguous_()

void cytnx::UniTensor::contiguous_ ( )
inline

Make the UniTensor contiguous by coalescing the memory (storage), inplacely.

See also
contiguous()

◆ contract()

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

Contract the UniTensor with common labels.

This function contract the UniTensor lags with common labels.

Parameters
[in]inRThe UniTensor you want to contract with.
[in]mv_elem_self
[in]mv_elem_rhs
Precondition
  1. Two UniTensor need to have same UniTensor type, namely, same UTenType. You cannot contract symmetric to non-symmetric UniTensor.
  2. You cannot contract tagged UniTensor and untagged UniTensor.
  3. For Dense diagonal UniTensor, the type of Bond (bra-ket) should match.
  4. For symmetric UniTensor (UTenType.Block), Symmetry, degeneracy, quantum numbers and Bond type should be consistent.
Returns
UniTensor
See also
uten_type(),
linalg::Tensordot(const Tensor &Tl, const Tensor &Tr, const std::vector<cytnx_uint64> &idxl, const std::vector<cytnx_uint64> &idxr, const bool &cacheL, const bool &cacheR);

◆ Dagger()

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

Take the conjugate transpose to the UniTensor.

Returns
UniTensor
Note
Compare to Dagger_(), this function will create a new UniTensor ojbect.
See also
Dagger_()

◆ Dagger_()

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

Take the conjugate transpose to the UniTensor, inplacely.

Returns
UniTensor&
Note
Compare to Dagger(), this is an inplace function.
See also
Dagger()

◆ device()

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

Return the device of the UniTensor.

The function return the device of the UniTensor.

Returns
int

◆ device_str()

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

Return the device of the UniTensor in 'string' form.

Returns
std::string
See also
device()

◆ Div() [1/2]

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

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.

Parameters
[in]rhsa scalar you want to divide in the UniTensor.
Returns
UniTensor
Note
Compare to Div_(const Scalar&), this function will create a new UniTensor.
See also
Div_(const Scalar&), Div_(const UniTensor&), Div(const UniTensor&)const, operator/=(const UniTensor&), operator/=(const Scalar&), operator/

◆ Div() [2/2]

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

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.

Parameters
[in]rhsthe divisor
Returns
UniTensor
Precondition
The two UniTensor need to have same structure.
Note
Compare to Div_(const UniTensor&), this function will create a new UniTensor.
See also
Div_(const UniTensor&), Div_(const Scalar&), Div(const Scalar&)const , operator/=(const UniTensor&), operator/=(const Scalar&), operator/

◆ Div_() [1/2]

UniTensor & cytnx::UniTensor::Div_ ( const Scalar rhs)
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.

Parameters
[in]rhsa scalar you want to divide in the UniTensor.
Returns
UniTensor&
Note
Compare to Sub(const Scalar&)const, this is an inplace function.
See also
Div_(const UniTensor&), Div(const UniTensor&)const, Div(const Scalar&)const , operator/=(const UniTensor&), operator/=(const Scalar&), operator/

◆ Div_() [2/2]

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

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.

Parameters
[in]rhsthe divisor
Returns
UniTensor&
Precondition
The two UniTensor need to have same structure.
Note
Compare to Div(const UniTensor&)const, this is an inplace function.
See also
Div_(const Scalar&), Div(const UniTensor&)const, Div(const Scalar&)const , operator/=(const UniTensor&), operator/=(const Scalar&), operator/

◆ dtype()

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

Return the data type of the UniTensor.

The function return the data type of the UniTensor.

Returns
unsigned int

◆ dtype_str()

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

Return the data type of the UniTensor in 'string' form.

Returns
std::string
See also
dtype()

◆ 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/4]

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

Get the block of the UniTensor for a given index.

Parameters
[in]idxthe index of the block we want to get
Returns
Tensor

◆ get_block() [2/4]

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

◆ get_block() [3/4]

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

Get the block of the UniTensor for the given quantun number.

Parameters
[in]qnuminput the quantum number
[in]forceIf 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.)
Returns
Tensor

◆ get_block() [4/4]

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

◆ get_block_() [1/8]

Tensor & cytnx::UniTensor::get_block_ ( const cytnx_uint64 idx = 0)
inline
See also
get_block_(const cytnx_uint64 &idx) const
Note
This function only works for non-symmetric UniTensor.

◆ get_block_() [2/8]

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

Get the shared view of block for the given index.

Parameters
[in]idxinput the index you want to get the corresponding block
Returns
const Tensor&
Note
This function only works for non-symmetric UniTensor.

◆ get_block_() [3/8]

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

◆ get_block_() [4/8]

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

◆ get_block_() [5/8]

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

Get the shared view of block for the given quantum number.

Parameters
[in]qnuminput the quantum number you want to get the corresponding block
[in]forceIf 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.)
Returns
Tensor&
Note
This function only works for non-symmetric UniTensor.

◆ get_block_() [6/8]

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

◆ get_block_() [7/8]

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

◆ get_block_() [8/8]

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

◆ get_blocks()

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

Get all the blocks of the UniTensor.

get_blocks will return the blocks of the UniTensor. Furthermore,

  1. For symmetric UniTensor, it will call contiguous() and then return the shared view of blocks.
  2. For non-symmetric UniTensor, it will return the shared view of blocks.
    Returns
    std::vector<Tensor>

◆ get_blocks_() [1/2]

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

◆ get_blocks_() [2/2]

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

Get all the blocks of the UniTensor, inplacely.

See also
get_blocks()
Parameters
[in]silentwhether need to print out the warning messages.

◆ get_blocks_qnums()

std::vector< std::vector< cytnx_int64 > > cytnx::UniTensor::get_blocks_qnums ( ) const
inline
Note
This API just have not support.

◆ get_elem()

template<class T >
T cytnx::UniTensor::get_elem ( const std::vector< cytnx_uint64 > &  locator) const
inline
Deprecated:
This function is deprecated, please use at() instread.
Note
C++: Deprecated soon, use at()

◆ get_index()

cytnx_int64 cytnx::UniTensor::get_index ( std::string  lbl) const
inline

Get the index of an desired label string.

Parameters
lblLabel you want to find
Returns
The index of the label. If not found, return -1

◆ get_itoi() [1/2]

vec2d< cytnx_uint64 > & cytnx::UniTensor::get_itoi ( )
inline

◆ get_itoi() [2/2]

const vec2d< cytnx_uint64 > & cytnx::UniTensor::get_itoi ( ) const
inline

get the q-indices on each leg for all the blocks

Returns
[2d vector]

◆ get_qindices() [1/2]

std::vector< cytnx_uint64 > & cytnx::UniTensor::get_qindices ( const cytnx_uint64 bidx)
inline

get the q-indices on each leg for the [bidx]-th block

Parameters
bidxthe bidx-th block in current block list.
Returns
[vector]

◆ get_qindices() [2/2]

const std::vector< cytnx_uint64 > & cytnx::UniTensor::get_qindices ( const cytnx_uint64 bidx) const
inline

get the q-indices on each leg for the [bidx]-th block

Parameters
bidxthe bidx-th block in current block list.
Returns
[vector]

◆ getTotalQnums()

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

Get the total quantum number of the UniTensor.

Parameters
[in]physical
Precondition
The UniTensor need to be symmetric type, that is UTenType.Block.
Returns
std::vector<Bond>
Note
This API just have not support.

◆ group_basis()

UniTensor cytnx::UniTensor::group_basis ( ) const
inline

◆ group_basis_()

void cytnx::UniTensor::group_basis_ ( )
inline

◆ Init() [1/3]

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,
const std::string &  name = "" 
)
inline
Deprecated:
This function is deprecated. Please use
Init(const std::vector<Bond> &bonds, const std::vector<std::string> &in_labels, const cytnx_int64 &rowrank, const unsigned int &dtype, const int &device, const bool &is_diag)
instread.

◆ Init() [2/3]

void cytnx::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 = "" 
)
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.

Parameters
[in]bondsthe bond list. Each bond will be deep copy( not a shared view of bond object with input bond)
[in]in_labelsthe labels for each rank(bond)
[in]rowrankthe rank of physical row space
[in]dtypethe dtype of the UniTensor. It can be any type defined in cytnx::Type.
[in]devicethe device that the UniTensor is put on. It can be any device defined in cytnx::Device.
[in]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.
[in]nameuser specified name of the UniTensor.
Precondition
Please ensure that all of the Bond in bonds should be all symmetric or non-symmetric. You cannot mix them.
See also
UniTensor(const std::vector<Bond> &bonds, const std::vector<std::string> &in_labels, const cytnx_int64 &rowrank, const unsigned int &dtype, const int &device, const bool &is_diag)

◆ Init() [3/3]

void cytnx::UniTensor::Init ( const Tensor in_tensor,
const bool &  is_diag = false,
const cytnx_int64 rowrank = -1,
const std::string &  name = "" 
)
inline

Initialize a UniTensor with cytnx::Tensor.

Parameters
[in]in_tensora cytnx::Tensor
[in]is_diagif the current UniTensor is a diagonal Tensor. This will requires input of Tensor to be 1D.
[in]rowrankthe rowrank of the outcome UniTensor.
[in]nameuser specified name of the 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.
Attention
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.
See also
UniTensor(const Tensor &, const bool &, const cytnx_int64 &)

◆ 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

To tell whether the UniTensor is contiguous.

Returns
bool
See also
contiguous(), contiguous_()

◆ is_diag()

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

To tell whether the UniTensor is in diagonal form.

Returns
bool

◆ 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< std::string > & cytnx::UniTensor::labels ( ) const
inline

Return the labels of the UniTensor.

Returns
std::vector<std::string>

◆ Load() [1/2]

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

load a UniTensor from file

Parameters
fnamethe file name
Returns
the loaded UniTensor
Warning
This is static function, if called through UniTensor object, it will return a new UniTensor object instead of modifying the current one.

◆ Load() [2/2]

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

load a UniTensor from file

Parameters
[in]fnamethe file name
Returns
the loaded UniTensor
Warning
This is static function, if called through UniTensor object, it will return a new UniTensor object instead of modifying the current one.

◆ Mul() [1/2]

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

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.

Parameters
[in]rhsa scalar you want to multiply in the UniTensor.
Returns
UniTensor
Note
Compare to Mul_(const Scalar&), this function will create a new UniTensor.
See also
Mul_(const Scalar&), Mul_(const UniTensor&), Mul(const UniTensor&)const, operator*=(const UniTensor&), operator*=(const Scalar&), operator*

◆ Mul() [2/2]

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

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.

Parameters
[in]rhsThe UniTensor you want to multiplicate by.
Returns
UniTensor
Precondition
The two UniTensor need to have same structure.
Note
Compare to Mul_(const UniTensor&), this function will create a new UniTensor.
See also
Mul_(const UniTensor&), Mul_(const Scalar&), Mul(const Scalar&)const , operator*=(const UniTensor&), operator*=(const Scalar&), operator*

◆ Mul_() [1/2]

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

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.

Parameters
[in]rhsa scalar you want to multiplicate in the UniTensor.
Returns
UniTensor&
Note
Compare to Mul(const Scalar&)const, this is an inplace function.
See also
Mul_(const UniTensor&), Mul(const UniTensor&)const, Mul(const Scalar&)const , operator*=(const UniTensor&), operator*=(const Scalar&), operator*

◆ Mul_() [2/2]

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

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.

Parameters
[in]rhsThe UniTensor you want to multiplcate by.
Returns
UniTensor&
Precondition
The two UniTensor need to have same structure.
Note
Compare to Mul(const UniTensor&)const, this is an inplace function.
See also
Mul_(const Scalar&), Mul(const UniTensor&)const, Mul(const Scalar&)const , operator*=(const UniTensor&), operator*=(const Scalar&), operator*

◆ name()

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

Return the name of the UniTensor.

Returns
std::string

◆ Nblocks()

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

Return the blocks' number.

Returns
cytnx_uint64

◆ Norm()

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

Return the norm of the UniTensor.

Norm() return the 2-norm of the UniTensor \(UT\). Namely, it return

\[ ||UT||_2 \]

Returns
Tensor

◆ normalize()

UniTensor cytnx::UniTensor::normalize ( ) const
inline

normalize the current UniTensor instance with 2-norm.

Returns
UniTensor
Note
Compare to normalize_(), this fucntion will return new UniTensor object.
See also
normalize_()

◆ normalize_()

UniTensor & cytnx::UniTensor::normalize_ ( )
inline

normalize the UniTensor, inplacely.

Returns
UniTensor
Note
Compare to normalize(), this fucntion is inplace function.
See also
normalize()

◆ operator*=() [1/2]

UniTensor & cytnx::UniTensor::operator*= ( const Scalar rhs)
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.

Parameters
[in]rhsa scalar you want to multiply in the UniTensor.
Returns
UniTensor&
See also
operator*=(const Scalar&), operator*, Mul_(const UniTensor&), Mul_(const Scalar&), Mul(const UniTensor&), Mul(const Scalar&)const

◆ operator*=() [2/2]

UniTensor & cytnx::UniTensor::operator*= ( const UniTensor rhs)
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 \]

Parameters
[in]rhsThe UniTensor you want to multilicate by.
Returns
UniTensor&
Precondition
The two UniTensor need to have same structure.
See also
operator*=(const Scalar&), operator*, Mul_(const UniTensor&), Mul_(const Scalar&), Mul(const UniTensor&), Mul(const Scalar&)const

◆ operator+=() [1/2]

UniTensor & cytnx::UniTensor::operator+= ( const Scalar rhs)
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.

Parameters
[in]rhsa scalar you want to add in the UniTensor.
Returns
UniTensor&
See also
operator+=(const UniTensor&), operator+, Add_(const UniTensor&), Add_(const Scalar&), Add(const UniTensor&), Add(const Scalar&)const

◆ operator+=() [2/2]

UniTensor & cytnx::UniTensor::operator+= ( const UniTensor rhs)
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 \]

Parameters
[in]rhsThe UniTensor you want to add by.
Returns
UniTensor&
Precondition
The two UniTensor need to have same structure.
See also
operator+=(const Scalar&), operator+, Add_(const UniTensor&), Add_(const Scalar&), Add(const UniTensor&), Add(const Scalar&)const

◆ operator-=() [1/2]

UniTensor & cytnx::UniTensor::operator-= ( const Scalar rhs)
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.

Parameters
[in]rhsthe subtrahend
Returns
UniTensor&
See also
operator-=(const UniTensor&), operator-, Sub_(const UniTensor&), Sub_(const Scalar&), Sub(const UniTensor&), Sub(const Scalar&)const

◆ operator-=() [2/2]

UniTensor & cytnx::UniTensor::operator-= ( const UniTensor rhs)
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 \]

Parameters
[in]rhsthe subtrahend
Returns
UniTensor&
Precondition
The two UniTensor need to have same structure.
See also
operator-=(const Scalar&), operator-, Sub_(const UniTensor&), Sub_(const Scalar&), Sub(const UniTensor&), Sub(const Scalar&)const

◆ operator/=() [1/2]

UniTensor & cytnx::UniTensor::operator/= ( const Scalar rhs)
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.

Parameters
[in]rhsthe divisor
Returns
UniTensor&
See also
operator/=(const UniTensor&), operator/, Div_(const UniTensor&), Div_(const Scalar&), Div(const UniTensor&), Div(const Scalar&)const

◆ operator/=() [2/2]

UniTensor & cytnx::UniTensor::operator/= ( const UniTensor rhs)
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 \]

Parameters
[in]rhsthe divisor
Returns
UniTensor&
Precondition
The two UniTensor need to have same structure.
See also
operator/=(const Scalar&), operator/, Div_(const UniTensor&), Div_(const Scalar&), Div(const UniTensor&), Div(const Scalar&)const

◆ permute() [1/3]

UniTensor cytnx::UniTensor::permute ( const std::initializer_list< char * > &  mapper,
const cytnx_int64 rowrank = -1 
) const
inline
See also
permute(const std::vector<std::string> &mapper, const cytnx_int64 &rowrank = -1)

◆ permute() [2/3]

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

permute the lags of the UniTensor

Parameters
[in]mapperthe mapper of the permutation
[in]rowrankthe new rowrank after the permutation
[in]by_labelWhether permute the lags by label. It can only be used if labels are integer form, which will be deprecated soon.
Returns
UniTensor
Warning
by_label will be deprecated!

◆ permute() [3/3]

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

permute the lags of the UniTensor by labels

Parameters
[in]mapperthe mapper by babels
[in]rowrankthe row rank
Returns
UniTensor

◆ permute_() [1/2]

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

permute the lags of the UniTensor, inplacely.

Deprecated:
It is recommended to use permute_(const std::vector<std::string> &mapper, const cytnx_int64 &rowrank = -1)
Parameters
[in]mapperthe mapper by labels
[in]rowrankthe row rank after the permutation
[in]by_labelpermute by label or index.
Note
bylabel will be deprecated!

◆ permute_() [2/2]

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

permute the lags of the UniTensor, inplacely.

Parameters
[in]mapperthe mapper by labels
[in]rowrankthe row rank after the permutation
See also
permute(const std::vector<std::string> &mapper, const cytnx_int64 &rowrank = -1)

◆ Pow()

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

Power function.

Take power p on all the elements in the UniTensor.

Parameters
ppower
Returns
UniTensor
Note
Compare to Pow_(), this function will create a new UniTensor ojbect.
See also
Pow_()

◆ Pow_()

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

Power function.

Take power p on all the elements in the UniTensor, inplacely.

Parameters
ppower
Returns
UniTensor&
Note
Compare to Pow(), this function is an inplacely function.
See also
Pow()

◆ print_block()

void cytnx::UniTensor::print_block ( const cytnx_int64 idx,
const bool &  full_info = true 
) const
inline

Given a index and print out the corresponding block of the UniTensor.

Parameters
[in]idxthe input index
[in]full_infowhether need to print the full information of the block

◆ print_blocks()

void cytnx::UniTensor::print_blocks ( const bool &  full_info = true) const
inline

Print all of the blocks in the UniTensor.

Parameters
[in]full_infowhether need to print the full information of the blocks

◆ print_diagram()

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

Plot the diagram of the UniTensor.

Parameters
[in]bond_infowhether need to print the information of the bonds of the UniTensor.

◆ put_block() [1/2]

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

Put the block into the UniTensor with given index.

Parameters
[in]inthe block you want to put into UniTensor
[in]inthe index of the UniTensor you want to put the block in in.
Note
the put block will have shared view with the internal block, i.e. non-clone.

◆ put_block() [2/2]

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

Put the block into the UniTensor with given quantum number.

Parameters
[in]inthe block you want to put into UniTensor
[in]inthe quantum number of the UniTensor you want to put the block in in.
Note
the put block will have shared view with the internal block, i.e. non-clone.

◆ put_block_() [1/2]

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

Put the block into the UniTensor with given index, inplacely.

Note
the put block will have shared view with the internal block, i.e. non-clone.
See also
put_block(const Tensor &in, const cytnx_uint64 &idx)

◆ put_block_() [2/2]

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

Put the block into the UniTensor with given quantum number, inplacely.

Note
the put block will have shared view with the internal block, i.e. non-clone.
See also
put_block(const Tensor &in, const cytnx_uint64 &idx)

◆ rank()

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

Return the rank of the UniTensor.

Returns
cytnx_uint64

◆ relabel() [1/3]

UniTensor cytnx::UniTensor::relabel ( const cytnx_int64 inx,
const cytnx_int64 new_label,
const bool &  by_label = false 
) const
inline
Deprecated:
It is recommened to use relabel(const cytnx_int64 &inx, const std::string &new_label)

◆ relabel() [2/3]

UniTensor cytnx::UniTensor::relabel ( const cytnx_int64 inx,
const std::string &  new_label 
) const
inline

rebable the lags in the UniTensor by given index.

Parameters
[in]inxa given index
[in]new_labelthe new label of the UniTensor in the index inx

◆ relabel() [3/3]

UniTensor cytnx::UniTensor::relabel ( const std::string &  old_label,
const std::string &  new_label 
) const
inline

rebable the lags in the UniTensor by a given label.

Parameters
[in]old_labeloriginal label you want to replace
[in]new_labelthe new label

◆ relabels() [1/3]

UniTensor cytnx::UniTensor::relabels ( const std::initializer_list< char * > &  new_lbls) const
inline
See also
relabels(const std::vector<std::string> &new_labels)

◆ relabels() [2/3]

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

◆ relabels() [3/3]

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

rebables all of the labels in UniTensor.

Returns
UniTensor

◆ reshape()

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

Reshape the UniTensor.

Parameters
[in]new_shapethe new shape you want to reshape to.
[in]rowrankthe rowrank of the UniTensor after you reshape it.

◆ 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

Return the row rank of the UniTensor.

Returns
cytnx_uint64

◆ same_data()

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

◆ Save() [1/2]

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

save a UniTensor to file

Parameters
[in]fnamethe file name (exclude the file extension).
Postcondition
The file extension will be extended as '.cytnx'

◆ Save() [2/2]

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

save a UniTensor to file

Parameters
[in]fnamethe file name (exclude the file extension).
Postcondition
The file extension will be extended as '.cytnx'

◆ 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
Deprecated:
This function is deprecated, please use at() instread.
Note
C++: Deprecated soon, use at()

◆ set_label() [1/8]

UniTensor & cytnx::UniTensor::set_label ( const char *  old_label,
const char *  new_label 
)
inline

◆ set_label() [2/8]

UniTensor & cytnx::UniTensor::set_label ( const char *  old_label,
const std::string &  new_label 
)
inline

◆ set_label() [3/8]

UniTensor & cytnx::UniTensor::set_label ( const cytnx_int64 idx,
const char *  new_label 
)
inline

◆ set_label() [4/8]

UniTensor & cytnx::UniTensor::set_label ( const cytnx_int64 idx,
const cytnx_int64 new_label 
)
inline
Deprecated:
This function is deprecated. Please use
\n instead
Note
the new assign label cannot be the same as the label of any other bonds in the UniTensor. ( cannot have duplicate labels )

◆ set_label() [5/8]

UniTensor & cytnx::UniTensor::set_label ( const cytnx_int64 idx,
const cytnx_int64 new_label,
const bool &  by_label 
)
inline
Deprecated:
This function is deprecated. Please use
\n instead.
Note
the new assign label cannot be the same as the label of any other bonds in the UniTensor. ( cannot have duplicate labels )

◆ set_label() [6/8]

UniTensor & cytnx::UniTensor::set_label ( const cytnx_int64 idx,
const std::string &  new_label 
)
inline

Set a new label for bond at the assigned index.

Parameters
[in]idxthe index of the bond.
[in]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_label() [7/8]

UniTensor & cytnx::UniTensor::set_label ( const std::string &  old_label,
const char *  new_label 
)
inline

◆ set_label() [8/8]

UniTensor & cytnx::UniTensor::set_label ( const std::string &  old_label,
const std::string &  new_label 
)
inline

set a new label for bond to replace one of the current label.

Parameters
[in]old_labelthe current label of the bond.
[in]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() [1/3]

UniTensor & cytnx::UniTensor::set_labels ( const std::initializer_list< char * > &  new_labels)
inline

◆ set_labels() [2/3]

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 )

Deprecated:
This is deprecated function. Please use \n instead

◆ set_labels() [3/3]

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

Set new labels for all the bonds.

Parameters
[in]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.

You can use this function to give a name for the UniTensor.

Parameters
[in]inInput the name you want to set for the UniTensor. It should be a string.
Returns
UniTensor

◆ set_rowrank()

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

Set the row rank of the UniTensor.

You can use this function to set the row rank of the UniTensor. The row rank is important if you want to use the linear algebra process.

Parameters
[in]new_rowrankthe new row rank of the UniTensor

◆ shape()

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

Get the shape of the UniTensor.

Returns
std::vector<cytnx_uint64>

◆ Sub() [1/2]

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

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.

Parameters
[in]rhsthe subtrahend
Returns
UniTensor
Note
Compare to Sub_(const Scalar&), this function will create a new UniTensor.
See also
Sub_(const Scalar&), Sub_(const UniTensor&), Sub(const UniTensor&)const, operator-=(const UniTensor&), operator-=(const Scalar&), operator-

◆ Sub() [2/2]

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

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.

Parameters
[in]rhsthe subtrahend
Returns
UniTensor
Precondition
The two UniTensor need to have same structure.
Note
Compare to Sub_(const UniTensor&), this function will create a new UniTensor.
See also
Sub_(const UniTensor&), Sub_(const Scalar&), Sub(const Scalar&)const , operator-=(const UniTensor&), operator-=(const Scalar&), operator-

◆ Sub_() [1/2]

UniTensor & cytnx::UniTensor::Sub_ ( const Scalar rhs)
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.

Parameters
[in]rhsa scalar you want to subtract in the UniTensor.
Returns
UniTensor&
Note
Compare to Sub(const Scalar&)const, this is an inplace function.
See also
Sub_(const UniTensor&), Sub(const UniTensor&)const, Sub(const Scalar&)const , operator-=(const UniTensor&), operator-=(const Scalar&), operator-

◆ Sub_() [2/2]

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

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.

Parameters
[in]rhsthe subtrahend
Returns
UniTensor&
Precondition
The two UniTensor need to have same structure.
Note
Compare to Sub(const UniTensor&)const, this is an inplace function.
See also
Sub_(const Scalar&), Sub(const UniTensor&)const, Sub(const Scalar&)const , operator-=(const UniTensor&), operator-=(const Scalar&), operator-

◆ syms()

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

Return the symmetry type of the UniTensor.

We can get the Symmetry structure by calling this function.

Returns
std::vector<Symmetry>

◆ tag()

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

◆ to()

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

move the current UniTensor to the assigned device.

Warning
if the device-id is the same as current Tensor's device, then return self. otherwise, return a copy of instance that located on the target device.
Parameters
[in]devicethe device-id(cytnx::Device) that is moving to. It can by any device defined in cytnx::Device.
Returns
UniTensor
See also
to(const int &device)

◆ to_()

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

move the current UniTensor to the assigned device (inplace).

Parameters
[in]devicethe device-id(cytnx::Device) that is moving to. It can by any device defined in cytnx::Device.
See also
to_(const int &device)

◆ to_dense()

UniTensor cytnx::UniTensor::to_dense ( )
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.

Precondition
  1. The UniTensor need to be Dense UniTensor, that means this function is only support for UTenType.Dense.
  2. The UniTensor need to be diagonal form (that means is_diag is true.)
Returns
UniTensor
See also
to_dense_(), is_diag()

◆ to_dense_()

void cytnx::UniTensor::to_dense_ ( )
inline

Convert the UniTensor to non-diagonal form, inplacely.

See also
to_dense(), is_diag()

◆ Trace() [1/3]

UniTensor cytnx::UniTensor::Trace ( const cytnx_int64 a,
const cytnx_int64 b,
const bool &  by_label 
) const
inline
Deprecated:
This is deprecated function, please use
Trace(const std::string &a, const std::string &b) const
instead.

◆ Trace() [2/3]

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

Take the partial trance to the UniTensor.

Take the partial trace to the UniTensor with the give two labels.

Parameters
[in]alabel 1
[in]blabel 2
Returns
UniTensor
Note
Compare to Trace_(), this fucntion will return a new UniTensor object.
See also
Trace_()

◆ Trace() [3/3]

UniTensor cytnx::UniTensor::Trace ( const std::string &  a,
const std::string &  b 
) const
inline

Take the partial trance to the UniTensor.

Take the partial trace to the UniTensor with the give two labels.

Parameters
[in]alabel 1
[in]blabel 2
Returns
UniTensor
Note
Compare to Trace_(), this fucntion will return a new UniTensor object.
See also
Trace_()

◆ Trace_() [1/3]

UniTensor & cytnx::UniTensor::Trace_ ( const cytnx_int64 a,
const cytnx_int64 b,
const bool &  by_label 
)
inline
Deprecated:
This function is deprecated, please use
&Trace_(const std::string &a, const std::string &b)
instread.

◆ Trace_() [2/3]

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

Take the partial trance to the UniTensor, inplacely.

Take the partial trace to the UniTensor with the give two labels.

Parameters
[in]alabel 1
[in]blabel 2
Returns
UniTensor&
Note
Compare to Trace(), this is an inplace function.
See also
Trace()

◆ Trace_() [3/3]

UniTensor & cytnx::UniTensor::Trace_ ( const std::string &  a,
const std::string &  b 
)
inline

Take the partial trance to the UniTensor, inplacely.

Take the partial trace to the UniTensor with the give two labels.

Parameters
[in]alabel 1
[in]blabel 2
Returns
UniTensor&
Note
Compare to Trace(), this is an inplace function.
See also
Trace()

◆ Transpose()

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

Take the transpose of the UniTensor.

Returns
UniTensor
Note
Compare to Transpose_(), this fucntion will return new UniTensor object.
See also
Transpose_()

◆ Transpose_()

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

Take the transpose of the UniTensor, inplacely.

Returns
UniTensor
Note
Compare to Transpose(), this fucntion is inplace function.
See also
Transpose()

◆ truncate() [1/3]

UniTensor cytnx::UniTensor::truncate ( const cytnx_int64 bond_idx,
const cytnx_uint64 dim 
) const
inline

◆ truncate() [2/3]

UniTensor cytnx::UniTensor::truncate ( const cytnx_int64 bond_idx,
const cytnx_uint64 dim,
const bool &  by_label 
) const
inline
Deprecated:
Parameters
bond_idx
dim
by_label
Returns
UniTensor

◆ truncate() [3/3]

UniTensor cytnx::UniTensor::truncate ( const std::string &  bond_idx,
const cytnx_uint64 dim 
) const
inline

◆ truncate_() [1/3]

UniTensor & cytnx::UniTensor::truncate_ ( const cytnx_int64 bond_idx,
const cytnx_uint64 dim 
)
inline

◆ truncate_() [2/3]

UniTensor & cytnx::UniTensor::truncate_ ( const cytnx_int64 bond_idx,
const cytnx_uint64 dim,
const bool &  by_label 
)
inline
Deprecated:
Parameters
bond_idx
dim
by_label
Returns
UniTensor&

◆ truncate_() [3/3]

UniTensor & cytnx::UniTensor::truncate_ ( const std::string &  bond_idx,
const cytnx_uint64 dim 
)
inline

◆ uten_type()

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

Return the UniTensor type (cytnx::UTenType) of the UniTensor.

The function return the UniTensor type of the UniTensor.

Returns
int
See also
uten_type_str()

◆ uten_type_str()

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

Return the UniTensor type (cytnx::UTenType) of the UniTensor in 'string' form.

Returns
std::string
See also
uten_type()

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