OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Private Member Functions | Private Attributes | List of all members
BandLUMatrix Class Reference

#include <newmat.h>

Inheritance diagram for BandLUMatrix:
GeneralMatrix BaseMatrix

Public Member Functions

 BandLUMatrix (const BaseMatrix &)
 
MatrixType Type () const
 
void lubksb (Real *, int=0)
 
 ~BandLUMatrix ()
 
GeneralMatrixMakeSolver ()
 
LogAndSign LogDeterminant () const
 
void Solver (MatrixColX &, const MatrixColX &)
 
void GetRow (MatrixRowCol &)
 
void GetCol (MatrixRowCol &)
 
void GetCol (MatrixColX &c)
 
void CleanUp ()
 
void MiniCleanUp ()
 
bool IsEqual (const GeneralMatrix &) const
 
bool IsSingular () const
 
- Public Member Functions inherited from GeneralMatrix
GeneralMatrixEvaluate (MatrixType mt=MatrixTypeUnSp)
 
int Nrows () const
 
int Ncols () const
 
int Storage () const
 
RealStore () const
 
virtual ~GeneralMatrix ()
 
void tDelete ()
 
bool reuse ()
 
void Protect ()
 
int Tag () const
 
bool IsZero () const
 
void Release ()
 
void Release (int t)
 
void ReleaseAndDelete ()
 
void operator<< (const Real *)
 
void operator<< (const int *)
 
void operator<< (const BaseMatrix &X)
 
void Inject (const GeneralMatrix &)
 
void operator+= (const BaseMatrix &)
 
void operator-= (const BaseMatrix &)
 
void operator*= (const BaseMatrix &)
 
void operator|= (const BaseMatrix &)
 
void operator &= (const BaseMatrix &)
 
void operator+= (Real)
 
void operator-= (Real r)
 
void operator*= (Real)
 
void operator/= (Real r)
 
virtual void RestoreRow (MatrixRowCol &)
 
virtual void NextRow (MatrixRowCol &)
 
virtual void RestoreCol (MatrixRowCol &)
 
virtual void RestoreCol (MatrixColX &)
 
virtual void NextCol (MatrixRowCol &)
 
virtual void NextCol (MatrixColX &)
 
Real SumSquare () const
 
Real SumAbsoluteValue () const
 
Real Sum () const
 
Real MaximumAbsoluteValue1 (int &i) const
 
Real MinimumAbsoluteValue1 (int &i) const
 
Real Maximum1 (int &i) const
 
Real Minimum1 (int &i) const
 
Real MaximumAbsoluteValue () const
 
Real MaximumAbsoluteValue2 (int &i, int &j) const
 
Real MinimumAbsoluteValue () const
 
Real MinimumAbsoluteValue2 (int &i, int &j) const
 
Real Maximum () const
 
Real Maximum2 (int &i, int &j) const
 
Real Minimum () const
 
Real Minimum2 (int &i, int &j) const
 
void CheckStore () const
 
virtual void SetParameters (const GeneralMatrix *)
 
 operator ReturnMatrix () const
 
ReturnMatrix ForReturn () const
 
virtual bool SameStorageType (const GeneralMatrix &A) const
 
virtual void ReSizeForAdd (const GeneralMatrix &A, const GeneralMatrix &B)
 
virtual void ReSizeForSP (const GeneralMatrix &A, const GeneralMatrix &B)
 
virtual void ReSize (const GeneralMatrix &A)
 
MatrixInput operator<< (Real)
 
MatrixInput operator<< (int f)
 
- Public Member Functions inherited from BaseMatrix
AddedMatrix operator+ (const BaseMatrix &) const
 
MultipliedMatrix operator* (const BaseMatrix &) const
 
SubtractedMatrix operator- (const BaseMatrix &) const
 
ConcatenatedMatrix operator| (const BaseMatrix &) const
 
StackedMatrix operator & (const BaseMatrix &) const
 
ShiftedMatrix operator+ (Real) const
 
ScaledMatrix operator* (Real) const
 
ScaledMatrix operator/ (Real) const
 
ShiftedMatrix operator- (Real) const
 
TransposedMatrix t () const
 
NegatedMatrix operator- () const
 
