17 using namespace NEWMAT;
25 for (
int i = 0; i < p; ++i)
for (
int k = 0; k < r; ++k)
28 for (
int j = 0; j < q; ++j) sum += a[i][j] * b[j][k];
38 Tracer et(
"Seventh test of Matrix package");
46 for (i=1;i<=6;i++) {
for (j=i;j<=6;j++) U(i,j)=i*i*j-50; D(i,i)=i*i+i-10; }
49 for (i=1;i<=6;i++)
for (j=i;j<=6;j++) S(i,j)=i*i+2.0+j;
53 for (i=1;i<=6;i++)
for (j=1;j<=6;j++) M(i,j)=i*j+i*i-10.0;
74 LY=D.
i()*L; MS=D*LY-M;
Clean(MS,0.00000001);
Print(MS);
80 for (i=1;i<=11;i++)
for (j=i;j<=11;j++) UT(i,j)=i*i+j*3;
84 GM = UB2-UT/8; X = GM;
Print(X);
86 X = SB - UT - UT.
t();
Print(X);
93 X1=SB.
t(); X2 = B.
t(); X = SB.
i() * B - X1.
i() * X2.
t();
95 X = SB.
i(); X = X * B - X1.
i() * X2.
t();
97 D = 1; X = SB.
i() * SB - D;
Clean(X,0.00000001);
Print(X);
99 CV << 2 << 6 <<3 << 8 << -4 << 17.5 << 2 << 1 << -2 << 5 << 3.75;
100 D << 2 << 6 <<3 << 8 << -4 << 17.5 << 2 << 1 << -2 << 5 << 3.75;
105 for (i=1;i<=11;i++)
for (j=1;j<=11;j++)
107 if (abs(i-j)<=7) X(i,j)=5;
108 if (i==j) X(i,j)+=CV(i);
111 SM=SB; SB = SB+SB2; X1 = SM+X-SB;
Print(X1);
112 SB2=0; X2=SB2; X1=SB;
Print(X2);
113 for (i=1;i<=11;i++) SB2.Column(i)<<SB.Column(i);
114 X1=X1-SB2;
Print(X1);
115 X = SB; SB2.ReSize(11,4); SB2 = SB*5; SB2 = SB + SB2;
116 X1 = X*6 - SB2;
Print(X1);
117 X1 =
SP(SB,SB2/3); X1=X1-
SP(X,X*2);
Print(X1);
118 X1 =
SP(SB2/6,X*2); X1=X1-
SP(X*2,X);
Print(X1);
127 for (i = 0; i < 100; i++) A[i] = i*i+1;
129 B = A; A.
ReSize(50,
true); C = A; A.
ReSize(150,
true); D = A;
130 for (i = 0; i < 100; i++)
if (B[i] != i*i+1) Test(1)=1;
131 for (i = 0; i < 50; i++)
if (C[i] != i*i+1) Test(2)=1;
132 for (i = 0; i < 50; i++)
if (D[i] != i*i+1) Test(3)=1;
133 for (i = 50; i < 150; i++)
if (D[i] != 0) Test(3)=1;
135 for (i = 0; i < 75; i++)
if (A[i] != 75) Test(4)=1;
137 for (i = 0; i < 25; i++)
if (A[i] != 25) Test(5)=1;
139 for (i = 0; i < 25; i++)
if (A[i] != 23) Test(6)=1;
141 for (i = 0; i < 15; i++)
if (A[i] != 15) Test(7)=1;
143 for (i = 0; i < 100; i++)
if (E[i] != i*i+1) Test(8)=1;
145 for (i = 0; i < 5; i++)
if (F[i] != 0) Test(9)=1;
154 Matrix A(10, 12), B(12, 15), C(10, 15);
161 A.ReSize(11, 10); B.ReSize(10,8); C.
ReSize(11,8);
179 M.resize_keep(15,25); Y = X - M;
Print(Y);
182 M.resize_keep(0,5); M.resize_keep(10,10);
Print(M);
183 M.resize_keep(15,0); M.resize_keep(10,10);
Print(M);
205 nM.resize_keep(15,25); Y = X - nM;
Print(Y);
208 nM.resize_keep(0,5); nM.resize_keep(10,10);
Print(nM);
209 nM.resize_keep(15,0); nM.resize_keep(10,10);
Print(nM);
231 SQM.resize_keep(13); Y = X - SQM;
Print(Y);
233 SQM.resize_keep(23,23); Y -= SQM;
Print(Y);
234 SQM.resize_keep(0); SQM.resize_keep(50);
Print(SQM);
240 SM.resize_keep(13); Y = X - SM;
Print(Y);
242 SM.resize_keep(23); Y -= SM;
Print(Y);
243 SM.resize_keep(0); SM.resize_keep(50);
Print(SM);
249 LT.resize_keep(13); Y = X - LT;
Print(Y);
251 LT.resize_keep(23); Y -= LT;
Print(Y);
252 LT.resize_keep(0); LT.resize_keep(50);
Print(LT);
258 UT.resize_keep(13); Y = X - UT;
Print(Y);
260 UT.resize_keep(23); Y -= UT;
Print(Y);
261 UT.resize_keep(0); UT.resize_keep(50);
Print(UT);
267 DM.resize_keep(13); Y = X - DM;
Print(Y);
269 DM.resize_keep(23); Y -= DM;
Print(Y);
270 DM.resize_keep(0); DM.resize_keep(50);
Print(DM);
276 RV.resize_keep(13); Y = X - RV;
Print(Y);
278 RV.resize_keep(1,23); Y -= RV;
Print(Y);
279 RV.resize_keep(0); RV.resize_keep(50);
Print(RV);
285 CV.resize_keep(13); Y = X - CV;
Print(Y);
287 CV.resize_keep(23,1); Y -= CV;
Print(Y);
288 CV.resize_keep(0); CV.resize_keep(50);
Print(CV);
Real Sum(const BaseMatrix &B)
void resize_keep(int i)
change length, keep data
GetSubMatrix rows(int, int) const
SPMatrix SP(const BaseMatrix &, const BaseMatrix &)
GetSubMatrix columns(int, int) const
virtual void ReSize(int m, int n)
void Inject(const GeneralMatrix &GM)
void c_matrix_multiply(int p, int q, int r, const Real **a, const Real **b, Real **c)
virtual void ReSize(int m, int n, int b)
Upper triangular band matrix.
void Clean(Matrix &A, Real c)
TransposedMatrix t() const
GetSubMatrix sym_submatrix(int, int) const
Real Trace(const BaseMatrix &B)
int Size() const
return the size of the array
void ReSize(int m, int b)
Let matrix simulate a C type two dimensional array.
The usual rectangular matrix.
Rectangular matrix for use with Numerical Recipes in C.
FloatVector FloatVector * a
void resize(int i, bool keep=false)
change length, keep data if keep = true
int size() const
return the size of the array
virtual void resize(int, int)
Real sum(const BaseMatrix &B)
DiagedMatrix AsDiagonal() const
ColedMatrix AsColumn() const
void Print(const Matrix &X)
virtual void resize_keep(int, int)
GetSubMatrix submatrix(int, int, int, int) const
A matrix which can be of any GeneralMatrix type.
void resize_keep(int m, int n)
Let matrix simulate a C type const two dimensional array.
void FillWithValues(MultWithCarry &MWC, Matrix &M)
void ReSize(int i, bool keep=false)
change length, keep data if keep = true