Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions include/Accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <vector>
#include <cstring>
#include <string>
#include <iostream>
#include <initializer_list>
#include <ostream>

namespace cytnx {

Expand Down Expand Up @@ -63,7 +63,6 @@ namespace cytnx {
std::vector<T> tmp = list;
this->_type = this->list;
this->idx_list = std::vector<cytnx_int64>(tmp.begin(), tmp.end());
// std::cout << "VV" << this->idx_list.size() << std::endl;
}; // construct from vector/list, should be 1d with dtype integer.

template <class T>
Expand Down Expand Up @@ -184,10 +183,8 @@ namespace cytnx {

template <class T, class... Ts>
std::vector<cytnx::Accessor> Indices_resolver(const T &a, const Ts &...args) {
// std::cout << a << std::endl;;
std::vector<cytnx::Accessor> idxs;
_resolve_elems(idxs, a, args...);
// cout << idxs << endl;
return idxs;
}
///@endcond
Expand Down
14 changes: 8 additions & 6 deletions include/Bond.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#ifndef CYTNX_BOND_H_
#define CYTNX_BOND_H_

#include "Type.hpp"
#include "cytnx_error.hpp"
#include "Symmetry.hpp"
#include <initializer_list>
#include <vector>
#include <algorithm>
#include <fstream>
#include <initializer_list>
#include <map>
#include <algorithm>
#include <ostream>
#include <vector>

#include "Symmetry.hpp"
#include "Type.hpp"
#include "cytnx_error.hpp"
#include "intrusive_ptr_base.hpp"
#include "utils/vec_clone.hpp"

Expand Down
8 changes: 6 additions & 2 deletions include/Device.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifndef CYTNX_DEVICE_H_
#define CYTNX_DEVICE_H_

#include <vector>
#include <iostream>
#include <string>
#include <vector>

namespace cytnx {

Expand All @@ -18,7 +19,10 @@ namespace cytnx {
int Ncpus;
std::vector<std::vector<bool>> CanAccessPeer;
Device_class();
void Print_Property();
void Print_Property() { this->Print_Property(std::cout); }
/// @cond
void Print_Property(std::ostream &os);
/// @endcond
std::string getname(const int &device_id);
~Device_class();
// void cudaDeviceSynchronize();
Expand Down
31 changes: 18 additions & 13 deletions include/Gncon.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#ifndef CYTNX_GNCON_H_
#define CYTNX_GNCON_H_

#include "Type.hpp"
#include "cytnx_error.hpp"
#include <fstream>
#include <initializer_list>
#include <vector>
#include <iostream>
#include <map>
#include <fstream>
#include "intrusive_ptr_base.hpp"
#include "utils/utils.hpp"
#include <vector>

#include "Type.hpp"
#include "UniTensor.hpp"
#include "contraction_tree.hpp"
#include "cytnx_error.hpp"
#include "intrusive_ptr_base.hpp"
#include "utils/utils.hpp"

#ifdef BACKEND_TORCH
#else
Expand Down Expand Up @@ -69,7 +71,7 @@ namespace cytnx {
return true;
}

// void print_Gncon() const;
// void print_Gncon(std::ostream &os = std::cout) const;

// void PreConstruct(bool force = true);

Expand All @@ -93,7 +95,7 @@ namespace cytnx {
virtual void clear();
virtual std::string getOptimalOrder();
virtual UniTensor Launch(const bool &optimal = false, const std::string &contract_order = "");
virtual void PrintNet(std::ostream &os);
virtual void PrintNet(std::ostream &os) const;
virtual boost::intrusive_ptr<Gncon_base> clone();
virtual void Savefile(const std::string &fname);
virtual ~Gncon_base(){};
Expand Down Expand Up @@ -137,7 +139,7 @@ namespace cytnx {
boost::intrusive_ptr<Gncon_base> out(tmp);
return out;
}
void PrintNet(std::ostream &os);
void PrintNet(std::ostream &os) const;
void Savefile(const std::string &fname);
~RegularGncon(){};
};
Expand Down Expand Up @@ -182,9 +184,9 @@ namespace cytnx {
boost::intrusive_ptr<Gncon_base> out(tmp);
return out;
}
void PrintNet(std::ostream &os){};
void Savefile(const std::string &fname){};
~FermionGncon(){};
void PrintNet(std::ostream &os) const;
void Savefile(const std::string &fname);
~FermionGncon();
Comment thread
manuschneider marked this conversation as resolved.
Outdated
};

///@endcond
Expand Down Expand Up @@ -352,7 +354,10 @@ namespace cytnx {
out._impl = this->_impl->clone();
return out;
}
void PrintNet() { this->_impl->PrintNet(std::cout); }
void PrintNet() const { this->_impl->PrintNet(std::cout); }
/// @cond
void PrintNet(std::ostream &os) const { this->_impl->PrintNet(os); }
/// @endcond

void Savefile(const std::string &fname) { this->_impl->Savefile(fname); }
};
Expand Down
17 changes: 11 additions & 6 deletions include/LinOp.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#ifndef CYTNX_LINOP_H_
#define CYTNX_LINOP_H_

#include "Type.hpp"
#include "cytnx_error.hpp"
#include <vector>
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <utility>
#include <algorithm>
#include "intrusive_ptr_base.hpp"
#include <vector>

#include "Tensor.hpp"
#include "Type.hpp"
#include "UniTensor.hpp"
#include "cytnx_error.hpp"
#include "intrusive_ptr_base.hpp"

#ifdef BACKEND_TORCH
#else
Expand Down Expand Up @@ -156,7 +158,10 @@ namespace cytnx {
int dtype() const { return this->_dtype; };
cytnx_uint64 nx() const { return this->_nx; };

void _print();
void _print() { this->_print(std::cout); };
/// @cond
void _print(std::ostream &os);
/// @endcond

/// @cond
// this expose to interitance:
Expand Down
31 changes: 18 additions & 13 deletions include/Network.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#ifndef CYTNX_NETWORK_H_
#define CYTNX_NETWORK_H_

#include "Type.hpp"
#include "cytnx_error.hpp"
#include <fstream>
#include <initializer_list>
#include <vector>
#include <iostream>
#include <map>
#include <fstream>
#include "intrusive_ptr_base.hpp"
#include "utils/utils.hpp"
#include <vector>

#include "Type.hpp"
#include "UniTensor.hpp"
#include "contraction_tree.hpp"
#include "cytnx_error.hpp"
#include "intrusive_ptr_base.hpp"
#include "utils/utils.hpp"

#ifdef BACKEND_TORCH
#else
Expand Down Expand Up @@ -95,7 +97,7 @@ namespace cytnx {
return true;
}

// void print_network() const;
// void print_network(std::ostream &os = std::cout) const;

// void PreConstruct(bool force = true);

Expand Down Expand Up @@ -135,7 +137,7 @@ namespace cytnx {
const std::vector<std::vector<std::string>> &labels,
const std::vector<std::string> &outlabel, const cytnx_int64 &outrk,
const std::string &order, const bool optim);
virtual void PrintNet(std::ostream &os);
virtual void PrintNet(std::ostream &os = std::cout) const;
virtual boost::intrusive_ptr<Network_base> clone();
virtual void Savefile(const std::string &fname);
virtual ~Network_base(){};
Expand Down Expand Up @@ -194,7 +196,7 @@ namespace cytnx {
boost::intrusive_ptr<Network_base> out(tmp);
return out;
}
void PrintNet(std::ostream &os);
void PrintNet(std::ostream &os = std::cout) const;
void Savefile(const std::string &fname);
~RegularNetwork(){};
};
Expand Down Expand Up @@ -245,9 +247,9 @@ namespace cytnx {
boost::intrusive_ptr<Network_base> out(tmp);
return out;
}
void PrintNet(std::ostream &os){};
void Savefile(const std::string &fname){};
~FermionNetwork(){};
void PrintNet(std::ostream &os = std::cout) const;
void Savefile(const std::string &fname);
~FermionNetwork();
Comment thread
manuschneider marked this conversation as resolved.
Outdated
};

///@endcond
Expand Down Expand Up @@ -450,7 +452,10 @@ namespace cytnx {
out._impl = this->_impl->clone();
return out;
}
void PrintNet() { this->_impl->PrintNet(std::cout); }
void PrintNet() const { this->_impl->PrintNet(std::cout); }
/// @cond
void PrintNet(std::ostream &os) const { this->_impl->PrintNet(os); }
/// @endcond

void Savefile(const std::string &fname) { this->_impl->Savefile(fname); }
};
Expand Down
23 changes: 13 additions & 10 deletions include/Symmetry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define CYTNX_SYMMETRY_H_