ReversedMatrix Reverse () const
 
InvertedMatrix i () const
 
RowedMatrix AsRow () const
 
ColedMatrix AsColumn () const
 
DiagedMatrix AsDiagonal () const
 
MatedMatrix AsMatrix (int, int) const
 
GetSubMatrix SubMatrix (int, int, int, int) const
 
GetSubMatrix SymSubMatrix (int, int) const
 
GetSubMatrix Row (int) const
 
GetSubMatrix Rows (int, int) const
 
GetSubMatrix Column (int) const
 
GetSubMatrix Columns (int, int) const
 
Real AsScalar () const
 
Real Determinant () const
 
Real NormFrobenius () const
 
virtual Real Trace () const
 
Real Norm1 () const
 
Real NormInfinity () const
 
virtual MatrixBandWidth BandWidth () const
 
void IEQND () const
 

Private Member Functions

void ludcmp ()
 
void operator= (const BandLUMatrix &)
 

Private Attributes

int * indx
 
bool d
 
bool sing
 
Realstore2
 
int storage2
 
int m1
 
int m2
 

Additional Inherited Members

- Protected Member Functions inherited from GeneralMatrix
 GeneralMatrix ()
 
 GeneralMatrix (ArrayLengthSpecifier)
 
void Add (GeneralMatrix *, Real)
 
void Add (Real)
 
void NegAdd (GeneralMatrix *, Real)
 
void NegAdd (Real)
 
void Multiply (GeneralMatrix *, Real)
 
void Multiply (Real)
 
void Negate (GeneralMatrix *)
 
void Negate ()
 
void ReverseElements ()
 
void ReverseElements (GeneralMatrix *)
 
void operator= (Real)
 
Real * GetStore ()
 
GeneralMatrixBorrowStore (GeneralMatrix *, MatrixType)
 
void GetMatrix (const GeneralMatrix *)
 
void Eq (const BaseMatrix &, MatrixType)
 
void Eq (const GeneralMatrix &)
 
void Eq (const BaseMatrix &, MatrixType, bool)
 
void Eq2 (const BaseMatrix &, MatrixType)
 
int search (const BaseMatrix *) const
 
virtual GeneralMatrixTranspose (TransposedMatrix *, MatrixType)
 
void CheckConversion (const BaseMatrix &)
 
void ReSize (int, int, int)
 
virtual short SimpleAddOK (const GeneralMatrix *)
 
void PlusEqual (const GeneralMatrix &gm)
 
void MinusEqual (const GeneralMatrix &gm)
 
void PlusEqual (Real f)
 
void MinusEqual (Real f)
 
- Protected Attributes inherited from GeneralMatrix
int tag
 
int nrows
 
int ncols
 
int storage
 
Realstore
 

Detailed Description

Definition at line 1111 of file newmat.h.

Constructor & Destructor Documentation

◆ BandLUMatrix()

BandLUMatrix::BandLUMatrix ( const BaseMatrix m)

Definition at line 226 of file bandmat.cpp.

References MatrixType::BM, GeneralMatrix::Evaluate(), MatrixErrorNoSpace(), MONITOR_INT_NEW, MONITOR_REAL_NEW, and REPORT.

227 {
228  REPORT
229  Tracer tr("BandLUMatrix");
230  storage2 = 0; store2 = 0; // in event of exception during build
232  m1 = ((BandMatrix*)gm)->lower; m2 = ((BandMatrix*)gm)->upper;
233  GetMatrix(gm);
234  if (nrows!=ncols) Throw(NotSquareException(*this));
235  d = true; sing = false;
236  indx = new int [nrows]; MatrixErrorNoSpace(indx);
237  MONITOR_INT_NEW("Index (BndLUMat)",nrows,indx)
238  storage2 = nrows * m1;
240  MONITOR_REAL_NEW("Make (BandLUMat)",storage2,store2)
241  ludcmp();
242 }
double Real
Definition: include.h:57
void ludcmp()
Definition: bandmat.cpp:273
GeneralMatrix * Evaluate(MatrixType mt=MatrixTypeUnSp)
Definition: newmat5.cpp:79
#define MONITOR_INT_NEW(Operation, Size, Pointer)
Definition: myexcept.h:318
void MatrixErrorNoSpace(const void *)
Definition: newmatex.cpp:292
int storage2
Definition: newmat.h:1118
int * indx
Definition: newmat.h:1114
#define MONITOR_REAL_NEW(Operation, Size, Pointer)
Definition: myexcept.h:317
bool sing
Definition: newmat.h:1116
Real * store2
Definition: newmat.h:1117
#define REPORT
Definition: bandmat.cpp:24
void GetMatrix(const GeneralMatrix *)
Definition: newmat4.cpp:610

