|
1 | 1 | #ifndef ATG_SIMPLE_2D_CONSTRAINT_SOLVER_MATRIX_H
|
2 | 2 | #define ATG_SIMPLE_2D_CONSTRAINT_SOLVER_MATRIX_H
|
3 | 3 |
|
4 |
| -#include <assert.h> |
5 |
| - |
6 |
| -namespace atg_scs { |
7 |
| - class Matrix { |
8 |
| - public: |
9 |
| - Matrix(); |
10 |
| - Matrix(int width, int height, double value = 0.0); |
11 |
| - ~Matrix(); |
12 |
| - |
13 |
| - void initialize(int width, int height, double value); |
14 |
| - void initialize(int width, int height); |
15 |
| - void resize(int width, int height); |
16 |
| - void destroy(); |
17 |
| - |
18 |
| - void set(const double *data); |
19 |
| - |
20 |
| - __forceinline void set(int column, int row, double value) { |
21 |
| - assert(column >= 0 && column < m_width); |
22 |
| - assert(row >= 0 && row < m_height); |
23 |
| - |
24 |
| - m_matrix[row][column] = value; |
25 |
| - } |
26 |
| - |
27 |
| - __forceinline void add(int column, int row, double value) { |
28 |
| - assert(column >= 0 && column < m_width); |
29 |
| - assert(row >= 0 && row < m_height); |
30 |
| - |
31 |
| - m_matrix[row][column] += value; |
32 |
| - } |
33 |
| - |
34 |
| - __forceinline double get(int column, int row) { |
35 |
| - assert(column >= 0 && column < m_width); |
36 |
| - assert(row >= 0 && row < m_height); |
37 |
| - |
38 |
| - return m_matrix[row][column]; |
39 |
| - } |
40 |
| - |
41 |
| - void set(Matrix *reference); |
42 |
| - |
43 |
| - void multiply(Matrix &b, Matrix *target); |
44 |
| - void componentMultiply(Matrix &b, Matrix *target); |
45 |
| - void transposeMultiply(Matrix &b, Matrix *target); |
46 |
| - void leftScale(Matrix &scale, Matrix *target); |
47 |
| - void rightScale(Matrix &scale, Matrix *target); |
48 |
| - void scale(double s, Matrix *target); |
49 |
| - void subtract(Matrix &b, Matrix *target); |
50 |
| - void add(Matrix &b, Matrix *target); |
51 |
| - void negate(Matrix *target); |
52 |
| - bool equals(Matrix &b, double err = 1e-6); |
53 |
| - double vectorMagnitudeSquared() const; |
54 |
| - double dot(Matrix &b) const; |
55 |
| - |
56 |
| - void madd(Matrix &b, double s); |
57 |
| - void pmadd(Matrix &b, double s); |
58 |
| - |
59 |
| - void transpose(Matrix *target); |
60 |
| - int getWidth() const { return m_width; } |
61 |
| - int getHeight() const { return m_height; } |
62 |
| - |
63 |
| - __forceinline void fastRowSwap(int a, int b) { |
64 |
| - double *temp = m_matrix[a]; |
65 |
| - m_matrix[a] = m_matrix[b]; |
66 |
| - m_matrix[b] = temp; |
67 |
| - } |
68 |
| - |
69 |
| - protected: |
70 |
| - double **m_matrix; |
71 |
| - double *m_data; |
72 |
| - int m_width; |
73 |
| - int m_height; |
74 |
| - int m_capacityWidth; |
75 |
| - int m_capacityHeight; |
76 |
| - }; |
77 |
| -} /* namespace atg_scs */ |
| 4 | +#ifdef ATG_S2C_USE_EIGEN |
| 5 | +#include "matrix_eigen.h" |
| 6 | +#else |
| 7 | +#include "matrix_custom.h" |
| 8 | +#endif |
78 | 9 |
|
79 | 10 | #endif /* ATG_SIMPLE_2D_CONSTRAINT_SOLVER_MATRIX_H */
|
0 commit comments