Class matrix_view_table (o2scl)

O2scl : Class List

template<class vec_t = std::vector<double>, class fp_t = double>
class matrix_view_table : public o2scl::matrix_view

View a o2scl::table object as a matrix.

When connected to a table, the size1() function returns the number of lines in the table, and the size2() function returns the number of columns which were originally specified in either the constructor or the set() function.

Note

This stores a pointer to the table and the user must ensure that the pointer is valid with the matrix view is accessed.

Public Functions

inline matrix_view_table()

Create a matrix view object from the specified table and list of columns.

inline matrix_view_table(o2scl::table<vec_t, fp_t> &t, std::vector<std::string> cols)

Create a matrix view object from the specified table and list of columns.

inline void set(o2scl::table<vec_t, fp_t> &t, std::vector<std::string> cols)

Create a matrix view object from the specified table and list of columns.

inline size_t size1() const

Return the number of rows.

inline size_t size2() const

Return the number of columns.

inline const fp_t &operator()(size_t row, size_t col) const

Return a reference to the element at row row and column col.

inline fp_t &operator()(size_t row, size_t col)

Return a reference to the element at row row and column col.

Protected Attributes

size_t nc

The number of columns.

size_t nlines

The number of lines in the table.

std::vector<vec_t*> col_ptrs

Pointers to each column.

Friends

template<class vec2_t>
friend void swap(matrix_view_table<vec2_t> &t1, matrix_view_table<vec2_t> &t2)