31 std::map<cytnx_uint64, std::pair<std::vector<cytnx_uint64>,
Tensor>>
33 std::map<cytnx_uint64, std::pair<std::vector<cytnx_uint64>,
Tensor>>::iterator _elems_it;
71 }
else if (type ==
"mv_elem") {
74 "[ERROR][LinOp] currently only type=\"mv\" (matvec) can be used.%s",
"\n");
98 this->_elems_it = this->_elems.find(
i);
99 if (this->_elems_it == this->_elems.end()) {
103 this->_elems[
i] = std::pair<std::vector<cytnx_uint64>,
Tensor>({
j},
x);
106 std::vector<cytnx_uint64> &
vi = this->_elems_it->second.first;
107 Tensor &
ie = this->_elems_it->second.second;
110 "[ERROR] the element is set%s",
"\n");
119 this->_elems_it = this->_elems.find(
i);
120 if (this->_elems_it == this->_elems.end()) {
124 this->_elems[
i] = std::pair<std::vector<cytnx_uint64>,
Tensor>({
j},
x);
125 return this->_elems[
i].second(0);
127 std::vector<cytnx_uint64> &
vi = this->_elems_it->second.first;
128 Tensor &
ie = this->_elems_it->second.second;
138 return ie(
vi.size() - 1);
151 this->_dtype =
dtype;
153 int device()
const {
return this->_device; };
154 int dtype()
const {
return this->_dtype; };
constexpr Type_class Type
data type
Definition Type.hpp:553
virtual Tensor matvec(const Tensor &Tin)
int device() const
Definition LinOp.hpp:153
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:68
int dtype() const
Definition LinOp.hpp:154
cytnx_uint64 nx() const
Definition LinOp.hpp:155
void set_elem(const cytnx_uint64 &i, const cytnx_uint64 &j, const T &elem, const bool check_exists=true)
Definition LinOp.hpp:96
void set_device(const int &device)
Definition LinOp.hpp:145
void set_dtype(const int &dtype)
Definition LinOp.hpp:149
Tensor::Tproxy operator()(const cytnx_uint64 &i, const cytnx_uint64 &j)
Definition LinOp.hpp:116
an tensor (multi-dimensional array)
Definition Tensor.hpp:33
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:2773
#define cytnx_error_msg(is_true, format,...)
Definition cytnx_error.hpp:118
Definition Accessor.hpp:12
Device_class Device
data on which devices.