OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Classes | Macros | Functions
newmat.h File Reference
#include <ossim/matrix/include.h>
#include <ossim/matrix/myexcept.h>

Go to the source code of this file.

Classes

class  LogAndSign
 
class  MatrixType
 
class  MatrixBandWidth
 
class  ArrayLengthSpecifier
 
class  BaseMatrix
 
class  GeneralMatrix
 
class  Matrix
 
class  SquareMatrix
 
class  nricMatrix
 
class  SymmetricMatrix
 
class  UpperTriangularMatrix
 
class  LowerTriangularMatrix
 
class  DiagonalMatrix
 
class  RowVector
 
class  ColumnVector
 
class  CroutMatrix
 
class  BandMatrix
 
class  UpperBandMatrix
 
class  LowerBandMatrix
 
class  SymmetricBandMatrix
 
class  BandLUMatrix
 
class  IdentityMatrix
 
class  GenericMatrix
 
class  MultipliedMatrix
 
class  AddedMatrix
 
class  SPMatrix
 
class  KPMatrix
 
class  ConcatenatedMatrix
 
class  StackedMatrix
 
class  SolvedMatrix
 
class  SubtractedMatrix
 
class  ShiftedMatrix
 
class  NegShiftedMatrix
 
class  ScaledMatrix
 
class  NegatedMatrix
 
class  TransposedMatrix
 
class  ReversedMatrix
 
class  InvertedMatrix
 
class  RowedMatrix
 
class  ColedMatrix
 
class  DiagedMatrix
 
class  MatedMatrix
 
class  ReturnMatrix
 
class  GetSubMatrix
 
class  LinearEquationSolver
 
class  MatrixInput
 
class  SimpleIntArray
 
class  NPDException
 
class  ConvergenceException
 
class  SingularException
 
class  OverflowException
 
class  ProgramException
 
class  IndexException
 
class  VectorException
 
class  NotSquareException
 
class  SubMatrixDimensionException
 
class  IncompatibleDimensionsException
 
class  NotDefinedException
 
class  CannotBuildException
 
class  InternalException
 

Macros

#define NEWMAT_LIB   0
 
#define MatrixTypeUnSp   0
 

Functions

void MatrixErrorNoSpace (const void *)
 
bool operator== (const GeneralMatrix &A, const GeneralMatrix &B)
 
bool operator== (const BaseMatrix &A, const BaseMatrix &B)
 
bool operator!= (const GeneralMatrix &A, const GeneralMatrix &B)
 
bool operator!= (const BaseMatrix &A, const BaseMatrix &B)
 
bool operator<= (const BaseMatrix &A, const BaseMatrix &)
 
bool operator>= (const BaseMatrix &A, const BaseMatrix &)
 
bool operator< (const BaseMatrix &A, const BaseMatrix &)
 
bool operator> (const BaseMatrix &A, const BaseMatrix &)
 
bool IsZero (const BaseMatrix &A)
 
OSSIM_DLL Matrix CrossProduct (const Matrix &A, const Matrix &B)
 
OSSIM_DLL ReturnMatrix CrossProductRows (const Matrix &A, const Matrix &B)
 
OSSIM_DLL ReturnMatrix CrossProductColumns (const Matrix &A, const Matrix &B)
 
OSSIM_DLL Real DotProduct (const Matrix &A, const Matrix &B)
 
LogAndSign LogDeterminant (const BaseMatrix &B)
 
Real Determinant (const BaseMatrix &B)
 
Real SumSquare (const BaseMatrix &B)
 
Real NormFrobenius (const BaseMatrix &B)
 
Real Trace (const BaseMatrix &B)
 
Real SumAbsoluteValue (const BaseMatrix &B)
 
Real Sum (const BaseMatrix &B)
 
Real MaximumAbsoluteValue (const BaseMatrix &B)
 
Real MinimumAbsoluteValue (const BaseMatrix &B)
 
Real Maximum (const BaseMatrix &B)
 
Real Minimum (const BaseMatrix &B)
 
Real Norm1 (const BaseMatrix &B)
 
Real Norm1 (RowVector &RV)
 
Real NormInfinity (const BaseMatrix &B)
 
Real NormInfinity (ColumnVector &CV)
 
bool IsZero (const GeneralMatrix &A)
 

Macro Definition Documentation

◆ MatrixTypeUnSp

#define MatrixTypeUnSp   0

Definition at line 271 of file newmat.h.

◆ NEWMAT_LIB

#define NEWMAT_LIB   0

Definition at line 6 of file newmat.h.

Function Documentation

◆ CrossProduct()

OSSIM_DLL Matrix CrossProduct ( const Matrix A,
const Matrix B 
)

Definition at line 964 of file newmat7.cpp.

965 {
966  REPORT
967  int ac = A.Ncols(); int ar = A.Nrows();
968  int bc = B.Ncols(); int br = B.Nrows();
969  Real* a = A.Store(); Real* b = B.Store();
970  if (ac == 3)
971  {
972  if (bc != 3 || ar != 1 || br != 1)
973  { Tracer et("CrossProduct"); IncompatibleDimensionsException(A, B); }
974  REPORT
975  RowVector C(3); Real* c = C.Store(); CrossProductBody(a, b, c);
976  return C;
977  }
978  else
979  {
980  if (ac != 1 || bc != 1 || ar != 3 || br != 3)
981  { Tracer et("CrossProduct"); IncompatibleDimensionsException(A, B); }
982  REPORT
983  ColumnVector C(3); Real* c = C.Store(); CrossProductBody(a, b, c);
984  return C;
985  }
986 }
double Real
Definition: include.h:57
int Ncols() const
Definition: newmat.h:431
#define A(r, c)
#define REPORT
Definition: newmat7.cpp:18
int Nrows() const
Definition: newmat.h:430
void CrossProductBody(Real *a, Real *b, Real *c)
Definition: newmat7.cpp:957
Real * Store() const
Definition: newmat.h:433

◆ CrossProductColumns()

OSSIM_DLL ReturnMatrix CrossProductColumns ( const Matrix A,
const Matrix B 
)

Definition at line 1009 of file newmat7.cpp.

1010 {
1011  REPORT
1012  int n = A.Ncols();
1013  if (A.Nrows() != 3 || B.Nrows() != 3 || n != B.Ncols())
1014  { Tracer et("CrossProductColumns"); IncompatibleDimensionsException(A, B); }
1015  Matrix C(3, n);
1016  Real* a = A.Store(); Real* b = B.Store(); Real* c = C.Store();
1017  Real* an = a+n; Real* an2 = an+n;
1018  Real* bn = b+n; Real* bn2 = bn+n;
1019  Real* cn = c+n; Real* cn2 = cn+n;
1020 
1021  int i = n;
1022  while (i--)
1023  {
1024  *c++ = *an * *bn2 - *an2 * *bn;
1025  *cn++ = *an2++ * *b - *a * *bn2++;
1026  *cn2++ = *a++ * *bn++ - *an++ * *b++;
1027  }
1028 
1029  return C.ForReturn();
1030 }
double Real
Definition: include.h:57
int Ncols() const
Definition: newmat.h:431
#define A(r, c)
#define REPORT
Definition: newmat7.cpp:18
os2<< "> n<< " > nendobj n
Definition: newmat.h:543
int Nrows() const
Definition: newmat.h:430
Real * Store() const
Definition: newmat.h:433

◆ CrossProductRows()

OSSIM_DLL ReturnMatrix CrossProductRows ( const Matrix A,
const Matrix B 
)

Definition at line 988 of file newmat7.cpp.

