19 using namespace NEWMAT;
29 Tracer et(
"First test of Matrix package");
36 for (i=1;i<=10;i++)
for (j=1;j<=i;j++) L(i,j)=2.0+i*i+j;
38 for (i=1;i<=10;i++)
for (j=1;j<=i;j++) S(i,j)=i*j+1.0;
44 for (i=1;i<=10;i++) D(i,i)=(i-4)*(i-5)*(i-6);
45 Matrix M=(S+U-D+L)*(L+U-D+S);
49 Matrix M1 = S*L + U*L - D*L + L*L + 10.0;
50 { M1 = M1 + S*U + U*U - D*U + L*U - S*D; }
51 { M1 = M1 - U*D + DD - LD + S*S; }
52 { M1 = M1 + U*S - D*S + L*S - 10.0; }
61 for (i=1;i<=9;i++)
for (j=1;j<=i;j++) L(i,j)=1.0+j;
63 for (j=1;j<=9;j++)
for (i=1;i<=j;i++) U1(i,j)=1.0+i;
65 for (i=1;i<=9;i++)
for (j=1;j<=i;j++) LX(i,j)=1.0+i*i;
67 for (j=1;j<=9;j++)
for (i=1;i<=j;i++) UX(i,j)=1.0+j*j;
69 L=L+LX/0.5; L=L-LX*3.0; L=LX*2.0+L;
70 U1=U1+UX*2.0; U1=U1-UX*3.0; U1=UX*2.0+U1;
75 for (i=1;i<=9;i++)
for (j=1;j<=i;j++) S(i,j)=i*i+j;
83 for (i=1;i<=9;i++) D(i,i)=S(i,i);
86 U1=U1*2.0 - U;
Print(U1);
95 for (i = 1; i<=10; i++)
for (j = 1; j<=3; j++)
96 { M(i,j) = 2*i-j; N(i,j) = i*j + 20; }
99 M1 = M; M1 += N; M1 -= MN;
Print(M1);
100 M1 = M; M1 += M1; M1 = M1 - M * 2;
Print(M1);
101 M1 = M; M1 += N * 2; M1 -= (MN + N);
Print(M1);
102 M1 = M; M1 -= M1;
Print(M1);
103 M1 = M; M1 -= MN + M1; M1 += N + M;
Print(M1);
104 M1 = M; M1 -= 5; M1 -= M; M1 *= 0.2; M1 = M1 + 1;
Print(M1);
106 M1 = M; M1 *= NT; M1 -= M * N.
t();
Print(M1);
109 M1 = M; M1 += D; M1 -= M; M1 = M1 - D;
Print(M1);
110 M1 = M; M1 -= D; M1 -= M; M1 = M1 + D;
Print(M1);
111 M1 = M; M1 *= D; M1 /= 2; M1 -= M;
Print(M1);
114 SM += 10; M1 = SM - M; M1 /=10; M1 = M1 - 1;
Print(M1);
120 for (i = 1; i<=10; i++)
for (j = 1; j<=3; j++) M(i,j) = 2*i-j;
121 for (i = 1; i<=10; i++)
for (j = 1; j<=5; j++) N(i,j) = i*j + 20;
123 M1 = M; M1 |= N; M1 &= N | M;
124 M1 -= (M | N) & (N | M);
Print(M1);
125 M1 = M; M1 |= M1; M1 &= M1;
126 M1 -= (M | M) & (M | M);
Print(M1);
133 for (i=1;i<=10;i++)
for (j=1;j<=10;j++)
134 { M1(i,j) = 0.5*i+j*j-50; M2(i,j) = (i*101 + j*103) % 13; }
138 MX -= M1X + M2X;
Print(MX);
139 MX = BM1; MX += BM2; MX -= M1X; MX -= M2X;
Print(MX);
143 M1X *= M1X.
t(); M1X *= 5.5; M2X *= M2X.
t();
144 SM1 -= SM2; M1 = SM1 - M1X + M2X;
Print(M1);
145 M1 = BM1; BM1 *= SM1; M1 = M1 * SM1 - BM1;
Print(M1);
146 M1 = BM1; BM1 -= SM1; M1 = M1 - SM1 - BM1;
Print(M1);
147 M1 = BM1; BM1 += SM1; M1 = M1 + SM1 - BM1;
Print(M1);
153 Matrix M(10,10), N(10,10);
154 for (i = 1; i<=10; i++)
for (j = 1; j<=10; j++)
155 { M(i,j) = 2*i-j; N(i,j) = i*j + 20; }
159 GM = D; GM += N; GM += M; GM += D;
160 M1 = D*2 - GM + M + N;
Print(M1);
161 GM = D; GM *= 4; GM += 16; GM /= 8; GM -= 2;
162 GM -= D / 2; M1 = GM;
Print(M1);
163 GM = D; GM *= M; GM *= N; GM /= 3; M1 = M*N - GM;
Print(M1);
164 GM = D; GM |= M; GM &= N | D; M1 = GM - ((D | M) & (N | D));
166 GM = M; M1 = M; GM += 5; GM *= 3; M *= 3; M += 15; M1 = GM - M;
168 D.
ReSize(10);
for (i = 1; i<=10; i++) D(i) = i;
169 M1 = D + 10; GM = D; GM += 10; M1 -= GM;
Print(M1);
170 GM = M; GM -= D; M1 = GM; GM = D; GM -= M; M1 += GM;
Print(M1);
171 GM = M; GM *= D; M1 = GM; GM = D; GM *= M.
t();
173 GM = M; GM += 2 * GM; GM -= 3 * M; M1 = GM;
Print(M1);
174 GM = M; GM |= GM; GM -= (M | M); M1 = GM;
Print(M1);
175 GM = M; GM &= GM; GM -= (M & M); M1 = GM;
Print(M1);
176 M1 = M; M1 = (M1.
t() & M.
t()) - (M | M).
t();
Print(M1);
177 M1 = M; M1 = (M1.
t() | M.
t()) - (M & M).
t();
Print(M1);
191 for (j = 1; j <= n; j++) A(k,j) = ((k-1) * (2*j-1));
198 for (j = 1; j <= n; j++) B(k,j) = (k1 * (2*j-1));
203 cout <<
"\nVisual C++ version 5 compiler error?";
204 cout <<
"\nTurn off optimisation";
236 X << (d1 - d0) << (d2 - d0) << (d3 - d0);
254 for (i = 1; i<=10; i++)
for (j = 1; j<=3; j++)
255 { M(i,j) = 2*i-j; N(i,j) = i*j + 20; }
259 for (i = 1; i<=10; i++)
261 CP2 -= CP1;
Print(CP2);
264 CP2 -= CP1.
t();
Print(CP2);
272 for (
int i = 1; i <= 10; ++i) cv(i) = mwc.
Next();
ReturnMatrix CrossProductColumns(const Matrix &A, const Matrix &B)
Real DotProduct(const Matrix &A, const Matrix &B)
void Inject(const GeneralMatrix &GM)
void Clean(Matrix &A, Real c)
RowedMatrix AsRow() const
TransposedMatrix t() const
Matrix CrossProduct(const Matrix &A, const Matrix &B)
The usual rectangular matrix.
GetSubMatrix Row(int f) const
Real Determinant(const BaseMatrix &B)
void Print(const Matrix &X)
A matrix which can be of any GeneralMatrix type.
ReturnMatrix CrossProductRows(const Matrix &A, const Matrix &B)