◆ ~BandLUMatrix()

BandLUMatrix::~BandLUMatrix ( )

Definition at line 244 of file bandmat.cpp.

References MONITOR_INT_DELETE, MONITOR_REAL_DELETE, and REPORT.

245 {
246  REPORT
247  MONITOR_INT_DELETE("Index (BndLUMat)",nrows,indx)
248  MONITOR_REAL_DELETE("Delete (BndLUMt)",storage2,store2)
249  delete [] indx; delete [] store2;
250 }
#define MONITOR_INT_DELETE(Operation, Size, Pointer)
Definition: myexcept.h:320
int storage2
Definition: newmat.h:1118
#define MONITOR_REAL_DELETE(Operation, Size, Pointer)
Definition: myexcept.h:319
int * indx
Definition: newmat.h:1114
Real * store2
Definition: newmat.h:1117
#define REPORT
Definition: bandmat.cpp:24

Member Function Documentation

◆ CleanUp()

void BandLUMatrix::CleanUp ( )
virtual

Reimplemented from GeneralMatrix.

Definition at line 912 of file newmat4.cpp.

References GeneralMatrix::CleanUp(), indx, GeneralMatrix::nrows, REPORT, storage2, and store2.

913 {
914  REPORT
915  if (nrows) delete [] indx;
916  if (storage2) delete [] store2;
918 }
void CleanUp()
Definition: newmat4.cpp:874
#define REPORT
Definition: newmat4.cpp:19
int storage2
Definition: newmat.h:1118
int * indx
Definition: newmat.h:1114
Real * store2
Definition: newmat.h:1117

◆ GetCol() [1/2]

void BandLUMatrix::GetCol ( MatrixRowCol )
virtual

Implements GeneralMatrix.

Definition at line 307 of file newmatex.cpp.

308  { Throw(NotDefinedException("GetCol","BandLUMatrix")); }

◆ GetCol() [2/2]

void BandLUMatrix::GetCol ( MatrixColX c)
inlinevirtual

Implements GeneralMatrix.

Definition at line 1132 of file newmat.h.

References GetCol().

Referenced by GetCol().

1132 { GetCol((MatrixRowCol&)c); }
void GetCol(MatrixRowCol &)
Definition: newmatex.cpp:307

◆ GetRow()

void BandLUMatrix::GetRow ( MatrixRowCol )
virtual

Implements GeneralMatrix.

Definition at line 305 of file newmatex.cpp.

306  { Throw(NotDefinedException("GetRow","BandLUMatrix")); }

◆ IsEqual()

bool BandLUMatrix::IsEqual ( const GeneralMatrix A) const
virtual

Reimplemented from GeneralMatrix.

Definition at line 935 of file newmat7.cpp.

References A, and REPORT.

936 {
937  Tracer tr("BandLUMatrix IsEqual");
938  if (A.Type() != Type()) // not same types
939  { REPORT return false; }
940  if (&A == this) // same matrix
941  { REPORT return true; }
942  if ( A.Nrows() != nrows || A.Ncols() != ncols
943  || ((BandLUMatrix&)A).m1 != m1 || ((BandLUMatrix&)A).m2 != m2 )
944  // different dimensions
945  { REPORT return false; }
946 
947  // matrix storage the same - compare store
948  REPORT
949  return RealEqual(A.Store(),store,storage)
950  && RealEqual(((BandLUMatrix&)A).store2,store2,storage2)
951  && intEqual(((BandLUMatrix&)A).indx, indx, nrows);
952 }
MatrixType Type() const
Definition: bandmat.cpp:252
#define A(r, c)
#define REPORT
Definition: newmat7.cpp:18
int storage2
Definition: newmat.h:1118
int * indx
Definition: newmat.h:1114
Real * store
Definition: newmat.h:393
Real * store2
Definition: newmat.h:1117
int storage
Definition: newmat.h:392

