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

#include <Network.hpp>

Public Member Functions

void Fromfile (const std::string &fname, const int &network_type=NtType.Regular)
 Construct Network from network file.
 
void FromString (const std::vector< std::string > &contents, const int &network_type=NtType.Regular)
 Construct Network from a list of strings, where each string is the same as each line in network file.
 
 Network (const std::string &fname, const int &network_type=NtType.Regular)
 
void RmUniTensor (const std::string &name)
 
void RmUniTensor (const cytnx_uint64 &idx)
 
void RmUniTensors (const std::vector< std::string > &names)
 
void PutUniTensor (const std::string &name, const UniTensor &utensor, const std::vector< std::string > &label_order={})
 
void PutUniTensor (const cytnx_uint64 &idx, const UniTensor &utensor, const std::vector< std::string > &label_order={})
 
void PutUniTensors (const std::vector< std::string > &name, const std::vector< UniTensor > &utensors)
 
std::string getOptimalOrder (const int &network_type=NtType.Regular)
 
std::string getOrder ()
 
void setOrder (const bool &optimal, const std::string &contract_order)
 
UniTensor Launch (const int &network_type=NtType.Regular)
 
void construct (const std::vector< std::string > &alias, const std::vector< std::vector< std::string > > &labels, const std::vector< std::string > &outlabel=std::vector< std::string >(), const cytnx_int64 &outrk=0, const std::string &order="", const bool optim=false, const int &network_type=NtType.Regular)
 
void clear ()
 
Network clone ()
 
void PrintNet ()
 
void Savefile (const std::string &fname)
 

Static Public Member Functions

static Network Contract (const std::vector< UniTensor > &tensors, const std::string &Tout, const std::vector< std::string > &alias={}, const std::string &contract_order="")
 

Constructor & Destructor Documentation

◆ Network()

cytnx::Network::Network ( const std::string &  fname,
const int &  network_type = NtType.Regular 
)
inline

Member Function Documentation

◆ clear()

void cytnx::Network::clear ( )
inline

◆ clone()

Network cytnx::Network::clone ( )
inline

◆ construct()

void cytnx::Network::construct ( const std::vector< std::string > &  alias,
const std::vector< std::vector< std::string > > &  labels,
const std::vector< std::string > &  outlabel = std::vector<std::string>(),
const cytnx_int64 outrk = 0,
const std::string &  order = "",
const bool  optim = false,
const int &  network_type = NtType.Regular 
)
inline

◆ Contract()

static Network cytnx::Network::Contract ( const std::vector< UniTensor > &  tensors,
const std::string &  Tout,
const std::vector< std::string > &  alias = {},
const std::string &  contract_order = "" 
)
inlinestatic

◆ Fromfile()

void cytnx::Network::Fromfile ( const std::string &  fname,
const int &  network_type = NtType.Regular 
)
inline

Construct Network from network file.

Parameters
fnameThe network file path
network_typeThe type of network. This can be [NtType.Regular] or [NtType.Fermion.]. Currently, only Regular Network is support!

note:

  1. each network file cannot have more than 1024 lines.

detail:

Format of a network file:

  • each line defines a UniTensor, that takes the format '[name] : [Labels]'
  • the name can be any alphabets A-Z, a-z
  • There are two reserved name: 'TOUT' and 'ORDER' (all capital)
  • One can use 'TOUT' line to specify the output UniTensor's bond order using labels
  • The 'ORDER' line is used to specify the contraction order

About [Labels]:

  • each label should seperate by a comma ","
  • one ';' is needed and used to seperate Rowrank and column rank

About [ORDER]:

  • The contraction order, it can be specify using the standard mathmetical bracket ruls.
  • Without specify this line, the default contraction order will be from the first line to the last line

example network file:

A: 0,1,2
B: 0,3,4
C: 5,1,6
D: 5,7,8
TOUT: 2,3,4;6,7,8
ORDER: (A,B),(C,D)

example code for load the network file:

c++ API:

#include "cytnx.hpp"
#include <iostream>
using namespace cytnx;
using namespace std;
int main(int argc, char* argv[]) {
N.Fromfile("example.net");
cout << N << endl;
}
Definition Network.hpp:261
void Fromfile(const std::string &fname, const int &network_type=NtType.Regular)
Construct Network from network file.
Definition Network.hpp:320
Helper function to print vector with ODT:
Definition Accessor.hpp:12