989 {
990  REPORT
991  int n = A.Nrows();
992  if (A.Ncols() != 3 || B.Ncols() != 3 || n != B.Nrows())
993  { Tracer et("CrossProductRows"); IncompatibleDimensionsException(A, B); }
994  Matrix C(n, 3);
995  Real* a = A.Store(); Real* b = B.Store(); Real* c = C.Store();
996  if (n--)
997  {
998  for (;;)
999  {
1000  CrossProductBody(a, b, c);
1001  if (!(n--)) break;
1002  a += 3; b += 3; c += 3;
1003  }
1004  }
1005 
1006  return C.ForReturn();
1007 }
double Real
Definition: include.h:57
int Ncols() const
Definition: newmat.h:431
#define A(r, c)
#define REPORT
Definition: newmat7.cpp:18
os2<< "> n<< " > nendobj n
Definition: newmat.h:543
int Nrows() const
Definition: newmat.h:430
void CrossProductBody(Real *a, Real *b, Real *c)
Definition: newmat7.cpp:957
Real * Store() const
Definition: newmat.h:433

◆ Determinant()

Real Determinant ( const BaseMatrix B)
inline

Definition at line 1753 of file newmat.h.

1754  { return B.Determinant(); }
Real Determinant() const
Definition: newmat8.cpp:711

◆ DotProduct()

OSSIM_DLL Real DotProduct ( const Matrix A,
const Matrix B 
)

Definition at line 526 of file newmat8.cpp.

527 {
528  REPORT
529  int n = A.storage;
530  if (n != B.storage) Throw(IncompatibleDimensionsException(A,B));
531  Real sum = 0.0; Real* a = A.store; Real* b = B.store;
532  while (n--) sum += *a++ * *b++;
533  return sum;
534 }
double Real
Definition: include.h:57
#define A(r, c)
#define REPORT
Definition: newmat8.cpp:21
os2<< "> n<< " > nendobj n
Real * store
Definition: newmat.h:393
int storage
Definition: newmat.h:392

◆ IsZero() [1/2]

bool IsZero ( const BaseMatrix A)

Definition at line 889 of file newmat7.cpp.

References A, GeneralMatrix::Evaluate(), GeneralMatrix::IsZero(), and REPORT.

890 {
891  Tracer tr("BaseMatrix::IsZero");
892  REPORT
893  GeneralMatrix* gm1 = 0; bool bx;
894  Try { gm1=((BaseMatrix&)A).Evaluate(); bx = gm1->IsZero(); }
895  CatchAll { if (gm1) gm1->tDelete(); ReThrow; }
896  gm1->tDelete();
897  return bx;
898 }
GeneralMatrix * Evaluate(MatrixType mt=MatrixTypeUnSp)
Definition: newmat5.cpp:79
#define A(r, c)
#define REPORT
Definition: newmat7.cpp:18
bool IsZero() const
Definition: newmat7.cpp:876

◆ IsZero() [2/2]

bool IsZero ( const GeneralMatrix A)
inline

Definition at line 1773 of file newmat.h.

References A.

1773 { return A.IsZero(); }
#define A(r, c)

◆ LogDeterminant()

LogAndSign LogDeterminant ( const BaseMatrix B)
inline

Definition at line 1751 of file newmat.h.

1752  { return B.LogDeterminant(); }
virtual LogAndSign LogDeterminant() const
Definition: newmat8.cpp:682

◆ MatrixErrorNoSpace()

void MatrixErrorNoSpace ( const void *  )

◆ Maximum()

Real Maximum ( const BaseMatrix B)
inline

Definition at line 1766 of file newmat.h.

Referenced by SVD().

1766 { return B.Maximum(); }
virtual Real Maximum() const
Definition: newmat8.cpp:490

◆ MaximumAbsoluteValue()

Real MaximumAbsoluteValue ( const BaseMatrix B)
inline

Definition at line 1762 of file newmat.h.

1763  { return B.MaximumAbsoluteValue(); }
virtual Real MaximumAbsoluteValue() const
Definition: newmat8.cpp:454

◆ Minimum()

Real Minimum ( const BaseMatrix B)
inline

Definition at line 1767 of file newmat.h.

Referenced by SVD().

1767 { return B.Minimum(); }
virtual Real Minimum() const
Definition: newmat8.cpp:508

◆ MinimumAbsoluteValue()

Real MinimumAbsoluteValue ( const BaseMatrix B)
inline

Definition at line 1764 of file newmat.h.

1765  { return B.MinimumAbsoluteValue(); }
virtual Real MinimumAbsoluteValue() const
Definition: newmat8.cpp:472

◆ Norm1() [1/2]

Real Norm1 ( const BaseMatrix B)
inline

Definition at line 1768 of file newmat.h.

1768 { return B.Norm1(); }
Real Norm1() const
Definition: newmat7.cpp:723

◆ Norm1() [2/2]

Real Norm1 ( RowVector RV)
inline

Definition at line 1769 of file newmat.h.

References GeneralMatrix::MaximumAbsoluteValue().

1769 { return RV.MaximumAbsoluteValue(); }
Real MaximumAbsoluteValue() const
Definition: newmat8.cpp:214

◆ NormFrobenius()

Real NormFrobenius ( const BaseMatrix B)
inline

Definition at line 1756 of file newmat.h.

1756 { return B.NormFrobenius(); }
Real NormFrobenius() const
Definition: newmat8.cpp:439

◆ NormInfinity() [1/2]

Real NormInfinity ( const BaseMatrix B)
inline

Definition at line 1770 of file newmat.h.

1770 { return B.NormInfinity(); }
Real NormInfinity() const
Definition: newmat7.cpp:735

◆ NormInfinity() [2/2]

Real NormInfinity ( ColumnVector CV)
inline

Definition at line 1771 of file newmat.h.

References GeneralMatrix::MaximumAbsoluteValue().

1772  { return CV.MaximumAbsoluteValue(); }
Real MaximumAbsoluteValue() const
Definition: newmat8.cpp:214

◆ operator!=() [1/2]

bool operator!= ( const GeneralMatrix A,
const GeneralMatrix B 
)
inline

Definition at line 1723 of file newmat.h.

1724  { return ! (A==B); }
#define A(r, c)

◆ operator!=() [2/2]

bool operator!= ( const BaseMatrix A,
const BaseMatrix B 
)
inline

Definition at line 1725 of file newmat.h.

1726  { return ! (A==B); }
#define A(r, c)

◆ operator<()

bool operator< ( const BaseMatrix A,
const BaseMatrix  
)
inline

Definition at line 1734 of file newmat.h.

References A.

1735  { A.IEQND(); return true; }
#define A(r, c)

◆ operator<=()

bool operator<= ( const BaseMatrix A,
const BaseMatrix  
)
inline

Definition at line 1730 of file newmat.h.

References A.

1731  { A.IEQND(); return true; }
#define A(r, c)

◆ operator==() [1/2]

bool operator== ( const GeneralMatrix A,
const GeneralMatrix B 
)

Definition at line 850 of file newmat7.cpp.

Referenced by MatrixBandWidth::operator!=().

851 {
852  Tracer tr("GeneralMatrix ==");
853  // May or may not call tDeletes
854  REPORT
855 
856  if (&A == &B) // same matrix
857  { REPORT return true; }
858 
859  if ( A.Nrows() != B.Nrows() || A.Ncols() != B.Ncols() )
860  { REPORT return false; } // different dimensions
861 
862  // check for CroutMatrix or BandLUMatrix
863  MatrixType AType = A.Type(); MatrixType BType = B.Type();
864  if (AType.CannotConvert() || BType.CannotConvert() )
865  { REPORT return A.IsEqual(B); }
866 
867  // is matrix storage the same
868  // will need to modify if further matrix structures are introduced
869  if (AType == BType && A.BandWidth() == B.BandWidth())
870  { REPORT return RealEqual(A.Store(),B.Store(),A.Storage()); }
871 
872  // matrix storage different - just subtract
873  REPORT return IsZero(A-B);
874 }
virtual MatrixBandWidth BandWidth() const
Definition: newmat4.cpp:431
int Ncols() const
Definition: newmat.h:431
bool CannotConvert() const
Definition: newmat.h:181
#define A(r, c)
#define REPORT
Definition: newmat7.cpp:18
bool IsZero(const BaseMatrix &A)
Definition: newmat7.cpp:889
virtual MatrixType Type() const =0
int Nrows() const
Definition: newmat.h:430
Real * Store() const
Definition: newmat.h:433

