>> From: Maple User Group "maple_gr"
| >> From: Carl Eberhart "carl"
| Converting between matrices, lists, vectors and Matrices, Vectors
| works well. But converting from a list to a matrix (in Maple 8 and
| Maple 7) returns an error
|
| convert([2,1,3],matrix);
| Error, (in convert/matrix) expecting array, rtable or list
|
| It would be convenient if Maple would return matrix([[1,2,3]])
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Tue, 15 Oct 2002 15:37:41 -0700 (PDT)
From: Robert Israel "israel"
To: "maple-list"
Subject: convert question
But maybe it should be matrix([[1],[2],[3]]). How is Maple to know
if you want your list interpreted as a row or as a column?
BTW, convert([2,1,3],Matrix) does work (and results in a row).
Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Tue, 15 Oct 2002 22:01:12 -0400
From: "Douglas B. Meade" "meade"
To: "maple-list"
Subject: convert question
Carl and MUG,
The problem, of course, is that Maple does not know the
dimension of the matrix that you want it to create.
One possible workaround is to convert to a vector, then
convert the vector to a matrix. This returns a COLUMN
matrix, not a row matrix. If you really want a row matrix,
use transpose:
> L := [1,2,3];
L := [1, 2, 3]
> Lv := convert(L,vector);
Lv := [1, 2, 3]
> Lm := convert( L, matrix );
Error, (in convert/matrix) expecting array, rtable or list
> Lvm := convert( Lv, matrix );
[1]
[ ]
Lvm := [2]
[ ]
[3]
> Lm_row := linalg[transpose]( convert( convert( L, vector ), matrix )
> );
Lm_row := [1 2 3]
This last result could be taught to convert so that convert(
L, matrix ) would do this. Or, you could write your own
convert procedure:
> convertLtoM := (L::list) ->
> linalg[transpose](convert(convert(L,vector),matrix)):
> convertLtoM( L );
[1 2 3]
I hope this is of some use to you,
Doug
-----------------------------------------------------------------------
Douglas B. Meade Phone: (803) 777-6183 FAX:
(803) 777-6527
Department of Mathematics URL:
http://www.math.sc.edu/~meade/
USC, Columbia, SC 29208 E-mail: "mailto:meade"
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: "Peter Weigand" "peter.weigand"
To: "maple-list"
Date: Wed, 16 Oct 2002 10:27:54 +0200
Subject: convert question
The conversion is possible in two steps
convert([2,1,3], array):convert(%,matrix):
The result is a 3x1 column.
With regards
Peter Weigand-----------------------------------------------------
Dr. Peter Weigand,
Chemnitz University of Technology
Faculty of Mathematics
Mail :D-09107 Chemnitz, Germany
Phone: +49 0371 531 2655
Fax : +49 0371 531 4947
E-mail: "weigand"
_____________________________________________________
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Thu, 17 Oct 2002 09:37:21 +0100
Subject: convert question
To: "maple-list"
From: John Trapp "j.j.trapp"
Try
>convert(
[
>[2,1,3]
]
>,matrix);
or
>convert(
[
>[2
]
>,
[
>1
]
>,
[
>3
]
>],matrix);
Maple does not know whether you require a 1x3 or 3x1 matrix.
John Trapp
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Thu, 17 Oct 2002 10:00:45 -0400 (EDT)
From: Carl Devore "devore"
To: "maple-list"
Subject: convert question
But what if it would be convenient for someone else if it returned
matrix([[1],[2],[3]])? If L is a list, what is so bad about saying
matrix([L]) or convert([L], matrix) to get what you want? Also Maple 8
allows
convert(L, compose, Matrix, matrix)
and
`<|>`(L[])
returns a 1 x n Matrix (not matrix).
|