WSGetRealArray()
This feature is not supported on the Wolfram Cloud.

int WSGetRealArray(WSLINK link,double **a,long **dims,char ***heads,long *d)
gets an array of floating-point numbers from the WSTP connection specified by link, storing the array in a, its dimensions in dims and its depth in d.

DetailsDetails

  • The array a is laid out in memory like a C array declared as .
  • heads gives a list of character strings corresponding to the names of symbols that appear as heads at each level in the array.
  • WSGetRealArray() allocates memory which must be released by calling WSDisownRealArray(). If WSGetRealArray() fails and the function's return value indicates an error, do not call WSReleaseRealArray() on the contents of a.
  • WSGetRealArray() returns immutable data.
  • WSGetRealArray() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSGetRealArray() fails.
  • WSGetRealArray() is equivalent to WSGetReal64Array().

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "wstp.h"

/* read an array of double-precision floating-point numbers from a link */

void f(MLINK lp)
{
    double *data;
    long *dims;
    char **heads;
    long d; /* stores the rank of the array */

    if(! WSGetRealArray(lp, &data, &dims, &heads, &d))
        {
            /* unable to read the array from lp */
            return;
        }

    /* ... */

    WSDisownRealArray(lp, data, dims, heads, d);    
}