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

the symmetry object More...

#include <Symmetry.hpp>

Public Member Functions

Symmetry clone () const
 return a clone instance of current Symmetry object.
 
int stype () const
 return the symmetry type-id of current Symmetry object.
 
int & n () const
 return the descrete n of current Symmetry object.
 
std::string stype_str () const
 return the symmetry type name of current Symmetry object.
 
bool check_qnum (const cytnx_int64 &qnum)
 check the quantum number is within the valid value range of current Symmetry.
 
bool check_qnums (const std::vector< cytnx_int64 > &qnums)
 check all the quantum numbers are within the valid value range of current Symmetry.
 
std::vector< cytnx_int64combine_rule (const std::vector< cytnx_int64 > &inL, const std::vector< cytnx_int64 > &inR)
 apply combine rule of current symmetry to two quantum number lists.
 
void combine_rule_ (std::vector< cytnx_int64 > &out, const std::vector< cytnx_int64 > &inL, const std::vector< cytnx_int64 > &inR)
 apply combine rule of current symmetry to two quantum number lists, and store it into parameter
 
cytnx_int64 combine_rule (const cytnx_int64 &inL, const cytnx_int64 &inR)
 apply combine rule of current symmetry to two quantum numbers.
 
void combine_rule_ (cytnx_int64 &out, const cytnx_int64 &inL, const cytnx_int64 &inR)
 apply combine rule of current symmetry to two quantum numbers, and store the combined quntun number into parameter
 
void reverse_rule_ (cytnx_int64 &out, const cytnx_int64 &in)
 
cytnx_int64 reverse_rule (const cytnx_int64 &in)
 
void Save (const std::string &fname) const
 
void Save (const char *fname) const
 
void print_info () const
 
bool operator== (const Symmetry &rhs) const
 
bool operator!= (const Symmetry &rhs) const
 

Static Public Member Functions

static Symmetry U1 ()
 create a U1 symmetry object
 
static Symmetry Zn (const int &n)
 create a Zn descrete symmetry object with \(n\in\mathbb{N}\)
 
static Symmetry Load (const std::string &fname)
 
static Symmetry Load (const char *fname)
 

Detailed Description

the symmetry object

Member Function Documentation

◆ check_qnum()

bool cytnx::Symmetry::check_qnum ( const cytnx_int64 qnum)
inline

check the quantum number is within the valid value range of current Symmetry.

Parameters
qnuma singule quantum number.
Returns
[bool]

◆ check_qnums()

bool cytnx::Symmetry::check_qnums ( const std::vector< cytnx_int64 > &  qnums)
inline

check all the quantum numbers are within the valid value range of current Symmetry.

Parameters
qnumsthe list of quantum numbers
Returns
[bool]

◆ clone()

Symmetry cytnx::Symmetry::clone ( ) const
inline

return a clone instance of current Symmetry object.

Returns
[Symmetry]

Example:

c++ API:

#include "cytnx.hpp"
#include <iostream>
using namespace cytnx;
using namespace std;
int main(){
/* 1.
create symmetry objects
*/
Symmetry sym_D = sym_A; // same instance.
//using is() to check if they are the same instance.
cout << is(sym_D,sym_A) << endl; //true. same instance
cout << (sym_D == sym_A) << endl; //true, same content
cout << is(sym_C,sym_A) << endl; //false. different instance
cout << (sym_C == sym_A) << endl; //true, sane content
return 0;
}
the symmetry object
Definition Symmetry.hpp:114
static Symmetry U1()
create a U1 symmetry object
Definition Symmetry.hpp:172
Definition Accessor.hpp:12

output>

1
1
0
1

python API:

from cytnx import *
sym_A = Symmetry.U1()
sym_C = Symmetry.U1()
sym_D = sym_A
print(sym_D is sym_A) #true
print(sym_D == sym_A) #true
print(sym_C is sym_A) #false
print(sym_C == sym_A) #true


output>

True
True
False
True

◆ combine_rule() [1/2]

cytnx_int64 cytnx::Symmetry::combine_rule ( const cytnx_int64 inL,
const cytnx_int64 inR 
)
inline

apply combine rule of current symmetry to two quantum numbers.

Parameters
inLthe #1 quantum number.
inRthe #2 quantum number.
Returns
the combined quantum number.

◆ combine_rule() [2/2]

std::vector< cytnx_int64 > cytnx::Symmetry::combine_rule ( const std::vector< cytnx_int64 > &  inL,
const std::vector< cytnx_int64 > &  inR 
)
inline

apply combine rule of current symmetry to two quantum number lists.

Parameters
inLthe #1 quantum number list that is to be combined.
inRthe #2 quantum number list that is to be combined.
Returns
the combined quantum numbers.

◆ combine_rule_() [1/2]

void cytnx::Symmetry::combine_rule_ ( cytnx_int64 out,
const cytnx_int64 inL,
const cytnx_int64 inR 
)
inline

apply combine rule of current symmetry to two quantum numbers, and store the combined quntun number into parameter

Parameters
out.
outthe output quantum number.
inLthe #1 quantum number.
inRthe #2 quantum number.

◆ combine_rule_() [2/2]

void cytnx::Symmetry::combine_rule_ ( std::vector< cytnx_int64 > &  out,
const std::vector< cytnx_int64 > &  inL,
const std::vector< cytnx_int64 > &  inR 
)
inline

apply combine rule of current symmetry to two quantum number lists, and store it into parameter

Parameters
out.
outthe output quantum number list.
inLthe #1 quantum number list that is to be combined.
inRthe #2 quantum number list that is to be combined.

◆ Load() [1/2]

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

◆ Load() [2/2]

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

◆ n()

int & cytnx::Symmetry::n ( ) const
inline

return the descrete n of current Symmetry object.

Returns
[int]

[Note]

  1. for U1, n=1 will be returned.
  2. for Zn, n is the descrete symmetry number. (ex: Z2, n=2)

◆ operator!=()

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

◆ operator==()

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

◆ print_info()

void cytnx::Symmetry::print_info ( ) const
inline

◆ reverse_rule()

cytnx_int64 cytnx::Symmetry::reverse_rule ( const cytnx_int64 in)
inline

◆ reverse_rule_()

void cytnx::Symmetry::reverse_rule_ ( cytnx_int64 out,
const cytnx_int64 in 
)
inline

◆ Save() [1/2]

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

◆ Save() [2/2]

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

◆ stype()

int cytnx::Symmetry::stype ( ) const
inline

return the symmetry type-id of current Symmetry object.

Returns
[int] the symmetry type-id.

◆ stype_str()

std::string cytnx::Symmetry::stype_str ( ) const
inline

return the symmetry type name of current Symmetry object.

Returns
[std::string] the symmetry type name.

◆ U1()

static Symmetry cytnx::Symmetry::U1 ( )
inlinestatic

create a U1 symmetry object

valid qnum value range:

\f$(-\infty , \infty)\f$

combine rule:

Q + Q            

description:

create a new U1 symmetry object that serive as a generator. The symmetry object is a property of Bond . It is used to identify the symmetry of the quantum number set, as well as providing the combining rule for the quantum number when Bonds are combined.

Example:

c++ API:

#include "cytnx.hpp"
#include <iostream>
using namespace cytnx;
using namespace std;
int main(){
/* 1.
create a U1 symmetry object
*/
Symmetry sym_u1 = Symmetry::U1();
/* 2.
using with Bond to define a bond with symmetry.
*/
Bond bd_sym_u1_a = Bond(4,BD_KET,{{0},{-4},{-2},{3}},{sym_u1});
Bond bd_sym_u1_b = Bond(4,BD_KET,{{0},{-4},{-2},{3}}); // default is U1 symmetry
cout << bd_sym_u1_a << endl;
cout << bd_sym_u1_b << endl;
cout << (bd_sym_u1_a == bd_sym_u1_b) << endl; //true
Bond bd_sym_u1_c = Bond(5,BD_KET,{{-1},{1},{2},{-2},{0}});
cout << bd_sym_u1_c << endl;
/* 3.
new qnums will be calculated using Symmetry::combine_rule.
*/
Bond bd_sym_all = bd_sym_u1_a.combineBond(bd_sym_u1_c);
cout << bd_sym_all << endl;
return 0;
}
the object contains auxiliary properties for each Tensor rank (bond)
Definition Bond.hpp:94
Bond combineBond(const Bond &bd_in) const
combine the input bond with self, and return a new combined Bond instance.
Definition Bond.hpp:294
@ BD_KET
Definition Bond.hpp:14

output>

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

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

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

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

python API:

from cytnx import *
sym_u1 = Symmetry.U1();
bd_sym_u1_a = Bond(4,BD_KET,[[0],[-4],[-2],[3]],[sym_u1])
bd_sym_u1_b = Bond(4,BD_KET,[[0],[-4],[-2],[3]]) #default is U1 symmetry
print(bd_sym_u1_a)
print(bd_sym_u1_b)
print(bd_sym_u1_a == bd_sym_u1_b,flush=True) #true
bd_sym_u1_c = Bond(5,BD_KET,[[-1],[1],[2],[-2],[0]])
print(bd_sym_u1_c)
bd_sym_all = bd_sym_u1_a.combineBond(bd_sym_u1_c)
print(bd_sym_all)


output>

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


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


