login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for List To Matrix revision 1 of 1

1
Editor: 127.0.0.1
Time: 2007/11/15 20:14:03 GMT-8
Note: transferred from axiom-developer

changed:
-
Assume that I have a 'List', like:
\begin{axiom}
L := [[- 1,3,- 3,1],[3,- 6,3],[- 3,3],[1]]
\end{axiom}
(which is calculated from some earlier expressions).
How can I convert it into a 'SquareMatrix'.
\begin{axiom}
L2:=[concat([L.i.j for j in 1..#L.i],[0 for j in ((#L.i)+1)..#L]) for i in 1..#L]
\end{axiom}

Namely I want to have a matrix like:
\begin{axiom}
A := matrix L2
\end{axiom}
so that I can do
\begin{axiom}
vp := vector[p0,p1,p2,p3]
\end{axiom}
and
\begin{axiom}
vp * A
\end{axiom}

Assume that I have a List, like:

fricas
L := [[- 1,3,- 3,1],[3,- 6,3],[- 3,3],[1]]

\label{eq1}\left[{\left[ - 1, \: 3, \: - 3, \: 1 \right]}, \:{\left[ 3, \: - 6, \: 3 \right]}, \:{\left[ - 3, \: 3 \right]}, \:{\left[ 1 \right]}\right](1)
Type: List(List(Integer))

(which is calculated from some earlier expressions). How can I convert it into a SquareMatrix.

fricas
L2:=[concat([L.i.j for j in 1..#L.i],[0 for j in ((#L.i)+1)..#L]) for i in 1..#L]

\label{eq2}\left[{\left[ - 1, \: 3, \: - 3, \: 1 \right]}, \:{\left[ 3, \: - 6, \: 3, \: 0 \right]}, \:{\left[ - 3, \: 3, \: 0, \: 0 \right]}, \:{\left[ 1, \: 0, \: 0, \: 0 \right]}\right](2)
Type: List(List(Integer))

Namely I want to have a matrix like:

fricas
A := matrix L2

\label{eq3}\left[ 
\begin{array}{cccc}
- 1 & 3 & - 3 & 1 
\
3 & - 6 & 3 & 0 
\
- 3 & 3 & 0 & 0 
\
1 & 0 & 0 & 0 
(3)
Type: Matrix(Integer)

so that I can do

fricas
vp := vector[p0,p1,p2,p3]

\label{eq4}\left[ p 0, \: p 1, \: p 2, \: p 3 \right](4)
Type: Vector(OrderedVariableList?([p0,p1,p2,p3]))

and

fricas
vp * A

\label{eq5}\left[{p 3 -{3 \  p 2}+{3 \  p 1}- p 0}, \:{{3 \  p 2}-{6 \  p 1}+{3 \  p 0}}, \:{{3 \  p 1}-{3 \  p 0}}, \: p 0 \right](5)
Type: Vector(Polynomial(Integer))