MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: elementary questio about packages

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108265] Re: [mg108238] elementary questio about packages
  • From: Francisco Gutierrez <fgutiers2002 at yahoo.com>
  • Date: Fri, 12 Mar 2010 07:09:30 -0500 (EST)

Right Becko. And thanks to Leonid, David, and Patrick for their answers. But maybe to make it very clear I should provide a an example.
  
Take the following function:
trivialfunc[ind_, depend_] :=
  Module[{letsee, ineq1, ineq2, func}, letsee = Array[L, Length[depend]];
   ineq1 = MapThread[
       GreaterEqual, {letsee, Table[0, {Length[letsee]}]}];
   ineq2 = MapThread[
       GreaterEqual, {ind - letsee, Table[0, {Length[letsee]}]}];
   func = {ind.letsee};
   NMinimize[Flatten[{func, ineq1, ineq2}], Flatten[letsee]]]

Of course, it should send all the L's to 0. Note that the L's vary in size, according to the length of the two variables.
  
I make a package called trivial, and run the function with  an  x and a y.
x={1,2,3,4,5}
y={6,7,8,9,10}
  
trivialfunc[y,y]
And the output is:
{0.,{trivial2`Private`L[1]->0.,trivial2`Private`L[2]->0.,trivial2`Private`L[3]->0.,trivial2`Private`L[4]->0.,trivial2`Private`L[5]->0.}}
If I eliminate the Private I get pure nonsense, and if a declare the Ls in the module I get something of the form L$something, which I do not want either.
  
I would want it to be simply L[1]->0, etc, for a varying number of L's.
Thank you for any help
Fg

--- On Thu, 3/11/10, becko BECKO <becko565 at hotmail.com> wrote:


From: becko BECKO <becko565 at hotmail.com>
Subject: [mg108265] RE: [mg108238] elementary questio about packages
To: fgutiers2002 at yahoo.com, mathgroup at smc.vnet.net
Date: Thursday, March 11, 2010, 7:52 AM




Whenever you declare a function in a package that uses some temporary variables, you should use Module to declare those variables. If this does not help, perhaps you should post some code so that the guys here can see where the problem is.

> Date: Thu, 11 Mar 2010 06:37:35 -0500
> From: fgutiers2002 at yahoo.com
> Subject: [mg108238] elementary questio about packages
> To: mathgroup at smc.vnet.net
>
> Dear List:
> I made a package with a function that has a minimization. The minimization
> returns, as should be, the value of the optimization, and then the values
> of the variables, in the form {z1->10,z2->20,z3->50}.
>
> In the notebook, this works perfectly well. In the package, however, the function throws back the variables in the form {contextname`z1->10,contextname`z2->20}.
> This is obnoxious, and makes the result much harder to utilize. How can I avoid this? I tried deleting
> Begin["`Private`"], but then I got a completely crazy result.
> What should I do?
> Fg
>


  • Prev by Date: Re: Re: elementary questio about packages
  • Next by Date: Manipulate [ Show [graphics ]]]
  • Previous by thread: Re: elementary questio about packages
  • Next by thread: Re: elementary questio about packages