APM:Libraries
matrixN.h
Go to the documentation of this file.
1 /*
2  * N dimensional matrix operations
3  */
4 
5 #pragma once
6 
7 #include "math.h"
8 #include <stdint.h>
9 #include "vectorN.h"
10 
11 template <typename T, uint8_t N>
12 class VectorN;
13 
14 
15 template <typename T, uint8_t N>
16 class MatrixN {
17 
18  friend class VectorN<T,N>;
19 
20 public:
21  // constructor from zeros
22  MatrixN<T,N>(void) {
23  memset(v, 0, sizeof(v));
24  }
25 
26  // constructor from 4 diagonals
27  MatrixN<T,N>(const float d[N]) {
28  memset(v, 0, sizeof(v));
29  for (uint8_t i = 0; i < N; i++) {
30  v[i][i] = d[i];
31  }
32  }
33 
34  // multiply two vectors to give a matrix, in-place
35  void mult(const VectorN<T,N> &A, const VectorN<T,N> &B);
36 
37  // subtract B from the matrix
39 
40  // add B to the matrix
42 
43  // Matrix symmetry routine
44  void force_symmetry(void);
45 
46 private:
47  T v[N][N];
48 };
void mult(const VectorN< T, N > &A, const VectorN< T, N > &B)
Definition: matrixN.cpp:12
void force_symmetry(void)
Definition: matrixN.cpp:47
MatrixN< T, N > & operator+=(const MatrixN< T, N > &B)
Definition: matrixN.cpp:35
T v[N][N]
Definition: matrixN.h:47
#define N
MatrixN< T, N > & operator-=(const MatrixN< T, N > &B)
Definition: matrixN.cpp:23