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;
74 }
else if (type ==
"mv_elem") {
77 "[ERROR][LinOp] currently only type=\"mv\" (matvec) can be used.%s",
"\n");
101 this->_elems_it = this->_elems.find(
i);
102 if (this->_elems_it == this->_elems.end()) {
106 this->_elems[
i] = std::pair<std::vector<cytnx_uint64>,
Tensor>({
j},
x);
109 std::vector<cytnx_uint64> &
vi = this->_elems_it->second.first;
110 Tensor &
ie = this->_elems_it->second.second;
113 "[ERROR] the element is set%s",
"\n");
122 this->_elems_it = this->_elems.find(
i);
123 if (this->_elems_it == this->_elems.end()) {
127 this->_elems[
i] = std::pair<std::vector<cytnx_uint64>,
Tensor>({
j},
x);
128 return this->_elems[
i].second(0);
130 std::vector<cytnx_uint64> &
vi = this->_elems_it->second.first;
131 Tensor &
ie = this->_elems_it->second.second;
141 return ie(
vi.size() - 1);
154 this->_dtype =
dtype;
156 int device()
const {
return this->_device; };
157 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:156
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:71
int dtype() const
Definition LinOp.hpp:157
cytnx_uint64 nx() const
Definition LinOp.hpp:158
void set_elem(const cytnx_uint64 &i, const cytnx_uint64 &j, const T &elem, const bool check_exists=true)
Definition LinOp.hpp:99
void set_device(const int &device)
Definition LinOp.hpp:148
void set_dtype(const int &dtype)
Definition LinOp.hpp:152
Tensor::Tproxy operator()(const cytnx_uint64 &i, const cytnx_uint64 &j)
Definition LinOp.hpp:119
an tensor (multi-dimensional array)
Definition Tensor.hpp:41
int device() const
the device-id of the Tensor
Definition Tensor.hpp:577
An Enhanced tensor specifically designed for physical Tensor network simulation.
Definition UniTensor.hpp:1794
#define cytnx_error_msg(is_true, format,...)
Definition cytnx_error.hpp:18
Definition Accessor.hpp:12
Device_class Device
data on which devices.