Matrix Inverse#
Synopsis#
This will compute and display an NxN matrix and its inverse.
Results#
Output:
M: 1 2
3 5
Inverse: -5 2
3 -1
Code#
C++#
#include <itkMatrix.h>
#include <iostream>
int
main()
{
using MatrixType = itk::Matrix<double, 2, 2>;
MatrixType M;
M(0, 0) = 1.0;
M(0, 1) = 2.0;
M(1, 0) = 3.0;
M(1, 1) = 5.0;
std::cout << "M: " << M << std::endl;
MatrixType Minv(M.GetInverse());
std::cout << "Inverse: " << Minv << std::endl;
return EXIT_SUCCESS;
}
Classes demonstrated#
-
template<typename T, unsigned int NRows = 3, unsigned int NColumns = 3>
class Matrix A templated class holding a M x N size Matrix.
This class contains a vnl_matrix_fixed in order to make all the vnl mathematical methods available.
- ITK Sphinx Examples: