2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2008 - INRIA - Vincent COUVERT
4 * Copyright (C) 2010 - DIGITEO - Yann COLLETTE
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
17 #include "CreateMatlabVariable.h"
18 #include "api_scilab.h"
19 #include "sci_malloc.h"
21 int CreateDoubleVariable(void *pvApiCtx, int iVar, matvar_t *matVariable, int * parent, int item_position)
23 int nbRow = 0, nbCol = 0;
24 mat_complex_split_t *mat5ComplexData = NULL;
29 if (matVariable->rank == 2) /* 2-D array */
31 nbRow = (int)matVariable->dims[0];
32 nbCol = (int)matVariable->dims[1];
33 if (matVariable->isComplex == 0)
37 sciErr = createMatrixOfDouble(pvApiCtx, iVar, nbRow, nbCol, (double*)matVariable->data);
40 printError(&sciErr, 0);
46 sciErr = createMatrixOfDoubleInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol, (double*)matVariable->data);
49 printError(&sciErr, 0);
56 /* Since MATIO 1.3.2 data is a ComplexSplit for MAT4 and MAT5 formats */
57 mat5ComplexData = matVariable->data;
60 sciErr = createComplexMatrixOfDouble(pvApiCtx, iVar, nbRow, nbCol, (double*)mat5ComplexData->Re, (double*)mat5ComplexData->Im);
64 sciErr = createComplexMatrixOfDoubleInList(pvApiCtx, iVar, parent, item_position, nbRow, nbCol,
65 (double*)mat5ComplexData->Re, (double*)mat5ComplexData->Im);
69 else /* Multi-dimension array -> Scilab HyperMatrix */
71 piDims = (int *) MALLOC(matVariable->rank * sizeof(int));
72 for (i = 0 ; i < matVariable->rank ; ++i)
74 piDims[i] = (int)matVariable->dims[i];
77 CreateHyperMatrixVariable(pvApiCtx, iVar, matVariable->class_type, &matVariable->isComplex, &matVariable->rank,
78 piDims, matVariable, parent, item_position);