ITK/Examples/Math/MatrixInverse

From KitwarePublic
< ITK‎ | Examples
Revision as of 17:06, 11 December 2012 by Lorensen (talk | contribs)
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

MatrixInverse.cxx

<source lang="cpp">

  1. include <itkMatrix.h>
  1. include <iostream>

int main() {

 typedef itk::Matrix<double, 2, 2> MatrixType;
 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;

}

</source>

Please try the new VTKExamples website.

CMakeLists.txt

<syntaxhighlight lang="cmake"> cmake_minimum_required(VERSION 2.8)

PROJECT(MatrixInverse)

find_package(VTK REQUIRED) include(${VTK_USE_FILE})

add_executable(MatrixInverse MACOSX_BUNDLE MatrixInverse.cxx)

if(VTK_LIBRARIES)

 target_link_libraries(MatrixInverse ${VTK_LIBRARIES})

else()

 target_link_libraries(MatrixInverse vtkHybrid vtkWidgets)

endif() </syntaxhighlight>

Download and Build MatrixInverse

Click here to download MatrixInverse. and its CMakeLists.txt file.

Once the tarball MatrixInverse.tar has been downloaded and extracted,

cd MatrixInverse/build 
  • If VTK is installed:
cmake ..
  • If VTK is not installed but compiled on your system, you will need to specify the path to your VTK build:
cmake -DVTK_DIR:PATH=/home/me/vtk_build ..

Build the project:

make

and run it:

./MatrixInverse

WINDOWS USERS PLEASE NOTE: Be sure to add the VTK bin directory to your path. This will resolve the VTK dll's at run time.