True
Dim = 5 |type: KET>     
 U1::  -1 +1 +2 -2 +0


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


◆ Zn()

static Symmetry cytnx::Symmetry::Zn ( const int &  n)
inlinestatic

create a Zn descrete symmetry object with \(n\in\mathbb{N}\)

valid qnum value range:

\f$[0 , n)\f$

combine rule:

(Q + Q)%n           

description:

create a new Zn descrete symmetry object with integer \( n \) that serive as a generator. The symmetry object is a property of Bond . It is used to identify the symmetry of the quantum number set, as well as providing the combining rule for the quantum number when Bonds are combined.

Example:

c++ API:

#include "cytnx.hpp"
#include <iostream>
using namespace cytnx;
using namespace std;
int main(){
//example of Z2 symmetry object
//------------------------------------
// 1. create Z2 object
Symmetry sym_z2 = Symmetry::Zn(2);
/* 2.
using with Bond to define a bond with symmetry.
Note that the qnums should obey the valid value range of the correspond symmetry.
with Z2 = [0,2)
*/
Bond bd_sym_z2_A = Bond(4,BD_KET,{{0},{0},{1},{1}},{sym_z2});
Bond bd_sym_z2_B = Bond(3,BD_KET,{{0},{1},{1}},{sym_z2});
cout << bd_sym_z2_A << endl;
cout << bd_sym_z2_B << endl;
/* 3.
new qnums will be calculated internally using Symmetry::combine_rule.
*/
Bond bd_sym_z2all = bd_sym_z2_A.combineBond(bd_sym_z2_B);
cout << bd_sym_z2all << endl;
//example of Z4 symmetry object
//------------------------------------
// 1. create Z4 object
Symmetry sym_z4 = Symmetry::Zn(4);
/* 2.
using with Bond to define a bond with symmetry.
Note that the qnums should obey the valid value range of the correspond symmetry.
with Z4 = [0,4)
*/
Bond bd_sym_z4_A = Bond(4,BD_KET,{{0},{3},{1},{2}},{sym_z4});
Bond bd_sym_z4_B = Bond(3,BD_KET,{{2},{3},{1}},{sym_z4});
cout << bd_sym_z4_A << endl;
cout << bd_sym_z4_B << endl;
/* 3.
new qnums will be calculated internally using Symmetry::combine_rule.
*/
Bond bd_sym_z4all = bd_sym_z4_A.combineBond(bd_sym_z4_B);
cout << bd_sym_z4all << endl;
return 0;
}
static Symmetry Zn(const int &n)
create a Zn descrete symmetry object with
Definition Symmetry.hpp:203

output>

Dim = 4 |type: KET>     
 Z2::  +0 +0 +1 +1

Dim = 3 |type: KET>     
 Z2::  +0 +1 +1

Dim = 12 |type: KET>     
 Z2::  +0 +1 +1 +0 +1 +1 +1 +0 +0 +1 +0 +0

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

Dim = 3 |type: KET>     
 Z4::  +2 +3 +1

Dim = 12 |type: KET>     
 Z4::  +2 +3 +1 +1 +2 +0 +3 +0 +2 +0 +1 +3

python API:

from cytnx import *
#example of Z2 symmetry object
#------------------------------------
sym_z2 = Symmetry.Zn(2);
bd_sym_z2_A = Bond(4,BD_KET,[[0],[0],[1],[1]],[sym_z2])
bd_sym_z2_B = Bond(3,BD_KET,[[0],[1],[1]],[sym_z2])
print(bd_sym_z2_A)
print(bd_sym_z2_B)
bd_sym_z2all = bd_sym_z2_A.combineBond(bd_sym_z2_B)
print(bd_sym_z2all)
#example of Z4 symmetry object
#------------------------------------
sym_z4 = Symmetry.Zn(4)
bd_sym_z4_A = Bond(4,BD_KET,[[0],[3],[1],[2]],[sym_z4])
bd_sym_z4_B = Bond(3,BD_KET,[[2],[3],[1]],[sym_z4])
print(bd_sym_z4_A)
print(bd_sym_z4_B)
bd_sym_z4all = bd_sym_z4_A.combineBond(bd_sym_z4_B)
print(bd_sym_z4all)


output>

Dim = 4 |type: KET>     
 Z2::  +0 +0 +1 +1


Dim = 3 |type: KET>     
 Z2::  +0 +1 +1


Dim = 12 |type: KET>     
 Z2::  +0 +1 +1 +0 +1 +1 +1 +0 +0 +1 +0 +0


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


Dim = 3 |type: KET>     
 Z4::  +2 +3 +1


Dim = 12 |type: KET>     
 Z4::  +2 +3 +1 +1 +2 +0 +3 +0 +2 +0 +1 +3



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