<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello, ITK users,<br>
<br>
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:<br>
<br>
#include <iostream><br>
#include <vnl_vector.h><br>
#include <vnl_matrix.h><br>
<br>
int main()<br>
{<br>
vnl_matrix<double> matrix(2, 2);<br>
matrix.put(0, 0, 4);<br>
matrix.put(0, 1, 3);<br>
matrix.put(1, 0, 2);<br>
matrix.put(1, 1, 1);<br>
<br>
// Display the matrix<br>
std::cout << "Matrix" << std::endl;<br>
std::cout << matrix << std::endl;<br>
<br>
// Display the first row of the matrix,<br>
vnl_vector<double> matrixRow;<br>
matrixRow = matrix.get_row(0);<br>
std::cout << "First row, stored in a vnl_vector" <<
std::endl;<br>
std::cout << matrixRow << std::endl;<br>
<br>
double* matrixRowData = matrix.get_row(0).data_block();<br>
std::cout << "First row, stored in a double*" <<
std::endl;<br>
std::cout << matrixRowData[0] << " " <<
matrixRowData[1] << std::endl;<br>
<br>
double* matrixRowDataFromVector = matrixRow.data_block();<br>
std::cout << "First row, stored in a double* after passing
through a vnl_vector" << std::endl;<br>
std::cout << matrixRowDataFromVector[0] << " "
<< matrixRowDataFromVector[1] << std::endl;<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
Output : <br>
<meta name="qrichtext" content="1">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><!--StartFragment--><span style=" font-family:'Monospace'; font-size:9pt; color:#31363b;">Matrix</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Monospace'; font-size:9pt; color:#31363b;">4 3 </span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Monospace'; font-size:9pt; color:#31363b;">2 1 </span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Monospace'; font-size:9pt; color:#31363b;">
</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Monospace'; font-size:9pt; color:#31363b;">First row, stored in a vnl_vector</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Monospace'; font-size:9pt; color:#31363b;">4 3</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Monospace'; font-size:9pt; color:#31363b;">First row, stored in a double*</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Monospace'; font-size:9pt; color:#31363b;">0 3</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Monospace'; font-size:9pt; color:#31363b;">First row, stored in a double* after passing through a vnl_vector</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Monospace'; font-size:9pt; color:#31363b;">4 3</span><!--EndFragment--></p>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<style type="text/css">
p, li { white-space: pre-wrap; }
</style><br>
<br>
It was compiled with the following CMakeLists.txt:<br>
<br>
<br>
cmake_minimum_required(VERSION 2.8)<br>
<br>
project(IsThisAvnlBug)<br>
<br>
find_package(ITK REQUIRED)<br>
include(${ITK_USE_FILE})<br>
<br>
add_executable(IsThisAvnlBug MACOSX_BUNDLE IsThisAvnlBug.cxx)<br>
target_link_libraries(IsThisAvnlBug ${ITK_LIBRARIES})<br>
<br>
</body>
</html>