MathGroup Archive 2001

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

Search the Archive

Re: Laveling solution in package. Problems with context

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31207] Re: Laveling solution in package. Problems with context
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Fri, 19 Oct 2001 03:11:57 -0400 (EDT)
  • References: <9qjjfr$j7u$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Guillerm,
Add the line
        q1;q2;
after the line
        Options[q] = {AI1 -> 0.3 AI, AI2 -> 0.6 AI, AI3 -> 0.1 AI};

This  will cause q1and q2 to be created in the context "Test`Test`".
You  might also wish to have usage messages for q, q1 and q2.

One other point:
I suggest using  opts___?OptionQ  instead of  opts___Rule.
Since options can use RuleDelayed and can be in nested lists.


--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

<guillerm at usal.es> wrote in message news:9qjjfr$j7u$1 at smc.vnet.net...
> I have a package such as the follow (it is an easy example of the real
package).
>
> BeginPackage["Test`Test`"]
>
> fTest::"usage" = "fTest gives solution."
>
> Options[q] = {AI1 -> 0.3 AI, AI2 -> 0.6 AI, AI3 -> 0.1 AI};
>
> Begin["`Private`"]
>
> fTest[int_List, t_, t1_, opts___Rule] := Module[{ic, sol},
>       ic = {AI1, AI2} /.{opts} /. Options[q];
>       sol = Dot[ic, int];
>       Thread[{q1[t1], q2[t1]} -> sol]];
>
> End[]
>
> Protect[fTest];
>
> EndPackage[]
>
> I test the package
>
> in[]:=fTest[{a1 Exp[-b1 t], a2 Exp[-b2 t]}, t, t1, AI3 -> 0.9 AI]
>
> out[]:={Test`Test`Private`q1[t1] -> (0.3*a1*AI)/E^(b1*t) + (0.6*a2*AI)/E^
> (b2*t), Test`Test`Private`q2[t1] -> (0.3*a1*AI)/E^(b1*t) +
(0.6*a2*AI)/E^(b2*t)}
>
> Of course, I receive the message that q1[t], q2[t] are defined in a
private
> context. How can I fix this problem?.
>
> I know that using fTest[int_List, t_, t1_, q1_, q2_, opts___Rule] the
problem
> is solved but I can avoid write q1 and q2 in  fTest.
>
>
>
>
> But I wish that the solution will be labeled with q1[t],
> q2[t].
>
> ---------------------------------------------
> This message was sent using Endymion MailMan.
> http://www.endymion.com/products/mailman/
>
>
>




  • Prev by Date: Re: Solve bug !!
  • Next by Date: Re: fonts
  • Previous by thread: Laveling solution in package. Problems with context
  • Next by thread: fonts