Class tensor (o2scl)¶
-
template<class data_t = double, class vec_t = std::vector<data_t>, class vec_size_t = std::vector<size_t>>
class tensor : public o2scl::tensor_base<double, std::vector<double>, std::vector<size_t>>¶ Tensor class with arbitrary dimensions (floating-point extension)
Subclassed by o2scl::tensor_grid< std::vector< double >, std::vector< size_t > >, o2scl::tensor1< data_t, vec_t, vec_size_t >, o2scl::tensor2< data_t, vec_t, vec_size_t >, o2scl::tensor3< data_t, vec_t, vec_size_t >, o2scl::tensor4< data_t, vec_t, vec_size_t >, o2scl::tensor_grid< vec_t, vec_size_t >
Slicing and converting to table3d objects
-
inline void copy_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")¶
Copy to a o2scl::table3d object by summing over all but two indices.
-
template<class size_vec2_t>
inline void copy_table3d(size_t ix_x, size_t ix_y, size_vec2_t &index, table3d &tab, std::string x_name = "x", std::string y_name = "y", std::string slice_name = "z") const¶ Copy to a table3d object by fixing two indices.
Warning
The vector input
indexmust be initialized before calling this function so that all elements in the vector (except for those at indexix_xandix_y) are specified. If this is not the case, then this function will return unpredictable results.
-
inline void copy_table3d(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") const¶
Copy to a table3d object by fixing two indices.
In this function, all other indices are set to 0. The indices
ix_xandix_ymay be the same, in which case this function effectively performs a trace over those two indices.
Public Types
-
typedef tensor_base<data_t, vec_t, vec_size_t> parent_t¶
Public Functions
-
inline tensor()¶
Create an empty tensor with zero rank.
-
template<class size_vec_t>
inline tensor(size_t rank, const size_vec_t &dim)¶ Create a tensor of rank
rankwith sizes given indim.The parameter
dimmust be a pointer to a vector of sizes with lengthrank. If the user requests any of the sizes to be zero, this constructor will call the error handler, create an empty tensor, and will allocate no memory.
-
inline virtual ~tensor()¶
-
inline double total_sum() const¶
Return the sum over every element in the tensor.
-
inline void copy_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")¶