TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::Matrix::Impl Class Reference

#include <Matrix.h>

Public Member Functions

 ~Impl ()
 
- Public Member Functions inherited from G3D::ReferenceCountedObject
virtual ~ReferenceCountedObject ()
 

Static Public Member Functions

static void * operator new (size_t size)
 
static void operator delete (void *p)
 

Private Member Functions

void setSize (int newRows, int newCols)
 
 Impl ()
 
 Impl (const Matrix3 &M)
 
 Impl (const Matrix4 &M)
 
 Impl (int r, int c)
 
Imploperator= (const Impl &m)
 
 Impl (const Impl &B)
 
void setZero ()
 
void set (int r, int c, T v)
 
const Tget (int r, int c) const
 
void mul (const Impl &B, Impl &out) const
 
void add (const Impl &B, Impl &out) const
 
void add (T B, Impl &out) const
 
void sub (const Impl &B, Impl &out) const
 
void sub (T B, Impl &out) const
 
void lsub (T B, Impl &out) const
 
void arrayMul (const Impl &B, Impl &out) const
 
void mul (T B, Impl &out) const
 
void arrayDiv (const Impl &B, Impl &out) const
 
void div (T B, Impl &out) const
 
void negate (Impl &out) const
 
void inverseViaAdjoint (Impl &out) const
 
void inverseInPlaceGaussJordan ()
 
void adjoint (Impl &out) const
 
void cofactor (Impl &out) const
 
T cofactor (int r, int c) const
 
void transpose (Impl &out) const
 
T determinant () const
 
T determinant (int r, int c) const
 
void arrayLog (Impl &out) const
 
void arrayExp (Impl &out) const
 
void arraySqrt (Impl &out) const
 
void arrayCos (Impl &out) const
 
void arraySin (Impl &out) const
 
void swapRows (int r0, int r1)
 
void swapAndNegateCols (int c0, int c1)
 
void mulRow (int r, const T &v)
 
void abs (Impl &out) const
 
void withoutRowAndCol (int excludeRow, int excludeCol, Impl &out) const
 
bool anyNonZero () const
 
bool allNonZero () const
 
void setRow (int r, const T *vals)
 
void setCol (int c, const T *vals)
 

Private Attributes

T ** elt
 
Tdata
 
int R
 
int C
 
int dataSize
 

Friends

class Matrix
 

Detailed Description

Used internally by Matrix.

Does not throw exceptions– assumes the caller has taken care of argument checking.

Constructor & Destructor Documentation

G3D::Matrix::Impl::~Impl ( )
580  {
581  //delete[] elt;
582  System::free(elt);
584 }
static void alignedFree(void *ptr)
Definition: System.cpp:1546
T * data
Definition: Matrix.h:102
T ** elt
Definition: Matrix.h:99
static void free(void *p)
Definition: System.cpp:1473

+ Here is the call graph for this function:

G3D::Matrix::Impl::Impl ( )
inlineprivate
117 : elt(NULL), data(NULL), R(0), C(0), dataSize(0) {}
int dataSize
Definition: Matrix.h:110
arena_t NULL
Definition: jemalloc_internal.h:624
int R
Definition: Matrix.h:105
T * data
Definition: Matrix.h:102
T ** elt
Definition: Matrix.h:99
int C
Definition: Matrix.h:108
G3D::Matrix::Impl::Impl ( const Matrix3 M)
private
529  : elt(NULL), data(NULL), R(0), C(0), dataSize(0){
530  setSize(3, 3);
531  for (int r = 0; r < 3; ++r) {
532  for (int c = 0; c < 3; ++c) {
533  set(r, c, M[r][c]);
534  }
535  }
536 
537 }
int dataSize
Definition: Matrix.h:110
arena_t NULL
Definition: jemalloc_internal.h:624
int R
Definition: Matrix.h:105
T * data
Definition: Matrix.h:102
T ** elt
Definition: Matrix.h:99
void setSize(int newRows, int newCols)
Definition: Matrix.cpp:550
void set(int r, int c, T v)
Definition: Matrix.h:136
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

