[Date Index]
[Thread Index]
[Author Index]
Re: Generate expression from result
*To*: mathgroup at smc.vnet.net
*Subject*: [mg32829] Re: Generate expression from result
*From*: Albert Retey <albert.retey at visualanalysis.com>
*Date*: Thu, 14 Feb 2002 01:43:57 -0500 (EST)
*Organization*: Visual Analysis AG
*References*: <a4aum0$bug$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Johannes Ludsteck wrote:
>
> Dear Mathgroup Members,
> I obtain the vector {x1,x2} as solution to a
> (rather complicated) equation system
>
> {x1,x2}=LinearSolve[m[{a1,a2}],b[{a1,a2}]]
> Of course, the xi are functions of {a1,a2}.
>
> Since I use the xi later on for complex operations,
> it would be of gread help if the arguments ai appeared
> in the vector {x1,x2}.
> Therefore I defined
> f[{a1_,a2_}]=LinearSolve[m[{a1,a2}],b[{a1,a2}]]
>
> (I need "=" here instead of ":=", since f[] is called
> often and the LinearSolve[] command uses some time,
> since the vectors {x1,x2} and {a1,a2} are only
> examples and can have dimension 10 to 20 in my application.
>
> Up to now the solution works well, but I am bothering
> whether this construction could generate modularity or
> naming problems, since the Assignment
> appears in a Module where {a1,a2} are defined as local variables.
>
> fun[...]:=Module[{a1,a2,f},
> ...
> f[{a1_,a2_}]=LinearSolve[m[{a1,a2}],b[{a1,a2}]]
> ...
> ]
>
I think they are save, as you can see when evaluating the following.
Module[{a1, a2, f}, f[{a1_, a2_}] = LinearSolve[m[{a1, a2}], b[{a1,
a2}]];
Print[DownValues[f]];
Print[a1];
Print[a2];
]
If things get more complicated I don't know, but why not just use
different names for the f-pattern to be on the save side?
HTH
Albert
Prev by Date:
**Re: Understanding the Output**
Next by Date:
**Re: Stumped again on a simple list**
Previous by thread:
**Generate expression from result**
Next by thread:
**Re: Generate expression from result**
| |