List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] convert question
| [MUG] convert question |
|
Author: Carl Eberhart
Posted: Sun, 13 Oct 2002 11:34:29 -0400
|
>> 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]])
Carl Eberhart, Mathematics 859-257-1258
University of Kentucky 759 POT
Lexington, Ky 40506
http://www.msc.uky.edu/carl
|
| [MUG] Re: convert question |
|
Author: Maple User Group
Posted: Fri, 18 Oct 2002 17:35:12 -0400
|
>> 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).
|
| [MUG] Re: convert question |
|
Author: Carl Eberhart
Posted: Mon, 21 Oct 2002 21:35:29 -0400
|
>> From: Carl Eberhart "carl"
Thanks for all the suggestions.
I wasn't being clear with my complaint.
The command convert([1,2,3],matrix) returns the error
expecting array, rtable or list
But [1,2,3] is a list.
I would be happy for maple to assume that I wanted a row matrix,
otherwise I would have asked it to convert([[1],[2],[3]],matrix)
But at least don't return that particular error message.
Carl
Carl Eberhart, Mathematics 859-257-1258
University of Kentucky 759 POT
Lexington, Ky 40506
http://www.msc.uky.edu/carl
|
Previous by date: [MUG] Simplex Bug (?), PierLuigi Zezza
Next by date: [MUG] Re: solving numerically, Robert Israel
Previous thread: [MUG] Problem with inequal, Dean Bernsten
Next thread: [MUG] Re: solving numerically, Robert Israel
|