15#include "utils/vec_clone.hpp"
34 std::map<cytnx_uint64, std::pair<std::vector<cytnx_uint64>,
Tensor>>
36 std::map<cytnx_uint64, std::pair<std::vector<cytnx_uint64>,
Tensor>>::iterator _elems_it;
78 }
else if (type ==
"mv_elem") {
81 "[ERROR][LinOp] currently only type=\"mv\" (matvec) can be used.%s",
"\n");
105 this->_elems_it = this->_elems.find(
i);
106 if (this->_elems_it == this->_elems.end()) {
108 Tensor x({1}, this->_dtype);
110 this->_elems[
i] = std::pair<std::vector<cytnx_uint64>,
Tensor>({
j}, x);
113 std::vector<cytnx_uint64> &
vi = this->_elems_it->second.first;
114 Tensor &
ie = this->_elems_it->second.second;
117 "[ERROR] the element is set%s",
"\n");
126 this->_elems_it = this->_elems.find(
i);
127 if (this->_elems_it == this->_elems.end()) {
129 Tensor x({1}, this->_dtype);
131 this->_elems[
i] = std::pair<std::vector<cytnx_uint64>,
Tensor>({
j}, x);
132 return this->_elems[
i].second(0);
134 std::vector<cytnx_uint64> &
vi = this->_elems_it->second.first;
135 Tensor &
ie = this->_elems_it->second.second;
145 return ie(
vi.size() - 1);
158 this->_dtype =
dtype;
160 int device()
const {
return this->_device; };
161 int dtype()
const {
return this->_dtype; };
virtual Tensor matvec(const Tensor &Tin)
int device() const
Definition LinOp.hpp:160
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:75
int dtype() const
Definition LinOp.hpp:161
cytnx_uint64 nx() const
Definition LinOp.hpp:162
void set_elem(const cytnx_uint64 &i, const cytnx_uint64 &j, const T &elem, const bool check_exists=true)
Definition LinOp.hpp:103
void set_device(const int &device)
Definition LinOp.hpp:152
void set_dtype(const int &dtype)
Definition LinOp.hpp:156
Tensor::Tproxy operator()(const cytnx_uint64 &i, const cytnx_uint64 &j)
Definition LinOp.hpp:123
an tensor (multi-dimensional array)
Definition Tensor.hpp:41
int device() const
the device-id of the Tensor
Definition Tensor.hpp:521
An Enhanced tensor specifically designed for physical Tensor network simulation.
Definition UniTensor.hpp:1706
#define cytnx_error_msg(is_true, format,...)
Definition cytnx_error.hpp:16
Helper function to print vector with ODT:
Definition Accessor.hpp:12
Device_class Device
data on which devices.
uint64_t cytnx_uint64
Definition Type.hpp:55