[Insight-users] itkMatrix

Corinne Mattmann mattmaco at ee . ethz . ch
Mon, 15 Dec 2003 17:05:34 -0700


Hi Luis,

Thanks for your answer. You were right, I had an "old" ITK version. I
made a CVS update today and VNL-VNL and ITK-VNL multiplications are now
working fine. But the ITK-ITK still doesn't (I still get the same
error-message). I guess it is because the operator*(const Self &
matrix)-function in itkMatrix.txx (see below) has the same return-type
as the left-hand operand. But if I want to multiply a 2x3 with a 3x2
matrix, the result is a 2x2 matrix which is not covered by the above
mentioned function. Is that right?

/**
 *  Product by a matrix
 */
template<class T, unsigned int NRows, unsigned int NColumns >
Matrix<T, NRows, NColumns>
Matrix<T, NRows, NColumns>
::operator*( const Self & matrix ) const
{
  Self result;
  result = m_Matrix * matrix.m_Matrix;
  return result;
}



I have another problem: A link error. If I use the following code,
everything works fine.
      itk::Matrix<double,2,3> m4;
      m4.Fill(1.0);
      m4.GetTranspose();
But if I change the Matrix-Type to float (itk::Matrix<float,2,3> m4;), I
get the following link error:

Linking...
   Creating library
D:\packwin\vtkMy\bin\bin\Debug/TestExtrapolateDeformationFieldFilter.lib
and object
D:\packwin\vtkMy\bin\bin\Debug/TestExtrapolateDeformationFieldFilter.exp
TestExtrapolateDeformationFieldFilter.obj : error LNK2001: unresolved
external symbol "public: void __thiscall
vnl_matrix_fixed<float,2,3>::fill(float)"
(?fill@?$vnl_matrix_fixed at M$01$02@@QAEXM at Z)
TestExtrapolateDeformationFieldFilter.obj : error LNK2001: unresolved
external symbol "public: class vnl_matrix_fixed<float,3,2> __thiscall
vnl_matrix_fixed<float,2,3>::transpose(void)const "
(?transpose@?$vnl_matrix_fixed at M$01$02@@QBE?AV?$vnl_matri
x_fixed at M$02$01@@XZ)
D:\packwin\vtkMy\bin\bin\Debug/TestExtrapolateDeformationFieldFilter.exe
: fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

Why can't it find the two functions if I declare the Matrix-Type to
float?

Thanks very much for all your answers,
Corinne



-----Original Message-----
From: Luis Ibanez [mailto:luis . ibanez at kitware . com] 
Sent: Monday, December 15, 2003 1:52 PM
To: Corinne Mattmann
Cc: insight-users at itk . org
Subject: Re: [Insight-users] itkMatrix : bug ID 412



Hi Corinne,

What version of ITK are you using ?

This seems to be related to a bug in itkMatrix.txx that
was recently fixed.

It is bug ID=412: http://www . itk . org/Bug/bug . php?op=show&bugid=412&pos=5

The return type of the operator*() in itk::Matrix<> was incorrect. This
prevented non-square matrices to multiply correctly.

The bug report was made on the users-list:
http://www . itk . org/pipermail/insight-users/2003-November/005710 . html

The notification for the fix was:
http://www . itk . org/pipermail/insight-users/2003-December/005726 . html

You may have to update your CVS checkout.
Please look at the instructions posted in the recent email:
http://www . itk . org/pipermail/insight-users/2003-December/005930 . html


Regards,


    Luis


----------------------------
Corinne Mattmann wrote:
> Hi,
> 
> I would like to use the class itkMatrix. I tried itkMatrixTest.cxx and

> everything was working fine. But if I change the code to non-square 
> matrices, I get the following compiling error:
> 
> 
> Compiling...
> TestExtrapolateDeformationFieldFilter.cxx
> D:\packwin\vtkMy\src\TestProjects\TestExtrapolateDeformationFieldFilte
> r\
> ExtrapolateDeformationFieldFilter.txx(238) : error C2678: binary '*' :
> no operator defined which takes a left-hand operand of type 'class
> itk::Matrix<float,2,3>' (or there is no acceptable conversion)
>
D:\packwin\itk\Insight\Code\Common\itkImportImageContainer.h(87)
> : while compiling class-template member function 'void __thiscall
> itk::ExtrapolateDeformationFieldFilter<class itk::Image<class
> itk::Vector<float,3>,3>,class itk::Image<class itk::Vector<float,3>,3>
> 
>>::LinearExtrapolation(void)'
> 
> Error executing cl.exe.
> 
> 
> 
> What am I doing wrong?
> Here's the code I'm using:
> 
> 
>   typedef Matrix<float,2,3> MatrixType;
>   typedef Matrix<float,3,2> Matrix2Type;
>   typedef Matrix<float,2,2> MatrixProductType;
> 
>   MatrixType matrix;
>   matrix.Fill( 0.0 );
>   matrix.SetIdentity();
> 
>   Matrix2Type matrix2;
>   matrix2.SetIdentity();
>   matrix2.GetVnlMatrix()(0,0) = 10;
> 
>   MatrixProductType matrixProduct;
>   matrixProduct = matrix * matrix2;
> 
> 
> Thanks very much,
> Corinne
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org 
> http://www . itk . org/mailman/listinfo/insight-users
>