MathGroup Archive 2002

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

Search the Archive

Different Methods inside one package. More details

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33707] Different Methods inside one package. More details
  • From: "J. Guillermo Sanchez" <guillerm at usal.es>
  • Date: Tue, 9 Apr 2002 01:02:43 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

(* Dear friends,
I find that this pattern is mush better that the message that I post a 
few hours ago.
I wish build a package where the user, as one option,  can be choose one 
of three methods of evaluation, i.e: Automatic, LT or EV. Some thing 
like the silly example that follow. It works, I will appreciate any idea 
to enhanced it , i.e.: I need write EV and LT before Begin["`Private`"], 
how can avoid write its? .*)


BeginPackage["test`test1`"]

methodTest1::usage="SystemDSolve1. This is an example"

EV;LT; (*How can avoid write its?*)

Options[methodTest1]={Method\[Rule]Automatic};

Begin["`Private`"]

methodTest1[matrixA_, incond_, opts___]:=
  Module[{a, b, r, Opts},Opts= Method/.{opts}/.Options[methodTest1];
    Which[Opts=== Automatic,(a = matrixA; b = incond; r = a 
/ b),
      Opts=== LT,(a = matrixA; b = incond; r = a + b),
      Opts=== EV,(a = matrixA; b = incond; r = a - b)]]

End[]

Protect[methodTest1];

EndPackage[]

list1 ={{a11, a12 },{a21,a22}}

list2 = {b1, b2}

methodTest1[list1,list2]

methodTest1[list1,list2, Method\[Rule]LT]

methodTest1[list1,list2, Method\[Rule]EV]



  • Prev by Date: Re: function assignment to list of functions
  • Next by Date: Re: Symbols using Prolog
  • Previous by thread: Re: FullSimplify[Abs[Sign[x]],x>=0] equals 1?
  • Next by thread: Re: Different Methods inside one package. More details