◆ operator==() [2/2]

bool operator== ( const BaseMatrix A,
const BaseMatrix B 
)

Definition at line 812 of file newmat7.cpp.

813 {
814  Tracer tr("BaseMatrix ==");
815  REPORT
816  GeneralMatrix* gmA = ((BaseMatrix&)A).Evaluate();
817  GeneralMatrix* gmB = ((BaseMatrix&)B).Evaluate();
818 
819  if (gmA == gmB) // same matrix
820  { REPORT gmA->tDelete(); return true; }
821 
822  if ( gmA->Nrows() != gmB->Nrows() || gmA->Ncols() != gmB->Ncols() )
823  // different dimensions
824  { REPORT gmA->tDelete(); gmB->tDelete(); return false; }
825 
826  // check for CroutMatrix or BandLUMatrix
827  MatrixType AType = gmA->Type(); MatrixType BType = gmB->Type();
828  if (AType.CannotConvert() || BType.CannotConvert() )
829  {
830  REPORT
831  bool bx = gmA->IsEqual(*gmB);
832  gmA->tDelete(); gmB->tDelete();
833  return bx;
834  }
835 
836  // is matrix storage the same
837  // will need to modify if further matrix structures are introduced
838  if (AType == BType && gmA->BandWidth() == gmB->BandWidth())
839  { // compare store
840  REPORT
841  bool bx = RealEqual(gmA->Store(),gmB->Store(),gmA->Storage());
842  gmA->tDelete(); gmB->tDelete();
843  return bx;
844  }
845 
846  // matrix storage different - just subtract
847  REPORT return IsZero(*gmA-*gmB);
848 }
void tDelete()
Definition: newmat4.cpp:535
virtual MatrixBandWidth BandWidth() const
Definition: newmat4.cpp:431
int Ncols() const
Definition: newmat.h:431
GeneralMatrix * Evaluate(MatrixType mt=MatrixTypeUnSp)
Definition: newmat5.cpp:79
bool CannotConvert() const
Definition: newmat.h:181
#define A(r, c)
#define REPORT
Definition: newmat7.cpp:18
bool IsZero(const BaseMatrix &A)
Definition: newmat7.cpp:889
virtual MatrixType Type() const =0
int Nrows() const
Definition: newmat.h:430
Real * Store() const
Definition: newmat.h:433

◆ operator>()

bool operator> ( const BaseMatrix A,
const BaseMatrix  
)
inline

Definition at line 1736 of file newmat.h.

References A.

1737  { A.IEQND(); return true; }
#define A(r, c)

◆ operator>=()

bool operator>= ( const BaseMatrix A,
const BaseMatrix  
)
inline

Definition at line 1732 of file newmat.h.

References A.

1733  { A.IEQND(); return true; }
#define A(r, c)

◆ Sum()

Real Sum ( const BaseMatrix B)
inline

Definition at line 1760 of file newmat.h.

1761  { return B.Sum(); }
virtual Real Sum() const
Definition: newmat8.cpp:448

◆ SumAbsoluteValue()

Real SumAbsoluteValue ( const BaseMatrix B)
inline

Definition at line 1758 of file newmat.h.

1759  { return B.SumAbsoluteValue(); }
virtual Real SumAbsoluteValue() const
Definition: newmat8.cpp:442

◆ SumSquare()

Real SumSquare ( const BaseMatrix B)
inline

Definition at line 1755 of file newmat.h.

Referenced by MLE_D_FI::NextPoint(), and BaseMatrix::NormFrobenius().

1755 { return B.SumSquare(); }
virtual Real SumSquare() const
Definition: newmat8.cpp:433

◆ Trace()

Real Trace ( const BaseMatrix B)
inline

Definition at line 1757 of file newmat.h.

Referenced by IdentityMatrix::Sum(), and IdentityMatrix::SumAbsoluteValue().

1757 { return B.Trace(); }
virtual Real Trace() const
Definition: newmat8.cpp:609