MCL
A C++ library mirroring some of the most common Matlab functions.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
mcl::Matrix< T > Class Template Reference

#include <matrixop.h>

Public Member Functions

 Matrix () noexcept
 
 Matrix (Int num_rows, Int num_columns) noexcept
 
 Matrix (const std::vector< std::vector< T > > vectors) noexcept
 
void SetElement (const Int &index_row, const Int &index_column, const T &element) noexcept
 
void SetColumn (Int index_column, std::vector< T > column) noexcept
 
void SetRow (Int index_row, std::vector< T > row) noexcept
 
GetElement (const Int &index_row, const Int &index_column) const noexcept
 
std::vector< T > GetRow (Int index_row) const noexcept
 
std::vector< T > GetColumn (Int index_column) const noexcept
 
std::vector< T > Serial () const noexcept
 
Int num_rows () const noexcept
 
Int num_columns () const noexcept
 
void Save (std::string file_name, mcl::Int precision=5)
 
std::vector< std::vector< T > > data () noexcept
 

Static Public Member Functions

static Matrix Load (std::string file_name)
 
static Matrix Ones (Int number_of_rows, Int number_of_columns) noexcept
 
static Matrix Ones (Int matrix_dimension) noexcept
 

Detailed Description

template<class T>
class mcl::Matrix< T >

Matrix class

Constructor & Destructor Documentation

template<class T>
mcl::Matrix< T >::Matrix ( )
inlinenoexcept

Default constructor with empty (0x0) matrix

template<class T>
mcl::Matrix< T >::Matrix ( Int  num_rows,
Int  num_columns 
)
inlinenoexcept

Constructs a matrix with default entries

template<class T>
mcl::Matrix< T >::Matrix ( const std::vector< std::vector< T > >  vectors)
inlinenoexcept

Constructs a matrix from a vector of vectors (outer vector represents rows)

Member Function Documentation

template<class T>
std::vector<std::vector<T> > mcl::Matrix< T >::data ( )
inlinenoexcept

Returns the raw data

template<class T>
std::vector<T> mcl::Matrix< T >::GetColumn ( Int  index_column) const
inlinenoexcept

Accesses an entire column

template<class T>
T mcl::Matrix< T >::GetElement ( const Int index_row,
const Int index_column 
) const
inlinenoexcept

Accesses an element in given row and column

template<class T>
std::vector<T> mcl::Matrix< T >::GetRow ( Int  index_row) const
inlinenoexcept

Accesses an entire row

template<class T>
static Matrix mcl::Matrix< T >::Load ( std::string  file_name)
inlinestatic

Reads a matrix. Elements have to be separated by tabs and there must be no ending empty line (e.g. 5 lines == 5 rows).

template<class T>
Int mcl::Matrix< T >::num_columns ( ) const
inlinenoexcept

Returns the number of columns

template<class T>
Int mcl::Matrix< T >::num_rows ( ) const
inlinenoexcept

Returns the number of rows

template<class T>
static Matrix mcl::Matrix< T >::Ones ( Int  number_of_rows,
Int  number_of_columns 
)
inlinestaticnoexcept

Constructs a matrix of all ones. Equivalent to Matlab's ones(N,M).

template<class T>
static Matrix mcl::Matrix< T >::Ones ( Int  matrix_dimension)
inlinestaticnoexcept

Constructs a matrix of all ones. Equivalent to Matlab's ones(N).

template<class T>
void mcl::Matrix< T >::Save ( std::string  file_name,
mcl::Int  precision = 5 
)
inline

Writes the matrix to a file. The optional parameter precision sets the number of decimal positions in the output file

template<class T>
std::vector<T> mcl::Matrix< T >::Serial ( ) const
inlinenoexcept

Returns the serialised matrix. Equivalent to Matlab's matrix(:)

template<class T>
void mcl::Matrix< T >::SetColumn ( Int  index_column,
std::vector< T >  column 
)
inlinenoexcept

Sets an entire column

template<class T>
void mcl::Matrix< T >::SetElement ( const Int index_row,
const Int index_column,
const T &  element 
)
inlinenoexcept

Sets element in given row and column

template<class T>
void mcl::Matrix< T >::SetRow ( Int  index_row,
std::vector< T >  row 
)
inlinenoexcept

Sets an entire row


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