[cig-commits] r4809 - in long/3D/Gale/trunk/src/StGermain: .
Discretisation/Geometry/src
walter at geodynamics.org
walter at geodynamics.org
Wed Oct 11 13:45:36 PDT 2006
Author: walter
Date: 2006-10-11 13:45:36 -0700 (Wed, 11 Oct 2006)
New Revision: 4809
Modified:
long/3D/Gale/trunk/src/StGermain/
long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/TensorMultMath.c
Log:
r2866 at earth: boo | 2006-10-11 13:42:24 -0700
r2782 at earth (orig r3770): JulianGiordani | 2006-08-23 22:51:55 -0700
Adding the function NonSquareMatrix_MatrixVectorMultiplication. This function does what it says; multiplying a nonSquare matrix by a vector.
Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
- 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2865
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3769
+ 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2866
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3770
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/TensorMultMath.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/TensorMultMath.c 2006-10-11 20:45:34 UTC (rev 4808)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Geometry/src/TensorMultMath.c 2006-10-11 20:45:36 UTC (rev 4809)
@@ -550,6 +550,7 @@
return contraction;
}
+/************ All NonSquareMatrix Functions assume the output Matrix/Vector data structure is already initialised *******/
/** This function calculates the transpose of a non-square nxm 2D matrix
It requires the row and column dimensions, and assumes an answer matrix
that is the correct size, ie mxn */
@@ -602,6 +603,28 @@
}
}
+/** This function multiplies a M x N matrices by a N vector.. It requires the column
+ dimensions of the matrix and the row dimension. Columns In Matrix A = Rows In Vector B
+ resultMatrix_ij = AMatrix_ij x BVecotr_j */
+void NonSquareMatrix_MatrixVectorMultiplication( double** AMatrix, int rowsInA, int colsInA,
+ double* BVec, int rowsInB,
+ double* resultVector ) {
+ int row_I, col_I; // counters through matrix rows and columns respectively
+ Stream* error = Journal_Register( ErrorStream_Type, "TensorMultMath" );
+ Journal_Firewall( ( colsInA == rowsInB ), error,
+ "In func '%s' column dimensions of A_Matrix = %d is not equal to the row dimensions of B_Vec = %d\n",
+ __func__, colsInA, rowsInB );
+ Journal_Firewall( (resultVector == NULL) || (AMatrix == NULL) || (BVec == NULL) , error,
+ "In func '%s', Input matrices: %s %s, or Output matrix: %s is NULL \n",
+ __func__, AMatrix, BVec, resultVector);
+ /* calculate the result Vector */
+ for( row_I = 0 ; row_I < rowsInA ; row_I++ ) {
+ for( col_I = 0 ; col_I < colsInA ; col_I++ ) {
+ resultVector[ row_I ] += AMatrix[ row_I ][ col_I ] * BVec[ col_I ];
+ }
+ }
+}
+
/** Prints out a non square matrix if given the row and col dimension */
void Journal_PrintNonSquareMatrix_Unnamed( Stream* stream, double** NonSquareMatrix,
Dimension_Index rowDim, Dimension_Index colDim )
More information about the cig-commits
mailing list