G3D::Matrix::Impl::Impl ( const Matrix4 M)
private
540  : elt(NULL), data(NULL), R(0), C(0), dataSize(0) {
541  setSize(4, 4);
542  for (int r = 0; r < 4; ++r) {
543  for (int c = 0; c < 4; ++c) {
544  set(r, c, M[r][c]);
545  }
546  }
547 }
int dataSize
Definition: Matrix.h:110
arena_t NULL
Definition: jemalloc_internal.h:624
int R
Definition: Matrix.h:105
T * data
Definition: Matrix.h:102
T ** elt
Definition: Matrix.h:99
void setSize(int newRows, int newCols)
Definition: Matrix.cpp:550
void set(int r, int c, T v)
Definition: Matrix.h:136
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

G3D::Matrix::Impl::Impl ( int  r,
int  c 
)
inlineprivate
123  : elt(NULL), data(NULL), R(0), C(0), dataSize(0) {
124  setSize(r, c);
125  }
int dataSize
Definition: Matrix.h:110
arena_t NULL
Definition: jemalloc_internal.h:624
int R
Definition: Matrix.h:105
T * data
Definition: Matrix.h:102
T ** elt
Definition: Matrix.h:99
void setSize(int newRows, int newCols)
Definition: Matrix.cpp:550
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

G3D::Matrix::Impl::Impl ( const Impl B)
inlineprivate
129  : elt(NULL), data(NULL), R(0), C(0), dataSize(0) {
130  // Use the assignment operator
131  *this = B;
132  }
int dataSize
Definition: Matrix.h:110
arena_t NULL
Definition: jemalloc_internal.h:624
int R
Definition: Matrix.h:105
T * data
Definition: Matrix.h:102
T ** elt
Definition: Matrix.h:99
int C
Definition: Matrix.h:108

Member Function Documentation

void G3D::Matrix::Impl::abs ( Impl out) const
private
void G3D::Matrix::Impl::add ( const Impl B,
Impl out 
) const
private

Ok if out == this or out == B

void G3D::Matrix::Impl::add ( T  B,
Impl out 
) const
private

Ok if out == this or out == B

void G3D::Matrix::Impl::adjoint ( Impl out) const
private
776  {
777  cofactor(out);
778  // Transpose is safe to perform in place
779  out.transpose(out);
780 }
void cofactor(Impl &out) const
Definition: Matrix.cpp:783

+ Here is the call graph for this function:

bool G3D::Matrix::Impl::allNonZero ( ) const
private
1474  {
1475  int N = R * C;
1476  for (int i = 0; i < N; ++i) {
1477  if (data[i] == 0.0) {
1478  return false;
1479  }
1480  }
1481  return true;
1482 }
int R
Definition: Matrix.h:105
T * data
Definition: Matrix.h:102
int C
Definition: Matrix.h:108
bool G3D::Matrix::Impl::anyNonZero ( ) const
private
1463  {
1464  int N = R * C;
1465  for (int i = 0; i < N; ++i) {
1466  if (data[i] != 0.0) {
1467  return true;
1468  }
1469  }
1470  return false;
1471 }
int R
Definition: Matrix.h:105
T * data
Definition: Matrix.h:102
int C
Definition: Matrix.h:108
void G3D::Matrix::Impl::arrayCos ( Impl out) const
private
void G3D::Matrix::Impl::arrayDiv ( const Impl B,
Impl out 
) const
private

Ok if out == this or out == B

void G3D::Matrix::Impl::arrayExp ( Impl out) const
private
void G3D::Matrix::Impl::arrayLog ( Impl out) const
private
void G3D::Matrix::Impl::arrayMul ( const Impl B,
Impl out 
) const
private

