function mapleinit(arg)
%MAPLEINIT MEX file initialization of the Maple Kernel.
%   MAPLEINIT is called by MAPLEMEX to initialize the Maple Kernel. 
%   It should never be run directly by itself.
%
%   MAPLEINIT determines the path to the directory containing the Maple
%   Library, loads the linear algebra package, initializes Digits,
%   and establishes several aliases. 
%
%   This M-file, "symbolic/mapleinit.m", may be modified to access
%   a copy of the Maple V, Release 4, Library available elsewhere.

%   Copyright (c) 1993-1999 The Mathworks, Inc. All Rights Reserved.
%   $Revision: 1.33 $  $Date: 1999/01/04 21:55:05 $

% If you already have a copy of the Library for Maple V, Release 4,
% you may modify the following code to set "maplelib" to the full
% path name of that library, e.g. maplelib = '/usr/local/Maple/lib',
% or maplelib = 'C:MAPLE\LIB', or maplelib = 'MyDisk:Maple:Lib'.
% Then do a "clear maplemex" from the command-line to re-initialize
% the Maple kernel to use the new path. You can then delete the copy 
% of the Maple Library that is distributed with MATLAB.
% Exception: DEC Alpha OSF/1 requires a separate Maple V, Release 4 Library
% called lib64. Both lib and lib64 can coexist in the same directory.
%
% EDIT the following three lines if you already have a copy of the Library.

already_have_Maple = 0;
if (already_have_Maple)
   maplelib = '.....';
else
%  Set library path to the Maple library in @symlibs.
   maplelib = which('mapleinit');
   maplelib = [maplelib(1:findstr(maplelib,'mapleinit')-1) '@symlibs'];
   maplelib = [maplelib filesep 'lib'];
end

% Must be called by maplemex.
if (nargin < 1) | ~strcmp(arg,'maplemex')
   error('mapleinit must be called by maplemex')
end

% Inform Maple of path to its library.
maplemex(maplelib,0);

% Load linear algebra package, set digits.
maplemex('with(linalg):');
maplemex('readlib(ifactor):');
maplemex('with(inttrans):');
maplemex('readlib(ztrans):');
maplemex('readlib(hypergeom):');
maplemex('readlib(C):');
maplemex('Digits := 32;');

% Establish aliases.
maplemex('alias(I=I, i=sqrt(-1), j=sqrt(-1), pi=Pi, eye=&*());');
maplemex('alias(log=ln, inf=infinity, Inf=infinity, fix=trunc);');
maplemex('alias(asin=arcsin, acos=arccos, atan=arctan);');
maplemex('alias(asinh=arcsinh, acosh=arccosh, atanh=arctanh);');
maplemex('alias(acsc=arccsc, asec=arcsec, acot=arccot);');
maplemex('alias(acsch=arccsch, asech=arcsech, acoth=arccoth);');
maplemex('alias(besselj=BesselJ, bessely=BesselY);');
maplemex('alias(besseli=BesselI, besselk=BesselK);');
maplemex('alias(sinint=Si, cosint=Ci, lambertw=LambertW, zeta=Zeta);');
maplemex('alias(gamma=GAMMA, eulergamma=gamma, conj=conjugate);');
