[ITK-users] Assigning to VariableSizeMatrix

Bradley Lowekamp blowekamp at mail.nih.gov
Tue Jul 22 17:58:29 EDT 2014


Where do you set the size of the matrix? Likely this the buffer is initialized to NULL and being dereferenced.

Likely you should do it in the constructor[1] or with the SetSize method[2].

Brad

[1] http://www.itk.org/Doxygen/html/classitk_1_1VariableSizeMatrix.html#a42fd764a36e3a229de900bcec3997de7
[2] http://www.itk.org/Doxygen/html/classitk_1_1VariableSizeMatrix.html#a422d01338a63aa30041b1fc7c7e504a2
On Jul 22, 2014, at 5:53 PM, DVigneault <davis.vigneault at gmail.com> wrote:

> All--
> 
> I'm getting a segmentation fault upon attempting to assign to an
> itk::VariableSizeMatrix.  I tried to find an example of its usage in the
> doxygen, wiki, and software manual, but didn't see one.  Here's a minimal
> example of my problem:
> 
> #include "itkVariableSizeMatrix.h"
> 
> int main( int argc, char * argv[] )
> {
> 	
> 	if( argc != 1 )
>    {
>        std::cerr << "Usage: " << argv[0] << std::endl;
>        return EXIT_FAILURE;
>    }
> 
>    typedef itk::VariableSizeMatrix< double > MatrixType;
> 
> 	MatrixType matrix;
> 	matrix(0,0) = 1.0; // Segmentation fault: 11
> 
>  return EXIT_SUCCESS;
> 
> }
> 
> Can anyone point out my mistake, or point me toward an example?
> 
> Best, and thanks,
> 
> --Davis
> 
> 
> 
> --
> View this message in context: http://itk-users.7.n7.nabble.com/Assigning-to-VariableSizeMatrix-tp34285.html
> Sent from the ITK - Users mailing list archive at Nabble.com.
> _____________________________________
> 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 Insight-users mailing list