Ok if out == this or out == B

void G3D::Matrix::Impl::arraySin ( Impl out) const
private
void G3D::Matrix::Impl::arraySqrt ( Impl out) const
private
void G3D::Matrix::Impl::cofactor ( Impl out) const
private

Matrix of all cofactors

783  {
784  debugAssert(&out != this);
785  for(int r = 0; r < R; ++r) {
786  for(int c = 0; c < C; ++c) {
787  out.set(r, c, cofactor(r, c));
788  }
789  }
790 }
void cofactor(Impl &out) const
Definition: Matrix.cpp:783
int R
Definition: Matrix.h:105
#define debugAssert(exp)
Definition: debugAssert.h:160
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

Matrix::T G3D::Matrix::Impl::cofactor ( int  r,
int  c 
) const
private

Cofactor [r][c] is defined as C[r][c] = -1 ^(r+c) * det(A[r][c]), where A[r][c] is the (R-1)x(C-1) matrix formed by removing row r and column c from the original matrix.

793  {
794  // Strang p. 217
795  float s = isEven(r + c) ? 1.0f : -1.0f;
796 
797  return s * determinant(r, c);
798 }
T determinant() const
Definition: Matrix.cpp:823
bool isEven(int num)
Definition: g3dmath.h:794

+ Here is the call graph for this function:

Matrix::T G3D::Matrix::Impl::determinant ( ) const
private
823  {
824 
825  debugAssert(R == C);
826 
827  // Compute using cofactors
828  switch(R) {
829  case 0:
830  return 0;
831 
832  case 1:
833  // Determinant of a 1x1 is the element
834  return elt[0][0];
835 
836  case 2:
837  // Determinant of a 2x2 is ad-bc
838  return elt[0][0] * elt[1][1] - elt[0][1] * elt[1][0];
839 
840  case 3:
841  {
842  // Determinant of an nxn matrix is the dot product of the first
843  // row with the first row of cofactors. The base cases of this
844  // method get called a lot, so we spell out the implementation
845  // for the 3x3 case.
846 
847  float cofactor00 = elt[1][1] * elt[2][2] - elt[1][2] * elt[2][1];
848  float cofactor10 = elt[1][2] * elt[2][0] - elt[1][0] * elt[2][2];
849  float cofactor20 = elt[1][0] * elt[2][1] - elt[1][1] * elt[2][0];
850 
851  return Matrix::T(
852  elt[0][0] * cofactor00 +
853  elt[0][1] * cofactor10 +
854  elt[0][2] * cofactor20);
855  }
856 
857  default:
858  {
859  // Determinant of an n x n matrix is the dot product of the first
860  // row with the first row of cofactors
861  T det = 0;
862 
863  for (int c = 0; c < C; ++c) {
864  det += elt[0][c] * cofactor(0, c);
865  }
866 
867  return det;
868  }
869  }
870 }
void cofactor(Impl &out) const
Definition: Matrix.cpp:783
int R
Definition: Matrix.h:105
T ** elt
Definition: Matrix.h:99
#define debugAssert(exp)
Definition: debugAssert.h:160
float T
Definition: Matrix.h:65
int C
Definition: Matrix.h:108

+ Here is the caller graph for this function:

Matrix::T G3D::Matrix::Impl::determinant ( int  r,
int  c 
) const
private

Determinant computed without the given row and column

801  {
802  debugAssert(R > 0);
803  debugAssert(C > 0);
804  Impl A(R - 1, C - 1);
805  withoutRowAndCol(nr, nc, A);
806  return A.determinant();
807 }
int R
Definition: Matrix.h:105
#define debugAssert(exp)
Definition: debugAssert.h:160
Impl()
Definition: Matrix.h:117
void withoutRowAndCol(int excludeRow, int excludeCol, Impl &out) const
Definition: Matrix.cpp:873
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

void G3D::Matrix::Impl::div ( T  B,
Impl out 
) const
private

