31 #ifndef _MATH_MATRIX_H 32 #define _MATH_MATRIX_H 57 vector<rvector> v_row = vector<rvector>(row, row+
sizeof(row)/
sizeof(row[0]));
74 for(
size_t i = 0;
i != p_row.size(); ++
i) {
75 if(!p_row[
i].is_null()) row[
i].from_json(p_row[
i].
dump());
78 cerr<<
"ERROR: <"<<error<<
">"<<endl;
86 std::ostream& operator << (std::ostream& out, const vector<rmatrix>&
a);
127 if(!parsed[
"r1"].is_null()) r1.
from_json(parsed[
"r1"].
dump());
128 if(!parsed[
"r2"].is_null()) r2.
from_json(parsed[
"r2"].
dump());
129 if(!parsed[
"r3"].is_null()) r3.
from_json(parsed[
"r3"].
dump());
131 cerr<<
"ERROR: <"<<error<<
">"<<endl;
276 r0[0] = m.
array[0][0];
277 r0[1] = m.
array[0][1];
278 r0[2] = m.
array[0][2];
279 r1[0] = m.
array[1][0];
280 r1[1] = m.
array[1][1];
281 r1[2] = m.
array[1][2];
282 r2[0] = m.
array[2][0];
283 r2[1] = m.
array[2][1];
284 r2[2] = m.
array[2][2];
329 c[0] = (*this)[0][0];
330 c[1] = (*this)[1][0];
331 c[2] = (*this)[2][0];
338 c[0] = (*this)[0][1];
339 c[1] = (*this)[1][1];
340 c[2] = (*this)[2][0];
347 c[0] = (*this)[0][2];
348 c[1] = (*this)[1][2];
349 c[2] = (*this)[2][2];
353 Vector &operator [] (
const int &index);
355 Matrix &operator *= (
const double scale);
381 Matrix change_around_x(
double angle);
382 Matrix change_around_y(
double angle);
383 Matrix change_around_z(
double angle);
384 Matrix change_around(
int axis,
double angle);
388 double determinant();
412 if(!parsed[
"r0"].is_null()) r0.
from_json(parsed[
"r0"].
dump());
413 if(!parsed[
"r1"].is_null()) r1.
from_json(parsed[
"r1"].
dump());
414 if(!parsed[
"r2"].is_null()) r2.
from_json(parsed[
"r2"].
dump());
416 cerr<<
"ERROR: <"<<error<<
">"<<endl;
rmatrix rm_from_rv(rvector vector, int direction)
rvector to rmatrix.
Definition: matrix.cpp:828
rvector rv_unskew(rmatrix matrix)
Unskew 3x3 row matrix.
Definition: matrix.cpp:880
double y
Y value.
Definition: vector.h:114
matrix1d m1_smult(double number, matrix1d row)
Multiply 1D matrix by a scalar.
Definition: matrix.cpp:979
Definition: agentclass.cpp:54
rmatrix rm_add(rmatrix a, rmatrix b)
rmatrix addition. Sum of two rmatrix values.
Definition: matrix.cpp:269
std::map< std::string, Json > object
Definition: json11.hpp:88
matrix2d m2_eye(uint16_t rows)
Create 2D identity matrix.
Definition: matrix.cpp:1261
rmatrix rm_skew(rvector row1)
Create skew symmetric rmatrix from rvector.
Definition: matrix.cpp:857
uint16_t cols
Number of elements.
Definition: matrix.h:149
Matrix(rmatrix m0)
Definition: matrix.h:267
Definition: json11.hpp:79
cvector cv_diag(cmatrix a)
Matrix diagonal.
Definition: matrix.cpp:549
matrix2d m2_skew(matrix1d row1)
Create skew symmetric matrix2d from matrix1d.
Definition: matrix.cpp:1103
Matrix(Vector vector, int direction)
::Vector to ::Matrix.
Definition: matrix.h:307
double norm_cm(cmatrix a)
cmatrix norm. Calculates the Norm of the supplied cmatrix
Definition: matrix.cpp:493
void from_json(const string &s)
Set class contents from JSON string.
Definition: matrix.h:408
3x3 element cartesian matrix
Definition: matrix.h:96
rmatrix rm_change_around(int axis, double angle)
Rotation matrix for indicated axis.
Definition: matrix.cpp:397
3 element generic row vector
Definition: vector.h:53
int i
Definition: rw_test.cpp:37
matrix2d m2_smult(double number, matrix2d matrix)
Multiply 2D matrix by a scalar.
Definition: matrix.cpp:1281
rmatrix rm_zero()
Zero filled rmatrix.
Definition: matrix.cpp:125
double trace_rm(rmatrix a)
rmatrix Trace Calculates the trace of the supplied rmatrix.
Definition: matrix.cpp:154
rvector rv_diag(rmatrix a)
Matrix diagonal.
Definition: matrix.cpp:63
json11::Json to_json() const
Convert class contents to JSON object.
Definition: matrix.h:394
cmatrix cm_change_around(int axis, double angle)
Rotation matrix for indicated axis.
Definition: matrix.cpp:773
rmatrix rm_square(rmatrix a)
Square rmatrix.
Definition: matrix.cpp:317
cmatrix cm_mmult(cmatrix a, cmatrix b)
cmatrix Matrix Product
Definition: matrix.cpp:566
Definition: vector.cpp:1578
matrix2d m2_sub(matrix2d matrix1, matrix2d matrix2)
Subtract one matrix2d from another.
Definition: matrix.cpp:1332
cvector r1
Row 1.
Definition: matrix.h:99
matrix2d m2_transpose(matrix2d matrix)
Return transpose of a 2D matrix.
Definition: matrix.cpp:1358
matrix2d m2_diag(matrix1d row1)
Create diagonal matrix2d from matrix1d.
Definition: matrix.cpp:1131
double x
X value.
Definition: vector.h:112
double norm_rm(rmatrix a)
rmatrix norm. Calculates the Norm of the supplied rmatrix
Definition: matrix.cpp:137
Vector r2
Definition: matrix.h:324
matrix1d m1_mmult(matrix2d matrix, matrix1d row)
Multiply matrix1d by matrix2d.
Definition: matrix.cpp:1041
long b
Definition: jpegint.h:371
double m1_norm(matrix1d matrix)
Compute the Euclidean norm of a 1D matrix.
Definition: matrix.cpp:1215
rmatrix()
Definition: matrix.h:45
cmatrix cm_sub(cmatrix a, cmatrix b)
cmatrix subtraction. Subtract two cmatrix values.
Definition: matrix.cpp:662
double determinant_rm(rmatrix a)
Determinant of row column matrix.
Definition: matrix.cpp:942
Vector c1()
Definition: matrix.h:335
rmatrix rm_mult(rmatrix a, rmatrix b)
Element-wise rmatrix multiplication.
Definition: matrix.cpp:223
rmatrix rm_eye()
Identity rmatrix.
Definition: matrix.cpp:114
cmatrix cm_change_around_z(double angle)
Rotation matrix for Z axis.
Definition: matrix.cpp:757
double array[4][4]
Elements.
Definition: matrix.h:160
void dump(std::string &out) const
Vector eye(double scale)
Definition: vector.cpp:2068
void from_json(const string &s)
Set class contents from JSON string.
Definition: vector.h:783
double m2_trace(matrix2d matrix)
Calculate the trace of a 2D matrix.
Definition: matrix.cpp:1404
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
cmatrix cm_change_around_x(double angle)
Rotation matrix for X axis.
Definition: matrix.cpp:727
rmatrix rm_inverse(rmatrix m)
Inverse of rmatrix.
Definition: matrix.cpp:897
static void dump(NullStruct, string &out)
Definition: json11.cpp:53
Vector c0()
Definition: matrix.h:326
cmatrix cm_smult(double a, cmatrix b)
Scalar cmatrix multiplication.
Definition: matrix.cpp:615
uint16_t rows
Number of rows.
Definition: matrix.h:156
3x3 element generic matrix
Definition: matrix.h:41
cmatrix cm_diag(cvector a)
Diagonal cmatrix Creates an cmatrix whose diagonal is filled with the supplied cvector.
Definition: matrix.cpp:453
cmatrix cm_mult(cmatrix a, cmatrix b)
Element-wise cmatrix multiplication.
Definition: matrix.cpp:591
cmatrix cm_add(cmatrix a, cmatrix b)
cmatrix addition. Sum of two cmatrix values.
Definition: matrix.cpp:637
rmatrix rm_diag(rvector a)
Diagonal rmatrix Creates an rmatrix whose diagonal is filled with the supplied rvector.
Definition: matrix.cpp:97
Headers and definitions common to all COSMOS.
rmatrix rm_sub(rmatrix a, rmatrix b)
rmatrix subtraction. Subtract two rmatrix values.
Definition: matrix.cpp:294
rmatrix rm_change_around_x(double angle)
Rotation matrix for X axis.
Definition: matrix.cpp:358
const array & array_items() const
Definition: json11.cpp:284
cmatrix cm_eye()
Identity cmatrix.
Definition: matrix.cpp:470
matrix2d cv_to_m2(cvector vector, int direction)
Definition: matrix.cpp:1516
nxm element 2D matrix
Definition: matrix.h:153
void from_json(const string &s)
Set class contents from JSON string.
Definition: vector.h:150
matrix1d m2_eig2x2(matrix2d matrix)
Eigen values of a 2x2 square matrix.
Definition: matrix.cpp:1580
void from_json(const string &s)
Set class contents from JSON string.
Definition: matrix.h:69
rmatrix rm_change_around_y(double angle)
Rotation matrix for Y axis.
Definition: matrix.cpp:368
#define DIRECTION_COLUMN
Definition: math/constants.h:64
Matrix(Vector r00=Vector(), Vector r10=Vector(), Vector r20=Vector())
Constructor, initialize to zero.
Definition: matrix.h:260
double m1_dot(matrix1d a, matrix1d b)
matrix1d dot product
Definition: matrix.cpp:1085
Vector r0
Definition: matrix.h:322
matrix1d m1_cross(matrix1d row1, matrix1d row2)
matrix1d cross product
Definition: matrix.cpp:1067
Definition: eci2kep_test.cpp:33
matrix1d cv_to_m1(cvector vector)
Definition: matrix.cpp:1498
cmatrix cm_zero()
Zero filled cmatrix.
Definition: matrix.cpp:481
cmatrix cm_change_between_cv(cvector from, cvector to)
Create rotation matrix from 2 vectors.
Definition: mathlib.cpp:2407
matrix2d m2_inverse(matrix2d m)
Inverse of matrix2d.
Definition: matrix.cpp:1152
n element row matrix
Definition: matrix.h:144
Vector c2()
Definition: matrix.h:344
double z
Z value.
Definition: vector.h:116
cmatrix cm_from_rm(rmatrix matrix)
cmatrix from rmatrix
Definition: matrix.cpp:428
Vector operator*(const double scale, const Vector &v)
Reverse scalar product.
Definition: vector.cpp:1794
double trace_cm(cmatrix a)
cmatrix Trace Calculates the trace of the supplied cmatrix.
Definition: matrix.cpp:510
std::ostream & operator<<(std::ostream &out, const Vector &v)
Definition: vector.cpp:1983
rmatrix rm_smult(double a, rmatrix b)
Scalar rmatrix multiplication.
Definition: matrix.cpp:247
Vector r1
Definition: matrix.h:323
rmatrix rm_transpose(rmatrix a)
rmatrix Transpose. Calculate the transpose of the supplied rmatrix.
Definition: matrix.cpp:172
uint16_t cols
Number of elements.
Definition: matrix.h:158
matrix2d m2_mmult(matrix2d matrix1, matrix2d matrix2)
Matrix product.
Definition: matrix.cpp:1423
cmatrix cm_square(cmatrix a)
Square cmatrix.
Definition: matrix.cpp:685
rmatrix rm_mmult(rmatrix a, rmatrix b)
rmatrix Matrix Product
Definition: matrix.cpp:198
rmatrix rm_change_around_z(double angle)
Rotation matrix for Z axis.
Definition: matrix.cpp:382
rmatrix(rvector rv0, rvector rv1, rvector rv2)
Definition: matrix.h:46
Matrix(cmatrix m)
Definition: matrix.h:287
matrix2d m1_to_m2(matrix1d vector, int direction)
Matrix1d to matrix2d.
Definition: matrix.cpp:1546
Matrix(matrix2d m)
Definition: matrix.h:274
void from_json(const string &s)
Set class contents from JSON string.
Definition: matrix.h:123
cmatrix cm_change_around_y(double angle)
Rotation matrix for Y axis.
Definition: matrix.cpp:742
matrix2d m2_cross(matrix2d matrix1, matrix2d matrix2)
rmatrix rm_change_between_rv(rvector from, rvector to)
Create rotation matrix from 2 row vectors.
Definition: rotation.cpp:164
json11::Json to_json() const
Convert class contents to JSON object.
Definition: matrix.h:109
Vector Class.
Definition: vector.h:672
cmatrix cm_transpose(cmatrix a)
cmatrix Transpose. Calculate the transpose of the supplied cmatrix.
Definition: matrix.cpp:525
json11::Json to_json() const
Convert class contents to JSON object.
Definition: matrix.h:56
matrix2d m2_zero(uint16_t rows, uint16_t cols)
Create 2D zero matrix.
Definition: matrix.cpp:1233
rmatrix rm_from_cm(cmatrix matrix)
rmatrix from cmatrix
Definition: matrix.cpp:804
cvector cv_mmult(cmatrix a, cvector b)
Multiply cartesian vector by cartesian matrix.
Definition: matrix.cpp:80
matrix2d cm3x3_to_m2(cmatrix matrix)
Definition: matrix.cpp:1474
rvector rv_mmult(rmatrix a, rvector b)
Multiply rmatrix by rvector.
Definition: matrix.cpp:41
matrix1d m2_unskew(matrix2d matrix)
Unskew 3x3 2D matrix.
Definition: matrix.cpp:1384
std::istream & operator>>(std::istream &out, rmatrix &a)
Definition: matrix.cpp:1648
rvector row[3]
Definition: matrix.h:43
matrix1d m1_add(matrix1d row1, matrix1d row2)
Add one 1D matrix to another.
Definition: matrix.cpp:1000
matrix1d m1_zero(uint16_t cols)
Fill 1D matrix with zeros.
Definition: matrix.cpp:959
matrix1d m1_sub(matrix1d row1, matrix1d row2)
Subtract one 1D matrix from another.
Definition: matrix.cpp:1021
double m2_snorm2x2(matrix2d matrix)
Spectral norm of a 2x2 matrix.
Definition: matrix.cpp:1607
double m2_determinant(matrix2d m)
Determinant of a 2D matrix.
Definition: matrix.cpp:1189
cvector r3
Row 3.
Definition: matrix.h:103
3 element cartesian vector
Definition: vector.h:107
matrix2d m2_from_rm(rmatrix matrix)
rmatrix from rmatrix
Definition: matrix.cpp:1453
matrix2d m2_add(matrix2d matrix1, matrix2d matrix2)
Add one matrix2d to another.
Definition: matrix.cpp:1304
cvector r2
Row 2.
Definition: matrix.h:101
rmatrix rm_from_m2(matrix2d m)
rmatrix from matrix2d
Definition: matrix.cpp:921