[ITK] [ITK-users] Is this a bug ?
Cyril Mory
cyril.mory at creatis.insa-lyon.fr
Fri Nov 4 10:26:31 EDT 2016
Hello, ITK users,
I've encountered a behavior with vnl_matrix, and I'm wondering whether
it is a bug or a feature. The following code outputs differents results:
#include <iostream>
#include <vnl_vector.h>
#include <vnl_matrix.h>
int main()
{
vnl_matrix<double> matrix(2, 2);
matrix.put(0, 0, 4);
matrix.put(0, 1, 3);
matrix.put(1, 0, 2);
matrix.put(1, 1, 1);
// Display the matrix
std::cout << "Matrix" << std::endl;
std::cout << matrix << std::endl;
// Display the first row of the matrix,
vnl_vector<double> matrixRow;
matrixRow = matrix.get_row(0);
std::cout << "First row, stored in a vnl_vector" << std::endl;
std::cout << matrixRow << std::endl;
double* matrixRowData = matrix.get_row(0).data_block();
std::cout << "First row, stored in a double*" << std::endl;
std::cout << matrixRowData[0] << " " << matrixRowData[1] << std::endl;
double* matrixRowDataFromVector = matrixRow.data_block();
std::cout << "First row, stored in a double* after passing through a
vnl_vector" << std::endl;
std::cout << matrixRowDataFromVector[0] << " " <<
matrixRowDataFromVector[1] << std::endl;
return EXIT_SUCCESS;
}
Output :
Matrix
4 3
2 1
First row, stored in a vnl_vector
4 3
First row, stored in a double*
0 3
First row, stored in a double* after passing through a vnl_vector
4 3
It was compiled with the following CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(IsThisAvnlBug)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
add_executable(IsThisAvnlBug MACOSX_BUNDLE IsThisAvnlBug.cxx)
target_link_libraries(IsThisAvnlBug ${ITK_LIBRARIES})
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20161104/584d34de/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
More information about the Community
mailing list