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

the object contains auxiliary properties for each Tensor rank (bond) More...

#include <Bond.hpp>

Public Member Functions

 Bond (const cytnx_uint64 &dim, const bondType &bd_type=bondType::BD_REG, const std::vector< std::vector< cytnx_int64 > > &in_qnums={}, const std::vector< Symmetry > &in_syms={})
 
void Init (const cytnx_uint64 &dim, const bondType &bd_type=bondType::BD_REG, const std::vector< std::vector< cytnx_int64 > > &in_qnums={}, const std::vector< Symmetry > &in_syms={})
 init a bond object
 
bondType type () const
 return the current tag type
 
const std::vector< std::vector< cytnx_int64 > > & qnums () const
 return the current quantum number set(s) by reference
 
std::vector< std::vector< cytnx_int64 > > & qnums ()
 
std::vector< std::vector< cytnx_int64 > > qnums_clone () const
 return copy of the current quantum number set(s)
 
cytnx_uint64 dim () const
 return the dimension of the bond
 
cytnx_uint32 Nsym () const
 return the number of symmetries
 
const std::vector< Symmetry > & syms () const
 return the vector of symmetry objects by reference.
 
std::vector< Symmetry > & syms ()
 
std::vector< Symmetrysyms_clone () const
 return copy of the vector of symmetry objects.
 
Bondset_type (const bondType &new_bondType)
 change the tag-type of the instance Bond
 
Bond retype (const bondType &new_bondType)
 create a new instance of Bond with type changed to the new tag-type:
 
Bond redirect () const
 create a new instance of Bond with type changed in btwn BRA / KET:
 
void clear_type ()
 change the tag-type to the default value BD_REG
 
Bond clone () const
 return a copy of the instance Bond
 
void combineBond_ (const Bond &bd_in)
 combine the input bond with self, inplacely
 
Bond combineBond (const Bond &bd_in) const
 combine the input bond with self, and return a new combined Bond instance.
 
Bond combineBonds (const std::vector< Bond > &bds)
 combine multiple input bonds with self, and return a new combined Bond instance.
 
void combineBonds_ (const std::vector< Bond > &bds)
 combine multiple input bonds with self, inplacely
 
std::vector< std::vector< cytnx_int64 > > getUniqueQnums (std::vector< cytnx_uint64 > &counts)
 return a sorted qnum sets by removing all the duplicate qnum sets.
 
std::vector< std::vector< cytnx_int64 > > getUniqueQnums ()
 
cytnx_uint64 getDegeneracy (const std::vector< cytnx_int64 > &qnum) const
 return the degeneracy of specify qnum set.
 
cytnx_uint64 getDegeneracy (const std::vector< cytnx_int64 > &qnum, std::vector< cytnx_uint64 > &indices) const
 
std::vector< std::vector< cytnx_int64 > > calc_reverse_qnums ()
 
void Save (const std::string &fname) const
 
void Save (const char *fname) const
 
bool operator== (const Bond &rhs) const
 
bool operator!= (const Bond &rhs) const
 
Bond operator* (const Bond &rhs) const
 
Bondoperator*= (const Bond &rhs)
 

Static Public Member Functions

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

Detailed Description

the object contains auxiliary properties for each Tensor rank (bond)

Constructor & Destructor Documentation

◆ Bond()

cytnx::Bond::Bond ( const cytnx_uint64 dim,
const bondType bd_type = bondType::BD_REG,
const std::vector< std::vector< cytnx_int64 > > &  in_qnums = {},
const std::vector< Symmetry > &  in_syms = {} 
)
inline

Member Function Documentation

◆ calc_reverse_qnums()

std::vector< std::vector< cytnx_int64 > > cytnx::Bond::calc_reverse_qnums ( )
inline

◆ clear_type()

void cytnx::Bond::clear_type ( )
inline

change the tag-type to the default value BD_REG

◆ clone()

Bond cytnx::Bond::clone ( ) const
inline

return a copy of the instance Bond

Returns
[Bond] a new instance of Bond that have the same contents

Example:

c++ API:

#include "cytnx.hpp"
#include <iostream>
using namespace std;
using namespace cytnx;
int main(){
/* 1.
create a non-symmetry, regular bond (BD_REG)
with dimension 10
*/
Bond bd_a = Bond(10);
cout << bd_a << endl;
Bond bd_b = bd_a;
Bond bd_c = bd_a.clone();
cout << is(bd_b,bd_a) << endl; //true, the same instance
cout << is(bd_c,bd_a) << endl; //false, different instance
cout << (bd_b == bd_a) << endl; //true, same content
cout << (bd_c == bd_a) << endl; //true, same content
return 0;
}
the object contains auxiliary properties for each Tensor rank (bond)
Definition Bond.hpp:97
Bond clone() const
return a copy of the instance Bond
Definition Bond.hpp:257
Definition Accessor.hpp:12

output>

Dim = 10 |type: REGULAR 

1
0
1
1

python API:

from cytnx import *
bd_a = Bond(10)
print(bd_a)
bd_b = bd_a;
bd_c = bd_a.clone();
print(bd_b is bd_a) #true
print(bd_c is bd_a) #false
print(bd_b == bd_a) #true
print(bd_c == bd_a) #true


output>

Dim = 10 |type: REGULAR 


True
False
True
True

◆ combineBond()

Bond cytnx::Bond::combineBond ( const Bond bd_in) const
inline

combine the input bond with self, and return a new combined Bond instance.

Parameters
bd_inthe bond that to be combined.
Returns
[Bond] a new combined bond instance.

Example:

c++ API:

#include "cytnx.hpp"
#include <iostream>
using namespace cytnx;
using namespace std;
int main(){
/* 1.
create a non-symmetry, regular bond (BD_REG)
with dimension 10
*/
Bond bd_a = Bond(10,BD_KET);
Bond bd_b = Bond(15,BD_KET);
Bond bd_c = bd_a.combineBond(bd_b);
cout << bd_c << endl;
cout << bd_a << endl;
cout << bd_b << endl;
/* 2.
combine symmetry bonds,
with U1 x Z2 multiple symmetry
*/
Bond bd_d = Bond(3,BD_BRA,{{0,1},{2,0},{-4,1}},
Bond bd_e = Bond(4,BD_BRA,{{0,0},{2,1},{-1,1},{3,0}},
Bond bd_f = bd_d.combineBond(bd_e);
cout << bd_f << endl;
cout << bd_d << endl;
cout << bd_e << endl;
return 0;
}
Bond combineBond(const Bond &bd_in) const
combine the input bond with self, and return a new combined Bond instance.
Definition Bond.hpp:297
static Symmetry Zn(const int &n)
create a Zn descrete symmetry object with
Definition Symmetry.hpp:203
static Symmetry U1()
create a U1 symmetry object
Definition Symmetry.hpp:172
@ BD_BRA
Definition Bond.hpp:15
@ BD_KET
Definition Bond.hpp:14

output>

Dim = 150 |type: KET>     

Dim = 10 |type: KET>     

Dim = 15 |type: KET>     

Dim = 12 |type: <BRA     
 U1::  +0 +2 -1 +3 +2 +4 +1 +5 -4 -2 -5 -1
 Z2::  +1 +0 +0 +1 +0 +1 +1 +0 +1 +0 +0 +1

Dim = 3 |type: <BRA     
 U1::  +0 +2 -4
 Z2::  +1 +0 +1

Dim = 4 |type: <BRA     
 U1::  +0 +2 -1 +3
 Z2::  +0 +1 +1 +0

python API:

from cytnx import *
bd_a = Bond(10,BD_KET)
bd_b = Bond(15,BD_KET)
bd_c = bd_a.combineBond(bd_b)
print(bd_a)
print(bd_b)
print(bd_c)
bd_d = Bond(3,BD_BRA,[[0,1],[2,0],[-4,1]],
[Symmetry.U1(),
Symmetry.Zn(2)])
bd_e = Bond(4,BD_BRA,[[0,0],[2,1],[-1,1],[3,0]],
[Symmetry.U1(),
Symmetry.Zn(2)])
bd_f = bd_d.combineBond(bd_e)
print(bd_f)
print(bd_d)
print(bd_e)


output>

Dim = 10 |type: KET>     


Dim = 15 |type: KET>     


Dim = 150 |type: KET>     


Dim = 12 |type: <BRA     
 U1::  +0 +2 -1 +3 +2 +4 +1 +5 -4 -2 -5 -1
 Z2::  +1 +0 +0 +1 +0 +1 +1 +0 +1 +0 +0 +1


Dim = 3 |type: <BRA     
 U1::  +0 +2 -4
 Z2::  +1 +0 +1


Dim = 4 |type: <BRA     
 U1::  +0 +2 -1 +3
 Z2::  +0 +1 +1 +0


◆ combineBond_()

void cytnx::Bond::combineBond_ ( const Bond bd_in)
inline

combine the input bond with self, inplacely

Parameters
bd_inthe bond that to be combined with self.

Example:

c++ API:

#include "cytnx.hpp"
#include <iostream>
using namespace cytnx;
using namespace std;
int main(){
/* 1.
create a non-symmetry, regular bond (BD_REG)
with dimension 10
*/
Bond bd_a = Bond(10);
cout << bd_a << endl;
Bond bd_b = Bond(5);
cout << bd_b << endl;
bd_a.combineBond_(bd_b);
cout << bd_a << endl;
/* 2.
combine symmetry bonds,
with U1 x Z2 multiple symmetry
*/
Bond bd_c = Bond(3,BD_BRA,{{0,1},{2,0},{-4,1}},
cout << bd_c << endl;
Bond bd_d = Bond(4,BD_BRA,{{0,0},{2,1},{-1,1},{3,0}},
cout << bd_d << endl;
bd_c.combineBond_(bd_d);
cout << bd_c << endl;
return 0;
}
void combineBond_(const Bond &bd_in)
combine the input bond with self, inplacely
Definition Bond.hpp:278

output>

Dim = 10 |type: REGULAR 

Dim = 5 |type: REGULAR 

Dim = 50 |type: REGULAR 

Dim = 3 |type: <BRA     
 U1::  +0 +2 -4
 Z2::  +1 +0 +1

Dim = 4 |type: <BRA     
 U1::  +0 +2 -1 +3
 Z2::  +0 +1 +1 +0

Dim = 12 |type: <BRA     
 U1::  +0 +2 -1 +3 +2 +4 +1 +5 -4 -2 -5 -1
 Z2::  +1 +0 +0 +1 +0 +1 +1 +0 +1 +0 +0 +1

python API:

from cytnx import *
bd_a = Bond(10)
print(bd_a)
bd_b = Bond(5)
print(bd_b)
bd_a.combineBond_(bd_b)
print(bd_a)
bd_c = Bond(3,BD_BRA,[[0,1],[2,0],[-4,1]],
[Symmetry.U1(),
Symmetry.Zn(2)])
print(bd_c)
bd_d = Bond(4,BD_BRA,[[0,0],[2,1],[-1,1],[3,0]],
[Symmetry.U1(),
Symmetry.Zn(2)])
print(bd_d)
bd_c.combineBond_(bd_d)
print(bd_c)


output>

Dim = 10 |type: REGULAR 


Dim = 5 |type: REGULAR 


Dim = 50 |type: REGULAR 


Dim = 3 |type: <BRA     
 U1::  +0 +2 -4
 Z2::  +1 +0 +1


Dim = 4 |type: <BRA     
 U1::  +0 +2 -1 +3
 Z2::  +0 +1 +1 +0


Dim = 12 |type: <BRA     
 U1::  +0 +2 -1 +3 +2 +4 +1 +5 -4 -2 -5 -1
 Z2::  +1 +0 +0 +1 +0 +1 +1 +0 +1 +0 +0 +1


◆ combineBonds()

Bond cytnx::Bond::combineBonds ( const std::vector< Bond > &  bds)
inline

combine multiple input bonds with self, and return a new combined Bond instance.

Parameters
bdsthe bonds that to be combined with self.
Returns
[Bond] a new combined bond instance.

Example:

c++ API:

#include "cytnx.hpp"
#include <iostream>
using namespace cytnx;
using namespace std;
int main(){
/* 1.
combine multiple KET bonds
*/
Bond bd_a = Bond(10,BD_KET);
Bond bd_b = Bond(4,BD_KET);
Bond bd_c = Bond(5,BD_KET);
Bond bd_d = Bond(2,BD_KET);
// note that this will not create copy instances for each Bond elements.
// so it is both memory efficient and fast!
Bond bd_all = bd_a.combineBonds({bd_b,bd_c,bd_d});
cout << bd_a << endl;
cout << bd_b << endl;
cout << bd_c << endl;
cout << bd_d << endl;
cout << bd_all << endl;
/* 2.
combine symmetry bonds,
with U1 x Z2 multiple symmetry
*/
Bond bd_sym_a = Bond(3,BD_BRA,{{0,1},
{2,0},
{-4,1}},
Bond bd_sym_b = Bond(4,BD_BRA,{{0 ,0},
{2 ,1},
{-1,1},
{3 ,0}},
Bond bd_sym_c = Bond(5,BD_BRA,{{1 ,1},
{1 ,1},
{-1,1},
{-2,0},
{0 ,0}},
Bond bd_sym_d = bd_sym_a.combineBonds({bd_sym_b,bd_sym_c});
cout << bd_sym_a << endl;
cout << bd_sym_b << endl;
cout << bd_sym_c << endl;
cout << bd_sym_d << endl;
return 0;
}
Bond combineBonds(const std::vector< Bond > &bds)
combine multiple input bonds with self, and return a new combined Bond instance.
Definition Bond.hpp:318

output>

Dim = 10 |type: KET>     

Dim = 4 |type: KET>     

Dim = 5 |type: KET>     

Dim = 2 |type: KET>     

Dim = 400 |type: KET>     

Dim = 3 |type: <BRA     
 U1::  +0 +2 -4
 Z2::  +1 +0 +1

Dim = 4 |type: <BRA     
 U1::  +0 +2 -1 +3
 Z2::  +0 +1 +1 +0

Dim = 5 |type: <BRA     
 U1::  +1 +1 -1 -2 +0
 Z2::  +1 +1 +1 +0 +0

Dim = 60 |type: <BRA     
 U1::  +1 +1 -1 -2 +0 +3 +3 +1 +0 +2 +0 +0 -2 -3 -1 +4 +4 +2 +1 +3 +3 +3 +1 +0 +2 +5 +5 +3 +2 +4 +2 +2 +0 -1 +1 +6 +6 +4 +3 +5 -3 -3 -5 -6 -4 -1 -1 -3 -4 -2 -4 -4 -6 -7 -5 +0 +0 -2 -3 -1
 Z2::  +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1

python API:

from cytnx import *
bd_a = Bond(10,BD_KET);
bd_b = Bond(4,BD_KET);
bd_c = Bond(5,BD_KET);
bd_d = Bond(2,BD_KET);
bd_all = bd_a.combineBonds([bd_b,bd_c,bd_d]);
print( bd_a )
print( bd_b )
print( bd_c )
print( bd_d )
print( bd_all )
bd_sym_a = Bond(3,BD_BRA,[[0,1],
[2,0],
[-4,1]],
[Symmetry.U1(),
Symmetry.Zn(2)]);
bd_sym_b = Bond(4,BD_BRA,[[0 ,0],
[2 ,1],
[-1,1],
[3 ,0]],
[Symmetry.U1(),
Symmetry.Zn(2)]);
bd_sym_c = Bond(5,BD_BRA,[[1 ,1],
[1 ,1],
[-1,1],
[-2,0],
[0 ,0]],
[Symmetry.U1(),
Symmetry.Zn(2)]);
bd_sym_d = bd_sym_a.combineBonds([bd_sym_b,bd_sym_c]);
print( bd_sym_a )
print( bd_sym_b )
print( bd_sym_c )
print( bd_sym_d )


output>

Dim = 10 |type: KET>     


Dim = 4 |type: KET>     


Dim = 5 |type: KET>     


Dim = 2 |type: KET>     


Dim = 400 |type: KET>     


Dim = 3 |type: <BRA     
 U1::  +0 +2 -4
 Z2::  +1 +0 +1


Dim = 4 |type: <BRA     
 U1::  +0 +2 -1 +3
 Z2::  +0 +1 +1 +0


Dim = 5 |type: <BRA     
 U1::  +1 +1 -1 -2 +0
 Z2::  +1 +1 +1 +0 +0


Dim = 60 |type: <BRA     
 U1::  +1 +1 -1 -2 +0 +3 +3 +1 +0 +2 +0 +0 -2 -3 -1 +4 +4 +2 +1 +3 +3 +3 +1 +0 +2 +5 +5 +3 +2 +4 +2 +2 +0 -1 +1 +6 +6 +4 +3 +5 -3 -3 -5 -6 -4 -1 -1 -3 -4 -2 -4 -4 -6 -7 -5 +0 +0 -2 -3 -1
 Z2::  +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1


◆ combineBonds_()

void cytnx::Bond::combineBonds_ ( const std::vector< Bond > &  bds)
inline

combine multiple input bonds with self, inplacely

Parameters
bdsthe bonds that to be combined with self.

Example:

c++ API:

#include "cytnx.hpp"
#include <iostream>
using namespace cytnx;
using namespace std;
int main(){
/* 1.
combine multiple KET bonds
*/
Bond bd_a = Bond(10,BD_KET);
Bond bd_b = Bond(4,BD_KET);
Bond bd_c = Bond(5,BD_KET);
Bond bd_d = Bond(2,BD_KET);
cout << bd_a << endl;
cout << bd_b << endl;
cout << bd_c << endl;
cout << bd_d << endl;
bd_a.combineBonds_({bd_b,bd_c,bd_d});
cout << bd_a << endl;
/* 2.
combine symmetry bonds,
with U1 x Z2 multiple symmetry
*/
Bond bd_sym_a = Bond(3,BD_BRA,{{0,1},
{2,0},
{-4,1}},
Bond bd_sym_b = Bond(4,BD_BRA,{{0 ,0},
{2 ,1},
{-1,1},
{3 ,0}},
Bond bd_sym_c = Bond(5,BD_BRA,{{1 ,1},
{1 ,1},
{-1,1},
{-2,0},
{0 ,0}},
cout << bd_sym_a << endl;
cout << bd_sym_b << endl;
cout << bd_sym_c << endl;
bd_sym_a.combineBonds_({bd_sym_b,bd_sym_c});
cout << bd_sym_a << endl;
return 0;
}
void combineBonds_(const std::vector< Bond > &bds)
combine multiple input bonds with self, inplacely
Definition Bond.hpp:340

output>

Dim = 10 |type: KET>     

Dim = 4 |type: KET>     

Dim = 5 |type: KET>     

Dim = 2 |type: KET>     

Dim = 400 |type: KET>     

Dim = 3 |type: <BRA     
 U1::  +0 +2 -4
 Z2::  +1 +0 +1

Dim = 4 |type: <BRA     
 U1::  +0 +2 -1 +3
 Z2::  +0 +1 +1 +0

Dim = 5 |type: <BRA     
 U1::  +1 +1 -1 -2 +0
 Z2::  +1 +1 +1 +0 +0

Dim = 60 |type: <BRA     
 U1::  +1 +1 -1 -2 +0 +3 +3 +1 +0 +2 +0 +0 -2 -3 -1 +4 +4 +2 +1 +3 +3 +3 +1 +0 +2 +5 +5 +3 +2 +4 +2 +2 +0 -1 +1 +6 +6 +4 +3 +5 -3 -3 -5 -6 -4 -1 -1 -3 -4 -2 -4 -4 -6 -7 -5 +0 +0 -2 -3 -1
 Z2::  +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1

python API:

from cytnx import *
bd_a = Bond(10,BD_KET);
bd_b = Bond(4,BD_KET);
bd_c = Bond(5,BD_KET);
bd_d = Bond(2,BD_KET);
print( bd_a )
print( bd_b )
print( bd_c )
print( bd_d )
bd_a.combineBonds_([bd_b,bd_c,bd_d]);
print( bd_a )
bd_sym_a = Bond(3,BD_BRA,[[0,1],
[2,0],
[-4,1]],
[Symmetry.U1(),
Symmetry.Zn(2)]);
bd_sym_b = Bond(4,BD_BRA,[[0 ,0],
[2 ,1],
[-1,1],
[3 ,0]],
[Symmetry.U1(),
Symmetry.Zn(2)]);
bd_sym_c = Bond(5,BD_BRA,[[1 ,1],
[1 ,1],
[-1,1],
[-2,0],
[0 ,0]],
[Symmetry.U1(),
Symmetry.Zn(2)]);
print( bd_sym_a )
print( bd_sym_b )
print( bd_sym_c )
bd_sym_a.combineBonds_([bd_sym_b,bd_sym_c]);
print( bd_sym_a )


output>

Dim = 10 |type: KET>     


Dim = 4 |type: KET>     


Dim = 5 |type: KET>     


Dim = 2 |type: KET>     


Dim = 400 |type: KET>     


Dim = 3 |type: <BRA     
 U1::  +0 +2 -4
 Z2::  +1 +0 +1


Dim = 4 |type: <BRA     
 U1::  +0 +2 -1 +3
 Z2::  +0 +1 +1 +0


Dim = 5 |type: <BRA     
 U1::  +1 +1 -1 -2 +0
 Z2::  +1 +1 +1 +0 +0


Dim = 60 |type: <BRA     
 U1::  +1 +1 -1 -2 +0 +3 +3 +1 +0 +2 +0 +0 -2 -3 -1 +4 +4 +2 +1 +3 +3 +3 +1 +0 +2 +5 +5 +3 +2 +4 +2 +2 +0 -1 +1 +6 +6 +4 +3 +5 -3 -3 -5 -6 -4 -1 -1 -3 -4 -2 -4 -4 -6 -7 -5 +0 +0 -2 -3 -1
 Z2::  +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +0 +0 +1 +1 +1 +0 +0 +0 +0 +0 +1 +1


◆ dim()

cytnx_uint64 cytnx::Bond::dim ( ) const
inline

return the dimension of the bond

Returns
[cytnx_uint64]

◆ getDegeneracy() [1/2]

cytnx_uint64 cytnx::Bond::getDegeneracy ( const std::vector< cytnx_int64 > &  qnum) const
inline

return the degeneracy of specify qnum set.

Returns
degeneracy

[Note]

if the bond has no symmetries, return 0.

◆ getDegeneracy() [2/2]

cytnx_uint64 cytnx::Bond::getDegeneracy ( const std::vector< cytnx_int64 > &  qnum,
std::vector< cytnx_uint64 > &  indices 
) const
inline

◆ getUniqueQnums() [1/2]

std::vector< std::vector< cytnx_int64 > > cytnx::Bond::getUniqueQnums ( )
inline

◆ getUniqueQnums() [2/2]

std::vector< std::vector< cytnx_int64 > > cytnx::Bond::getUniqueQnums ( std::vector< cytnx_uint64 > &  counts)
inline

return a sorted qnum sets by removing all the duplicate qnum sets.

Returns
unique_qnums

◆ Init()

void cytnx::Bond::Init ( const cytnx_uint64 dim,
const bondType bd_type = bondType::BD_REG,
const std::vector< std::vector< cytnx_int64 > > &  in_qnums = {},
const std::vector< Symmetry > &  in_syms = {} 
)
inline

init a bond object

Parameters
dimthe dimension of the bond (rank)
bd_typethe tag of the bond, it can be BD_BRA, BD_KET as physical tagged; or BD_REG as regular bond (rank)
in_qnumsthe quantum number(s) of the bond. it should be a 2d vector with shape (# of symmetry, dim)
in_symsthe symmetry object of the bond. [Note] if qnums are provided, the default symmetry type is Symmetry::U1

description:

  1. each bond can be tagged with BD_BRA or BD_KET that represent the bond is defined in Bra space or Ket space.
  2. the bond can have arbitrary multiple symmetries, with the type of each symmetry associate to the qnums are provided with the in_syms.

[Note]

  1. if quantum number(s) are provided (which means the bond is with symmetry) then the bond MUST be tagged with either BD_BRA or BD_KET
  2. if the bond is non-symmetry, then it can be tagged with BD_BRA or BD_KET, or BD_REG depending on the usage.

Example:

c++ API:

#include "cytnx.hpp"
#include <iostream>
using namespace cytnx;
using namespace std;
int main(){
/* 1.
create a non-symmetry, regular bond (BD_REG)
with dimension 10
*/
Bond bd_a = Bond(10);
cout << bd_a << endl;
/* 2.
create a non-symmetry bond tagged with BD_KET
with dimension 10
*/
Bond bd_b = Bond(10,BD_KET);
cout << bd_b << endl;
/* 3.
crate a symmetry bond,
with single U1 (default) symmetry and qnums = (0,2,-1,3)
*/
Bond bd_c = Bond(4,BD_KET,{{0},{2},{-1},{3}});
cout << bd_c << endl;
/* 3.
crate a symmetry bond,
with U1 x Z2 multiple symmetry
and qnums = U1:(0,2,-1,3) x Z2:(0,1,1,0)
*/
Bond bd_d = Bond(4,BD_BRA,{{0 ,0},
{2 ,1},
{-1,1},
{3 ,0}},
cout << bd_d << endl;
}

output>

Dim = 10 |type: REGULAR 

Dim = 10 |type: KET>     

Dim = 4 |type: KET>     
 U1::  +0 +2 -1 +3

Dim = 4 |type: <BRA     
 U1::  +0 +2 -1 +3
 Z2::  +0 +1 +1 +0

python API:

from cytnx import *
bd_a = Bond(10)
print(bd_a)
bd_b = Bond(10,BD_KET)
print(bd_b)
bd_c = Bond(4,BD_KET,[[0],[2],[-1],[3]])
print(bd_c)
bd_d = Bond(4,BD_BRA,[[0 ,0],
[2 ,1],
[-1,1],
[3 ,0]],
[Symmetry.U1(),
Symmetry.Zn(2)])
print(bd_d)


output>

Dim = 10 |type: REGULAR 


Dim = 10 |type: KET>     


Dim = 4 |type: KET>     
 U1::  +0 +2 -1 +3


Dim = 4 |type: <BRA     
 U1::  +0 +2 -1 +3
 Z2::  +0 +1 +1 +0


◆ Load() [1/2]

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

◆ Load() [2/2]

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

◆ Nsym()

cytnx_uint32 cytnx::Bond::Nsym ( ) const
inline

return the number of symmetries

Returns
[cytnx_uint32]

◆ operator!=()

bool cytnx::Bond::operator!= ( const Bond rhs) const

◆ operator*()

Bond cytnx::Bond::operator* ( const Bond rhs) const
inline

◆ operator*=()

Bond & cytnx::Bond::operator*= ( const Bond rhs)
inline

◆ operator==()

bool cytnx::Bond::operator== ( const Bond rhs) const

◆ qnums() [1/2]

std::vector< std::vector< cytnx_int64 > > & cytnx::Bond::qnums ( )
inline

◆ qnums() [2/2]

const std::vector< std::vector< cytnx_int64 > > & cytnx::Bond::qnums ( ) const
inline

return the current quantum number set(s) by reference

Returns
[2d vector] with shape: (dim, # of Symmetry)

◆ qnums_clone()

std::vector< std::vector< cytnx_int64 > > cytnx::Bond::qnums_clone ( ) const
inline

return copy of the current quantum number set(s)

Returns
[2d vector] with shape: (dim, # of Symmetry)

◆ redirect()

Bond cytnx::Bond::redirect ( ) const
inline

create a new instance of Bond with type changed in btwn BRA / KET:

◆ retype()

Bond cytnx::Bond::retype ( const bondType new_bondType)
inline

create a new instance of Bond with type changed to the new tag-type:

Parameters
new_bondTypethe new tag-type, it can be BD_BRA,BD_KET or BD_REG

[Note] This is equivalent to Bond.clone().set_type()

◆ Save() [1/2]

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

◆ Save() [2/2]

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

◆ set_type()

Bond & cytnx::Bond::set_type ( const bondType new_bondType)
inline

change the tag-type of the instance Bond

Parameters
new_bondTypethe new tag-type, it can be BD_BRA,BD_KET or BD_REG

◆ syms() [1/2]

std::vector< Symmetry > & cytnx::Bond::syms ( )
inline

◆ syms() [2/2]

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

return the vector of symmetry objects by reference.

Returns
[vector of Symmetry]

◆ syms_clone()

std::vector< Symmetry > cytnx::Bond::syms_clone ( ) const
inline

return copy of the vector of symmetry objects.

Returns
[vector of Symmetry]

◆ type()

bondType cytnx::Bond::type ( ) const
inline

return the current tag type

Returns
[bondType] can be BD_BRA, BD_KET or BD_REG

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