VTK-m  2.1
Matrix.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_Matrix_h
11 #define vtk_m_Matrix_h
12 
13 #include <vtkm/Assert.h>
14 #include <vtkm/Math.h>
15 #include <vtkm/TypeTraits.h>
16 #include <vtkm/Types.h>
17 #include <vtkm/VecTraits.h>
18 
19 namespace vtkm
20 {
21 
32 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
33 class Matrix
34 {
35 public:
36  using ComponentType = T;
37  static constexpr vtkm::IdComponent NUM_ROWS = NumRow;
38  static constexpr vtkm::IdComponent NUM_COLUMNS = NumCol;
39 
42  Matrix() {}
43 
46  explicit Matrix(const ComponentType& value)
48  {
49  }
50 
56  {
57  VTKM_ASSERT(rowIndex >= 0);
58  VTKM_ASSERT(rowIndex < NUM_ROWS);
59  return this->Components[rowIndex];
60  }
61 
67  {
68  VTKM_ASSERT(rowIndex >= 0);
69  VTKM_ASSERT(rowIndex < NUM_ROWS);
70  return this->Components[rowIndex];
71  }
72 
78  {
79  VTKM_ASSERT(rowIndex >= 0);
80  VTKM_ASSERT(rowIndex < NUM_ROWS);
81  VTKM_ASSERT(colIndex >= 0);
82  VTKM_ASSERT(colIndex < NUM_COLUMNS);
83  return (*this)[rowIndex][colIndex];
84  }
85 
91  {
92  VTKM_ASSERT(rowIndex >= 0);
93  VTKM_ASSERT(rowIndex < NUM_ROWS);
94  VTKM_ASSERT(colIndex >= 0);
95  VTKM_ASSERT(colIndex < NUM_COLUMNS);
96  return (*this)[rowIndex][colIndex];
97  }
98 
99 private:
101 };
102 
106 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
108  const vtkm::Matrix<T, NumRow, NumCol>& matrix,
109  vtkm::IdComponent rowIndex)
110 {
111  return matrix[rowIndex];
112 }
113 
117 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
119  vtkm::IdComponent columnIndex)
120 {
121  vtkm::Vec<T, NumRow> columnValues;
122  for (vtkm::IdComponent rowIndex = 0; rowIndex < NumRow; rowIndex++)
123  {
124  columnValues[rowIndex] = matrix(rowIndex, columnIndex);
125  }
126  return columnValues;
127 }
128 
131 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
133  vtkm::IdComponent rowIndex,
134  const vtkm::Vec<T, NumCol>& rowValues)
135 {
136  matrix[rowIndex] = rowValues;
137 }
138 
141 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
143  vtkm::IdComponent columnIndex,
144  const vtkm::Vec<T, NumRow>& columnValues)
145 {
146  for (vtkm::IdComponent rowIndex = 0; rowIndex < NumRow; rowIndex++)
147  {
148  matrix(rowIndex, columnIndex) = columnValues[rowIndex];
149  }
150 }
151 
154 template <typename T,
155  vtkm::IdComponent NumRow,
156  vtkm::IdComponent NumCol,
157  vtkm::IdComponent NumInternal>
159  const vtkm::Matrix<T, NumRow, NumInternal>& leftFactor,
160  const vtkm::Matrix<T, NumInternal, NumCol>& rightFactor)
161 {
163  for (vtkm::IdComponent rowIndex = 0; rowIndex < NumRow; rowIndex++)
164  {
165  for (vtkm::IdComponent colIndex = 0; colIndex < NumCol; colIndex++)
166  {
167  T sum = T(leftFactor(rowIndex, 0) * rightFactor(0, colIndex));
168  for (vtkm::IdComponent internalIndex = 1; internalIndex < NumInternal; internalIndex++)
169  {
170  sum = T(sum + (leftFactor(rowIndex, internalIndex) * rightFactor(internalIndex, colIndex)));
171  }
172  result(rowIndex, colIndex) = sum;
173  }
174  }
175  return result;
176 }
177 
180 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
182  const vtkm::Matrix<T, NumRow, NumCol>& leftFactor,
183  const vtkm::Vec<T, NumCol>& rightFactor)
184 {
185  vtkm::Vec<T, NumRow> product;
186  for (vtkm::IdComponent rowIndex = 0; rowIndex < NumRow; rowIndex++)
187  {
188  product[rowIndex] = vtkm::Dot(vtkm::MatrixGetRow(leftFactor, rowIndex), rightFactor);
189  }
190  return product;
191 }
192 
195 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
197  const vtkm::Vec<T, NumRow>& leftFactor,
198  const vtkm::Matrix<T, NumRow, NumCol>& rightFactor)
199 {
200  vtkm::Vec<T, NumCol> product;
201  for (vtkm::IdComponent colIndex = 0; colIndex < NumCol; colIndex++)
202  {
203  product[colIndex] = vtkm::Dot(leftFactor, vtkm::MatrixGetColumn(rightFactor, colIndex));
204  }
205  return product;
206 }
207 
210 template <typename T, vtkm::IdComponent Size>
212 {
213  vtkm::Matrix<T, Size, Size> result(T(0));
214  for (vtkm::IdComponent index = 0; index < Size; index++)
215  {
216  result(index, index) = T(1.0);
217  }
218  return result;
219 }
220 
223 template <typename T, vtkm::IdComponent Size>
225 {
226  matrix = vtkm::MatrixIdentity<T, Size>();
227 }
228 
231 template <typename T, vtkm::IdComponent NumRows, vtkm::IdComponent NumCols>
233  const vtkm::Matrix<T, NumRows, NumCols>& matrix)
234 {
236  for (vtkm::IdComponent index = 0; index < NumRows; index++)
237  {
238  vtkm::MatrixSetColumn(result, index, vtkm::MatrixGetRow(matrix, index));
239 #ifdef VTKM_ICC
240  // For reasons I do not really understand, the Intel compiler with with
241  // optimization on is sometimes removing this for loop. It appears that the
242  // optimizer sometimes does not recognize that the MatrixSetColumn function
243  // has side effects. I cannot fathom any reason for this other than a bug in
244  // the compiler, but unfortunately I do not know a reliable way to
245  // demonstrate the problem.
246  __asm__("");
247 #endif
248  }
249  return result;
250 }
251 
252 namespace detail
253 {
254 
255 // Used with MatrixLUPFactor.
256 template <typename T, vtkm::IdComponent Size>
257 VTKM_EXEC_CONT void MatrixLUPFactorFindPivot(vtkm::Matrix<T, Size, Size>& A,
259  vtkm::IdComponent topCornerIndex,
260  T& inversionParity,
261  bool& valid)
262 {
263  vtkm::IdComponent maxRowIndex = topCornerIndex;
264  T maxValue = vtkm::Abs(A(maxRowIndex, topCornerIndex));
265  for (vtkm::IdComponent rowIndex = topCornerIndex + 1; rowIndex < Size; rowIndex++)
266  {
267  T compareValue = vtkm::Abs(A(rowIndex, topCornerIndex));
268  if (maxValue < compareValue)
269  {
270  maxValue = compareValue;
271  maxRowIndex = rowIndex;
272  }
273  }
274 
275  if (maxValue < vtkm::Epsilon<T>())
276  {
277  valid = false;
278  return;
279  }
280 
281  if (maxRowIndex != topCornerIndex)
282  {
283  // Swap rows in matrix.
284  vtkm::Vec<T, Size> maxRow = vtkm::MatrixGetRow(A, maxRowIndex);
285  vtkm::MatrixSetRow(A, maxRowIndex, vtkm::MatrixGetRow(A, topCornerIndex));
286  vtkm::MatrixSetRow(A, topCornerIndex, maxRow);
287 
288  // Record change in permutation matrix.
289  vtkm::IdComponent maxOriginalRowIndex = permutation[maxRowIndex];
290  permutation[maxRowIndex] = permutation[topCornerIndex];
291  permutation[topCornerIndex] = maxOriginalRowIndex;
292 
293  // Keep track of inversion parity.
294  inversionParity = -inversionParity;
295  }
296 }
297 
298 // Used with MatrixLUPFactor
299 template <typename T, vtkm::IdComponent Size>
300 VTKM_EXEC_CONT void MatrixLUPFactorFindUpperTriangleElements(vtkm::Matrix<T, Size, Size>& A,
301  vtkm::IdComponent topCornerIndex,
302  bool& valid)
303 {
304  // Compute values for upper triangle on row topCornerIndex
305  if (A(topCornerIndex, topCornerIndex) == 0)
306  {
307  valid = false;
308  return;
309  }
310  else
311  {
312  // Let's make the reciprocal approximation here.
313  // Doesn't make things much fast for small 'Size',
314  // but definitely improves performance as 'Size' gets large.
315  T rAdiag = 1 / A(topCornerIndex, topCornerIndex);
316  for (vtkm::IdComponent colIndex = topCornerIndex + 1; colIndex < Size; colIndex++)
317  {
318  A(topCornerIndex, colIndex) *= rAdiag;
319  }
320  }
321 
322  // Update the rest of the matrix for calculations on subsequent rows
323  for (vtkm::IdComponent rowIndex = topCornerIndex + 1; rowIndex < Size; rowIndex++)
324  {
325  for (vtkm::IdComponent colIndex = topCornerIndex + 1; colIndex < Size; colIndex++)
326  {
327  A(rowIndex, colIndex) -= A(rowIndex, topCornerIndex) * A(topCornerIndex, colIndex);
328  }
329  }
330 }
331 
362 template <typename T, vtkm::IdComponent Size>
363 VTKM_EXEC_CONT void MatrixLUPFactor(vtkm::Matrix<T, Size, Size>& A,
365  T& inversionParity,
366  bool& valid)
367 {
368  // Initialize permutation.
369  for (vtkm::IdComponent index = 0; index < Size; index++)
370  {
371  permutation[index] = index;
372  }
373  inversionParity = T(1);
374  valid = true;
375 
376  for (vtkm::IdComponent rowIndex = 0; rowIndex < Size; rowIndex++)
377  {
378  MatrixLUPFactorFindPivot(A, permutation, rowIndex, inversionParity, valid);
379  if (!valid)
380  {
381  break;
382  }
383  MatrixLUPFactorFindUpperTriangleElements(A, rowIndex, valid);
384  if (!valid)
385  {
386  break;
387  }
388  }
389 }
390 
395 template <typename T, vtkm::IdComponent Size>
396 VTKM_EXEC_CONT vtkm::Vec<T, Size> MatrixLUPSolve(
397  const vtkm::Matrix<T, Size, Size>& LU,
398  const vtkm::Vec<vtkm::IdComponent, Size>& permutation,
399  const vtkm::Vec<T, Size>& b)
400 {
401  // The LUP-factorization gives us PA = LU or equivalently A = inv(P)LU.
402  // Substituting into Ax = b gives us inv(P)LUx = b or LUx = Pb.
403  // Now consider the intermediate vector y = Ux.
404  // Substituting in the previous two equations yields Ly = Pb.
405  // Solving Ly = Pb is easy because L is triangular and P is just a
406  // permutation.
408  for (vtkm::IdComponent rowIndex = 0; rowIndex < Size; rowIndex++)
409  {
410  y[rowIndex] = b[permutation[rowIndex]];
411  // Recall that L is stored in the lower triangle of LU including diagonal.
412  for (vtkm::IdComponent colIndex = 0; colIndex < rowIndex; colIndex++)
413  {
414  y[rowIndex] -= LU(rowIndex, colIndex) * y[colIndex];
415  }
416  if (LU(rowIndex, rowIndex) == 0)
417  {
418  y[rowIndex] = std::numeric_limits<T>::quiet_NaN();
419  }
420  else
421  {
422  y[rowIndex] /= LU(rowIndex, rowIndex);
423  }
424  }
425 
426  // Now that we have y, we can easily solve Ux = y for x.
428  for (vtkm::IdComponent rowIndex = Size - 1; rowIndex >= 0; rowIndex--)
429  {
430  // Recall that U is stored in the upper triangle of LU with the diagonal
431  // implicitly all 1's.
432  x[rowIndex] = y[rowIndex];
433  for (vtkm::IdComponent colIndex = rowIndex + 1; colIndex < Size; colIndex++)
434  {
435  x[rowIndex] -= LU(rowIndex, colIndex) * x[colIndex];
436  }
437  }
438 
439  return x;
440 }
441 
442 } // namespace detail
443 
447 template <typename T, vtkm::IdComponent Size>
449  const vtkm::Vec<T, Size>& b,
450  bool& valid)
451 {
452  // First, we will make an LUP-factorization to help us.
455  T inversionParity; // Unused.
456  detail::MatrixLUPFactor(LU, permutation, inversionParity, valid);
457 
458  // Next, use the decomposition to solve the system.
459  return detail::MatrixLUPSolve(LU, permutation, b);
460 }
461 
465 template <typename T, vtkm::IdComponent Size>
467  bool& valid)
468 {
469  // First, we will make an LUP-factorization to help us.
472  T inversionParity; // Unused
473  detail::MatrixLUPFactor(LU, permutation, inversionParity, valid);
474 
475  // We will use the decomposition to solve AX = I for X where X is
476  // clearly the inverse of A. Our solve method only works for vectors,
477  // so we solve for one column of invA at a time.
479  vtkm::Vec<T, Size> ICol(T(0));
480  for (vtkm::IdComponent colIndex = 0; colIndex < Size; colIndex++)
481  {
482  ICol[colIndex] = 1;
483  vtkm::Vec<T, Size> invACol = detail::MatrixLUPSolve(LU, permutation, ICol);
484  ICol[colIndex] = 0;
485  vtkm::MatrixSetColumn(invA, colIndex, invACol);
486  }
487  return invA;
488 }
489 
492 template <typename T, vtkm::IdComponent Size>
494 {
495  // First, we will make an LUP-factorization to help us.
498  T inversionParity;
499  bool valid;
500  detail::MatrixLUPFactor(LU, permutation, inversionParity, valid);
501 
502  // If the matrix is singular, the factorization is invalid, but in that
503  // case we know that the determinant is 0.
504  if (!valid)
505  {
506  return 0;
507  }
508 
509  // The determinant is equal to the product of the diagonal of the L matrix,
510  // possibly negated depending on the parity of the inversion. The
511  // inversionParity variable is set to 1.0 and -1.0 for even and odd parity,
512  // respectively. This sign determines whether the product should be negated.
513  T product = inversionParity;
514  for (vtkm::IdComponent index = 0; index < Size; index++)
515  {
516  product *= LU(index, index);
517  }
518  return product;
519 }
520 
521 // Specializations for common small determinants.
522 
523 template <typename T>
525 {
526  return A(0, 0);
527 }
528 
529 template <typename T>
531 {
532  return vtkm::DifferenceOfProducts(A(0, 0), A(1, 1), A(1, 0), A(0, 1));
533 }
534 
535 template <typename T>
537 {
538  return A(0, 0) * A(1, 1) * A(2, 2) + A(1, 0) * A(2, 1) * A(0, 2) + A(2, 0) * A(0, 1) * A(1, 2) -
539  A(0, 0) * A(2, 1) * A(1, 2) - A(1, 0) * A(0, 1) * A(2, 2) - A(2, 0) * A(1, 1) * A(0, 2);
540 }
541 
542 //---------------------------------------------------------------------------
543 // Implementations of traits for matrices.
544 
549 {
550 };
551 
552 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
553 struct TypeTraits<vtkm::Matrix<T, NumRow, NumCol>>
554 {
557 
560  {
562  }
563 };
564 
567 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
568 struct VecTraits<vtkm::Matrix<T, NumRow, NumCol>>
569 {
570 private:
572 
573 public:
574  using ComponentType = T;
576  static constexpr vtkm::IdComponent NUM_COMPONENTS = NumRow * NumCol;
579 
582 
584  static const ComponentType& GetComponent(const MatrixType& matrix, vtkm::IdComponent component)
585  {
586  vtkm::IdComponent colIndex = component % NumCol;
587  vtkm::IdComponent rowIndex = component / NumCol;
588  return matrix(rowIndex, colIndex);
589  }
592  {
593  vtkm::IdComponent colIndex = component % NumCol;
594  vtkm::IdComponent rowIndex = component / NumCol;
595  return matrix(rowIndex, colIndex);
596  }
598  static void SetComponent(MatrixType& matrix, vtkm::IdComponent component, T value)
599  {
600  GetComponent(matrix, component) = value;
601  }
602 
603  template <typename NewComponentType>
605 
606  template <typename NewComponentType>
609  NumRow,
610  NumCol>;
611 };
612 
613 //---------------------------------------------------------------------------
614 // Basic comparison operators.
615 
616 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
619 {
620  for (vtkm::IdComponent colIndex = 0; colIndex < NumCol; colIndex++)
621  {
622  for (vtkm::IdComponent rowIndex = 0; rowIndex < NumRow; rowIndex++)
623  {
624  if (a(rowIndex, colIndex) != b(rowIndex, colIndex))
625  return false;
626  }
627  }
628  return true;
629 }
630 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
633 {
634  return !(a == b);
635 }
636 
639 template <typename T, vtkm::IdComponent NumRow, vtkm::IdComponent NumCol>
640 VTKM_CONT std::ostream& operator<<(std::ostream& stream, const vtkm::Matrix<T, NumRow, NumCol>& mat)
641 {
642  stream << std::endl;
643  for (vtkm::IdComponent row = 0; row < NumRow; ++row)
644  {
645  stream << "| ";
646  for (vtkm::IdComponent col = 0; col < NumCol; ++col)
647  {
648  stream << mat(row, col) << "\t";
649  }
650  stream << "|" << std::endl;
651  }
652  return stream;
653 }
654 } // namespace vtkm
655 
656 #endif //vtk_m_Matrix_h
vtkm::operator!=
bool operator!=(const vtkm::Matrix< T, NumRow, NumCol > &a, const vtkm::Matrix< T, NumRow, NumCol > &b)
Definition: Matrix.h:631
vtkm::Matrix::operator[]
vtkm::Vec< ComponentType, NUM_COLUMNS > & operator[](vtkm::IdComponent rowIndex)
Brackets are used to referens a matrix like a 2D array i.e.
Definition: Matrix.h:66
vtkm::MatrixTranspose
vtkm::Matrix< T, NumCols, NumRows > MatrixTranspose(const vtkm::Matrix< T, NumRows, NumCols > &matrix)
Returns the transpose of the given matrix.
Definition: Matrix.h:232
vtkm::VecTraitsTagMultipleComponents
A tag for vectors that are "true" vectors (i.e.
Definition: VecTraits.h:23
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::MatrixGetRow
const vtkm::Vec< T, NumCol > & MatrixGetRow(const vtkm::Matrix< T, NumRow, NumCol > &matrix, vtkm::IdComponent rowIndex)
Returns a tuple containing the given row (indexed from 0) of the given matrix.
Definition: Matrix.h:107
vtkm::TypeTraits
The TypeTraits class provides helpful compile-time information about the basic types used in VTKm (an...
Definition: TypeTraits.h:61
Types.h
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::TypeTraits< vtkm::Matrix< T, NumRow, NumCol > >::NumericTag
typename TypeTraits< T >::NumericTag NumericTag
Definition: Matrix.h:555
vtkm::VecTraits::NUM_COMPONENTS
static constexpr vtkm::IdComponent NUM_COMPONENTS
Number of components in the vector.
Definition: VecTraits.h:85
vtkm::operator<<
std::ostream & operator<<(std::ostream &stream, const vtkm::Bounds &bounds)
Helper function for printing bounds during testing.
Definition: Bounds.h:248
vtkm::Matrix::NUM_COLUMNS
static constexpr vtkm::IdComponent NUM_COLUMNS
Definition: Matrix.h:38
vtkm::VecTraits< vtkm::Matrix< T, NumRow, NumCol > >::BaseComponentType
typename vtkm::VecTraits< T >::BaseComponentType BaseComponentType
Definition: Matrix.h:575
vtkm::Matrix::operator[]
const vtkm::Vec< ComponentType, NUM_COLUMNS > & operator[](vtkm::IdComponent rowIndex) const
Brackets are used to reference a matrix like a 2D array (i.e.
Definition: Matrix.h:55
Assert.h
vtkm::VecTraits< vtkm::Matrix< T, NumRow, NumCol > >::SetComponent
static void SetComponent(MatrixType &matrix, vtkm::IdComponent component, T value)
Definition: Matrix.h:598
vtkm::DifferenceOfProducts
T DifferenceOfProducts(T a, T b, T c, T d)
Definition: Math.h:2778
vtkm::MatrixGetColumn
vtkm::Vec< T, NumRow > MatrixGetColumn(const vtkm::Matrix< T, NumRow, NumCol > &matrix, vtkm::IdComponent columnIndex)
Returns a tuple containing the given column (indexed from 0) of the given matrix.
Definition: Matrix.h:118
vtkm::VecTraits::BaseComponentType
T BaseComponentType
Base component type in the vector.
Definition: VecTraits.h:78
vtkm::operator==
bool operator==(const vtkm::Matrix< T, NumRow, NumCol > &a, const vtkm::Matrix< T, NumRow, NumCol > &b)
Definition: Matrix.h:617
vtkm::MatrixIdentity
vtkm::Matrix< T, Size, Size > MatrixIdentity()
Returns the identity matrix.
Definition: Matrix.h:211
TypeTraits.h
vtkm::Matrix< vtkm::Float32, 4, 4 >::ComponentType
vtkm::Float32 ComponentType
Definition: Matrix.h:36
vtkm::Matrix::Matrix
Matrix()
Creates an uninitialized matrix. The values in the matrix are not determined.
Definition: Matrix.h:42
vtkm::VecTraits< vtkm::Matrix< T, NumRow, NumCol > >::ComponentType
T ComponentType
Definition: Matrix.h:574
Math.h
vtkm::TypeTraitsMatrixTag
Tag used to identify 2 dimensional types (matrices).
Definition: Matrix.h:548
vtkm::MatrixSetRow
void MatrixSetRow(vtkm::Matrix< T, NumRow, NumCol > &matrix, vtkm::IdComponent rowIndex, const vtkm::Vec< T, NumCol > &rowValues)
Convenience function for setting a row of a matrix.
Definition: Matrix.h:132
vtkm::Matrix::NUM_ROWS
static constexpr vtkm::IdComponent NUM_ROWS
Definition: Matrix.h:37
vtkm::SolveLinearSystem
vtkm::Vec< T, Size > SolveLinearSystem(const vtkm::Matrix< T, Size, Size > &A, const vtkm::Vec< T, Size > &b, bool &valid)
Solve the linear system Ax = b for x.
Definition: Matrix.h:448
vtkm::VecTraits< vtkm::Matrix< T, NumRow, NumCol > >::GetNumberOfComponents
static vtkm::IdComponent GetNumberOfComponents(const MatrixType &)
Definition: Matrix.h:581
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::MatrixMultiply
vtkm::Matrix< T, NumRow, NumCol > MatrixMultiply(const vtkm::Matrix< T, NumRow, NumInternal > &leftFactor, const vtkm::Matrix< T, NumInternal, NumCol > &rightFactor)
Standard matrix multiplication.
Definition: Matrix.h:158
vtkm::TypeTraitsUnknownTag
Tag used to identify types that aren't Real, Integer, Scalar or Vector.
Definition: TypeTraits.h:20
vtkm::TypeTraits< vtkm::Matrix< T, NumRow, NumCol > >::ZeroInitialization
static vtkm::Matrix< T, NumRow, NumCol > ZeroInitialization()
Definition: Matrix.h:559
vtkm::Vec
A short fixed-length array.
Definition: Types.h:357
vtkm::Matrix
Basic Matrix type.
Definition: Matrix.h:33
vtkm::VecTraits::GetComponent
static const ComponentType & GetComponent(const T &vector, vtkm::IdComponent)
Returns the value in a given component of the vector.
Definition: VecTraits.h:117
vtkm::VecTraitsTagSizeStatic
A tag for vectors where the number of components are known at compile time.
Definition: VecTraits.h:36
vtkm::MatrixSetColumn
void MatrixSetColumn(vtkm::Matrix< T, NumRow, NumCol > &matrix, vtkm::IdComponent columnIndex, const vtkm::Vec< T, NumRow > &columnValues)
Convenience function for setting a column of a matrix.
Definition: Matrix.h:142
vtkm::MatrixInverse
vtkm::Matrix< T, Size, Size > MatrixInverse(const vtkm::Matrix< T, Size, Size > &A, bool &valid)
Find and return the inverse of the given matrix.
Definition: Matrix.h:466
vtkm::VecTraits< vtkm::Matrix< T, NumRow, NumCol > >::GetComponent
static ComponentType & GetComponent(MatrixType &matrix, vtkm::IdComponent component)
Definition: Matrix.h:591
vtkm::VecTraits< vtkm::Matrix< T, NumRow, NumCol > >::GetComponent
static const ComponentType & GetComponent(const MatrixType &matrix, vtkm::IdComponent component)
Definition: Matrix.h:584
vtkm::Matrix::operator()
ComponentType & operator()(vtkm::IdComponent rowIndex, vtkm::IdComponent colIndex)
Parentheses are used to reference a matrix using mathematical tuple notation i.e.
Definition: Matrix.h:90
vtkm::VecTraits
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:61
vtkm::MatrixDeterminant
T MatrixDeterminant(const vtkm::Matrix< T, Size, Size > &A)
Compute the determinant of a matrix.
Definition: Matrix.h:493
vtkm::Matrix::operator()
const ComponentType & operator()(vtkm::IdComponent rowIndex, vtkm::IdComponent colIndex) const
Parentheses are used to reference a matrix using mathematical tuple notation i.e.
Definition: Matrix.h:77
vtkm::Matrix::Matrix
Matrix(const ComponentType &value)
Creates a matrix initialized with all values set to the provided value.
Definition: Matrix.h:46
VecTraits.h
vtkm::Matrix::Components
vtkm::Vec< vtkm::Vec< ComponentType, NUM_COLUMNS >, NUM_ROWS > Components
Definition: Matrix.h:100