patch for $diagmatrix needed?
- Subject: patch for $diagmatrix needed?
- From: van Nek
- Date: Thu, 20 Apr 2006 13:49:06 +0200
--Alt-Boundary-30880.1633859
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body
Hi all,
function $diagmatrix in src/matrix.lisp doesn't act like I expected.
I found
(%i1) mat: matrix([1,1],[1,-1]);
[ 1 1 ]
(%o1) [ ]
[ 1 - 1 ]
(%i2) diagmatrix(2,mat);
[ [ 1 1 ] ]
[ [ ] 0 ]
[ [ 1 - 1 ] ]
(%o2) [ ]
[ [ 1 1 ] ]
[ 0 [ ] ]
[ [ 1 - 1 ] ]
You can't multiply this with a 4-dim vector. This matrix is more or
less useless.
What I expected is the following.
(%i4) diagmatrix(2,mat);
[ 1 1 0 0 ]
[ ]
[ 1 - 1 0 0 ]
(%o4) [ ]
[ 0 0 1 1 ]
[ ]
[ 0 0 1 - 1 ]
I can offer a patch, which acts like shown in (%o4), if the second
arg to $diagmatrix is a matrix.
What do you think?
Volker
--Alt-Boundary-30880.1633859
Content-type: text/html; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title></title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
</head>
<body>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">Hi all,</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt"><br />
</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">function $diagmatrix in src/matrix.lisp doesn't act like I expected.
I found</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt"><br />
</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">(%i1) mat: matrix([1,1],[1,-1]);</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                              [ 1   1  ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">(%o1)                         [        ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                              [ 1  - 1 ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">(%i2) diagmatrix(2,mat);</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                      [ [ 1   1  ]             ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                      [ [        ]      0      ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                      [ [ 1  - 1 ]             ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">(%o2)                 [                        ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                      [             [ 1   1  ] ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                      [     0       [        ] ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                      [             [ 1  - 1 ] ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt"><br />
</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">You can't multiply this with a 4-dim vector. This matrix is more or
less useless.</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">What I expected is the following.</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt"><br />
</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">(%i4) diagmatrix(2,mat);</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                          [ 1   1   0   0  ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                          [                ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                          [ 1  - 1  0   0  ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">(%o4)                     [                ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                          [ 0   0   1   1  ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                          [                ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">                          [ 0   0   1  - 1 ]</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt"><br />
</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">I can offer a patch, which acts like shown in (%o4), if the second
arg to $diagmatrix is a matrix.</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt"><br />
</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">What do you think?</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt"><br />
</span></font></div>
<div align="left"><font face="Lucida Console" size="2"><span style="font-size:10pt">Volker</span></font></div>
</body>
</html>
--Alt-Boundary-30880.1633859--