Class tensor2 (o2scl)

O2scl : Class List

template<class data_t = double, class vec_t = std::vector<data_t>, class vec_size_t = std::vector<size_t>>
class tensor2 : public o2scl::tensor<double, std::vector<double>, std::vector<size_t>>

Rank 2 tensor.

Method to check for valid object

inline void is_valid() const

Check that the o2scl::tensor2 object is valid.

Specialized get and set functions

inline data_t &get(size_t ix1, size_t ix2)

Get the element indexed by (ix1,ix2)

inline const data_t &get(size_t ix1, size_t ix2) const

Get the element indexed by (ix1,ix2)

inline void set(size_t ix1, size_t ix2, data_t val)

Set the element indexed by (ix1,ix2) to value val.

inline size_t size1() const

The size of the first index, for matrix-like semantics.

inline size_t size2() const

The size of the second index, for matrix-like semantics.

inline void resize(size_t nr, size_t nc)

Alternate resize method, for matrix-like semantics.

AWS, 6/11/25: This hides the generic tensor::resize() method, but I think this is worth it to make tensor2<> behave like a mtrix.

template<class size_vec_t>
inline void set(const size_vec_t &index, data_t val)

Set the element indexed by index to value val.

(We have to explicitly provide this version since the set() function is overloaded in this child of tensor.)

inline data_t &operator()(size_t ix, size_t iy)

Get the element indexed by (ix1,ix2)

inline const data_t &operator()(size_t ix, size_t iy) const

Get the element indexed by (ix1,ix2) (const version)

Public Functions

inline tensor2()

Create an empty tensor.

inline tensor2(size_t sz, size_t sz2)

Create a rank 2 tensor of size (sz,sz2)