17 using namespace NEWMAT;
25 Tracer et(
"Third test of Matrix package");
32 for (i=1;i<=7;i++)
for (j=1;j<=i;j++) S(i,j)=i*i+j;
36 for (i=1;i<=7;i++) D(i,i)=S(i,i);
38 Matrix M4(7,7); { M4=D+(D+4.0); M4=M4-D*2.0; M4=M4-4.0;
Print(M4); }
42 M2=D; M2=M2-D;
Print(M2);
43 for (i=1;i<=7;i++)
for (j=1;j<=i;j++) L2(i,j)=2.0-i*i-j;
44 U2=L2.
t(); D=D.
t(); S=S.
t();
45 M4=(L2-1.0)+(U2+1.0)-D-S;
Print(M4);
46 M4=(-L2+1.0)+(-U2-1.0)+D+S;
Print(M4);
53 for (i=1;i<=6;i++) D(i,i)=i*3.0+i*i+2.0;
55 for (i=1;i<=7;i++)
for (j=1;j<=i;j++) L2(i,j)=2.0-i*i+j;
59 for (i=1;i<=6;i++)
for (j=1;j<=7;j++) M2(i,j)=2.0+i*j+i*i+2.0*j*j;
62 MX=MD*M2*MD1 - (D*M2)*D1;
Print(MX);
64 D.
ReSize(7);
for (i=1;i<=7;i++) D(i,i)=i*3.0+i*i+2.0;
67 M2=U2; M2=LD*M2*MD1 - D*(U2*D1);
Print(M2);
68 M2=U2; M2=UD*M2*MD1 - (D*U2)*D1;
Print(M2);
69 M2=L2; M2=LD*M2*MD1 - D*(L2*D1);
Print(M2);
70 M2=L2; M2=UD*M2*MD1 - (D*L2)*D1;
Print(M2);
78 for (
int i=1;i<=6;i++) D(i)=i*i;
81 E=D*E-I*4.0;
Print(E);
82 E = D.
i() / 0.25; E=D*E-I*4.0;
Print(E);
87 sigma = 0; sigma(1,1) = 1.0; sigma(2,2) = 1.0; sigma(3,3) = 1.0;
89 sigmaI -= sigma;
Clean(sigmaI, 0.000000001);
Print(sigmaI);
94 for (
int i=1; i<=5; i++)
for (
int j=1; j<=5; j++)
95 X(i,j) = (23*i+59*j) % 43;
96 DM << 1 << 8 << -7 << 2 << 3;
97 Matrix Y = X.
i() * DM; Y = X * Y - DM;
103 CV << 2 << 7 << 1 << 6 << -3 << 1 << 8 << -4 << 0 << 17;
104 RCV << 17 << 0 << -4 << 8 << 1 << -3 << 6 << 1 << 7 << 2;
113 Matrix A(3,3); A << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9;
114 Matrix B(3,3); B << 9 << 8 << 7 << 6 << 5 << 4 << 3 << 2 << 1;
116 Diff = (-A).Reverse() + B;
Print(Diff);
118 U << A.
Reverse(); Diff = U; U << B; Diff -= U;
Print(Diff);
119 U << (-A).Reverse(); Diff = U; U << B; Diff += U;
Print(Diff);
148 Matrix B = (A | Z) & (Z | A);
154 Y << 0.0 << 1.0 << 1.0
156 << 3.0 << 3.0 << 0.0;
160 YY -= Y1 & Y1;
Clean(YY, 0.000000001);
Print(YY);
161 Y1 = A * Y1 - Y;
Clean(Y1, 0.000000001);
Print(Y1);
void Inject(const GeneralMatrix &GM)
ReversedMatrix Reverse() const
void Clean(Matrix &A, Real c)
TransposedMatrix t() const
The usual rectangular matrix.
LU decomposition of a band matrix.
DiagedMatrix AsDiagonal() const
void Print(const Matrix &X)
GetSubMatrix Rows(int f, int l) const