Subject: Announcing Math::Mathematica 1.0.4
From: [email-masked] (Ulrich Pfeifer)
Date: 24 Nov 1995 14:42:04 GMT
Newsgroups: comp.lang.perl.announce,comp.lang.perl.misc

Hi all!

Here is my first try in interfacing Mathematica to Perl. It is still
very basic now. But if someone else is thinking about that, he/she
will know no that he/she is not alone ;-)

You can get the packet soon from your nearest CPAN site as:

        Math-Mathematica-1.0.4.tar.gz

Appended the (even more basic) documentation. If you need more
details, look in the Mathematica.xs file. If you want more functions
supported try the mh2xs on your mathlink.h and append the stuff to the
xs file.

By the way 'Math::Mathematica' is really long. Any suggestions for an
alternate name?

Ulrich
------------------------------------------------------------------------
MATHEMATICA(1)                                     MATHEMATICA(1)

NAME
       Math::Mathematica - Communicate to Mathematica via
       MathLink

SYNOPSIS
       use Math::Mathematica;

       $link = new Math::Mathematica( MathLink args )

DESCRIPTION
       This is a very basic interface to the MathLink library of
       Mathematica. Mathematica is registered trademark of
       Wolfram Research, Inc. I use version 2.2. There are tree
       groups of functions.

       As-Is functions

       Some functions have the same interface as in MathLink
       itself. For example

               int MLPutSymbol(MLINK, char*);

       Can be called from Perl like:

               Math::Mathematica::PutSymbol($link,"FooBar");

       I recommend to use the OO-Syntax:

               $link->PutSymbol("FooBar");

       More perlish functions

       There are a couple of functions in MathLink which return a
       error code and deliver results via reference parameters.

               int MLGetSymbol(MLINK, char**);

       the Perl versions of these functions return the result as
       result of the function. If the return code of the MathLink
       function indicates an error, undef is returned instead.
       You can use defined to disambiguate undef and 0 for
       functions returning numeric values.

               if (defined($result = $link->GetSymbol)) {
                  ....
               }

       Convenience functions

       In Mathematica.pm there are few functions to support
       OO-style syntax.

       new  Is an alias for open. It takes a list of named
            arguments as the math of Mathematica program does. To
            use launch mode use e.g.:

                $link = new Math::Mathematica('-linkname', "math  -mathlink",
                                              '-linkmode', 'launch');

            If you want to connect over TCP enter the following
            line in a shell to start the server

                math -linkmode listen -linkprotocol TCP -linkname
            3000 -mathlink

            and use this in your script to connect:

                $link = new Math::Mathematica('-linkname', '3000',
                                              '-linkmode', 'Connect',
                                              '-linkhost', 'schroeder',
                                              '-linkprotocol', 'TCP',
                                              );

       DESTROY
            Is an alias For Close. So you do not need to close a
            connection - Perl will do it for you.

       Call Takes a list of arguments. The first is assumed to be
            a Mathematica function name, the rest the arguments
            to pass to Mathematica. Arguments may be numbers,
            strings or array references. The latter is assumed to
            point to a argument list for another function call.
            Perhaps the following example helps to clarify this:

                    $e = $link->Call('N', ['Exp',1], 20);

            Since Call is written in Perl, there is no way to
            distinguish between "1234" and 1234. So the functions
            guesses that you meant String if the argument
            contained a letter. Perhaps someone will write Call
            as xsub?

       Result
            Looks for a result from Mathematica and returns it.
            Caution this function just handles the most frequent
            cases. It dies if it runs in an unknown case ;-(

                    $link->PutSymbol('$Version');
                    $link->EndPacket();
                    $version = $link->Result();

BUGS
       Doubless many.

       The tests complain about acessing uninitialized values
       when testing the aruments for references:

           if (ref($_) eq 'ARRAY') ...

       This seems to be a bug of my perl version rather than one
       of PutCall.

Contribute
       That is it for now. Let me know if somebody uses this (1)
       and is willing to test (2) or to contribute (3). The
       latter is preferred ;-)

AUTHOR
       Ulrich Pfeifer <[email-masked]>

                                                                3

-- 
Ulrich  UNIVERSITAET-DORTMUND     telefax:  49 231 755 2405        /////
Pfeifer Lehrstuhl Informatik VI   voice:    49 231 755 3032  ____UNI DO
@RR     D-44221 Dortmund          postbox:  50 05 00         \\*\\////
http://ls6-www.informatik.uni-dortmund.de/WhoIsWhoAtLS6.html  \\\\\//