[Community] [Insight-users] explicitly instantiate vnl_sparse_matrix

Wei Liu weiliu620 at gmail.com
Tue Oct 15 13:07:31 EDT 2013


Matt thanks for the information. I tried to add the following code in
my main.cpp but it doesn't work:
--------------------------
template class vnl_sparse_matrix<bool>;

static int vnl_sparse_matrix_float_tickler()
{
  vnl_sparse_matrix<bool> md(3, 5);
  vnl_sparse_matrix_bool_tickler(); // to avoid compiler warning
  return md(0,0);
}
----------------------------------------
Then I created a vnl_sparse_matrix+bool-.cxx file in the 'template'
folder, and put the above code in the file (and include the txx file),
and re-compile itk. I got the following errors:

=========================
/home/sci/weiliu/packages/InsightToolkit-4.3.1/Modules/ThirdParty/VNL/src/vxl/core/vnl/Templates/vnl_sparse_matrix+bool-.cxx:
In function ‘int vnl_sparse_matrix_float_tickler()’:
/home/sci/weiliu/packages/InsightToolkit-4.3.1/Modules/ThirdParty/VNL/src/vxl/core/vnl/Templates/vnl_sparse_matrix+bool-.cxx:8:34:
error: ‘vnl_sparse_matrix_bool_tickler’ was not declared in this scope
In file included from
/home/sci/weiliu/packages/InsightToolkit-4.3.1/Modules/ThirdParty/VNL/src/vxl/core/vnl/Templates/vnl_sparse_matrix+bool-.cxx:1:0:
/home/sci/weiliu/packages/InsightToolkit-4.3.1/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_sparse_matrix.txx:
In instantiation of ‘vnl_sparse_matrix<T>
vnl_sparse_matrix<T>::conjugate_transpose() const [with T = bool]’:
/home/sci/weiliu/packages/InsightToolkit-4.3.1/Modules/ThirdParty/VNL/src/vxl/core/vnl/Templates/vnl_sparse_matrix+bool-.cxx:3:16:
  required from here
/home/sci/weiliu/packages/InsightToolkit-4.3.1/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_sparse_matrix.txx:967:7:
error: incomplete type ‘vnl_complex_traits<bool>’ used in nested name
specifier
[ 60%] Built target itkhdf5_cpp
make[2]: *** [Modules/ThirdParty/VNL/src/vxl/core/vnl/CMakeFiles/itkvnl.dir/Templates/vnl_sparse_matrix+bool-.cxx.o]
Error 1
make[1]: *** [Modules/ThirdParty/VNL/src/vxl/core/vnl/CMakeFiles/itkvnl.dir/all]
Error 2
make[1]: *** Waiting for unfinished jobs....
[ 60%] Built target ITKGIFTI-all
make: *** [all] Error 2
===============================

It looks the 'bool' does not support some numeric traits defined in
the vnl_sparse_matrix template. There seems no easy workaround?

Thank you,
Wei


On Tue, Oct 15, 2013 at 8:20 AM, Matt McCormick
<matt.mccormick at kitware.com> wrote:
> Hi Wei,
>
> It may need a "tickle".
>
> For example,
>
>
> $ cat Modules/ThirdParty/VNL/src/vxl/core/vnl/Templates/vnl_sparse_matrix+int-.cxx
>
> #include <vnl/vnl_sparse_matrix.txx>
>
> template class vnl_sparse_matrix<int>;
>
> static int vnl_sparse_matrix_float_tickler()
> {
>   vnl_sparse_matrix<int> md(3, 5);
>   vnl_sparse_matrix_float_tickler(); // to avoid compiler warning
>   return md(0,0);
> }
>
>
> HTH,
> Matt
>
> On Tue, Oct 15, 2013 at 4:56 AM, Wei Liu <weiliu620 at gmail.com> wrote:
>> Dear ITK users,
>>
>> Is there a method to explicitly instantiate vnl_sparse_matrix<bool>?
>> I'm trying to define: vnl_sparse_matrix<bool> mymatrix, but get  error
>>
>> undefined reference to `vnl_sparse_matrix<bool>::vnl_sparse_matrix()'
>>
>> I tried to add
>>
>> template class vnl_sparse_matrix<bool>;
>>
>> on the top of my main.cxx but it doesn't work. I appreciate any insights.
>>
>> Wei
>> _____________________________________
>> 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://www.itk.org/mailman/listinfo/insight-users
>> _______________________________________________
>> Community mailing list
>> Community at itk.org
>> http://public.kitware.com/cgi-bin/mailman/listinfo/community
_____________________________________
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://www.itk.org/mailman/listinfo/insight-users



More information about the Community mailing list