matrix square



You may be aware that Common Lisp already provides a number of "map/reduce" operations which didn't make it into Maxima because they were added to Common Lisp after Maxima was implemented.

While Maxima does a pretty good job of mapping, I don't believe it does such a good job on "reduce" operations.

http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node143.html

Common Lisp got the ideas for some of its mapping & reducing operations from Iverson's APL language.

APL has some useful operations:

http://en.wikipedia.org/wiki/APL_%28programming_language%29

APL has the following extremely useful operations:

1.  (iota n) => sequence from 0..(n-1), i.e.,

(iota 5) => [0,1,2,3,4]

2.  "generalized inner product".  Given 2 binary operations "product" and "sum", and 2 vectors u,v of equal length compute

sum(i=0..(length-1),product(u[i],v[i])).  This generalized inner product is extended to matrices in the usual way, such that
innerproduct("+","*",A,B) is the usual _matrix product_ of the matrices A,B.

Implementing inner product in its full generality requires some way to determine the identity element for a given operation.  Thus, "+"[]=0,
"*"[]=1, "min"[]=+infinity, "max"[]=-infinity, etc.

3.  "outer product".  Basically, the tensor product.

4.  Binary select.  (Implemented in hardware on CDC & Cray computers).  Given a bit-vector b and a generic vector v of the same length,

select(b,v) is the vector whose length is the "number of 1 bits in b" which contains all of the elements of v which have a corresponding
bit in b equal to 1.

5.  "Scan" functions.  Basically, these provide for _running sums_, etc.  Given a binary operation "op" and a vector v,

scan(+,[a,b,c,d,e]) = [0,a,a+b,a+b+c,a+b+c+d,a+b+c+d+e]

I believe that APL may have done it backwards:

rscan(+,[a,b,c,d,e]) = [a+b+c+d+e,b+c+d+e,c+d+e,d+e,e,0]

6.  "reverse".  reverses a vector.

7.  "restructure".  This takes a simple 1-dimensional vector and "restructures" the elements into a multidimensional vector:

restructure(2,3,[0,1,2,3,4,5]) = matrix([0,1,2],[3,4,5])

8.  multidimensional "transpose".  Exchanges 2 indices in an n-dimensional array.

At 03:56 AM 1/2/2013, Jaime Villate wrote:
>On 12/30/2012 12:03 PM, Barton Willis wrote:
>>? kronecker_product;
>
>Great. This is exactly what I need in another problem I'm working on :)
>Last week I wrote some code to calculate the "outer product" of matrices; I didn't know it was also called Kronecker product and was already implemented in Maxima.
>
>If some developer is eager to start 2013 by improving the manual, here is an idea: improve kronecker_products documentation (linear algebra package) by adding it to category Matrices, adding a simple example and saying that it is also known as outer product.
>
>Regards,
>Jaime