◆ IsSingular()

bool BandLUMatrix::IsSingular ( ) const
inline

Definition at line 1136 of file newmat.h.

1136 { return sing; }
bool sing
Definition: newmat.h:1116

◆ LogDeterminant()

LogAndSign BandLUMatrix::LogDeterminant ( ) const
virtual

Reimplemented from GeneralMatrix.

Definition at line 255 of file bandmat.cpp.

References LogAndSign::ChangeSign(), and REPORT.

256 {
257  REPORT
258  if (sing) return 0.0;
259  Real* a = store; int w = m1+1+m2; LogAndSign sum; int i = nrows;
260  // while (i--) { sum *= *a; a += w; }
261  if (i) for (;;) { sum *= *a; if (!(--i)) break; a += w; }
262  if (!d) sum.ChangeSign(); return sum;
263 }
double Real
Definition: include.h:57
InvertedMatrix i() const
Definition: newmat6.cpp:325
Real * store
Definition: newmat.h:393
bool sing
Definition: newmat.h:1116
void ChangeSign()
Definition: newmat.h:50
#define REPORT
Definition: bandmat.cpp:24

◆ lubksb()

void BandLUMatrix::lubksb ( Real *  B,
int  mini = 0 
)

Definition at line 314 of file bandmat.cpp.

315 {
316  REPORT
317  Tracer tr("BandLUMatrix::lubksb");
318  if (sing) Throw(SingularException(*this));
319  int n = nrows; int l = m1; int w = m1 + 1 + m2;
320 
321  for (int k=0; k<n; k++)
322  {
323  int i = indx[k];
324  if (i!=k) { Real x=B[k]; B[k]=B[i]; B[i]=x; }
325  if (l<n) l++;
326  Real* m = store2 + k*m1; Real* b = B+k; Real* bi = b;
327  for (i=k+1; i<l; i++) *(++bi) -= *m++ * *b;
328  }
329 
330  l = -m1;
331  for (int i = n-1; i>=mini; i--)
332  {
333  Real* b = B + i; Real* bk = b; Real x = *bk;
334  Real* a = store + w*i; Real y = *a;
335  int k = l+m1; while (k--) x -= *(++a) * *(++bk);
336  *b = x / y;
337  if (l < m2) l++;
338  }
339 }
ossim_uint32 x
double Real
Definition: include.h:57
ossim_uint32 y
InvertedMatrix i() const
Definition: newmat6.cpp:325
os2<< "> n<< " > nendobj n
int * indx
Definition: newmat.h:1114
Real * store
Definition: newmat.h:393
bool sing
Definition: newmat.h:1116
Real * store2
Definition: newmat.h:1117
#define REPORT
Definition: bandmat.cpp:24

◆ ludcmp()

void BandLUMatrix::ludcmp ( )
private

Definition at line 273 of file bandmat.cpp.

References n, REPORT, and x.

274 {
275  REPORT
276  Real* a = store2; int i = storage2;
277  // clear store2 - so unused locations are always zero -
278  // required by operator==
279  while (i--) *a++ = 0.0;
280  a = store;
281  i = m1; int j = m2; int k; int n = nrows; int w = m1 + 1 + m2;
282  while (i)
283  {
284  Real* ai = a + i;
285  k = ++j; while (k--) *a++ = *ai++;
286  k = i--; while (k--) *a++ = 0.0;
287  }
288 
289  a = store; int l = m1;
290  for (k=0; k<n; k++)
291  {
292  Real x = *a; i = k; Real* aj = a;
293  if (l < n) l++;
294  for (j=k+1; j<l; j++)
295  { aj += w; if (std::fabs(x) < std::fabs(*aj)) { x = *aj; i = j; } }
296  indx[k] = i;
297  if (x==0) { sing = true; return; }
298  if (i!=k)
299  {
300  d = !d; Real* ak = a; Real* ai = store + i * w; j = w;
301  while (j--) { x = *ak; *ak++ = *ai; *ai++ = x; }
302  }
303  aj = a + w; Real* m = store2 + m1 * k;
304  for (j=k+1; j<l; j++)
305  {
306  *m++ = x = *aj / *a; i = w; Real* ak = a;
307  while (--i) { Real* aj1 = aj++; *aj1 = *aj - x * *(++ak); }
308  *aj++ = 0.0;
309  }
310  a += w;
311  }
312 }
ossim_uint32 x
double Real
Definition: include.h:57
InvertedMatrix i() const
Definition: newmat6.cpp:325
os2<< "> n<< " > nendobj n
int storage2
Definition: newmat.h:1118
int * indx
Definition: newmat.h:1114
Real * store
Definition: newmat.h:393
bool sing
Definition: newmat.h:1116
Real * store2
Definition: newmat.h:1117
#define REPORT
Definition: bandmat.cpp:24

