ITK/Examples/Math/MatrixInverse: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
Daviddoria (talk | contribs) (Created page with "==MatrixInverse.cxx== <source lang="cpp"> #include <itkMatrix.h> #include <iostream> int main() { typedef itk::Matrix<double, 2, 2> MatrixType; MatrixType M; M(0,0) = 1.0...") |
No edit summary |
||
Line 24: | Line 24: | ||
</source> | </source> | ||
{{ | {{VTKCMakeLists|{{SUBPAGENAME}}}} |
Revision as of 17:06, 11 December 2012
MatrixInverse.cxx
<source lang="cpp">
- include <itkMatrix.h>
- 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.