<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I forgot to mention that I always have the -O3 
optimization flag&nbsp;ON, while compiling.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Regards,</FONT></DIV>
<DIV><FONT face=Arial size=2>Suyash.</FONT></DIV>
<BLOCKQUOTE dir=ltr 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=suyash@cs.utah.edu href="mailto:suyash@cs.utah.edu">Suyash P. 
  Awate</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=millerjv@crd.ge.com 
  href="mailto:millerjv@crd.ge.com">Miller, James V (Research)</A> ; <A 
  title=jiafucang@asisz.com href="mailto:jiafucang@asisz.com">jiafucang</A> ; <A 
  title=jjomier@cs.unc.edu 
  href="mailto:jjomier@cs.unc.edu">jjomier@cs.unc.edu</A> ; <A 
  title=insight-users@itk.org 
  href="mailto:insight-users@itk.org">insight-users@itk.org</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, December 19, 2005 8:50 
  PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Insight-users] Re: On 
  incorrect matrix inverse</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=Arial size=2>Dear ITK Users,</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>I found the cause of the error. It deals with my 
  build of ITK in the SUSE 10&nbsp;environment that&nbsp;uses&nbsp;gcc 4.0 by 
  default. When I build itk and the applications on SUSE 9.3 using gcc 3.4 
  (definitely not gcc 4.0) or Fedora Core 2 (again not using gcc 4.0), I 
  did&nbsp;NOT get&nbsp;any vnl error.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>I confirmed that precision is&nbsp;NOT an issue 
  because the condition number for the matrix with truncated values is still 
  very close to 1. I found this via matlab. So numerical "instabilities" in 
  inverse-finding should not occur.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>So it seems that there is something strange about 
  the way the vnl code/libraries interact with gcc 4.0.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Thanks again for all your help.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Best regards,</FONT></DIV>
  <DIV><FONT face=Arial size=2>Suyash.</FONT></DIV>
  <BLOCKQUOTE dir=ltr 
  style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
    <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
    <DIV 
    style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
    <A title=millerjv@crd.ge.com href="mailto:millerjv@crd.ge.com">Miller, James 
    V (Research)</A> </DIV>
    <DIV style="FONT: 10pt arial"><B>To:</B> <A title=suyash@cs.utah.edu 
    href="mailto:suyash@cs.utah.edu">Suyash P. Awate</A> ; <A 
    title=jiafucang@asisz.com href="mailto:jiafucang@asisz.com">jiafucang</A> ; 
    <A title=jjomier@cs.unc.edu 
    href="mailto:jjomier@cs.unc.edu">jjomier@cs.unc.edu</A> ; <A 
    title=insight-users@itk.org 
    href="mailto:insight-users@itk.org">insight-users@itk.org</A> </DIV>
    <DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, November 11, 2005 11:24 
    AM</DIV>
    <DIV style="FONT: 10pt arial"><B>Subject:</B> RE: [Insight-users] Re: On 
    incorrect matrix inverse</DIV>
    <DIV><BR></DIV>
    <DIV><SPAN class=675082118-11112005><FONT face=Arial color=#0000ff 
    size=2>Suyash, </FONT></SPAN></DIV>
    <DIV><SPAN class=675082118-11112005><FONT face=Arial color=#0000ff 
    size=2></FONT></SPAN>&nbsp;</DIV>
    <DIV><SPAN class=675082118-11112005><FONT face=Arial color=#0000ff 
    size=2>You might not have enough precision in the matrix values that you are 
    reading&nbsp;from the command line.&nbsp; Try generating the values with 
    more</FONT></SPAN></DIV>
    <DIV><SPAN class=675082118-11112005><FONT face=Arial color=#0000ff 
    size=2>precision from whatever tool is generating them.&nbsp; Try going out 
    to about 12 decimal places.</FONT></SPAN></DIV>
    <DIV><SPAN class=675082118-11112005><FONT face=Arial color=#0000ff 
    size=2></FONT></SPAN>&nbsp;</DIV>
    <DIV><SPAN class=675082118-11112005><FONT face=Arial color=#0000ff size=2>I 
    have seen this before where one program computes a matrix that is supposed 
    to be invertible, writes the matrix in ascii, another program reads that 
    matrix and it is no longer invertible.&nbsp; </FONT></SPAN></DIV>
    <DIV><SPAN class=675082118-11112005><FONT face=Arial color=#0000ff 
    size=2></FONT></SPAN>&nbsp;</DIV>
    <DIV><SPAN class=675082118-11112005><FONT face=Arial color=#0000ff 
    size=2>Jim</FONT></SPAN></DIV>
    <DIV><SPAN class=675082118-11112005><FONT face=Arial color=#0000ff 
    size=2></FONT></SPAN>&nbsp;</DIV>
    <DIV><SPAN class=675082118-11112005><FONT face=Arial color=#0000ff 
    size=2></FONT></SPAN>&nbsp;</DIV>
    <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
      <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
      size=2>-----Original Message-----<BR><B>From:</B> <A 
      href="mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org">insight-users-bounces+millerjv=crd.ge.com@itk.org</A> 
      [mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org]<B>On Behalf Of 
      </B>Suyash P. Awate<BR><B>Sent:</B> Friday, November 11, 2005 1:06 
      PM<BR><B>To:</B> jiafucang; jjomier@cs.unc.edu; 
      insight-users@itk.org<BR><B>Subject:</B> [Insight-users] Re: On incorrect 
      matrix inverse<BR><BR></FONT></DIV>
      <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
      <DIV><FONT face=Arial>Hi everybody,</FONT></DIV>
      <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
      <DIV><FONT face=Arial>Thanks for the generous help.</FONT></DIV>
      <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
      <DIV><FONT face=Arial>I was also trying to get the inverse&nbsp;concerning 
      with&nbsp;the registration application, like Fucang (see email 
      attached).</FONT></DIV>
      <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
      <DIV><FONT face=Arial>Here is my piece of code that gave me the wrong 
      result:</FONT></DIV>
      <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
      <DIV><FONT face=Arial>------------</FONT></DIV>
      <DIV><FONT face=Arial>const unsigned int Dimension = 3;<BR>typedef double 
      PixelType;<BR>typedef itk::Matrix &lt;PixelType, Dimension, Dimension&gt; 
      MatrixType;<BR>MatrixType matrix;<BR>&nbsp; matrix.Fill (0);<BR>&nbsp; 
      matrix (0,0)= atof (argv[4]);<BR>&nbsp; matrix (0,1)= atof 
      (argv[5]);<BR>&nbsp; matrix (0,2)= atof (argv[6]);<BR>&nbsp; matrix (1,0)= 
      atof (argv[7]);<BR>&nbsp; matrix (1,1)= atof (argv[8]);<BR>&nbsp; matrix 
      (1,2)= atof (argv[9]);<BR>&nbsp; matrix (2,0)= atof (argv[10]);<BR>&nbsp; 
      matrix (2,1)= atof (argv[11]);<BR>&nbsp; matrix (2,2)= atof 
      (argv[12]);<BR>vnl_matrix_fixed &lt;PixelType, Dimension, Dimension&gt; 
      inverse;<BR>inverse= matrix.GetInverse();</DIV></FONT>
      <DIV><FONT face=Arial>-----------</FONT></DIV>
      <DIV><FONT face="Courier New">matrix<BR>&nbsp;0.99925&nbsp;&nbsp; 
      0.0371382 -0.0109982<BR>-0.0373772 0.99905&nbsp;&nbsp; 
      -0.0223916<BR>&nbsp;0.0101562 0.0227859&nbsp; 
      0.999689<BR><BR>warnings:<BR>InsightToolkit-2.2.0/Utilities/vxl/core/vnl/algo/vnl_svd.txx: 
      suspicious return value (2) from 
      SVDC<BR>InsightToolkit-2.2.0/Utilities/vxl/core/vnl/algo/vnl_svd.txx: M is 
      3x3<BR>M = [ ...<BR>&nbsp;0.9992500000000&nbsp; 0.0371382000000 
      -0.0109982000000<BR>-0.0373772000000&nbsp; 0.9990500000000 
      -0.0223916000000<BR>&nbsp;0.0101562000000&nbsp; 0.0227859000000&nbsp; 
      0.9996890000000&nbsp; ]<BR><BR></FONT><TT>matrix inverse using vnl in itk 
      (incorrect)<BR>-0.982557 -0.0644525 -0.174434<BR>-0.0677511 
      0.997618&nbsp;&nbsp; 0.0130162<BR>-0.17318&nbsp; -0.0246073&nbsp; 
      0.984583<BR><BR></TT><TT>matrix inverse in matlab 
      (correct)<BR>&nbsp;0.9992&nbsp;&nbsp; -0.0374&nbsp;&nbsp;&nbsp; 
      0.0102<BR>&nbsp;0.0371&nbsp;&nbsp;&nbsp; 0.9991&nbsp;&nbsp;&nbsp; 
      0.0228<BR>-0.0110&nbsp;&nbsp; -0.0224&nbsp;&nbsp;&nbsp; 
      0.9997<BR>------------</TT></DIV>
      <DIV><TT></TT>&nbsp;</DIV>
      <DIV><FONT face=Arial>I had also tried using the AffineTransform but for 
      some reason could not get that to work and so I wrote this simple matrix 
      code. Perhaps that was due to the&nbsp;same problem that Fucang 
      reported.</FONT></DIV>
      <DIV><FONT face=Arial>Currently, however, my problem is different. As we 
      can see I am not using any Transform class at all. Moreover I am getting 
      warnings from the vnl_svd class, so vnl is definitely involved 
      here.</FONT></DIV>
      <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
      <DIV><FONT face=Arial>Julien: I am giving 9 numbers (truncated: <FONT 
      face="Courier New">0.99925&nbsp;&nbsp; 0.0371382 -0.0109982 -0.0373772 
      0.99905&nbsp;-0.0223916 0.0101562 0.0227859&nbsp; 0.999689) to the matrix 
      in itk and also the same numbers to the matrix in matlab. I got these 
      numbers from the output of a separate program.</FONT><BR></FONT><FONT 
      face=Arial><FONT face=Arial>Just FYI, I have compiled ITK on Suse 10.0 
      using GCC 4.0. I wonder if that has anything to do with this 
      !</FONT></DIV></FONT>
      <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
      <DIV><FONT face=Arial>Best regards,</FONT></DIV>
      <DIV><FONT face=Arial>Suyash.</FONT></DIV>
      <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
      <BLOCKQUOTE dir=ltr 
      style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
        <DIV style="FONT: 10pt arial"><FONT size=3></FONT>&nbsp;</DIV>
        <DIV style="FONT: 10pt arial"><FONT size=3>----- Original Message ----- 
        </FONT></DIV>
        <DIV 
        style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><FONT 
        size=3><B>From:</B> </FONT><A title=jiafucang@asisz.com 
        href="mailto:jiafucang@asisz.com"><FONT size=3>jiafucang</FONT></A><FONT 
        size=3> </FONT></DIV>
        <DIV style="FONT: 10pt arial"><FONT size=3><B>To:</B> </FONT><A 
        title=suyash@cs.utah.edu href="mailto:suyash@cs.utah.edu"><FONT 
        size=3>suyash@cs.utah.edu</FONT></A><FONT size=3> ; </FONT><A 
        title=jjomier@cs.unc.edu href="mailto:jjomier@cs.unc.edu"><FONT 
        size=3>jjomier@cs.unc.edu</FONT></A><FONT size=3> </FONT></DIV>
        <DIV style="FONT: 10pt arial"><FONT size=3><B>Sent:</B> Friday, November 
        11, 2005 7:10 AM</FONT></DIV>
        <DIV style="FONT: 10pt arial"><FONT size=3><B>Subject:</B> On incorrect 
        matrix inverse</FONT></DIV>
        <DIV><FONT face=Arial></FONT><BR></DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3>Hello, Suyash, Jomier,</FONT></DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3></FONT>&nbsp;</DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3>I have reported similar problem on</FONT></DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><A 
        href="http://public.kitware.com/pipermail/insight-users/2005-October/015441.html"><FONT 
        size=3>http://public.kitware.com/pipermail/insight-users/2005-October/015441.html</FONT></A><FONT 
        size=3> </FONT></DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3></FONT>&nbsp;</DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3>and added a bug 2450</FONT></DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3></FONT>&nbsp;</DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><A 
        href="http://www.itk.org/Bug/bug.php?op=show&amp;bugid=2450&amp;pos=24"><FONT 
        size=3>http://www.itk.org/Bug/bug.php?op=show&amp;bugid=2450&amp;pos=24</FONT></A></DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3></FONT>&nbsp;</DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3>I think it is because ITK does not computer inverse when 
        setparameters used, and not VNL problem.</FONT></DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3></FONT>&nbsp;</DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3>HTH</FONT></DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3></FONT>&nbsp;</DIV>
        <DIV 
        style="FONT-SIZE: 10pt; FONT-FAMILY: tahoma; BACKGROUND-COLOR: white"><FONT 
        size=3>Fucang</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>