MathGroup Archive 2007

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

Search the Archive

Re: Please help in creating/installing my package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79328] Re: Please help in creating/installing my package
  • From: Peter Breitfeld <phbrf at t-online.de>
  • Date: Wed, 25 Jul 2007 01:58:30 -0400 (EDT)
  • References: <f84j48$pmr$1@smc.vnet.net>

jeremito schrieb:
> I have searched through this list and on the web, but haven't yet been
> able to find an explanation of how to write/install my own packages in
> Mathematica.
>
> I have a few functions that I want to be able to access from any
> Mathematica document.  I created my package "Arnoldi.m" (copied below)
> and put it into my ~/Library/Mathematica/Applications directory.  When
> I do
>
> <<Arnoldi.m
>
> There are no errors, but I can't use any of the functions I wrote.
> Can someone please help me learn how to write my own packages.
> Thanks,
> Jeremy
>
> BeginPackage["Arnoldi`"]
>
> arnoldi::usage = "{Q, H} = Arnoldi[A,q,iters]\nwhere A is a matrix, q
> \
> is the starting vector with same size as A, and iters is the number \
> of Arnoldi Iterations.  Arnoldi returns: orthonormal basis vectors, \
> columsn of Q; upper Hessenberg matrix, H."
>
[*** snipp ***]

The following line should be Begin["Private`"] instead of Begin["Arnoldi]

> Begin["Arnoldi`"]
>
> arnoldi[A_, v_, iters_] := (
>   (* *)
>   invariant = False;
>   m = Length[A];
>   If[iters > m,
>    Print["Iterations cannot be greater than size of matrix."];
>    iterations = m;
>    , iterations = iters];
>   (*Print["Iterations = ",iterations]*);
>
>   H = ConstantArray[0, {iterations + 1, iterations}];
>   Subscript[q, 1] = v/Norm[v];
>
[*** snipp ***] 
> End[]
>
> EndPackage[]
>
>

Gruss Peter
-- 
==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de


  • Prev by Date: Re: How to draw a discontinuous function (set of points)
  • Next by Date: Re: style question
  • Previous by thread: RE: Please help in creating/installing my package
  • Next by thread: Re: Please help in creating/installing my package