EllAlgo 1.6.13
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Matrix2< T > Class Template Reference

A simple 2D matrix class for linear algebra operations. More...

#include <linear_algebra.hpp>

Public Member Functions

 Matrix2 (size_t rows, size_t cols)
 Construct a matrix with specified dimensions.
 
std::vector< T > & operator[] (size_t i)
 
const std::vector< T > & operator[] (size_t i) const
 
size_t rows () const
 
size_t cols () const
 
Vector2< T > operator* (const Vector2< T > &v) const
 

Detailed Description

template<typename T>
class Matrix2< T >

A simple 2D matrix class for linear algebra operations.

This class provides basic matrix operations including matrix-vector multiplication. It is implemented using std::vector of std::vector as the underlying storage.

Template Parameters
TThe element type (typically float or double)

Constructor & Destructor Documentation

◆ Matrix2()

template<typename T >
Matrix2< T >::Matrix2 ( size_t  rows,
size_t  cols 
)
inline

Construct a matrix with specified dimensions.

Creates a matrix with the given number of rows and columns, initializing all elements to the default value of type T.

Parameters
[in]rowsThe number of rows in the Matrix2
[in]colsThe number of columns in the Matrix2

Member Function Documentation

◆ cols()

template<typename T >
size_t Matrix2< T >::cols ( ) const
inline

Returns the number of columns in the Matrix2.

Returns
The number of columns in the Matrix2.

◆ operator*()

template<typename T >
Vector2< T > Matrix2< T >::operator* ( const Vector2< T > &  v) const
inline

Multiplies the given Vector2 by the elements of this Matrix2.

\[ y_i = \sum_{j=1}^{n} A_{ij} x_j \]

Parameters
vThe Vector2 to multiply by the elements of this Matrix2.
Returns
The resulting Vector2 after the multiplication.

◆ operator[]() [1/2]

template<typename T >
std::vector< T > & Matrix2< T >::operator[] ( size_t  i)
inline

Returns a reference to the vector of elements at the specified row index.

Parameters
iThe row index to access.
Returns
A reference to the vector of elements at the specified row index.

◆ operator[]() [2/2]

template<typename T >
const std::vector< T > & Matrix2< T >::operator[] ( size_t  i) const
inline

Returns a constant reference to the vector of elements at the specified row index.

Parameters
iThe row index to access.
Returns
A constant reference to the vector of elements at the specified row index.

◆ rows()

template<typename T >
size_t Matrix2< T >::rows ( ) const
inline

Returns the number of rows in the Matrix2.

Returns
The number of rows in the Matrix2.

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