|
Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
|
3x3 matrix with Quantity components More...
#include <Matrix3x3.hpp>
Public Member Functions | |
| constexpr | Matrix () |
| Construct a zero matrix. | |
| constexpr | Matrix (const Vector3< T > &col0, const Vector3< T > &col1, const Vector3< T > &col2) |
| Construct from three column vectors. | |
| constexpr | Matrix (T m00, T m01, T m02, T m10, T m11, T m12, T m20, T m21, T m22) |
| Construct from individual components (row-major ordering) | |
| constexpr Matrix | Transpose () const |
| Compute the transpose of the matrix. | |
| constexpr T | Trace () const |
| Compute the trace of the matrix. | |
| constexpr auto | Symmetric () const |
| Compute the symmetric part of the matrix. | |
| constexpr auto | Antisymmetric () const |
| Compute the antisymmetric part of the matrix. | |
| const T & | At (const int i, const int j) const |
| Access element at row i, column j with bounds checking (0-based indexing) | |
| T & | At (const int i, const int j) |
| Access element at row i, column j with bounds checking (0-based indexing) - mutable version. | |
| constexpr const T & | operator() (const int i, const int j) const |
| Access element at row i, column j (0-based indexing) - no bounds checking. | |
| constexpr T & | operator() (const int i, const int j) |
| Access element at row i, column j (0-based indexing) - mutable version. | |
| template<typename U > | |
| constexpr auto | operator+ (const Matrix3x3< U > &other) const |
| Matrix addition. | |
| template<typename U > | |
| constexpr auto | operator- (const Matrix3x3< U > &other) const |
| Matrix subtraction. | |
| constexpr auto | operator- () const |
| Unary negation. | |
| template<typename U > | |
| constexpr auto | operator* (U scalar) const |
| Scalar multiplication (matrix * scalar) | |
| template<typename U > | |
| constexpr auto | operator* (const Vector3< U > &v) const |
| Matrix-vector multiplication: M * v. | |
| template<typename U > | |
| constexpr auto | operator* (const Matrix3x3< U > &other) const |
| Matrix-matrix multiplication: A * B. | |
| template<typename U > | |
| constexpr Matrix & | operator+= (const Matrix3x3< U > &other) |
| Addition assignment. | |
| template<typename U > | |
| constexpr Matrix & | operator-= (const Matrix3x3< U > &other) |
| Subtraction assignment. | |
| template<typename U > | |
| constexpr Matrix & | operator*= (U scalar) |
| Scalar multiplication assignment. | |
| template<typename U > | |
| constexpr bool | operator== (const Matrix3x3< U > &other) const |
| Equality comparison. | |
| template<typename U > | |
| constexpr bool | operator!= (const Matrix3x3< U > &other) const |
| Inequality comparison. | |
| template<typename UnitT > | |
| Matrix3x3< Quantity< UnitT > > | As () const |
| Convert all components to a different unit of the same dimension. | |
Static Public Member Functions | |
| static constexpr Matrix | Identity () |
| Create an identity matrix. | |
Public Attributes | |
| Vector3< T > | x_basis |
| Vector3< T > | y_basis |
| Vector3< T > | z_basis |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Matrix &m) |
| Stream insertion operator. | |
3x3 matrix with Quantity components
Matrix3x3 stores three column vectors, enabling matrix-vector operations while preserving physical dimensions.
| T | Component type (must be a Quantity instantiation) |
Example: Matrix3x3<Quantity<Meter>> m; // 3x3 matrix with meter components auto result = m * Vector3<Quantity<Meter>>(1.0_m, 0_m, 0_m);
Definition at line 27 of file Matrix3x3.hpp.
|
inlineconstexpr |
Construct a zero matrix.
Initializes all elements to zero using Quantity's default constructor.
Definition at line 39 of file Matrix3x3.hpp.
|
inlineconstexpr |
Construct from three column vectors.
| col0 | First column vector |
| col1 | Second column vector |
| col2 | Third column vector |
Definition at line 49 of file Matrix3x3.hpp.
|
inlineconstexpr |
Construct from individual components (row-major ordering)
This constructor takes components in row-major order but stores them internally in column-major order.
| m00 | Row 0, Col 0 |
| m01 | Row 0, Col 1 |
| m02 | Row 0, Col 2 |
| m10 | Row 1, Col 0 |
| m11 | Row 1, Col 1 |
| m12 | Row 1, Col 2 |
| m20 | Row 2, Col 0 |
| m21 | Row 2, Col 1 |
| m22 | Row 2, Col 2 |
Example: Matrix3x3 m(1, 2, 3, 4, 5, 6, 7, 8, 9); // m(1, 0) == 4, m(0, 1) == 2
Definition at line 75 of file Matrix3x3.hpp.
|
inlineconstexpr |
Compute the antisymmetric part of the matrix.
Returns (M - M^T) / 2
Example: auto anti = m.Antisymmetric(); // (m - m^T) / 2
Definition at line 157 of file Matrix3x3.hpp.
|
inline |
Convert all components to a different unit of the same dimension.
| UnitT | Target unit type |
Example: auto m_mm = m.as<Millimeter>();
Definition at line 444 of file Matrix3x3.hpp.
Access element at row i, column j with bounds checking (0-based indexing) - mutable version.
| i | Row index (0, 1, 2) |
| j | Column index (0, 1, 2) |
| std::out_of_range | if index is out of bounds |
Example: m.at(0, 1) = 5; // Set element at row 0, column 1 to 5
Definition at line 195 of file Matrix3x3.hpp.
Access element at row i, column j with bounds checking (0-based indexing)
| i | Row index (0, 1, 2) |
| j | Column index (0, 1, 2) |
| std::out_of_range | if index is out of bounds |
Example: auto val = m.at(1, 2); // Get element at row 1, column 2
Definition at line 172 of file Matrix3x3.hpp.
|
inlinestaticconstexpr |
Create an identity matrix.
Returns a 3x3 identity matrix with ones on the diagonal and zeros elsewhere.
Example: auto I = Matrix3x3<Quantity<Meter>>::Identity();
Definition at line 94 of file Matrix3x3.hpp.
|
inlineconstexpr |
Inequality comparison.
| U | Quantity type of the other matrix |
| other | Matrix to compare against |
Example: if (m1 != m2) { ... }
Definition at line 430 of file Matrix3x3.hpp.
|
inlineconstexpr |
Access element at row i, column j (0-based indexing) - mutable version.
| i | Row index (0, 1, 2) |
| j | Column index (0, 1, 2) |
Example: m(0, 1) = 5; // Set element at row 0, column 1 to 5
Definition at line 239 of file Matrix3x3.hpp.
|
inlineconstexpr |
Access element at row i, column j (0-based indexing) - no bounds checking.
| i | Row index (0, 1, 2) |
| j | Column index (0, 1, 2) |
Example: auto val = m(1, 2); // Get element at row 1, column 2
Definition at line 220 of file Matrix3x3.hpp.
|
inlineconstexpr |
Matrix-matrix multiplication: A * B.
| U | Quantity type of the other matrix |
| other | Matrix to multiply with |
Example: auto product = m1 * m2;
Definition at line 341 of file Matrix3x3.hpp.
|
inlineconstexpr |
Matrix-vector multiplication: M * v.
| U | Quantity type of the vector |
| v | Vector to multiply with |
Example: auto v = m * Vector3<Quantity<Meter>>(1, 2, 3);
Definition at line 325 of file Matrix3x3.hpp.
|
inlineconstexpr |
Scalar multiplication (matrix * scalar)
| U | Scalar type |
| scalar | Scalar value to multiply with |
Example: auto scaled = m * 2.0;
Definition at line 306 of file Matrix3x3.hpp.
|
inlineconstexpr |
Scalar multiplication assignment.
| U | Scalar type |
| scalar | Scalar value to multiply with |
Example: m *= 2.0;
Definition at line 397 of file Matrix3x3.hpp.
|
inlineconstexpr |
Matrix addition.
| U | Quantity type of the other matrix |
| other | Matrix to add |
Example: auto sum = m1 + m2;
Definition at line 256 of file Matrix3x3.hpp.
|
inlineconstexpr |
Addition assignment.
| U | Quantity type of the other matrix |
| other | Matrix to add |
Example: m += other;
Definition at line 361 of file Matrix3x3.hpp.
|
inlineconstexpr |
Unary negation.
Example: auto neg = -m;
Definition at line 291 of file Matrix3x3.hpp.
|
inlineconstexpr |
Matrix subtraction.
| U | Quantity type of the other matrix |
| other | Matrix to subtract |
Example: auto diff = m1 - m2;
Definition at line 275 of file Matrix3x3.hpp.
|
inlineconstexpr |
Subtraction assignment.
| U | Quantity type of the other matrix |
| other | Matrix to subtract |
Example: m -= other;
Definition at line 379 of file Matrix3x3.hpp.
|
inlineconstexpr |
Equality comparison.
| U | Quantity type of the other matrix |
| other | Matrix to compare against |
Example: if (m1 == m2) { ... }
Definition at line 415 of file Matrix3x3.hpp.
Compute the symmetric part of the matrix.
Returns (M + M^T) / 2
Example: auto sym = m.Symmetric(); // (m + m^T) / 2
Definition at line 143 of file Matrix3x3.hpp.
Compute the trace of the matrix.
The trace is the sum of the diagonal elements: M[0][0] + M[1][1] + M[2][2]
Example: auto tr = m.Trace(); // m00 + m11 + m22
Definition at line 129 of file Matrix3x3.hpp.
|
inlineconstexpr |
Compute the transpose of the matrix.
Example: auto m = Matrix3x3(...); auto mT = m.Transpose();
Definition at line 111 of file Matrix3x3.hpp.
Stream insertion operator.
| os | Output stream |
| m | Matrix to output |
Example: std::cout << m << std::endl;
Definition at line 462 of file Matrix3x3.hpp.
Definition at line 30 of file Matrix3x3.hpp.
Definition at line 31 of file Matrix3x3.hpp.
Definition at line 32 of file Matrix3x3.hpp.