Public Member Functions | List of all members
o2scl::tensor2< data_t, vec_t, vec_size_t > Class Template Reference

Rank 2 tensor. More...

#include <tensor.h>

Inheritance diagram for o2scl::tensor2< data_t, vec_t, vec_size_t >:
o2scl::tensor< double, std::vector< double >, std::vector< size_t > >

Detailed Description

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

Definition at line 1234 of file tensor.h.

Public Member Functions

 tensor2 ()
 Create an empty tensor.
 
 tensor2 (size_t sz, size_t sz2)
 Create a rank 2 tensor of size (sz,sz2)
 
Method to check for valid object
void is_valid () const
 Check that the o2scl::tensor2 object is valid.
 
Specialized get and set functions
data_t & get (size_t ix1, size_t ix2)
 Get the element indexed by (ix1,ix2)
 
const data_t & get (size_t ix1, size_t ix2) const
 Get the element indexed by (ix1,ix2)
 
void set (size_t ix1, size_t ix2, data_t val)
 Set the element indexed by (ix1,ix2) to value val.
 
template<class size_vec_t >
void set (const size_vec_t &index, data_t val)
 Set the element indexed by index to value val. More...
 
data_t & operator() (size_t ix, size_t iy)
 Get the element indexed by (ix1,ix2)
 
const data_t & operator() (size_t ix, size_t iy) const
 Get the element indexed by (ix1,ix2) (const version)
 
- Public Member Functions inherited from o2scl::tensor< double, std::vector< double >, std::vector< size_t > >
 tensor ()
 Create an empty tensor with zero rank.
 
 tensor (size_t rank, const size_vec_t &dim)
 Create a tensor of rank rank with sizes given in dim. More...
 
 tensor (const tensor< double, std::vector< double >, std::vector< size_t > > &t)
 Copy using operator()
 
tensor< double, std::vector< double >, std::vector< size_t > > & operator= (const tensor< double, std::vector< double >, std::vector< size_t > > &t)
 Copy using operator=()
 
void is_valid () const
 Check that the o2scl::tensor object is valid.
 
void clear ()
 Clear the tensor of all data and free allocated memory.
 
void set (const size_vec_t &index, double val)
 Set the element indexed by index to value val.
 
void set_all (double x)
 Set all elements in a tensor to some fixed value.
 
void swap_data (std::vector< double > &dat)
 Swap the data vector.
 
ubvector_slice vector_slice (size_t ix, const size_vec_t &index)
 Fix all but one index to create a vector. More...
 
void resize (size_t rank, const size_vec_t &dim)
 Resize the tensor to rank rank with sizes given in dim. More...
 
size_t get_rank () const
 Return the rank of the tensor.
 
size_t get_size (size_t i) const
 Returns the size of the ith index.
 
const std::vector< size_t > & get_size_arr () const
 Return the full vector of sizes.
 
const std::vector< double > & get_data () const
 Return the full data vector.
 
size_t total_size () const
 Returns the size of the tensor (the product of the sizes over every index)
 
size_t pack_indices (const size_vec_t &index)
 Pack the indices into a single vector index.
 
void unpack_index (size_t ix, size_vec_t &index)
 Unpack the single vector index into indices.
 
double min_value ()
 Compute the minimum value in the tensor.
 
void min_index (std::vector< size_t > &index)
 Compute the index of the minimum value in the tensor.
 
void min (std::vector< size_t > &index, double &val)
 Compute the index of the minimum value in the tensor and return the minimum.
 
double max_value ()
 Compute the maximum value in the tensor.
 
void max_index (std::vector< size_t > &index)
 Compute the index of the maximum value in the tensor.
 
void max (std::vector< size_t > &index, double &val)
 Compute the index and value of the maximum value in the tensor and return the maximum.
 
void minmax_value (double &min, double &max)
 Compute the minimum and maximum values in the tensor.
 
void minmax_index (std::vector< size_t > &index_min, std::vector< size_t > &index_max)
 Compute the indices of the minimum and maximum values in the tensor.
 
void minmax (std::vector< size_t > &index, size_t &index_min, double &min, size_t &index_max, double &max)
 Compute the indices and values of the maximum and minimum in the tensor.
 
double total_sum () const
 Return the sum over every element in the tensor.
 
void convert_table3d_sum (size_t ix_x, size_t ix_y, table3d &tab, std::string x_name="x", std::string y_name="y", std::string slice_name="z")
 Convert to a o2scl::table3d object by summing over all but two indices.
 
tensor< double > rearrange_and_copy (std::vector< index_spec > spec, int verbose=0, bool err_on_fail=true)
 Rearrange, sum and copy current tensor to a new tensor. More...
 
double & get (const size_vec_t &index)
 Get the element indexed by index.
 
const double & get (const size_vec_t &index) const
 Get a const reference to the element indexed by index.
 

Additional Inherited Members

- Public Types inherited from o2scl::tensor< double, std::vector< double >, std::vector< size_t > >
typedef boost::numeric::ublas::vector_slice< boost::numeric::ublas::vector< double > > ubvector_slice
 
typedef boost::numeric::ublas::slice slice
 
- Protected Attributes inherited from o2scl::tensor< double, std::vector< double >, std::vector< size_t > >
std::vector< double > data
 The data.
 
std::vector< size_t > size
 A rank-sized vector of the sizes of each dimension.
 
size_t rk
 Rank.
 

Member Function Documentation

◆ set()

template<class data_t = double, class vec_t = std::vector<data_t>, class vec_size_t = std::vector<size_t>>
template<class size_vec_t >
void o2scl::tensor2< data_t, vec_t, vec_size_t >::set ( const size_vec_t &  index,
data_t  val 
)
inline

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

Definition at line 1295 of file tensor.h.


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

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).