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

Go to the source code of this file.

Macros

#define REPORT   {}
 

Functions

bool operator== (const BaseMatrix &A, const BaseMatrix &B)
 
bool operator== (const GeneralMatrix &A, const GeneralMatrix &B)
 
bool IsZero (const BaseMatrix &A)
 
void CrossProductBody (Real *a, Real *b, Real *c)
 
Matrix CrossProduct (const Matrix &A, const Matrix &B)
 
ReturnMatrix CrossProductRows (const Matrix &A, const Matrix &B)
 
ReturnMatrix CrossProductColumns (const Matrix &A, const Matrix &B)
 

Macro Definition Documentation

◆ REPORT

#define REPORT   {}

Function Documentation

◆ CrossProduct()

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

◆ CrossProductBody()

void CrossProductBody ( Real *  a,
Real *  b,
Real *  c 
)
inline

Definition at line 957 of file newmat7.cpp.

958 {
959  c[0] = a[1] * b[2] - a[2] * b[1];
960  c[1] = a[2] * b[0] - a[0] * b[2];
961  c[2] = a[0] * b[1] - a[1] * b[0];
962 }

◆ CrossProductColumns()

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()

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

◆ IsZero()

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

◆ operator==() [1/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==() [2/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