środa, 9 stycznia 2013

creating mathematica package

One can find some tips, how to create the mathematica package in web e.g.

http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=FAQ_Writing_Packages

or

http://www.nhn.ou.edu/~morrison/Mathematica/TipSheets/Packages.pdf


or

http://12000.org/my_notes/how_to_write_package_in_mathematica/report/report.htm


My simple advice is:

1) Write in one cell e.g.

BeginPackage["vertexKG`",{"HighEnergyPhysics`FeynCalc`"}]

Unprotect @@ Names["vertexKG`*"];
ClearAll @@ Names["vertexKG`*"];

EMv::usage = "EMvertex[mu,f1,f2,x,M]";

Begin["`Private`"]

EMv[mu_, f1_, f2_, x_, M_] := Module[{temp=0},

Return[temp]];


End[]

Protect @@ Names["vertexKG`*"];
EndPackage[]

My package requires another package of Mathematica: HighEnergyPhysics`FeynCalc`, it is a second argument of BeginPackage.

After BeginPackage I write the declaration of the functions, and in the private part the definitions.

2) Then in cell menu one must choose Initialization Cell

3) Save as file.m

3) Load as Get["D:\\myMathematicaLibries\\file.m"]

Brak komentarzy:

Prześlij komentarz