/usr/include/newmat/newmatrm.h is in libnewmat10-dev 1.10.4-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | //$$newmatrm.h rectangular matrix operations
// Copyright (C) 1991,2,3,4: R B Davies
#ifndef NEWMATRM_LIB
#define NEWMATRM_LIB 0
#ifdef use_namespace
namespace NEWMAT {
#endif
// operations on rectangular matrices
class RectMatrixCol;
class RectMatrixRowCol
// a class for accessing rows and columns of rectangular matrices
{
protected:
#ifdef use_namespace // to make namespace work
public:
#endif
Real* store; // pointer to storage
int n; // number of elements
int spacing; // space between elements
int shift; // space between cols or rows
RectMatrixRowCol(Real* st, int nx, int sp, int sh)
: store(st), n(nx), spacing(sp), shift(sh) {}
void Reset(Real* st, int nx, int sp, int sh)
{ store=st; n=nx; spacing=sp; shift=sh; }
public:
Real operator*(const RectMatrixRowCol&) const; // dot product
void AddScaled(const RectMatrixRowCol&, Real); // add scaled
void Divide(const RectMatrixRowCol&, Real); // scaling
void Divide(Real); // scaling
void Negate(); // change sign
void Zero(); // zero row col
Real& operator[](int i) { return *(store+i*spacing); } // element
Real SumSquare() const; // sum of squares
Real& First() { return *store; } // get first element
void DownDiag() { store += (shift+spacing); n--; }
void UpDiag() { store -= (shift+spacing); n++; }
friend void ComplexScale(RectMatrixCol&, RectMatrixCol&, Real, Real);
friend void Rotate(RectMatrixCol&, RectMatrixCol&, Real, Real);
FREE_CHECK(RectMatrixRowCol)
};
class RectMatrixRow : public RectMatrixRowCol
{
public:
RectMatrixRow(const Matrix&, int, int, int);
RectMatrixRow(const Matrix&, int);
void Reset(const Matrix&, int, int, int);
void Reset(const Matrix&, int);
Real& operator[](int i) { return *(store+i); }
void Down() { store += shift; }
void Right() { store++; n--; }
void Up() { store -= shift; }
void Left() { store--; n++; }
FREE_CHECK(RectMatrixRow)
};
class RectMatrixCol : public RectMatrixRowCol
{
public:
RectMatrixCol(const Matrix&, int, int, int);
RectMatrixCol(const Matrix&, int);
void Reset(const Matrix&, int, int, int);
void Reset(const Matrix&, int);
void Down() { store += spacing; n--; }
void Right() { store++; }
void Up() { store -= spacing; n++; }
void Left() { store--; }
friend void ComplexScale(RectMatrixCol&, RectMatrixCol&, Real, Real);
friend void Rotate(RectMatrixCol&, RectMatrixCol&, Real, Real);
FREE_CHECK(RectMatrixCol)
};
class RectMatrixDiag : public RectMatrixRowCol
{
public:
RectMatrixDiag(const DiagonalMatrix& D)
: RectMatrixRowCol(D.Store(), D.Nrows(), 1, 1) {}
Real& operator[](int i) { return *(store+i); }
void DownDiag() { store++; n--; }
void UpDiag() { store--; n++; }
FREE_CHECK(RectMatrixDiag)
};
inline RectMatrixRow::RectMatrixRow
(const Matrix& M, int row, int skip, int length)
: RectMatrixRowCol( M.Store()+row*M.Ncols()+skip, length, 1, M.Ncols() ) {}
inline RectMatrixRow::RectMatrixRow (const Matrix& M, int row)
: RectMatrixRowCol( M.Store()+row*M.Ncols(), M.Ncols(), 1, M.Ncols() ) {}
inline RectMatrixCol::RectMatrixCol
(const Matrix& M, int skip, int col, int length)
: RectMatrixRowCol( M.Store()+col+skip*M.Ncols(), length, M.Ncols(), 1 ) {}
inline RectMatrixCol::RectMatrixCol (const Matrix& M, int col)
: RectMatrixRowCol( M.Store()+col, M.Nrows(), M.Ncols(), 1 ) {}
inline Real square(Real x) { return x*x; }
inline Real sign(Real x, Real y)
{ return (y>=0) ? x : -x; } // assume x >=0
#ifdef use_namespace
}
#endif
#endif
// body file: newmatrm.cpp
|