(*********************************************************************

Copyright 1989 by Roman E. Maeder

Adapted from
Roman E. Maeder: Programming in Mathematica, Addison-Wesley, 1989.

Permission is hereby granted to make copies of this file for
any purpose other than direct profit, or as part of a
commercial product, provided this copyright notice is left
intact. Sale, other than for the cost of media, is prohibited.

Permission is hereby granted to reproduce part or all of
this file, provided that the source is acknowledged.

*********************************************************************)

BeginPackage["RMPackages`VectorCalculus`"]

Div::usage = "Div[v, varlist] computes the divergence of
the vectorfield v w.r.t. the given variables in Cartesian coordinates."

Laplacian::usage = "Laplacian[s, varlist] computes the Laplacian of
the scalar field s w.r.t. the given variables in Cartesian coordinates."

Grad::usage = "Grad[s, varlist] computes the gradient of s
w.r.t. the given variables in Cartesian coordinates."

JacobianMatrix::usage = "JacobianMatrix[flist, varlist] computes the Jacobian of
the functions flist w.r.t. the given variables."

Begin["`Private`"]

Div[v_List, var_List] := Inner[D, v, var, Plus]

Grad[s_, var_List] := D[s, #]& /@ var

Laplacian[s_, var_List] := Div[ Grad[s, var], var]

JacobianMatrix[f_List, var_List] := Outer[D, f, var]

End[]

Protect[ Div, Laplacian, Grad, JacobianMatrix ]

EndPackage[]