Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Re: Different Methods inside one package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33702] Re: Different Methods inside one package
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 9 Apr 2002 01:02:24 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <a8rh77$b6a$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

set up the code:

methodTest[Automatic,matrixA_?MatrixQ, incond_, opts___?OptionQ]:=
something
methodTest[LT,       matrixA_?MatrixQ, incond_, opts___?OptionQ]:=
somethingelse
methodTest[EV,       matrixA_?MatrixQ, incond_, opts___?OptionQ]:=
somethingdifferent

methodTest[matrixA_?MatrixQ, incond_, opts___?OptionQ]:=
  Module[{meth},
    meth=Method /. {opts} /. Options[methodTest];
    methodTest[method,matrixA,incond,opts]
   ]

Regards
  Jens 

"J. Guillermo Sanchez" wrote:
> 
> (* 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?*)


  • Prev by Date: Re: Symbols using Prolog
  • Next by Date: Re: Using rules from Solve
  • Previous by thread: Different Methods inside one package
  • Next by thread: RE: Different Methods inside one package