Ok if out == this or out == B

+ Here is the caller graph for this function:

const T& G3D::Matrix::Impl::get ( int  r,
int  c 
) const
inlineprivate
142  {
143  debugAssert(r < R);
144  debugAssert(c < C);
145  return elt[r][c];
146  }
int R
Definition: Matrix.h:105
T ** elt
Definition: Matrix.h:99
#define debugAssert(exp)
Definition: debugAssert.h:160
int C
Definition: Matrix.h:108

+ Here is the caller graph for this function:

void G3D::Matrix::Impl::inverseInPlaceGaussJordan ( )
private

Use Gaussian elimination with pivots to solve for the inverse destructively in place.

1353  {
1354  debugAssertM(R == C,
1355  format(
1356  "Cannot perform Gauss-Jordan inverse on a non-square matrix."
1357  " (Argument was %dx%d)",
1358  R, C));
1359 
1360  // Exchange to float elements
1361 # define SWAP(x, y) {float temp = x; x = y; y = temp;}
1362 
1363  // The integer arrays pivot, rowIndex, and colIndex are
1364  // used for bookkeeping on the pivoting
1365  static Array<int> colIndex, rowIndex, pivot;
1366 
1367  int col = 0, row = 0;
1368 
1369  colIndex.resize(R);
1370  rowIndex.resize(R);
1371  pivot.resize(R);
1372 
1373  static const int NO_PIVOT = -1;
1374 
1375  // Initialize the pivot array to default values.
1376  for (int i = 0; i < R; ++i) {
1377  pivot[i] = NO_PIVOT;
1378  }
1379 
1380  // This is the main loop over the columns to be reduced
1381  // Loop over the columns.
1382  for (int c = 0; c < R; ++c) {
1383 
1384  // Find the largest element and use that as a pivot
1385  float largestMagnitude = 0.0;
1386 
1387  // This is the outer loop of the search for a pivot element
1388  for (int r = 0; r < R; ++r) {
1389 
1390  // Unless we've already found the pivot, keep going
1391  if (pivot[r] != 0) {
1392 
1393  // Find the largest pivot
1394  for (int k = 0; k < R; ++k) {
1395  if (pivot[k] == NO_PIVOT) {
1396  const float mag = fabs(elt[r][k]);
1397 
1398  if (mag >= largestMagnitude) {
1399  largestMagnitude = mag;
1400  row = r; col = k;
1401  }
1402  }
1403  }
1404  }
1405  }
1406 
1407  pivot[col] += 1;
1408 
1409  // Interchange columns so that the pivot element is on the diagonal (we'll have to undo this
1410  // at the end)
1411  if (row != col) {
1412  for (int k = 0; k < R; ++k) {
1413  SWAP(elt[row][k], elt[col][k])
1414  }
1415  }
1416 
1417  // The pivot is now at [row, col]
1418  rowIndex[c] = row;
1419  colIndex[c] = col;
1420 
1421  double piv = elt[col][col];
1422 
1423  debugAssertM(piv != 0.0, "Matrix is singular");
1424 
1425  // Divide everything by the pivot (avoid computing the division
1426  // multiple times).
1427  const double pivotInverse = 1.0 / piv;
1428  elt[col][col] = 1.0;
1429 
1430  for (int k = 0; k < R; ++k) {
1431  elt[col][k] *= Matrix::T(pivotInverse);
1432  }
1433 
1434  // Reduce all rows
1435  for (int r = 0; r < R; ++r) {
1436  // Skip over the pivot row
1437  if (r != col) {
1438 
1439  double oldValue = elt[r][col];
1440  elt[r][col] = 0.0;
1441 
1442  for (int k = 0; k < R; ++k) {
1443  elt[r][k] -= Matrix::T(elt[col][k] * oldValue);
1444  }
1445  }
1446  }
1447  }
1448 
1449 
1450  // Put the columns back in the correct locations
1451  for (int i = R - 1; i >= 0; --i) {
1452  if (rowIndex[i] != colIndex[i]) {
1453  for (int k = 0; k < R; ++k) {
1454  SWAP(elt[k][rowIndex[i]], elt[k][colIndex[i]]);
1455  }
1456  }
1457  }
1458 
1459 # undef SWAP
1460 }
Matrix col(int c) const
Definition: Matrix.cpp:217
#define SWAP(x, y)
#define debugAssertM(exp, message)
Definition: debugAssert.h:161
int R
Definition: Matrix.h:105
T ** elt
Definition: Matrix.h:99
Matrix row(int r) const
Definition: Matrix.cpp:208
std::string __cdecl format(const char *fmt...) G3D_CHECK_PRINTF_ARGS
float T
Definition: Matrix.h:65
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void G3D::Matrix::Impl::inverseViaAdjoint ( Impl out) const
private

