Re: MLPutRealList vs. sequence of MLPutDouble

• To: mathgroup at smc.vnet.net
• Subject: [mg61737] Re: MLPutRealList vs. sequence of MLPutDouble
• From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
• Date: Thu, 27 Oct 2005 05:54:31 -0400 (EDT)
• Organization: Uni Leipzig
• References: <djq618\$jb5\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi,

because

call in Mathematica SCRIPT_NAME[{x0,x1}]

and

for ( i=0; i<NUM_VARS; i++ ) { MLPutDouble(link,
x[i]); }

call in Mathematica

SCRIPT_NAME[x0,x1]

Regards
Jens

"Reese Jones" <rjones at sandia.gov> schrieb im
Newsbeitrag news:djq618\$jb5\$1 at smc.vnet.net...
| Hi
|   I am a new subscriber to the list and I have a
seemingly
| simple (read: stupid) question: why does this
code work
| when I send a sequence of reals and not work
when I send
| a list?
|
| <SNIP>
|        /* Now initialize and call Mathematica */
|        env = MLInitialize(NULL);
|        if (env == NULL) return 1;
|
|        if (link == NULL) return 1;
|
|
|        /* Load the compare function definition
into Mathematica */
1);
|
|        /* call the compare function with x[1],
x[2]*/
| #if REAL_LIST
| #else
NUM_VARS);
|        for ( i=0; i<NUM_VARS; i++ ) {
| #endif
|
|        /* skip any packets before the first
ReturnPacket
|           and then get the result from the
calculation   */
|        int pkt;
|        while( (pkt = MLNextPacket(link), pkt) &&
pkt != RETURNPKT) {
|                        fprintf( stderr, "2 Error
| %s.\n",
|        }
|
|        double fn_val=0.0;
|                fprintf( stderr, "3 Error
|        MLDeinitialize(env);
| <SNIP>
|
| this is the Mathematica script that is called
(it takes a list and
| returns a single value) :
|
| (* test[x_Real,x2_Real] := x; *)
| test[y_List] := y[[2]];
|
|
| this is the output:
|
| Error detected by MathLink: MLGet out of
sequence.
| test : { 0.616000, 29.000000} -> f: 0.000000
|
|
| thanks
| Reese
|
| --
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::
| Reese Jones
| Sandia National Laboratories, MS 9042, P.O. Box
0969
| Livermore, CA 94551
|
| phone: (925) 294-4744 or (800) 4SANDIA x4-4744
| fax:   (925) 294-1459
| e-mail: rjones at sandia.gov
|
:::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|

```

• Prev by Date: Re: ParametricPlot3D
• Next by Date: Re: aggregation of related elements in a list
• Previous by thread: MLPutRealList vs. sequence of MLPutDouble
• Next by thread: Re: Re: MLPutRealList vs. sequence of MLPutDouble