[Insight-users] [Community] explicitly instantiate vnl_sparse_matrix

Matt McCormick matt.mccormick at kitware.com
Tue Oct 15 14:39:30 EDT 2013


Hi Wei,

On Tue, Oct 15, 2013 at 5:07 PM, Wei Liu <weiliu620 at gmail.com> wrote:
> 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?

Yes, a different type may be required due to insufficient numeric traits.

Thanks,
Matt


More information about the Insight-users mailing list