inv() crash
yaoyansi <[email protected]> Fri, 5 Mar 2010 12:08:38 +0800 (CST)
| Newsgroups | gmane.comp.lib.mtl.devel |
|---|---|
| Message-ID | <30159_1267762126_o2548dO9006471_60181.99855.qm@web15607.mail.cnb.yahoo.com> |
--0-948338897-1267762118=:99855
Content-Type: multipart/alternative; boundary="0-877031329-1267762118=:99855"
--0-877031329-1267762118=:99855
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
hi, all
I am not sure whether it is a bug, but it seems very strange.
Here is the detail.
typedef dense2D<double> Matrix;
=A0=A0=A0 Matrix transP(trans(P));
=A0=A0=A0 Matrix tM0(num_rows(transP), num_cols(P) );
Then, I yeild tM0 from transP*P, then inv(tM0) crashes.
But when I assign tM0 with const number array, the inv(tM0) works fine. Not=
e that the const number array is exactly the result of transP*P;
Here is the code:
#ifdef SHOW_ERROR_CASE
=A0=A0=A0 //section 1
=A0=A0=A0 tM0 =3D transP*P;
=A0=A0=A0 std::cout << "tM0:\n" << tM0<< std::endl;
=A0=A0=A0 // you will see this tM0 is exactly as the tM0 in section 2.
=A0=A0=A0 Matrix invM0(inv(tM0));// CRASH!
=A0=A0=A0 std::cout << "invM0:\n" << invM0<< std::endl;=20
#else
=A0=A0=A0 //section 2
=A0=A0=A0 tM0=3D 1.7e+002,=A0 15,=A0=A0 9,=A0 30,
=A0=A0=A0 =A0=A0=A0 15, 1.8, 1.1, 3.5,
=A0=A0=A0 =A0=A0=A0 9, 1.1, 0.63, 2.1,
=A0=A0=A0 =A0=A0=A0 30, 3.5, 2.1, 7;
=A0=A0=A0 Matrix invM0(inv(tM0));// OK.
=A0=A0=A0 std::cout << "invM0:\n" << invM0<< std::endl;=20
#endif
My VC++ project solution is attached.=20
use #define SHOW_ERROR_CASE to show the crash case,=20
or omit #define SHOW_ERROR_CASE, the tM0 will be assigned with const number=
array, and it works fine.
Cheers
yaoyansi
***************************************************************************=
**
** =
**
** WARNING: This email contains an attachment of a very suspicious type. =
**
** You are urged NOT to open this attachment unless you are absolutely =
**
** sure it is legitimate. Opening this attachment may cause irreparable =
**
** damage to your computer and your files. If you have any questions =
**
** about the validity of this message, PLEASE SEEK HELP BEFORE OPENING IT. =
**
** =
**
** This warning was added by the IU Computer Science Dept. mail scanner. =
**
***************************************************************************=
**
--0-877031329-1267762118=:99855
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
<table cellspacing=3D"0" cellpadding=3D"0" border=3D"0" ><tr><td valign=3D"=
top" style=3D"font: inherit;">hi, all<br>I am not sure whether it is a bug,=
but it seems very strange.<br>Here is the detail.<br><br><span style=3D"ba=
ckground-color: rgb(162, 162, 162);">typedef dense2D<double> Matrix;<=
/span><br style=3D"background-color: rgb(162, 162, 162);"><span style=3D"ba=
ckground-color: rgb(162, 162, 162);"> Matrix transP(trans=
(P));</span><br style=3D"background-color: rgb(162, 162, 162);"><span style=
=3D"background-color: rgb(162, 162, 162);">
Matrix tM0(num_rows(transP), num_cols(P) );</span><br><b=
r>Then, I yeild tM0 from transP*P, then inv(tM0) crashes.<br>But when I as=
sign tM0 with const number array, the inv(tM0) works fine. Note that the co=
nst number array is exactly the result of transP*P;<br>Here is the code:<=
br>
<span style=3D"background-color: rgb(162, 162, 162);">#ifdef SHOW_ERROR_CAS=
E</span><br><br style=3D"background-color: rgb(162, 162, 162);"><span style=
=3D"background-color: rgb(162, 162, 162);">
//section 1</span><br style=3D"background-color: rgb(162=
, 162, 162);"><span style=3D"background-color: rgb(162, 162, 162);">
tM0 =3D transP*P;</span><br style=3D"background-color: r=
gb(162, 162, 162);"><span style=3D"background-color: rgb(162, 162, 162);">
std::cout << "tM0:\n" << tM0<< std::en=
dl;</span><br style=3D"background-color: rgb(162, 162, 162);"><span style=
=3D"background-color: rgb(162, 162, 162);">
// you will see this tM0 is exactly as the tM0 in sectio=
n 2.</span><br style=3D"background-color: rgb(162, 162, 162);"><span style=
=3D"background-color: rgb(162, 162, 162);">
Matrix invM0(inv(tM0));// CRASH!</span><br style=3D"back=
ground-color: rgb(162, 162, 162);"><span style=3D"background-color: rgb(162=
, 162, 162);">
std::cout << "invM0:\n" << invM0<< std=
::endl; </span><br><br style=3D"background-color: rgb(162, 162, 162);"><spa=
n style=3D"background-color: rgb(162, 162, 162);">
#else</span><br style=3D"background-color: rgb(162, 162, 162);">
<br style=3D"background-color: rgb(162, 162, 162);"><span style=3D"backgrou=
nd-color: rgb(162, 162, 162);">
//section 2</span><br style=3D"background-color: rgb(162=
, 162, 162);"><span style=3D"background-color: rgb(162, 162, 162);">
tM0=3D 1.7e+002, 15, 9, 30,</spa=
n><br style=3D"background-color: rgb(162, 162, 162);"><span style=3D"backgr=
ound-color: rgb(162, 162, 162);">
15, 1.8, 1.1, 3.5,</span><br style=3D=
"background-color: rgb(162, 162, 162);"><span style=3D"background-color: rg=
b(162, 162, 162);">
9, 1.1, 0.63, 2.1,</span><br style=3D=
"background-color: rgb(162, 162, 162);"><span style=3D"background-color: rg=
b(162, 162, 162);">
30, 3.5, 2.1, 7;</span><br style=3D"b=
ackground-color: rgb(162, 162, 162);"><span style=3D"background-color: rgb(=
162, 162, 162);">
Matrix invM0(inv(tM0));// OK.</span><br style=3D"backgro=
und-color: rgb(162, 162, 162);"><span style=3D"background-color: rgb(162, 1=
62, 162);">
std::cout << "invM0:\n" << invM0<< std=
::endl; </span><br style=3D"background-color: rgb(162, 162, 162);">
<br style=3D"background-color: rgb(162, 162, 162);"><span style=3D"backgrou=
nd-color: rgb(162, 162, 162);">
#endif</span><br><br>
<br>
<br>My VC++ project solution is attached. <br>use #define SHOW_ERROR_CASE t=
o show the crash case, <br>or omit #define SHOW_ERROR_CASE, the tM0 will be=
assigned with const number array, and it works fine.<br><br>Cheers<br>yaoy=
ansi<br></td></tr></table><br>
<PRE>
***************************************************************************=
**
** =
**
** WARNING: This email contains an attachment of a very suspicious type. =
**
** You are urged NOT to open this attachment unless you are absolutely =
**
** sure it is legitimate. Opening this attachment may cause irreparable =
**
** damage to your computer and your files. If you have any questions =
**
** about the validity of this message, PLEASE SEEK HELP BEFORE OPENING IT. =
**
** =
**
** This warning was added by the IU Computer Science Dept. mail scanner. =
**
***************************************************************************=
**
</PRE>=
--0-877031329-1267762118=:99855--
--0-948338897-1267762118=:99855
Content-Type: application/x-zip-compressed; name="mtl_test.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="mtl_test.zip"
UEsDBBQAAAAIAFqXZDxmZpXoWQEAAHADAAAMAAAAbXRsX3Rlc3Quc2xupZLN
ToNAEMfPJeEdCF5q0iXLRxs4eFgW0IOaRhI9GlqWZs2Wbdill9on8+Aj+Qou
EbC1jTF425n/fPxmZj/e3nXtji4rLnghjUcq6owZqaxzyo2Us1pSXhoJZWRi
JLxaZyqGVKJxBhaEunbxI8eBcKpr84q/kKUcmzs/xAGOQx/4oYeAbUcQ+JFt
AwgRxIGtVM/Zm5fGlWGuJXuWREhz8v22tsuNqtW4di5CrodtBMIwcIDnJx4I
sDsF9nSGUez5cBYFe1PX4jJv++vaNeOLjOna6OuRKqdiH3eTYV4WdFVXWWPM
WSYLNaNoaDYV6YJU9igii3r1+kRL11HigdWID4SRTJBebu0+QAEdtT/BaXF/
oeFCHuL8bRfWAaeFVKstwcXqmH9gtbCmLLfg4Frdik7ZWuWfFVu+Icfo9qyO
siGVpOTcf7iheW/f85yoiATdpvHZBr1H1z4BUEsBAhQAFAAAAAgAWpdkPGZm
lehZAQAAcAMAAAwAAAAAAAAAAAAgAAAAAAAAAG10bF90ZXN0LnNsblBLBQYA
AAAAAQABADoAAACDAQAAAAA=
--0-948338897-1267762118=:99855
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/
--0-948338897-1267762118=:99855--