Slow way of computing an inverse; for reference

734  {
735  debugAssert(&out != this);
736 
737  // Inverse = adjoint / determinant
738 
739  adjoint(out);
740 
741  // Don't call the determinant method when we already have an
742  // adjoint matrix; there's a faster way of computing it: the dot
743  // product of the first row and the adjoint's first col.
744  double det = 0.0;
745  for (int r = R - 1; r >= 0; --r) {
746  det += elt[0][r] * out.elt[r][0];
747  }
748 
749  out.div(Matrix::T(det), out);
750 }
void adjoint(Impl &out) const
Definition: Matrix.cpp:776
int R
Definition: Matrix.h:105
T ** elt
Definition: Matrix.h:99
#define debugAssert(exp)
Definition: debugAssert.h:160
float T
Definition: Matrix.h:65

+ Here is the call graph for this function:

void G3D::Matrix::Impl::lsub ( Matrix::T  B,
Impl out 
) const
private

B - this

722  {
723  const Impl& A = *this;
724 
725  debugAssert(A.C == out.C);
726  debugAssert(A.R == out.R);
727 
728  for (int i = R * C - 1; i >= 0; --i) {
729  out.data[i] = B - A.data[i];
730  }
731 }
int R
Definition: Matrix.h:105
#define debugAssert(exp)
Definition: debugAssert.h:160
Impl()
Definition: Matrix.h:117
int C
Definition: Matrix.h:108
void G3D::Matrix::Impl::mul ( const Impl B,
Impl out 
) const
private

Multiplies this by B and puts the result in out.

632  {
633  const Impl& A = *this;
634 
635  debugAssertM(
636  (this != &out) && (&B != &out),
637  "Output argument to mul cannot be the same as an input argument.");
638 
639  debugAssert(A.C == B.R);
640  debugAssert(A.R == out.R);
641  debugAssert(B.C == out.C);
642 
643  for (int r = 0; r < out.R; ++r) {
644  for (int c = 0; c < out.C; ++c) {
645  T sum = 0.0;
646  for (int i = 0; i < A.C; ++i) {
647  sum += A.get(r, i) * B.get(i, c);
648  }
649  out.set(r, c, sum);
650  }
651  }
652 }
#define debugAssertM(exp, message)
Definition: debugAssert.h:161
#define debugAssert(exp)
Definition: debugAssert.h:160
Impl()
Definition: Matrix.h:117
float T
Definition: Matrix.h:65

+ Here is the call graph for this function:

void G3D::Matrix::Impl::mul ( T  B,
Impl out 
) const
private

Ok if out == this or out == B

void G3D::Matrix::Impl::mulRow ( int  r,
const T v 
)
private
623  {
624  T* row = elt[r];
625 
626  for (int c = 0; c < C; ++c) {
627  row[c] *= v;
628  }
629 }
T ** elt
Definition: Matrix.h:99
Matrix row(int r) const
Definition: Matrix.cpp:208
float T
Definition: Matrix.h:65
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