◆ MakeSolver()

GeneralMatrix* BandLUMatrix::MakeSolver ( )
inlinevirtual

Reimplemented from GeneralMatrix.

Definition at line 1127 of file newmat.h.

1127 { return this; } // for solving

◆ MiniCleanUp()

void BandLUMatrix::MiniCleanUp ( )
virtual

Reimplemented from GeneralMatrix.

Definition at line 920 of file newmat4.cpp.

References indx, GeneralMatrix::MiniCleanUp(), GeneralMatrix::nrows, REPORT, storage2, and store2.

921 {
922  REPORT
923  if (nrows) delete [] indx;
924  if (storage2) delete [] store2;
926 }
virtual void MiniCleanUp()
Definition: newmat.h:421
#define REPORT
Definition: newmat4.cpp:19
int storage2
Definition: newmat.h:1118
int * indx
Definition: newmat.h:1114
Real * store2
Definition: newmat.h:1117

◆ operator=()

void BandLUMatrix::operator= ( const BandLUMatrix )
inlineprivate

Definition at line 1121 of file newmat.h.

1121 {} // no allowed

◆ Solver()

void BandLUMatrix::Solver ( MatrixColX mcout,
const MatrixColX mcin 
)
virtual

Reimplemented from GeneralMatrix.

Definition at line 341 of file bandmat.cpp.

References MatrixRowCol::data, REPORT, MatrixRowCol::skip, and MatrixRowCol::storage.

342 {
343  REPORT
344  int i = mcin.skip; Real* el = mcin.data-i; Real* el1=el;
345  while (i--) *el++ = 0.0;
346  el += mcin.storage; i = nrows - mcin.skip - mcin.storage;
347  while (i--) *el++ = 0.0;
348  lubksb(el1, mcout.skip);
349 }
double Real
Definition: include.h:57
InvertedMatrix i() const
Definition: newmat6.cpp:325
Real * data
Definition: newmatrc.h:43
int storage
Definition: newmatrc.h:40
void lubksb(Real *, int=0)
Definition: bandmat.cpp:314
#define REPORT
Definition: bandmat.cpp:24

◆ Type()

MatrixType BandLUMatrix::Type ( ) const
virtual

Implements GeneralMatrix.

Definition at line 252 of file bandmat.cpp.

References MatrixType::BC, and REPORT.

252 { REPORT return MatrixType::BC; }
#define REPORT
Definition: bandmat.cpp:24

Member Data Documentation

◆ d

bool BandLUMatrix::d
private

Definition at line 1115 of file newmat.h.

◆ indx

int* BandLUMatrix::indx
private

Definition at line 1114 of file newmat.h.

Referenced by CleanUp(), and MiniCleanUp().

◆ m1

int BandLUMatrix::m1
private

Definition at line 1120 of file newmat.h.

◆ m2

int BandLUMatrix::m2
private

Definition at line 1120 of file newmat.h.

◆ sing

bool BandLUMatrix::sing
private

Definition at line 1116 of file newmat.h.

◆ storage2

int BandLUMatrix::storage2
private

Definition at line 1118 of file newmat.h.

Referenced by CleanUp(), and MiniCleanUp().

◆ store2

Real* BandLUMatrix::store2
private

Definition at line 1117 of file newmat.h.

Referenced by CleanUp(), and MiniCleanUp().


The documentation for this class was generated from the following files: