HighMap library (C++)
Loading...
Searching...
No Matches
hmap::Mat< T > Struct Template Reference

Mat class for basic manipulation of 2D matrices. More...

#include <algebra.hpp>

Collaboration diagram for hmap::Mat< T >:

Public Member Functions

 Mat (Vec2< int > shape)
 Constructor to initialize a matrix with a given shape.
 
T & operator() (int i, int j)
 Access operator to get a reference to the element at (i, j).
 
const T & operator() (int i, int j) const
 Const access operator to get the value of the element at (i, j).
 

Public Attributes

std::vector< T > vector
 1D vector storing matrix elements in row-major order.
 
Vec2< int > shape
 Dimensions of the matrix (rows x columns).
 

Detailed Description

template<typename T>
struct hmap::Mat< T >

Mat class for basic manipulation of 2D matrices.

This class provides basic operations for 2D matrices, such as element access and initialization. It stores the matrix elements in a 1D vector and provides a convenient interface for accessing elements using 2D indices.

Template Parameters
TData type for the matrix elements (e.g., int, float, double).

Constructor & Destructor Documentation

◆ Mat()

template<typename T >
hmap::Mat< T >::Mat ( Vec2< int >  shape)
inline

Constructor to initialize a matrix with a given shape.

Allocates memory for the matrix elements based on the specified shape. The matrix is initialized with the default value of the type T.

Parameters
shapeA Vec2<int> representing the number of rows and columns in the matrix.

Member Function Documentation

◆ operator()() [1/2]

template<typename T >
T & hmap::Mat< T >::operator() ( int  i,
int  j 
)
inline

Access operator to get a reference to the element at (i, j).

Provides non-const access to the matrix element at the specified row and column.

Parameters
iRow index (0-based).
jColumn index (0-based).
Returns
A reference to the element at the specified position.

◆ operator()() [2/2]

template<typename T >
const T & hmap::Mat< T >::operator() ( int  i,
int  j 
) const
inline

Const access operator to get the value of the element at (i, j).

Provides const access to the matrix element at the specified row and column.

Parameters
iRow index (0-based).
jColumn index (0-based).
Returns
A const reference to the element at the specified position.

Member Data Documentation

◆ vector

template<typename T >
std::vector<T> hmap::Mat< T >::vector

1D vector storing matrix elements in row-major order.

◆ shape

template<typename T >
Vec2<int> hmap::Mat< T >::shape

Dimensions of the matrix (rows x columns).


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