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>

Public Member Functions

 Mat (glm::ivec2 shape)
 Constructor to initialize a matrix with a given shape.
 
 Mat (glm::ivec2 shape, T value)
 Constructor to initialize a matrix with a given shape and value.
 
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).
 
T & operator() (glm::ivec2 ij)
 
const T & operator() (glm::ivec2 ij) const
 

Public Attributes

std::vector< T > vector
 1D vector storing matrix elements in row-major order.
 
glm::ivec2 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() [1/2]

template<typename T >
hmap::Mat< T >::Mat ( glm::ivec2  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 glm::ivec2 representing the number of rows and columns in the matrix.

◆ Mat() [2/2]

template<typename T >
hmap::Mat< T >::Mat ( glm::ivec2  shape,
value 
)
inline

Constructor to initialize a matrix with a given shape and value.

Allocates memory for the matrix elements and initializes all elements with the provided value.

Parameters
shapeA glm::ivec2 representing the number of rows and columns in the matrix.
valueInitial value assigned to all matrix elements.

Member Function Documentation

◆ operator()() [1/4]

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/4]

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.

◆ operator()() [3/4]

template<typename T >
T & hmap::Mat< T >::operator() ( glm::ivec2  ij)
inline

◆ operator()() [4/4]

template<typename T >
const T & hmap::Mat< T >::operator() ( glm::ivec2  ij) const
inline

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 >
glm::ivec2 hmap::Mat< T >::shape

Dimensions of the matrix (rows x columns).


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