diff --git a/trick_source/trick_utils/math/src/matxmat.c b/trick_source/trick_utils/math/src/matxmat.c index f8f8a3a7..14aa42d2 100644 --- a/trick_source/trick_utils/math/src/matxmat.c +++ b/trick_source/trick_utils/math/src/matxmat.c @@ -1,25 +1,27 @@ /* - PURPOSE: (Matrix times Matrix) - ASSUMPTIONS AND LIMITATIONS: ((Square matrix)) - PROGRAMMERS: (((Les Quiocho) (NASA/JSC) (Jan 1993) (v1.0) (Init Release))) */ + * PURPOSE: (Matrix times Matrix) + * ASSUMPTIONS AND LIMITATIONS: ((Square matrix)) + * PROGRAMMERS: (((Les Quiocho) (NASA/JSC) (Jan 1993) (v1.0) (Init Release)) + * ((Robert McPhail) (CACI) (Feb 2017) (Updated algorithm))) + */ #include "trick/trick_math.h" void matxmat(double **prod, /* Out: Product of the two matrices */ double **mat1, /* In: Matrix 1 */ double **mat2, /* In: Matrix 2 */ - int n) -{ /* In: Array size */ + int n) { /* In: Array size */ int i, j, k; + double temp; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - prod[i][j] = 0.0; + temp = 0.0; for (k = 0; k < n; k++) { - prod[i][j] += mat1[i][k] * mat2[k][j]; + temp += mat1[i][k] * mat2[k][j]; } + prod[i][j] = temp; } } - return; } diff --git a/trick_source/trick_utils/math/src/matxtrans.c b/trick_source/trick_utils/math/src/matxtrans.c index 59a905fd..0e253286 100644 --- a/trick_source/trick_utils/math/src/matxtrans.c +++ b/trick_source/trick_utils/math/src/matxtrans.c @@ -1,27 +1,27 @@ /* - PURPOSE: (Matrix times Matrix transpose) - ASSUMPTIONS AND LIMITATIONS: ((Square matrix)) - PROGRAMMERS: (((Les Quiocho) (NASA/JSC) (Jan 1993) (v1.0) (Init Release))) */ + PURPOSE: (Matrix times Matrix transpose) + ASSUMPTIONS AND LIMITATIONS: ((Square matrix)) + PROGRAMMERS: (((Les Quiocho) (NASA/JSC) (Jan 1993) (v1.0) (Init Release)) + ((Robert McPhail) (CACI) (Feb 2017) (Updated algorithm))) */ #include "trick/trick_math.h" void matxtrans(double **prod, /* Out: product of the two matrices */ double **mat1, /* In: matrix 1 */ double **mat2, /* In: matrix 2 */ - int n) -{ /* In: array size */ + int n) { /* In: array size */ - int i, j, k; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - prod[i][j] = 0.0; - for (k = 0; k < n; k++) { - prod[i][j] += mat1[i][k] * mat2[j][k]; - } - } - } - - return; + int i, j, k; + double temp; + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + temp = 0.0; + for (k = 0; k < n; k++) { + temp += mat1[i][k] * mat2[j][k]; + } + prod[i][j] = temp; + } + } + return; } diff --git a/trick_source/trick_utils/math/src/transxmat.c b/trick_source/trick_utils/math/src/transxmat.c index ed97331f..6a036785 100644 --- a/trick_source/trick_utils/math/src/transxmat.c +++ b/trick_source/trick_utils/math/src/transxmat.c @@ -1,28 +1,29 @@ /* - PURPOSE: (Matrix transpose times Matrix) - ASSUMPTIONS AND LIMITATIONS: ((Square matrix)) - PROGRAMMERS: (((Les Quiocho) (NASA/JSC) (Jan 1993) (v1.0) (Init Release))) - */ + PURPOSE: (Matrix transpose times Matrix) + ASSUMPTIONS AND LIMITATIONS: ((Square matrix)) + PROGRAMMERS: (((Les Quiocho) (NASA/JSC) (Jan 1993) (v1.0) (Init Release)) + ((Robert McPhail) (CACI) (Feb 2017) (Updated algorithm))) +*/ #include "trick/trick_math.h" -void transxmat(double **prod, /* Out: Product of the two matrices */ +void transxmat(double **prod, /* Out: Product of the two matrices */ double **mat1, /* In: Matrix 1 */ double **mat2, /* In: Matrix 2 */ - int n) -{ /* In: Array size */ + int n) { /* In: Array size */ - int i, j, k; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - prod[i][j] = 0.0; - for (k = 0; k < n; k++) { - prod[i][j] += mat1[k][i] * mat2[k][j]; - } - } - } - - return; + int i, j, k; + double temp; + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + temp = 0.0; + for (k = 0; k < n; k++) { + temp += mat1[k][i] * mat2[k][j]; + } + prod[i][j] = temp; + } + } + return; } + diff --git a/trick_source/trick_utils/math/src/transxtrans.c b/trick_source/trick_utils/math/src/transxtrans.c index 35b9cbc2..47ad3869 100644 --- a/trick_source/trick_utils/math/src/transxtrans.c +++ b/trick_source/trick_utils/math/src/transxtrans.c @@ -1,28 +1,28 @@ /* - PURPOSE: (Matrix transpose times Matrix transpose) - ASSUMPTIONS AND LIMITATIONS: ((Square matrix)) - PROGRAMMERS: (((Les Quiocho) (NASA/JSC) (Jan 1993) (v1.0) (Init Release))) - */ + PURPOSE: (Matrix transpose times Matrix transpose) + ASSUMPTIONS AND LIMITATIONS: ((Square matrix)) + PROGRAMMERS: (((Les Quiocho) (NASA/JSC) (Jan 1993) (v1.0) (Init Release)) + ((Robert McPhail) (CACI) (Feb 2017) (Updated algorithm))) +*/ #include "trick/trick_math.h" void transxtrans(double **prod, /* Out: product of the two matrices */ double **mat1, /* In: matrix 1 */ double **mat2, /* In: matrix 2 */ - int n) -{ /* In: array size */ + int n) { /* In: array size */ - int i, j, k; - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - prod[i][j] = 0.0; - for (k = 0; k < n; k++) { - prod[i][j] += mat1[k][i] * mat2[j][k]; - } - } - } - - return; + int i, j, k; + double temp; + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + temp = 0.0; + for (k = 0; k < n; k++) { + temp += mat1[k][i] * mat2[j][k]; + } + prod[i][j] = temp; + } + } + return; }