33 std::map<cytnx_uint64, std::pair<std::vector<cytnx_uint64>,
Tensor>>
35 std::map<cytnx_uint64, std::pair<std::vector<cytnx_uint64>,
Tensor>>::iterator _elems_it;
73 }
else if (type ==
"mv_elem") {
76 "[ERROR][LinOp] currently only type=\"mv\" (matvec) can be used.%s",
"\n");
100 this->_elems_it = this->_elems.find(
i);
101 if (this->_elems_it == this->_elems.end()) {
105 this->_elems[
i] = std::pair<std::vector<cytnx_uint64>,
Tensor>({
j},
x);
108 std::vector<cytnx_uint64> &
vi = this->_elems_it->second.first;
109 Tensor &
ie = this->_elems_it->second.second;
112 "[ERROR] the element is set%s",
"\n");
121 this->_elems_it = this->_elems.find(
i);
122 if (this->_elems_it == this->_elems.end()) {
126 this->_elems[
i] = std::pair<std::vector<cytnx_uint64>,
Tensor>({
j},
x);
127 return this->_elems[
i].second(0);
129 std::vector<cytnx_uint64> &
vi = this->_elems_it->second.first;
130 Tensor &
ie = this->_elems_it->second.second;
140 return ie(
vi.size() - 1);
153 this->_dtype =
dtype;
155 int device()
const {
return this->_device; };
156 int dtype()
const {
return this->_dtype; };
constexpr Type_class Type
data type
Definition Type.hpp:426
virtual Tensor matvec(const Tensor &Tin)
int device() const
Definition LinOp.hpp:155
LinOp(const std::string &type, const cytnx_uint64 &nx, const int &dtype=Type.Double, const int &device=Device.cpu)
Linear Operator class for iterative solvers.
Definition LinOp.hpp:70
int dtype() const
Definition LinOp.hpp:156
cytnx_uint64 nx() const
Definition LinOp.hpp:157
void set_elem(const cytnx_uint64 &i, const cytnx_uint64 &j, const T &elem, const bool check_exists=true)
Definition LinOp.hpp:98
void set_device(const int &device)
Definition LinOp.hpp:147
void set_dtype(const int &dtype)
Definition LinOp.hpp:151
Tensor::Tproxy operator()(const cytnx_uint64 &i, const cytnx_uint64 &j)
Definition LinOp.hpp:118
an tensor (multi-dimensional array)
Definition Tensor.hpp:41
int device() const
the device-id of the Tensor
Definition Tensor.hpp:581
An Enhanced tensor specifically designed for physical Tensor network simulation.
Definition UniTensor.hpp:2599
#define cytnx_error_msg(is_true, format,...)
Definition cytnx_error.hpp:18
Definition Accessor.hpp:12
Device_class Device
data on which devices.