40#ifndef GEOGRAM_BASIC_MATRIX
41#define GEOGRAM_BASIC_MATRIX
64 template <index_t DIM,
class FT>
92 for(
index_t i = 0; i < DIM; i++) {
93 for(
index_t j = 0; j < DIM; j++) {
113 for(
index_t i = 0; i < DIM; i++) {
114 for(
index_t j = 0; j < DIM; j++) {
115 coeff_[i][j] = FT(0);
126 for(
index_t i = 0; i < DIM; i++) {
127 for(
index_t j = 0; j < DIM; j++) {
128 coeff_[i][j] = (i == j) ? FT(1) : FT(0);
139 for(
index_t i = 0; i < DIM; i++) {
140 for(
index_t j = 0; j < DIM; j++) {
141 FT rhs = ((i == j) ? FT(1) : FT(0));
142 if(coeff_[i][j] != rhs) {
185 for(
index_t i = 0; i < DIM; i++) {
186 for(
index_t j = 0; j < DIM; j++) {
187 coeff_[i][j] += m.coeff_[i][j];
200 for(
index_t i = 0; i < DIM; i++) {
201 for(
index_t j = 0; j < DIM; j++) {
202 coeff_[i][j] -= m.coeff_[i][j];
216 for(
index_t i = 0; i < DIM; i++) {
217 for(
index_t j = 0; j < DIM; j++) {
232 for(
index_t i = 0; i < DIM; i++) {
233 for(
index_t j = 0; j < DIM; j++) {
299 for(
index_t i = 0; i < DIM; i++) {
300 for(
index_t j = 0; j < DIM; j++) {
301 result.coeff_[i][j] = FT(0);
302 for(
index_t k = 0; k < DIM; k++) {
303 result.coeff_[i][j] += coeff_[i][k] * m.coeff_[k][j];
331 FT val=FT(0.0), val2=FT(0.0);
336 for(
index_t i = 0; i != DIM; i++) {
339 for(
index_t j = i + 1; j != DIM; j++) {
340 if(fabs(tmp(j, i)) > fabs(val)) {
347 for(
index_t j = 0; j != DIM; j++) {
349 result(i, j) = result(ind, j);
350 result(ind, j) = val2;
352 tmp(i, j) = tmp(ind, j);
361 for(
index_t j = 0; j != DIM; j++) {
366 for(
index_t j = 0; j != DIM; j++) {
371 for(
index_t k = 0; k != DIM; k++) {
372 tmp(j, k) -= tmp(i, k) * val;
373 result(j, k) -= result(i, k) * val;
387 for(
index_t i = 0; i < DIM; i++) {
388 for(
index_t j = 0; j < DIM; j++) {
389 result(i, j) = (* this)(j, i);
401 inline const FT*
data()
const {
402 return &(coeff_[0][0]);
412 return &(coeff_[0][0]);
423 for(
index_t i = 0; i < DIM; i++) {
424 for(
index_t j = 0; j <= i; j++) {
425 *store++ = coeff_[i][j];
445 template <index_t DIM,
class FT>
449 const char* sep =
"";
450 for(
index_t i = 0; i < DIM; i++) {
451 for(
index_t j = 0; j < DIM; j++) {
452 output << sep << m(i, j);
468 template <index_t DIM,
class FT>
472 for(
index_t i = 0; i < DIM; i++) {
473 for(
index_t j = 0; j < DIM; j++) {
495 template <index_t DIM,
class FT>
inline
497 for(
index_t i = 0; i < DIM; i++) {
499 for(
index_t j = 0; j < DIM; j++) {
500 y[i] += M(i, j) * x[j];
515 template <index_t DIM,
class FT>
inline
520 for(
index_t i = 0; i < DIM; i++) {
522 for(
index_t j = 0; j < DIM; j++) {
523 y[i] += M(i, j) * x[j];
537 template <index_t DIM,
class FT>
inline
542 for(
index_t i = 0; i < DIM; i++) {
544 for(
index_t j = 0; j < DIM; j++) {
545 y[i] += M(i, j) * x[j];
#define geo_assert(x)
Verifies that a condition is met.
#define geo_debug_assert(x)
Verifies that a condition is met.
Common include file, providing basic definitions. Should be included before anything else by all head...
matrix_type transpose() const
Computes the transposed matrix.
matrix_type & operator*=(FT val)
Multiplies by a scalar in place.
void get_lower_triangle(FT *store) const
Gets the lower triangle of the matrix.
matrix_type & operator-=(const matrix_type &m)
Subtracts a matrix in place.
Matrix(const FT *vals)
Constructs a matrix from an array of values.
index_t dimension() const
Gets the matrix dimension.
Matrix< DIM, FT > matrix_type
matrix_type operator+(const matrix_type &m) const
Adds 2 matrices.
const FT * data() const
Gets non-modifiable matrix data.
FT & operator()(index_t i, index_t j)
Gets a modifiable element.
matrix_type operator*(FT val) const
Multiplies a matrix by a scalar.
void load_zero()
Clears the matrix.
matrix_type & operator/=(FT val)
Divides by a scalar in place.
bool is_identity() const
Tests whether a matrix is the identity matrix.
matrix_type operator-(const matrix_type &m) const
Subtracts 2 matrices.
void mult(const Matrix< DIM, FT > &M, const FT *x, FT *y)
Multiplies a matrix by a vector.
FT * data()
Gets modifiable matrix data.
matrix_type inverse() const
Computes the inverse matrix.
void load_identity()
Sets the matrix to identity.
Matrix()
Default constructor.
bool compute_inverse(matrix_type &result) const
Computes the inverse matrix.
matrix_type & operator+=(const matrix_type &m)
Adds a matrix in place.
matrix_type operator/(FT val) const
Divides a matrix by a scalar.
Global Vorpaline namespace.
std::istream & operator>>(std::istream &in, Quaternion &q)
Reads a Quaternion from a stream.
std::ostream & operator<<(std::ostream &out, const Quaternion &q)
Writes a Quaternion to a stream.
geo_index_t index_t
The type for storing and manipulating indices.
vecng< DIM, FT > mult(const Matrix< DIM, FT > &M, const vecng< DIM, FT > &x)
Computes a matrix vector product.
vecng< DIM, FT > operator*(const Matrix< DIM, FT > &M, const vecng< DIM, FT > &x)
Computes a matrix vector product.
Generic implementation of geometric vectors.