List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] Re: evalm and mapping of function
| [MUG] Re: evalm and mapping of function |
|
Author: Maple User Group
Posted: Wed, 5 Jun 2002 14:16:12 -0400 (
|
>> From: Maple User Group "maple_gr"
> >> From: Guy Gendron "ggendron"
> I dont understand why Maple cannot map the "fcncarre" function onto the
> elements of the matrix "mat_a". I am trying to use evalm to square each
> element of the input matrix.
>
> > evalm(fcncarre(mat_a));#I want evalm to map the fonction onto each elem.
> of mat_a
> Error, (in linalg[multiply]) non matching dimensions for vector/matrix product
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Fri, 31 May 2002 17:25:33 +0200
From: Adri van der Meer "A.W.J.vanderMeer"
To: "maple-list"
Subject: evalm and mapping of function
You use the right word: "map":
> map( fcncarre, evalm(mat_a) );
--
A. van der Meer
Dept. Applied Mathematics
University of Twente Phone +31 (53) 4893427
P.O. Box 217 Fax +31 (53) 4894824
7500 AE Enschede
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Fri, 31 May 2002 09:23:32 -0700
To: "maple-list"
From: David Harrington "dharr"
Subject: evalm and mapping of function
try
> map(fcncarre,eval(a));
or
> map(fcncarre,evalm(a));
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Fri, 31 May 2002 12:09:46 -0400 (EDT)
From: Denis Sevee "dsevee"
To: "maple-list" "maple-list"
Subject: evalm and mapping of function
You should use
>map(fcncarre, mat_a);
This is how, in general, you should apply any function to the entries of
a matrix.
Denis Sevee
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: Douglas Wilhelm Harder "douglas"
Subject: evalm and mapping of function
To: "maple-list"
Date: Fri, 31 May 2002 13:46:58 -0400 (EDT)
Your function immediately returns something:
> fcncarre:=x->x*x; # I define a new function
2
fcncarre := x -> x
> mat_a := matrix( [[1,2,3],[4,5,6]] ):
> fcncarre( mat_a );
2
mat_a
unlike sin:
> sin( mat_a );
sin(mat_a)
and you cannot square a non-square matrix. Try:
> map( fcncarre, mat_a );
[ 1 4 9]
[ ]
[16 25 36]
Cheers,
Douglas
--
Douglas Wilhelm Harder ||\_ _\ /_/\_ _/\_\ /_ _/|| MM BSc MCpl (Retd)
University of Waterloo ||\ _\ /_/\_\ /_ _/
Waterloo Fractal Compression Project _\ / _/||
"douglas" _/\_\||\_ _/ /_/\_
http://links.uwaterloo.ca/~douglas _/||\_ _/ /_/\
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Sun, 2 Jun 2002 11:43:09 -0700 (PDT)
From: Robert Israel "israel"
To: "maple-list"
Subject: evalm and mapping of function
If you told it to map, it would map.
> map(fcncarre, mat_a);
If you say fcncarre(mat_a), you are telling Maple to square the matrix.
And since this is a 2 x 3 matrix, that is impossible.
The real question is, why does sin map into the matrix. In my opinion,
that is a bug. A function of a matrix should be defined using the
functional calculus, so that
sin(M) = (exponential(I*M)-exponential(-I*M))/(2*I). Of course this would
only be defined for square matrices.
Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Sun, 2 Jun 2002 19:42:41 -0400 (EDT)
From: Alain Goupil "goupil"
To: "maple-list"
Subject: evalm and mapping of function
Dear mr Gendron, The command map is the standard command to map a
function on the elements of a matrix as in the following :
> mat_a:=matrix([[1,2,3],[4,5,6]]):
>fcncarre:=x->x*x:
> map(fcncarre,mat_a);
matrix([[1, 4, 9], [16, 25, 36]])
Best regards,
Alain Goupil,
On Thu, 30 May 2002, Guy Gendron wrote:
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Tue, 4 Jun 2002 09:46:57 -0400 (EDT)
From: Carl Devore "devore"
To: "maple-list"
Subject: evalm and mapping of function
map(fcncarre, mat_a);
|
[View Complete Thread]
Previous by date: [MUG] 4 examples - an explanation?, Vladimir Bondarenko
Next by date: [MUG] LTP - Package for Lie Algebraic Computations, M Torres-Torriti
Previous thread: [MUG] minimizing functions - question, Alexander Serebrenik
Next thread: [MUG] LTP - Package for Lie Algebraic Computations, M Torres-Torriti
|