/// <Summary>
/// Multiplication of the matrix
/// </Summary>
Public void multiplymatrix (double [,] A, double [,] B, out double [,] C)
{
C = new double [A. getlength (0), B. getlength (1)];
For (INT I = 0; I <A. getlength (0); I ++)
{
For (Int J = 0; j <B. getlength (1); j ++)
{
C [I, j] = 0;
For (int K = 0; k <B. getlength (0); k ++)
{
C [I, j] + = A [I, K] * B [K, J];
}
}
}
}
/// <Summary>
/// Transpose the Matrix
/// </Summary>
/// <Param name = "A"> original matrix </param>
/// <Param name = "B"> transposed matrix </param>
Public void inversematrix (double [,] A, out double [,] B)
{
B = new double [A. getlength (1), a. getlength (0)];
For (INT I = 0; I <A. getlength (1); I ++)
{
For (Int J = 0; j <A. getlength (0); j ++)
{
B [I, j] = A [J, I];
}
}
}
/// <Summary>
/// Determine the value of the matrix.
/// </Summary>
/// <Param name = "A"> matrix </param>
/// <Returns> value of the determinant </returns>
Public double surplusmatrix (double [,])
{
Int I, J, K, P, R, M, N;
M = A. getlength (0 );
N = A. getlength (1 );
Double X, temp = 1, temp1 = 1, s = 0, S1 = 0;
If (n = 2)
{
For (I = 0; I <m; I ++)
{
For (j = 0; j <n; j ++)
{
If (I + J) % 2> 0)
{Temp1 * = A [I, j];}
Else
{Temp * = A [I, j];}
}
}
X = temp-temp1;
}
Else
{
For (k = 0; k <n; k ++)
{
For (I = 0, j = K; I <M & J <n; I ++, J ++)
{
Temp * = A [I, j];
}
If (M-I> 0)
{
For (P = m-I, r = m-1; P> 0; p --, r --)
{
Temp * = A [R, p-1];
}
}
S + = temp;
Temp = 1;
}
For (k = n-1; k> = 0; k --)
{
For (I = 0, j = K; I <M & J> = 0; I ++, j --)
{
Temp1 * = A [I, j];
}
If (M-I> 0)
{
For (P = m-1, R = I; r <m; p --, r ++)
{
Temp1 * = A [R, p];
}
}
S1 + = temp1;
Temp1 = 1;
}
X = s-S1;
}
Return X;
}
/// <Summary>
/// Inverse of the matrix
/// </Summary>
/// <Param name = "A"> matrix </param>
/// <Param name = "B"> inverse matrix </param>
Public void oppmatrix (double [,] A, out double [,] B)
{
Double X = surplusmatrix ();
X = 1/X;
Double [,] B = new double [A. getlength (0), A. getlength (1)];
Double [,] sp = new double [A. getlength (0), A. getlength (1)];
Double [,] AB = new double [A. getlength (0), A. getlength (1)];
For (INT I = 0; I <A. getlength (0); I ++)
{
For (Int J = 0; j <A. getlength (1); j ++)
{
For (INT m = 0; m <A. getlength (0); m ++)
{
For (INT n = 0; n <A. getlength (1); N ++)
{B [M, N] = A [M, N];}
}
For (INT x = 0; x <A. getlength (1); X ++)
{B [I, X] = 0 ;}
For (INT y = 0; y <A. getlength (0); y ++)
{B [y, J] = 0 ;}
B [I, j] = 1;
SP [I, j] = surplusmatrix (B );
AB [I, j] = x * SP [I, j];
}
}
Double [,] TMP;
Inversematrix (AB, out TMP );
B = new double [TMP. getlength (0), TMP. getlength (1)];
For (INT I = 0; I <TMP. getlength (0); I ++)
{
For (Int J = 0; j <TMP. getlength (1); j ++)
{
B [I, j] = TMP [I, j];
}
}
}
/// <Summary>
/// Matrix multiplied by one-dimensional array
/// </Summary>
/// <Param name = "A"> matrix </param>
/// <Param name = "B"> one-dimensional array </param>
/// <Param name = "C"> output array </param>
Public void multiply (double [,] A, double [] B, out double [] C)
{
C = new double [A. getlength (0)];
For (INT I = 0; I <A. getlength (0); I ++)
{
For (Int J = 0; j <A. getlength (1); j ++)
{
C [I] + = A [I, j] * B [J];
}
}
}
The last one is complimentary, Which I adapted based on the specific needs of the project.