Category : C++ Source Code
Archive   : BLFMATH.ZIP
Filename : TSTMAT2.CPP
// tstmat2.cpp: Matrix test program using shape elements.
// Copyright(c) 1993 Azarona Software. All rights reserved.
/////////////////////////////////////////////////////////////
#include
#include
#include "matrix.h"
#include "shape.h"
template
void PrtMat(const Matrix
// We'll test 2D subscripting here while we're at it.
{
for (int i = 0; i
}
cout << '\n';
}
}
template
void PrtVec(const Vector
{
VecPtr
unsigned i, len = v.Length();
for (i = 0; i
elemptr++;
}
cout << '\n';
}
// BC++ needs the next statements
void PrtMat(const Matrix
void PrtVec(const Vector
// You need one of these statements for each type of vector:
INITNULLVEC(Shape);
#ifdef ONE_WAY
// A low-level C array we'll copy and transform into matrix
const int arr_size = 56;
Shape arr[arr_size];
#endif
void test()
{
int i;
#ifdef ONE_WAY
// Set up low level array to be transformed to a matrix
for (i = 0; i
cout << "Creating a matrix\n";
#ifdef ONE_WAY
Matrix
#else
Matrix
Vector
// Testing 1D vector subscripting too
for (i = 0; i
cout << "mymat: \n";
PrtMat(mymat); cout << '\n';
cout << "Creating copy of the matrix\n";
#ifdef ONE_WAY
Matrix
#else
Matrix
#endif
cout << "matii: \n";
PrtMat(matii); cout << '\n';
cout << "Creating a share of the diagonal\n";
Vector
PrtVec(Diag);
cout << "Setting shared diagonal = 1\n";
Diag = Shape(1,1);
cout << "mymat: \n";
PrtMat(mymat); cout << '\n';
cout << "Creating a copy of the diagonal\n";
Vector
PrtVec(Diag2);
cout << "Setting copied diagonal = 99\n";
Diag2 = Shape(99,99);
PrtVec(Diag2); cout << '\n';
cout << "mymat: \n";
PrtMat(mymat); cout << '\n';
cout << "Creating a share of row 3\n";
Vector
PrtVec(Row);
cout << "Setting row 3 to 17's\n";
Row = Shape(17, 17);
cout << "mymat: \n";
PrtMat(mymat); cout << '\n';
cout << "Creating a share of col 5\n";
Vector
PrtVec(Col);
cout << "Setting col 5 to 42's\n";
Col = Shape(42,42);
cout << "mymat: \n";
PrtMat(mymat);
cout << "\nUsing the copy of the original matrix\n";
cout << "matii: \n";
PrtMat(matii); cout << '\n';
cout << "Transposing this copy\n";
matii = matii.Transpose();
cout << "matii: \n";
PrtMat(matii); cout << '\n';
cout << "Set row 2 to 55's\n";
matii.Row(2) = Shape(55,55);
cout << "matii: \n";
PrtMat(matii); cout << '\n';
cout << "Set col 3 to 77's\n";
matii.Col(3) = Shape(77,77);
cout << "matii: \n";
PrtMat(matii); cout << '\n';
cout << "Creating shared submatrix of transpose\n";
Matrix
cout << "submat: \n";
PrtMat(submat); cout << '\n';
cout << "Transposing the submatrix\n";
submat = submat.Transpose();
cout << "submat: \n";
PrtMat(submat); cout << '\n';
cout << "\nTesting a[][] form of subscripting\n";
cout << "submat[3][2] = " << submat[3][2] << "\n\n";
cout << "Setting diagonal of submatrix to 0\n";
submat.Diag() = Shape(0,0);
cout << "submat: \n";
PrtMat(submat); cout << '\n';
cout << "Setting second row of submatrix to 99's\n";
submat.Row(1) = Shape(99,99);
cout << "submat: \n";
PrtMat(submat); cout << '\n';
cout << "matii: \n";
PrtMat(matii); cout << '\n';
cout << "Creating sub-sub-matrix\n";
Matrix
cout << "subsubmat: \n";
PrtMat(subsubmat); cout << '\n';
cout << "Set rows of subsubmatrix to 91's, 92's, and 93's\n";
subsubmat.Row(0) = Shape(91,91);
subsubmat.Row(1) = Shape(92,92);
subsubmat.Row(2) = Shape(93,93);
cout << "subsubmat: \n";
PrtMat(subsubmat); cout << '\n';
cout << "matii: \n";
PrtMat(matii); cout << '\n';
cout << "Set diagonal of subsubmatrix to 77's\n";
subsubmat.Diag() = Shape(77,77);
cout << "subsubmat: \n";
PrtMat(subsubmat); cout << '\n';
cout << "matii: \n";
PrtMat(matii); cout << '\n';
cout << "Testing sub-matrix transpose\n";
cout << "subsubmat transposed: \n";
subsubmat = subsubmat.Transpose();
PrtMat(subsubmat); cout << '\n';
cout << "Set all elements of sub-sub-matrix to 42's\n";
subsubmat = Shape(42, 42);
cout << "subsubmat: \n";
PrtMat(subsubmat); cout << '\n';
cout << "matii: \n";
PrtMat(matii); cout << '\n';
}
#include "tstmain.cpp"
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/