Cytnx v0.9.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
cytnx::LinOp Class Reference

#include <LinOp.hpp>

Public Member Functions

 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.
 
template<class T >
void set_elem (const cytnx_uint64 &i, const cytnx_uint64 &j, const T &elem, const bool check_exists=true)
 
Tensor::Tproxy operator() (const cytnx_uint64 &i, const cytnx_uint64 &j)
 
void set_device (const int &device)
 
void set_dtype (const int &dtype)
 
int device () const
 
int dtype () const
 
cytnx_uint64 nx () const
 
void _print ()
 
virtual Tensor matvec (const Tensor &Tin)
 

Constructor & Destructor Documentation

◆ LinOp()

cytnx::LinOp::LinOp ( const std::string &  type,
const cytnx_uint64 nx,
const int dtype = Type.Double,
const int device = Device.cpu 
)
inline

Linear Operator class for iterative solvers.

Parameters
typethe type of operator, currently it can only be "mv" (matvec) or "mv_elem" (matvec with pre-store element)
nxthe last dimension of operator, this should be the dimension of the input vector when "mv_elem" is used.
dtypethe Operator's dtype. Note that this should match the input/output Tensor's dtype.
devicethe Operator's on device.

Note:

  1. the device and dtype should be set. This should be the same as the input and output vectors. by default, we assume custom_f take input and output vector to be on CPU and Double type.

Details:

The LinOp class is a class that defines a custom Linear operation acting on a Tensor or UniTensor. To use, inherit this class and override the matvec function. See the following examples for how to use them.

Example:

c++ API:

output>

 

python API:

output>

 

Member Function Documentation

◆ _print()

void cytnx::LinOp::_print ( )

◆ device()

int cytnx::LinOp::device ( ) const
inline

◆ dtype()

int cytnx::LinOp::dtype ( ) const
inline

◆ matvec()

virtual Tensor cytnx::LinOp::matvec ( const Tensor Tin)
virtual

◆ nx()

cytnx_uint64 cytnx::LinOp::nx ( ) const
inline

◆ operator()()

◆ set_device()

void cytnx::LinOp::set_device ( const int device)
inline

◆ set_dtype()

void cytnx::LinOp::set_dtype ( const int dtype)
inline

◆ set_elem()

template<class T >
void cytnx::LinOp::set_elem ( const cytnx_uint64 i,
const cytnx_uint64 j,
const T elem,
const bool  check_exists = true 
)
inline

The documentation for this class was generated from the following file: