A class representing static n times m-dimensional matrices.
Matrices are ubiquitous in mathematics and computer science. Often, matrices represent linear operations and are applied to accordingly-sized vectors.
A matrix can be constructed using a variadic constructor which takes the matrix components in row-major order. This way, you can arrange the matrix's components nicely in the source code, as seen in the following example:
Matrix defines addition, subtraction, multiplication, scalar multiplication and multiplication by a vector.
The matrix's internal representation is row-major, which means that a row is represented as a contiguous chunk of memory. Consequently, operator[]
takes the row number and returns a row, which is represented as an fcppt::math::vector::object using a view as storage type. Here is an example:
|
template<typename T , fcppt::math::size_type N, typename S > |
fcppt::math::matrix::static_< T, N, N > | fcppt::math::matrix::adjugate (fcppt::math::matrix::object< T, N, N, S > const &_matrix) |
| Calculates the adjugate matrix.
|
|
template<typename Left , typename Right , fcppt::math::size_type R, fcppt::math::size_type C, typename S1 , typename S2 > |
fcppt::math::matrix::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(Left,+, Right), R, C > | fcppt::math::matrix::operator+ (fcppt::math::matrix::object< Left, R, C, S1 > const &_left, fcppt::math::matrix::object< Right, R, C, S2 > const &_right) |
| Adds two matrices.
|
|
template<typename Left , typename Right , fcppt::math::size_type R, fcppt::math::size_type C, typename S1 , typename S2 > |
fcppt::math::matrix::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(Left, -, Right), R, C > | fcppt::math::matrix::operator- (fcppt::math::matrix::object< Left, R, C, S1 > const &_left, fcppt::math::matrix::object< Right, R, C, S2 > const &_right) |
| Subtracts one matrix from another.
|
|
template<typename L , typename R , fcppt::math::size_type N, fcppt::math::size_type M1, fcppt::math::size_type M2, typename S1 , typename S2 > |
fcppt::math::matrix::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L, *, R), M1, M2 > | fcppt::math::matrix::operator* (fcppt::math::matrix::object< L, M1, N, S1 > const &_left, fcppt::math::matrix::object< R, N, M2, S2 > const &_right) |
| Multiplies two matrices.
|
|
template<typename Left , typename Right , fcppt::math::size_type R, fcppt::math::size_type C, typename S > |
fcppt::math::matrix::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(Left, *, Right), R, C > | fcppt::math::matrix::operator* (fcppt::math::matrix::object< Left, R, C, S > const &_left, Right const &_right) |
| Multiplies a matrix by a scalar.
|
|
template<typename Left , typename Right , fcppt::math::size_type R, fcppt::math::size_type C, typename S > |
fcppt::math::matrix::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(Left, *, Right), R, C > | fcppt::math::matrix::operator* (Left const &_left, fcppt::math::matrix::object< Right, R, C, S > const &_right) |
| Multiplies a matrix by a scalar.
|
|
template<fcppt::math::size_type Index, typename Matrix > |
fcppt::container::to_reference_type< std::remove_reference_t< Matrix > > | fcppt::math::matrix::at_r (Matrix &_value) |
| Access a row using a compile-time constant.
|
|
template<fcppt::math::size_type R, fcppt::math::size_type C, typename Matrix > |
fcppt::container::to_reference_type< fcppt::container::to_reference_type< std::remove_reference_t< Matrix > > > | fcppt::math::matrix::at_r_c (Matrix &_value) |
| Access an element using compile-time constants for both row and column.
|
|
template<typename T1 , typename T2 , fcppt::math::size_type R, fcppt::math::size_type C, typename S1 , typename S2 , typename Function > |
fcppt::math::matrix::static_< std::invoke_result_t< Function, T1, T2 >, R, C > | fcppt::math::matrix::binary_map (fcppt::math::matrix::object< T1, R, C, S1 > const &_left, fcppt::math::matrix::object< T2, R, C, S2 > const &_right, Function const &_function) |
| Maps over two matrixs.
|
|
template<typename T , fcppt::math::size_type R, fcppt::math::size_type C, typename S1 , typename S2 > |
bool | fcppt::math::matrix::operator== (fcppt::math::matrix::object< T, R, C, S1 > const &_m1, fcppt::math::matrix::object< T, R, C, S2 > const &_m2) |
| Compares two matrices component-wise.
|
|
template<typename T , fcppt::math::size_type R, fcppt::math::size_type C, typename S1 , typename S2 > |
bool | fcppt::math::matrix::operator!= (fcppt::math::matrix::object< T, R, C, S1 > const &_m1, fcppt::math::matrix::object< T, R, C, S2 > const &_m2) |
| Compares two matrices component-wise.
|
|
template<typename T , fcppt::math::size_type R, fcppt::math::size_type C, typename S1 , typename S2 > |
bool | fcppt::math::matrix::componentwise_equal (fcppt::math::matrix::object< T, R, C, S1 > const &_m1, fcppt::math::matrix::object< T, R, C, S2 > const &_m2, T const _epsilon) |
| Compares two floating point matrices componentwise using an epsilon.
|
|
template<fcppt::math::size_type DR, fcppt::math::size_type DC, typename T , typename S , fcppt::math::size_type R, fcppt::math::size_type C> |
fcppt::math::matrix::static_< T, R - 1U, C - 1U > | fcppt::math::matrix::delete_row_and_column (fcppt::math::matrix::object< T, R, C, S > const &_matrix) |
| Deletes a specific row and rolumn (a cross) from the matrix.
|
|
template<typename T , fcppt::math::size_type N, typename S > |
T | fcppt::math::matrix::determinant (fcppt::math::matrix::object< T, N, N, S > const &_matrix) |
| Calculates the determinant of a matrix.
|
|
template<typename T , fcppt::math::size_type DN, typename S > |
fcppt::math::matrix::static_< T, DN, DN > | fcppt::math::matrix::exponential_pade (fcppt::math::matrix::object< T, DN, DN, S > const &_matrix) |
| Calculates the matrix exponential e^A using a Pade approximation.
|
|
template<typename Matrix > |
fcppt::math::matrix::to_static< Matrix > | fcppt::math::matrix::identity () |
| Returns the identity matrix;.
|
|
template<typename T , fcppt::math::size_type R, fcppt::math::size_type C, typename S > |
T | fcppt::math::matrix::infinity_norm (fcppt::math::matrix::object< T, R, C, S > const &_matrix) |
| Calculates the infinity norm.
|
|
template<typename Matrix , typename Function > |
Matrix | fcppt::math::matrix::init (Function const &_function) |
| Initializes a matrix.
|
|
template<typename T , fcppt::math::size_type N, typename S > |
fcppt::math::matrix::static_< T, N, N > | fcppt::math::matrix::inverse (fcppt::math::matrix::object< T, N, N, S > const &_matrix) |
| Calculates the inverse matrix, uses fcppt::math::matrix::adjugate and fcppt::math::matrix::determinant.
|
|
template<typename T , fcppt::math::size_type R, fcppt::math::size_type C, typename S , typename Function > |
fcppt::math::matrix::static_< std::invoke_result_t< Function, T >, R, C > | fcppt::math::matrix::map (fcppt::math::matrix::object< T, R, C, S > const &_value, Function const &_function) |
| Maps over the elements of a matrix.
|
|
template<typename T , fcppt::math::size_type R, fcppt::math::size_type C, typename S , typename Ch , typename Traits > |
std::basic_ostream< Ch, Traits > & | fcppt::math::matrix::operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::math::matrix::object< T, R, C, S > const &_matrix) |
| Outputs the matrix to a basic_ostream
|
|
template<typename T > |
fcppt::math::matrix::static_< T, 2, 2 > | fcppt::math::matrix::rotation_2d (T const _angle) |
| Calculates a two dimensional rotation matrix.
|
|
template<typename T , typename S > |
fcppt::math::matrix::static_< T, 4, 4 > | fcppt::math::matrix::rotation_axis (T const _angle, fcppt::math::vector::object< T, 3, S > const &_vector) |
| Calculates a 4x4 rotation matrix around an arbitrary axis given as a unit vector.
|
|
template<typename T > |
fcppt::math::matrix::static_< T, 4, 4 > | fcppt::math::matrix::rotation_x (T const _angle) |
| Calculates a 4x4 rotation matrix around the x axis.
|
|
template<typename T > |
fcppt::math::matrix::static_< T, 4, 4 > | fcppt::math::matrix::rotation_y (T const _angle) |
| Calculates a 4x4 rotation matrix around the y axis.
|
|
template<typename T > |
fcppt::math::matrix::static_< T, 4, 4 > | fcppt::math::matrix::rotation_z (T const _angle) |
| Calculates a 4x4 rotation matrix around the z axis.
|
|
template<typename Type , typename... Args>
requires ( std::conjunction_v<std::is_same<std::remove_cvref_t<Args>, std::remove_cvref_t<Type>>...>) |
fcppt::math::matrix::row_type< std::remove_cvref_t< Type >, fcppt::cast::size< fcppt::math::size_type >(sizeof...(Args)+1U)> | fcppt::math::matrix::row (Type &&_value, Args &&..._args) |
| Creates a matrix row for initialization.
|
|
template<typename T > |
fcppt::math::matrix::static_< T, 4, 4 > | fcppt::math::matrix::scaling (T const _x, T const _y, T const _z) |
| Calculates a 4x4 scaling matrix.
|
|
template<typename Dest , typename Conv , typename T , fcppt::math::size_type R, fcppt::math::size_type C, typename S > |
Dest | fcppt::math::matrix::structure_cast (fcppt::math::matrix::object< T, R, C, S > const &src) |
| Converts a matrix into a different matrix of the same dimension using Conv.
|
|
template<typename T , typename S1 , typename S2 > |
fcppt::math::vector::static_< T, 3 > | fcppt::math::matrix::transform_direction (fcppt::math::matrix::object< T, 4, 4, S1 > const &_matrix, fcppt::math::vector::object< T, 3, S2 > const &_vector) |
| Multiplies a 4x4 matrix by a 3D vector, adding 0 for w, returns a 3D vector.
|
|
template<typename T , typename S1 , typename S2 > |
fcppt::math::vector::static_< T, 3 > | fcppt::math::matrix::transform_point (fcppt::math::matrix::object< T, 4, 4, S1 > const &_matrix, fcppt::math::vector::object< T, 3, S2 > const &_vector) |
| Multiplies a 4x4 matrix by a 3D vector, adding 1 for w, returns a 3D vector.
|
|
template<typename T > |
fcppt::math::matrix::static_< T, 4, 4 > | fcppt::math::matrix::translation (T const _x, T const _y, T const _z) |
| Calculates a 4x4 translation matrix from three coordinates.
|
|
template<typename T , typename S > |
fcppt::math::matrix::static_< T, 4, 4 > | fcppt::math::matrix::translation (fcppt::math::vector::object< T, 3, S > const &_vec) |
| Calculates a 4x4 translation matrix from a three-dimensional vector.
|
|
template<typename T , fcppt::math::size_type R, fcppt::math::size_type C, typename S > |
fcppt::math::matrix::static_< T, C, R > | fcppt::math::matrix::transpose (fcppt::math::matrix::object< T, R, C, S > const &_matrix) |
| Calculates a transposed matrix.
|
|
template<typename Left , typename Right , fcppt::math::size_type R, fcppt::math::size_type C, typename S1 , typename S2 > |
fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(Left, *, Right), R > | fcppt::math::matrix::operator* (fcppt::math::matrix::object< Left, R, C, S1 > const &_left, fcppt::math::vector::object< Right, C, S2 > const &_right) |
| Multiplies a matrix by a vector.
|
|