output>

==== Network ====
[x] A : 0 ; 1 2
[x] B : 0 ; 3 4
[x] C : 5 ; 1 6
[x] D : 5 ; 7 8
TOUT : 2 3 4 ; 6 7 8
ORDER : (A,B),(C,D)
=================

python API

import sys
from pathlib import Path
home = str(Path.home())
sys.path.append(home + '/Cytnx_lib')
import cytnx
N = cytnx.Network("example.net")
print(N)

output>

==== Network ====
[x] A : 0 ; 1 2
[x] B : 0 ; 3 4
[x] C : 5 ; 1 6
[x] D : 5 ; 7 8
TOUT : 2 3 4 ; 6 7 8
ORDER : (A,B),(C,D)
=================

◆ FromString()

void cytnx::Network::FromString ( const std::vector< std::string > &  contents,
const int &  network_type = NtType.Regular 
)
inline

Construct Network from a list of strings, where each string is the same as each line in network file.

Parameters
contentsThe network file descriptions
network_typeThe type of network. This can be [NtType.Regular] or [NtType.Fermion.]. Currently, only Regular Network is support!

note:

  1. contents cannot have more than 1024 lines/strings.

detail:

Format of each string follows the same policy as Fromfile.

example code for load the network file:

c++ API:

#include "cytnx.hpp"
#include <iostream>
using namespace cytnx;
using namespace std;
int main(int argc, char* argv[]) {
{"A: 0,1,2", "B: 0,3,4", "C: 5,1,6", "D: 5,7,8", "TOUT: 2,3,4;6,7,8", "ORDER: (A,B),(C,D)"});
cout << N << endl;
}
void FromString(const std::vector< std::string > &contents, const int &network_type=NtType.Regular)
Construct Network from a list of strings, where each string is the same as each line in network file.
Definition Network.hpp:357

output>

==== Network ====
[x] A : 0 ; 1 2
[x] B : 0 ; 3 4
[x] C : 5 ; 1 6
[x] D : 5 ; 7 8
TOUT : 2 3 4 ; 6 7 8
ORDER : (A,B),(C,D)
=================

python API

import sys
from pathlib import Path
home = str(Path.home())
sys.path.append(home + '/Cytnx_lib')
import cytnx
N.FromString(["A: 0,1,2",\
"B: 0,3,4",\
"C: 5,1,6",\
"D: 5,7,8",\
"TOUT: 2,3,4;6,7,8",\
"ORDER: (A,B),(C,D)"\
])
print(N);

output>

==== Network ====
[x] A : 0 ; 1 2
[x] B : 0 ; 3 4
[x] C : 5 ; 1 6
[x] D : 5 ; 7 8
TOUT : 2 3 4 ; 6 7 8
ORDER : (A,B),(C,D)
=================

◆ getOptimalOrder()

std::string cytnx::Network::getOptimalOrder ( const int &  network_type = NtType.Regular)
inline

◆ getOrder()

std::string cytnx::Network::getOrder ( )
inline

◆ Launch()

UniTensor cytnx::Network::Launch ( const int &  network_type = NtType.Regular)
inline

◆ PrintNet()

void cytnx::Network::PrintNet ( )
inline

◆ PutUniTensor() [1/2]

void cytnx::Network::PutUniTensor ( const cytnx_uint64 idx,
const UniTensor utensor,
const std::vector< std::string > &  label_order = {} 
)
inline

◆ PutUniTensor() [2/2]

void cytnx::Network::PutUniTensor ( const std::string &  name,
const UniTensor utensor,
const std::vector< std::string > &  label_order = {} 
)
inline

◆ PutUniTensors()

void cytnx::Network::PutUniTensors ( const std::vector< std::string > &  name,
const std::vector< UniTensor > &  utensors 
)
inline

◆ RmUniTensor() [1/2]

void cytnx::Network::RmUniTensor ( const cytnx_uint64 idx)
inline

◆ RmUniTensor() [2/2]

void cytnx::Network::RmUniTensor ( const std::string &  name)
inline

◆ RmUniTensors()

void cytnx::Network::RmUniTensors ( const std::vector< std::string > &  names)
inline

◆ Savefile()

void cytnx::Network::Savefile ( const std::string &  fname)
inline

◆ setOrder()

void cytnx::Network::setOrder ( const bool &  optimal,
const std::string &  contract_order 
)
inline

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