#include
#include
#include
#include
using namespace std;
Void matrix_mul (int m, int n, int l, double [], a double [] b, double c [])
{
for(int i=0; i
For (int k=0; K
C * l + k] [I=0;
for(int j=0; j
}
}
}
Void matrix_sub (int m, int n, double [], a double [] b, double c [])
{
for(int i=0; i
}
//* * * * * * * * * * * * * * * * o matrix determinant of * * * * * * * * * * * * * * * * * * * * * * 8 * * * * * * * * * * * * * * *
A, double Surplus (double * int m, int n)
{
Int I, j, k, p, r.
Double X, temp=1, temp1=1, s=0, s1=0;
If (n==2)
{the for (I=0; I
Temp1 *=* (A + I * n + m);
The else
Temp *=* (A + I * n + m);
X=temp - temp1;
}
The else {
For (k=0; K
For (I=0, j=k; i
If (m - I)
{
For (p=m - I, m r=1; p> 0; P -, r -)
Temp *=* (A + r * n + p - 1); }
S +=temp;
Temp=1;
}
For (k=n - 1; K>=0; K -)
{
For (I=0, j=k; i
Temp1 *=* (A + I * n + m);
If (m - I)
{
For (p=m - 1, r=I; R
}
S1 +=temp1;
Temp1=1;
}
X=s - s1;
}
return X;
}
//* * * * * * * * * * * * * * * * * matrix inversion * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Double * MatrixOpp (double * A, int m, int n)
{
Int I, j, x, y, k;
Double X;
Double * C=new double [m * n];
Double * SP=new double [m * n];
Double * AB=new double [m * n];
Double * B=new double [m * n];
X=Surplus (A, m, n);
X=1/X;
For (I=0; i
For (k=0; K
{
For (x=0; x
For (y=0; Y
* (B + I * n + j)=1;
* (SP + I * n + j)=Surplus (B, m, n);
* (AB + I * n + j)=X * (* (SP + I * n + m));
}
}
For (I=0; i
For (j=0; j
}
Return the C;
}
Int main () {
Ifstream infile.
Infile. Open (" test_in. TXT ");
Ofstream outfile;
Outfile. Open (" test_out. TXT ");
Int I, j;
Int n, t, m;
Infile> N> T> m;
Cout<& lt;" B matrix for "& lt; & lt; endl;
Double * b=new double [n] * t;
Double * bt=new double t * [n];
Double * p=new double [n * n];
Double * l=new double [m] n *;
For (I=0; i
}
For (I=0; i
For (j=0; j
Cout<& lt; endl;
}
For (I=0; i
Cout<& lt;" "After the transpose & lt; & lt; endl;
For (I=0; i
For (j=0; j
Cout<& lt; + I * n + j * (bt) & lt; & lt;" ";
}
Cout<& lt; endl;
}
Cout<& lt;" P matrix for "& lt; & lt; endl;
//double * p=new double [n * n];
For (I=0; i
For (j=0; j
}
For (I=0; i
For (j=0; j
Cout<& lt; endl;
}
Cout<& lt;" L matrix for "& lt; & lt; endl;
//double * l=new double [n * 1];
For (I=0; i
For (j=0; j<1; J++)
Infile> * (l + I * 1 + I);
}
For (I=0; i
For (j=0; j<1; J++)
Cout<& lt; * (l + I * 1 + I);
Cout<& lt; endl;
}
Double * BTP=new double t * [n];
Matrix_mul (t, n, n, bt, p, BTP);
Cout<& lt; Endl<& lt;" BTP: "& lt; & lt; endl;
For (I=0; i
For (j=0; j
Cout<& lt; endl;
}
Double * btp1=new double t * [n];
Matrix_mul (t, n, n, bt, p, btp1);
Double * BTPL=new double [m] t *;
Matrix_mul (t, n, m, btp1, l, BTPL);
Cout<& lt; Endl<& lt;" BTPL: "& lt; & lt; endl;
For (I=0; i
For (j=0; j
Cout<& lt; endl;
}
Double * BTPB=new double [t * t];
Matrix_mul (t, n, t, BTP, b, BTPB);
Cout<& lt; Endl<& lt;" BTPB: "& lt; & lt; endl;
For (I=0; i
For (j=0; j
Cout<& lt; endl;
}
Double * W=new double [t * t];
W=MatrixOpp (BTPB, t, t);
Cout<& lt;" W=: "& lt; & lt; endl;
For (I=0; i
For (j=0; j
Cout<& lt; * (W + I * t + j) & lt; & lt;" ";
}
Cout<& lt; endl;
}
/* double * WBT=new double t * [n];
Matrix_mul (t, t, n, W, bt, WBT);
Cout<& lt; Endl<& lt;" WBT: "& lt; & lt; endl;
For (I=0; i