Category : C++ Source Code
Archive   : BLFMATH.ZIP
Filename : MATRIX.H
// matrix.h: Matrix class template.
// Copyright(c) 1993 Azarona Software. All rights reserved.
////////////////////////////////////////////////////////////
#ifndef H_MATRIX
#define H_MATRIX
#include "vector.h"
#define INLINE
template
class Matrix {
protected:
Vector
unsigned nrows, ncols, rowstride, colstride;
public:
Matrix(unsigned nr=0, unsigned nc=0, const TYPE *s = 0);
Matrix(const Matrix
Matrix(const Matrix
unsigned sr=0, unsigned sc=0,
unsigned nr=0, unsigned nc=0);
void Copy(const Matrix
void Share(const Matrix
Matrix
Matrix
Matrix
#ifndef NO_RANGE_CHECK
unsigned CheckRow(unsigned i) const;
unsigned CheckCol(unsigned i) const;
#endif
Vector
const Vector
TYPE &operator()(unsigned r, unsigned c);
const TYPE &operator()(unsigned r, unsigned c) const;
Vector
Vector
Vector
Vector
const Vector
const Vector
const Vector
const Vector
// Mid-level hooks. Use these at your own risk:
VecPtr
VecPtr
VecPtr
VecPtr
VecPtr
VecPtr
VecPtr
VecPtr
int IsNull() const;
int IsUnique() const;
Matrix
int EnsureUnique();
unsigned NCols() const;
unsigned NRows() const;
unsigned RowStride() const;
unsigned ColStride() const;
int IsRowMajor() const;
int IsColMajor() const;
int IsSquare() const;
};
template
INLINE Matrix
// Share semantics used for assignment.
{
if (this != &m) Share(m); // Note trap for assignment to self.
return *this;
}
template
INLINE Vector
// Row subscripting operator for non-const matrices.
// This routine does the same thing as Row(r,SHARED).
{
return Vector
ncols, rowstride, CHECKROW(r)*colstride);
}
template
INLINE const Vector
// Row subscripting operator for const matrices.
// This routine does the same thing as Row(r,SHARED).
{
return Vector
ncols, rowstride, CHECKROW(r)*colstride);
}
template
INLINE VecPtr
// Returns vector pointer to row r. No reference counting
// done. Use at your own risk.
{
return VecPtr
}
template
INLINE VecPtr
// Returns vector pointer to row r. No reference counting
// done. Use at your own risk.
{
return VecPtr
}
template
INLINE VecPtr
// Returns vector pointer to column c. No reference counting
// done. Use at your own risk.
{
return VecPtr
}
template
INLINE VecPtr
// Returns vector pointer to column c. No reference counting
// done. Use at your own risk.
{
return VecPtr
}
template
INLINE VecPtr
// Returns vector pointer to right/downward diagonal.
{
unsigned diastride = (rowstride == 1) ? colstride : rowstride;
diastride++;
return VecPtr
}
template
INLINE VecPtr
// Returns vector pointer to right/downward diagonal.
{
unsigned diastride = (rowstride == 1) ? colstride : rowstride;
diastride++;
return VecPtr
}
template
INLINE VecPtr
// Returns vector pointer to underlying 1D vector.
// No reference counting done, so use at your own risk.
{
return VecPtr
}
template
INLINE VecPtr
// Returns vector pointer to underlying 1D vector.
// No reference counting done, so use at your own risk.
{
return VecPtr
}
template
INLINE int Matrix
// Returns true if the matrix references null_rep.
{
return data.IsNull();
}
template
INLINE int Matrix
// Returns true of matrix has only reference to shared data.
{
return data.IsUnique();
}
template
INLINE unsigned Matrix
{
return ncols;
}
template
INLINE unsigned Matrix
{
return nrows;
}
template
INLINE unsigned Matrix
// Returns the stride that a row vector would have
// in the matrix. For normal row-major matrices,
// the row stride will be 1. For shared submatrices,
// the rowstride is that of the parent matrix.
{
return rowstride;
}
template
INLINE unsigned Matrix
// Returns the stride that a column vector would have
// in the matrix. For a column-major matrix, the
// column stride will be 1. For shared submatrices.
// the colstride is that of the parent matrix.
{
return colstride;
}
template
INLINE int Matrix
{
return rowstride == 1;
}
template
INLINE int Matrix
{
return colstride == 1;
}
template
INLINE int Matrix
{
return nrows == ncols;
}
#undef INLINE
// Whether or not we should include the non-line methods for
// our class templates here is implementation dependent.
#include "matrix.mth"
#endif
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/