#include <fstream>
#include <ostream>
#include <iostream>
#include <string>
#include <vector>

Expand Down Expand Up @@ -90,7 +90,7 @@ namespace cytnx {
virtual fermionParity get_fermion_parity(const cytnx_int64 &in_qnum) const;
virtual bool is_fermionic() const { return false; };

virtual void print_info() const;
virtual void print_info(std::ostream &os = std::cout) const;
virtual std::string stype_str() const;
// virtual std::vector<cytnx_int64>& combine_rule(const std::vector<cytnx_int64> &inL, const
// std::vector<cytnx_int64> &inR);
Expand All @@ -105,7 +105,7 @@ namespace cytnx {
void Init(const int &n) {
this->stype_id = SymmetryType::U;
this->n = n;
if (n != 1) cytnx_error_msg(1, "%s", "[ERROR] U1Symmetry should set n = 1");
if (n != 1) cytnx_error_msg(true, "%s", "[ERROR] U1Symmetry should set n = 1");
}
boost::intrusive_ptr<Symmetry_base> clone() {
boost::intrusive_ptr<Symmetry_base> out(new U1Symmetry(this->n));
Expand All @@ -118,7 +118,7 @@ namespace cytnx {
void combine_rule_(cytnx_int64 &out, const cytnx_int64 &inL, const cytnx_int64 &inR,
const bool &is_reverse);
void reverse_rule_(cytnx_int64 &out, const cytnx_int64 &in);
void print_info() const;
void print_info(std::ostream &os = std::cout) const;
std::string stype_str() const override { return "U1"; };
};
///@endcond
Expand All @@ -131,7 +131,7 @@ namespace cytnx {
void Init(const int &n) {
this->stype_id = SymmetryType::Z;
this->n = n;
if (n <= 1) cytnx_error_msg(1, "%s", "[ERROR] ZnSymmetry can only have n > 1");
if (n <= 1) cytnx_error_msg(true, "%s", "[ERROR] ZnSymmetry can only have n > 1");
}
boost::intrusive_ptr<Symmetry_base> clone() {
boost::intrusive_ptr<Symmetry_base> out(new ZnSymmetry(this->n));
Expand All @@ -144,7 +144,7 @@ namespace cytnx {
void combine_rule_(cytnx_int64 &out, const cytnx_int64 &inL, const cytnx_int64 &inR,
const bool &is_reverse);
void reverse_rule_(cytnx_int64 &out, const cytnx_int64 &in);
void print_info() const;
void print_info(std::ostream &os = std::cout) const;
std::string stype_str() const override { return "Z" + std::to_string(this->n); };
};
///@endcond
Expand All @@ -169,7 +169,7 @@ namespace cytnx {
void reverse_rule_(cytnx_int64 &out, const cytnx_int64 &in);
fermionParity get_fermion_parity(const cytnx_int64 &in_qnum) const override;
bool is_fermionic() const override { return true; };
void print_info() const;
void print_info(std::ostream &os = std::cout) const;
std::string stype_str() const override { return "fP"; }
};
///@endcond
Expand All @@ -194,7 +194,7 @@ namespace cytnx {
void reverse_rule_(cytnx_int64 &out, const cytnx_int64 &in);
fermionParity get_fermion_parity(const cytnx_int64 &in_qnum) const override;
bool is_fermionic() const override { return true; };
void print_info() const;
void print_info(std::ostream &os = std::cout) const;
std::string stype_str() const override { return "f#"; }
};
///@endcond
Expand Down Expand Up @@ -226,7 +226,7 @@ namespace cytnx {
boost::intrusive_ptr<Symmetry_base> tmp(new FermionNumberSymmetry());
this->_impl = tmp;
} else {
cytnx_error_msg(1, "%s", "[ERROR] invalid symmetry type.");
cytnx_error_msg(true, "%s", "[ERROR] invalid symmetry type.");
}
}
Symmetry &operator=(const Symmetry &rhs) {
Expand Down Expand Up @@ -524,7 +524,10 @@ namespace cytnx {
/**
* @brief Print the information of current Symmetry object.
*/
void print_info() const { this->_impl->print_info(); }
void print_info() const { this->_impl->print_info(std::cout); }
/// @cond
void print_info(std::ostream &os) const { this->_impl->print_info(os); }
/// @endcond

/**
* @brief the equality operator of the Symmetry object.
Expand Down
5 changes: 0 additions & 5 deletions include/Tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,25 +232,21 @@ namespace cytnx {
//----------------------------------------
template <class... Ts>
Tproxy operator()(const std::string &e1, const Ts &...elems) {
// std::cout << e1 << std::endl;
std::vector<cytnx::Accessor> tmp = Indices_resolver(e1, elems...);
return (*this)[tmp];
}
template <class... Ts>
Tproxy operator()(const cytnx_int64 &e1, const Ts &...elems) {
// std::cout << e1<< std::endl;
std::vector<cytnx::Accessor> tmp = Indices_resolver(e1, elems...);
return (*this)[tmp];
}
template <class... Ts>
Tproxy operator()(const cytnx::Accessor &e1, const Ts &...elems) {
// std::cout << e1 << std::endl;
std::vector<cytnx::Accessor> tmp = Indices_resolver(e1, elems...);
return (*this)[tmp];
}
template <class... Ts>
const Tproxy operator()(const std::string &e1, const Ts &...elems) const {
// std::cout << e1 << std::endl;
std::vector<cytnx::Accessor> tmp = Indices_resolver(e1, elems...);
return (*this)[tmp];
}
Expand Down Expand Up @@ -805,7 +801,6 @@ namespace cytnx {
template <class... Ts>
Tensor &reshape_(const cytnx_int64 &e1, const Ts... elems) {
std::vector<cytnx_int64> shape = dynamic_arg_int64_resolver(e1, elems...);
// std::cout << shape << std::endl;
this->_impl->reshape_(shape);
return *this;
}
Expand Down
Loading
Loading