No subject

From: ()
Date: Mon Dec 3 19:58:15 EST 2012

(array #[#[1 2]]) and (array #[1 2]) are more or less the same,
namely (eventually) a flat vector of length 2. Separating the
concepts of a column vector and a matrix therefore have
no real benefits.

--=20
Jens Axel S=C3=B8gaard

--20cf303348e5bf43a404dc25775b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

2013/5/7 Ray Racine <span dir=3D"ltr">&lt;<a href=3D"mailto:ray.racine at gmai=
l.com" target=3D"_blank">ray.racine at gmail.com</a>&gt;</span><br><div class=
=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr"><div><div><div><div>First of all I&#39;ve started using so=
me of the new math and prob stuff &quot;for real&quot; and it&#39;s all fan=
tastic work.=C2=A0 Thank you.<br><br>Was looking for a routine for sums of =
a matrix along the either the rows or cols axis.<br>

<br></div>See <a href=3D"http://docs.scipy.org/doc/numpy/reference/generate=
d/numpy.sum.html" target=3D"_blank">http://docs.scipy.org/doc/numpy/referen=
ce/generated/numpy.sum.html</a><br><br></div>I didn&#39;t notice anything b=
ut looks straightforward with matrix-map-rows/cols or similar.=C2=A0 </div>
</div></div></blockquote><div><br></div><div>I agree that we should some su=
mming functions to the matrix library.</div><div><br></div><div><br></div><=
div>In the mean time, you can use the summing functions for arrays.</div>
<div><br></div><div><a href=3D"http://docs.racket-lang.org/math/array_fold.=
html?q=3Darray&amp;q=3Dmatrix-co&amp;q=3Dcolumn&amp;q=3Darray&amp;q=3Din-co=
lumn#(form._((lib._math/array..rkt)._array-all-sum))">http://docs.racket-la=
ng.org/math/array_fold.html?q=3Darray&amp;q=3Dmatrix-co&amp;q=3Dcolumn&amp;=
q=3Darray&amp;q=3Din-column#(form._((lib._math/array..rkt)._array-all-sum))=
</a></div>
<div><br></div><div><div>&gt; (require math)</div><div>&gt; (define M (matr=
ix [[1 2]=C2=A0</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0[3 4]]))</div><div><br></div><div>&gt; (array-ax=
is-sum M 0)</div><div>(array #[4 6])</div><div>&gt; (array-axis-sum M 1)</d=
iv>
<div>(array #[3 7])</div><div>&gt; (array-all-sum M)</div><div>10</div><div=
>&gt; (array-all-sum (matrix-col M 0))</div><div>4</div></div><div><br></di=
v><div><br></div><div>This reminds me that we need to bring back in-column =
and=C2=A0</div>
<div>in-row so one can use them with for/sum and others.</div><div><br></di=
v><div><a href=3D"https://code.google.com/p/racket/source/browse/collects/m=
ath/private/matrix/matrix-sequences.rkt?spec=3Dsvn9a48e5d1e5f65abc0d06ed5f9=
8f8fcda0beae073&amp;r=3D9a48e5d1e5f65abc0d06ed5f98f8fcda0beae073">https://c=
ode.google.com/p/racket/source/browse/collects/math/private/matrix/matrix-s=
equences.rkt?spec=3Dsvn9a48e5d1e5f65abc0d06ed5f98f8fcda0beae073&amp;r=3D9a4=
8e5d1e5f65abc0d06ed5f98f8fcda0beae073</a></div>
<div><br></div><div>If I recall correctly there were a problem to get in-ro=
w and in-sum to work</div><div>with both normal Racket and Typed Racket.</d=
iv><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr"><div><div>As I started one thing I noticed was the treatme=
nt of Matrix Rows and Cols as themselves a Matrix and not as a flat Array.=
=C2=A0 <br>
<br>&gt; matrix-row<br>- : (All (A) ((Array A) Integer -&gt; (Array A)))<br=
>#&lt;procedure:matrix-row&gt;<br>&gt; (matrix-row m 0)<br>- : (Array Posit=
ive-Byte)<br>(array #[#[1 2]])<br><br>In lieu of (array #[#[1 2]]) I would =
have expected (array #[1 2]).=C2=A0=C2=A0 In=20
other words, a row or column of a matrix is a row or column vector.<br><br>=
</div><div>in fact currently<br><br>&gt; (matrix-row (matrix-row (matrix-ro=
w (matrix-row m 0) 0) 0) 0)<br>- : (Array Positive-Byte)<br>(array #[#[1 2]=
])<br>

</div><br></div><div>What is the advantage of current approach?</div></div>=
</blockquote><div><br></div><div>From a mathematical view the space of colu=
mn vectors=C2=A0</div><div>the space of nx1 matrices are isomorphic. This i=
s (ab)used</div>
<div>so often in formulas, that I find it convenient to represent</div><div=
>column vectors as matrices. For example:=C2=A0<span style=3D"background-co=
lor:rgb(249,249,249);font-family:monospace,Courier;font-size:15.83333301544=
1895px;line-height:1.3em">(matrix* (T x) x)</span></div>
<div>will work for a column matrix x.</div><div><pre class=3D"text highligh=
ted_source" style=3D"font-family:monospace,Courier;padding:1em;border:1px d=
ashed rgb(47,111,171);background-color:rgb(249,249,249);line-height:1.3em;o=
verflow:auto;font-size:15.833333015441895px">
#lang racket<br>(require math)<br>(define T matrix-transpose)<br>=C2=A0<br>=
(define (fit x y)<br>  (matrix-solve (matrix* (T x) x) (matrix* (T x) y)))<=
/pre></div><div><br></div><div>From a more down to earth view, the internal=
 representation of</div>
<div>(array #[#[1 2]]) and (array #[1 2]) are more or less the same,</div><=
div>namely (eventually) a flat vector of length 2. Separating the</div><div=
>concepts of a column vector and a matrix therefore have=C2=A0</div><div>no=
 real benefits.</div>
<div><br></div><div>--=C2=A0</div></div>Jens Axel S=C3=B8gaard<br><br>

--20cf303348e5bf43a404dc25775b--

Posted on the users mailing list.