Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: Français - Português - 日本語

Please note that the recommended version of Scilab is 6.1.1. This page might be outdated.
However, this page did not exist in the previous stable version.

Scilab help >> call_scilab API (Scilab engine) > creadcmat (obsolete)

creadcmat (obsolete)

Read a single complex or a matrix of complex from Scilab memory using call_scilab. Starting with Scilab 5.2, this function is obsolete. See API_Scilab: Complex double reading for remplacement.

int C2F(creadcmat)(char *name, int *m, int *n, double *scimat, unsigned long name_len);



The name of the future Scilab variable


Number of rows


Number of columns


The actual matrix of complex (array of double). Note that it is going to be stored in Scilab columnwise and the second half of the array is used for complex values.


The length of the variable name(fortran compatibility)


C2F is just a macro which provides to this function the ability to be called from fortran


This help describes how to use the function creadcmat.

Using this function will retrieve a variable called name from Scilab memory into a standard C double *.


/* Load the previously set variable B */
// See: modules/call_scilab/examples/basicExamples/readwritecomplexmatrix.c
int rowB_ = 0, colB_ = 0, lp_ = 0;
int i = 0,j = 0;

double *matrixOfComplexB = NULL;
char variableToBeRetrievedB[] = "B";

/* First, retrieve the size of the matrix */
C2F(cmatcptr)(variableToBeRetrievedB, &rowB_, &colB_, &lp_, strlen(variableToBeRetrievedB));

/* Alloc the memory */
matrixOfComplexB = (double*)malloc((rowB_*colB_*2)*sizeof(double));

/* Load the matrix */
C2F(creadcmat)(variableToBeRetrievedB,&rowB_,&colB_,matrixOfComplexB,strlen(variableToBeRetrievedB) );

printf("Display from B formated (size: %d, %d):\n",rowB_, colB_);
for(j = 0 ; j < rowB_ ; j++)
  for(i = 0 ; i < colB_ ; i++)
    /* Display the formated matrix ... the way the user
     * expect */
    printf("%5.2f + %5.2f.i  ",matrixOfComplexB[i * rowB_ + j],matrixOfComplexB[(rowB_*colB_)+(i * rowB_ + j)]);
  printf("\n"); /* New row of the matrix */

See Also

  • Call_Scilab — call_scilab is an interface which provides the ability to call Scilab engine from C/C++ code
  • api Scilab — api_scilab is the Scilab interface to read/write data from/to Scilab memory
  • API_Scilab: Complex double reading — How to read matrices of double in a gateway.
  • API_Scilab: Double writing — How to write matrices of doubles in a gateway.
  • SendScilabJob — Send a Scilab task from a C/C++ code (call_scilab)
  • StartScilab — Initializes and starts Scilab engine in Call Scilab
  • cwritecmat — Write a single complex or a matrix of complex into Scilab memory using call_scilab. Starting with Scilab 5.2, this function is obsolete. See API_Scilab: Complex double writing for remplacement.
  • Complex Management — How to manage Scilab's complex variable read and write process using call_scilab


Sylvestre Ledru

Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Mar 03 10:59:47 CET 2011