void G3D::Matrix::Impl::negate ( Impl out) const
private
static void G3D::Matrix::Impl::operator delete ( void *  p)
inlinestatic
89  {
90  System::free(p);
91  }
static void free(void *p)
Definition: System.cpp:1473

+ Here is the call graph for this function:

static void* G3D::Matrix::Impl::operator new ( size_t  size)
inlinestatic
85  {
86  return System::malloc(size);
87  }
static void * malloc(size_t bytes)
Definition: System.cpp:1441
Vector2int16 size() const
Definition: Matrix.h:550

+ Here is the call graph for this function:

Matrix::Impl & G3D::Matrix::Impl::operator= ( const Impl m)
private
587  {
588  setSize(m.R, m.C);
589  System::memcpy(data, m.data, R * C * sizeof(T));
591  return *this;
592 }
static void memcpy(void *dst, const void *src, size_t numBytes)
Definition: System.cpp:643
int R
Definition: Matrix.h:105
T * data
Definition: Matrix.h:102
void setSize(int newRows, int newCols)
Definition: Matrix.cpp:550
static int debugNumCopyOps
Definition: Matrix.h:69
float T
Definition: Matrix.h:65
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

void G3D::Matrix::Impl::set ( int  r,
int  c,
T  v 
)
inlineprivate
136  {
137  debugAssert(r < R);
138  debugAssert(c < C);
139  elt[r][c] = v;
140  }
int R
Definition: Matrix.h:105
T ** elt
Definition: Matrix.h:99
#define debugAssert(exp)
Definition: debugAssert.h:160
int C
Definition: Matrix.h:108

+ Here is the caller graph for this function:

void G3D::Matrix::Impl::setCol ( int  c,
const T vals 
)
private
816  {
817  for (int r = 0; r < R; ++r) {
818  elt[r][c] = vals[r];
819  }
820 }
int R
Definition: Matrix.h:105
T ** elt
Definition: Matrix.h:99
void G3D::Matrix::Impl::setRow ( int  r,
const T vals 
)
private
810  {
811  debugAssert(r >= 0);
812  System::memcpy(elt[r], vals, sizeof(T) * C);
813 }
static void memcpy(void *dst, const void *src, size_t numBytes)
Definition: System.cpp:643
T ** elt
Definition: Matrix.h:99
#define debugAssert(exp)
Definition: debugAssert.h:160
float T
Definition: Matrix.h:65
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

void G3D::Matrix::Impl::setSize ( int  newRows,
int  newCols 
)
private

If R*C is much larger or smaller than the current, deletes all previous data and resets to random data. Otherwise re-uses existing memory and just resets R, C, and the row pointers.

550  {
551  if ((R == newRows) && (C == newCols)) {
552  // Nothing to do
553  return;
554  }
555 
556  int newSize = newRows * newCols;
557 
558  R = newRows; C = newCols;
559 
560  // Only allocate if we need more space
561  // or the size difference is ridiculous
562  if ((newSize > dataSize) || (newSize < dataSize / 4)) {
564  data = (float*)System::alignedMalloc(R * C * sizeof(T), 16);
566  dataSize = newSize;
567  }
568 
569  // Construct the row pointers
570  //delete[] elt;
571  System::free(elt);
572  elt = (T**)System::malloc(R * sizeof(T*));// new T*[R];
573 
574  for (int r = 0; r < R; ++ r) {
575  elt[r] = data + r * C;
576  }
577 }
int dataSize
Definition: Matrix.h:110
static void alignedFree(void *ptr)
Definition: System.cpp:1546
int R
Definition: Matrix.h:105
T * data
Definition: Matrix.h:102
static void * malloc(size_t bytes)
Definition: System.cpp:1441
T ** elt
Definition: Matrix.h:99
static void * alignedMalloc(size_t bytes, size_t alignment)
Definition: System.cpp:1482
static void free(void *p)
Definition: System.cpp:1473
static int debugNumAllocOps
Definition: Matrix.h:73
float T
Definition: Matrix.h:65
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void G3D::Matrix::Impl::setZero ( )
private
595  {
596  System::memset(data, 0, R * C * sizeof(T));
597 }
static void memset(void *dst, uint8 value, size_t numBytes)
Definition: System.cpp:695
int R
Definition: Matrix.h:105
T * data
Definition: Matrix.h:102
float T
Definition: Matrix.h:65
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void G3D::Matrix::Impl::sub ( const Impl B,
Impl out 
) const
private

