The following constructors are available for the matrix class.
1. matrix ();
2. matrix (size_t nRow, size_t nCol);
3. matrix (size_t nRow, size_t nCol, const T& e);
4. matrix (size_t nRow, size_t nCol, const T* Array, MatArrayType aType = C_ARRAY);
5. matrix (size_t nRow, size_t nCol, const valarray<T>& vec);
6. matrix (const matrix<T>& m);
7. template <class X> matrix (const matrix<X>& m);
8. ~matrix ();
Constructs a matrix class object.
typedef techsoft::matrix<float> fMatrix;
typedef techsoft::matrix<double> dMatrix;
typedef std::valarray<float> fVector;
typedef std::complex<double> dComplex;
typedef techsoft::matrix<dComplex> cdMatrix;
dMatrix m(3,3); // Constructs a 3 x 3 matrix
dMatrix m2(3,3,1.0); // Constructs a 3 x 3 matrix with
// elements initialized to 1.0
cdMatrix cm(4,4); // Constructs a 4 x 4 matrix of type complex<double>
float fv[] = { 1.34f, 2.54f, 8.23f,
7.34f, -2.3f, 2.45f,
-1.2f, 4.50f, 7.34f };
fMatrix mf( 3,3,fv); // Constructs a matrix object from "C" array fv
fMatrix mf2( 3,3,fv,techsoft::FORTRAN_ARRAY); // Constructs a matrix object from Fortran array fv
fMatrix mf3 = mf;
fVector vf( fv,9);
fMatrix mf4( 3,3,vf);
dMatrix ma[5]; // Constructs an array of matrix objects
for (size_t i=0; i < 5; i++)
{
dMatrix temp( 4,4); // Use a temporary matrix to read
// individual matrix elements in the array
temp.rand(); // Initialize/read the matrix
ma[i] = temp; // Copy it to a matrix element in the array
}
dMatrix md = mf; // Requires member template support
cdMatrix cm2 = m2; // Requires member template support