Different Methods inside one package
- To: mathgroup at smc.vnet.net
- Subject: [mg33715] [mg33715] Different Methods inside one package
- From: "J. Guillermo Sanchez" <guillerm at usal.es>
- Date: Tue, 9 Apr 2002 01:03:12 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
(* Dear friends, 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 this silly example *) BeginPackage["test`test`"] methodTest::usage="methodTest. This is an example" Options[methodTest]={Method\[Rule]Automatic}; Begin["`Private`"] methodTest[matrixA_, incond_, opts___]:= If[Automatic == Method/.{opts}/.Options[methodTest], Module[{a, b, r},(a = matrixA; b = incond; r = a b)]] methodTest[matrixA_, incond_, opts___]:= If[LT == Method/.{opts}/.Options[methodTest], Module[{a, b, r},(a = matrixA; b = incond; r = a /b)]] methodTest[matrixA_, incond_, opts___]:= If[EV == Method/.{opts}/.Options[methodTest], Module[{a, b, r},(a = matrixA; b = incond; r = a + b)]] End[] Protect[methodTest]; EndPackage[] list1 ={{a11, a12 },{a21,a22}} methodTest[list1,list2] methodTest[list1,list2, Method\[Rule]EV] methodTest[list1,list2, Method\[Rule]LT] (*How can I get that this example work?*)