Ok if out == this or out == B

void G3D::Matrix::Impl::sub ( T  B,
Impl out 
) const
private

Ok if out == this or out == B

void G3D::Matrix::Impl::swapAndNegateCols ( int  c0,
int  c1 
)
private
612  {
613  for (int r = 0; r < R; ++r) {
614  T* row = elt[r];
615 
616  const T temp = -row[c0];
617  row[c0] = -row[c1];
618  row[c1] = temp;
619  }
620 }
int R
Definition: Matrix.h:105
T ** elt
Definition: Matrix.h:99
Matrix row(int r) const
Definition: Matrix.cpp:208
float T
Definition: Matrix.h:65

+ Here is the call graph for this function:

void G3D::Matrix::Impl::swapRows ( int  r0,
int  r1 
)
private
600  {
601  T* R0 = elt[r0];
602  T* R1 = elt[r1];
603 
604  for (int c = 0; c < C; ++c) {
605  T temp = R0[c];
606  R0[c] = R1[c];
607  R1[c] = temp;
608  }
609 }
T ** elt
Definition: Matrix.h:99
float T
Definition: Matrix.h:65
int C
Definition: Matrix.h:108
void G3D::Matrix::Impl::transpose ( Impl out) const
private

Ok if out == this or out == B

753  {
754  debugAssert(out.R == C);
755  debugAssert(out.C == R);
756 
757  if (&out == this) {
758  // Square matrix in place
759  for (int r = 0; r < R; ++r) {
760  for (int c = r + 1; c < C; ++c) {
761  T temp = get(r, c);
762  out.set(r, c, get(c, r));
763  out.set(c, r, temp);
764  }
765  }
766  } else {
767  for (int r = 0; r < R; ++r) {
768  for (int c = 0; c < C; ++c) {
769  out.set(c, r, get(r, c));
770  }
771  }
772  }
773 }
int R
Definition: Matrix.h:105
#define debugAssert(exp)
Definition: debugAssert.h:160
float T
Definition: Matrix.h:65
int C
Definition: Matrix.h:108

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void G3D::Matrix::Impl::withoutRowAndCol ( int  excludeRow,
int  excludeCol,
Impl out 
) const
private

Makes a (R-1)x(C-1) copy of this matrix

873  {
874  debugAssert(out.R == R - 1);
875  debugAssert(out.C == C - 1);
876 
877  for (int r = 0; r < out.R; ++r) {
878  for (int c = 0; c < out.C; ++c) {
879  out.elt[r][c] = elt[r + ((r >= excludeRow) ? 1 : 0)][c + ((c >= excludeCol) ? 1 : 0)];
880  }
881  }
882 }
int R
Definition: Matrix.h:105
T ** elt
Definition: Matrix.h:99
#define debugAssert(exp)
Definition: debugAssert.h:160
int C
Definition: Matrix.h:108

Friends And Related Function Documentation

friend class Matrix
friend

Member Data Documentation

int G3D::Matrix::Impl::C
private

The number of columns

T* G3D::Matrix::Impl::data
private

Row major data for the entire matrix.

int G3D::Matrix::Impl::dataSize
private
T** G3D::Matrix::Impl::elt
private

elt[r][c] = the element. Pointers into data.

int G3D::Matrix::Impl::R
private

The number of rows


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