src/c/CreateIntegerVariable.c \
src/c/CreateSparseVariable.c \
src/c/GetMatlabVariable.c \
- src/c/GetMlistVariable.c \
- src/c/GetSparseVariable.c
+ src/c/GetMlistVariable.c
#### List of the C++ files ####
MATIO_CPP_SOURCES = \
src/cpp/ConvertSciVarToMatVar.cpp \
src/cpp/GetIntegerVariable.cpp \
src/cpp/GetCharVariable.cpp \
- src/cpp/GetDoubleVariable.cpp
+ src/cpp/GetDoubleVariable.cpp \
+ src/cpp/GetSparseVariable.cpp
libscimatio_la_LDFLAGS = $(AM_LDFLAGS)
src/c/CreateCharVariable.c src/c/CreateDoubleVariable.c \
src/c/CreateIntegerVariable.c src/c/CreateSparseVariable.c \
src/c/GetMatlabVariable.c src/c/GetMlistVariable.c \
- src/c/GetSparseVariable.c src/cpp/CreateCellVariable.cpp \
+ src/cpp/CreateCellVariable.cpp \
src/cpp/CreateHyperMatrixVariable.cpp \
src/cpp/CreateMatlabTreeVariable.cpp \
src/cpp/GetCellVariable.cpp src/cpp/GetStructVariable.cpp \
src/cpp/CreateStructVariable.cpp \
src/cpp/ConvertSciVarToMatVar.cpp \
src/cpp/GetIntegerVariable.cpp src/cpp/GetCharVariable.cpp \
- src/cpp/GetDoubleVariable.cpp
+ src/cpp/GetDoubleVariable.cpp src/cpp/GetSparseVariable.cpp
am__dirstamp = $(am__leading_dot)dirstamp
@MATIO_TRUE@am__objects_1 = \
@MATIO_TRUE@ src/c/libscimatio_algo_la-matfile_manager.lo \
@MATIO_TRUE@ src/c/libscimatio_algo_la-CreateIntegerVariable.lo \
@MATIO_TRUE@ src/c/libscimatio_algo_la-CreateSparseVariable.lo \
@MATIO_TRUE@ src/c/libscimatio_algo_la-GetMatlabVariable.lo \
-@MATIO_TRUE@ src/c/libscimatio_algo_la-GetMlistVariable.lo \
-@MATIO_TRUE@ src/c/libscimatio_algo_la-GetSparseVariable.lo
+@MATIO_TRUE@ src/c/libscimatio_algo_la-GetMlistVariable.lo
@MATIO_TRUE@am__objects_2 = \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-CreateCellVariable.lo \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-CreateHyperMatrixVariable.lo \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-ConvertSciVarToMatVar.lo \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetIntegerVariable.lo \
@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetCharVariable.lo \
-@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetDoubleVariable.lo
+@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetDoubleVariable.lo \
+@MATIO_TRUE@ src/cpp/libscimatio_algo_la-GetSparseVariable.lo
am_libscimatio_algo_la_OBJECTS = $(am__objects_1) $(am__objects_2)
libscimatio_algo_la_OBJECTS = $(am_libscimatio_algo_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
@MATIO_TRUE@ src/c/CreateIntegerVariable.c \
@MATIO_TRUE@ src/c/CreateSparseVariable.c \
@MATIO_TRUE@ src/c/GetMatlabVariable.c \
-@MATIO_TRUE@ src/c/GetMlistVariable.c \
-@MATIO_TRUE@ src/c/GetSparseVariable.c
+@MATIO_TRUE@ src/c/GetMlistVariable.c
#### List of the C++ files ####
@MATIO_TRUE@ src/cpp/ConvertSciVarToMatVar.cpp \
@MATIO_TRUE@ src/cpp/GetIntegerVariable.cpp \
@MATIO_TRUE@ src/cpp/GetCharVariable.cpp \
-@MATIO_TRUE@ src/cpp/GetDoubleVariable.cpp
+@MATIO_TRUE@ src/cpp/GetDoubleVariable.cpp \
+@MATIO_TRUE@ src/cpp/GetSparseVariable.cpp
@MATIO_TRUE@libscimatio_la_LDFLAGS = $(AM_LDFLAGS)
@MATIO_FALSE@GATEWAY_CPP_SOURCES =
src/c/$(DEPDIR)/$(am__dirstamp)
src/c/libscimatio_algo_la-GetMlistVariable.lo: src/c/$(am__dirstamp) \
src/c/$(DEPDIR)/$(am__dirstamp)
-src/c/libscimatio_algo_la-GetSparseVariable.lo: src/c/$(am__dirstamp) \
- src/c/$(DEPDIR)/$(am__dirstamp)
src/cpp/$(am__dirstamp):
@$(MKDIR_P) src/cpp
@: > src/cpp/$(am__dirstamp)
src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
src/cpp/libscimatio_algo_la-GetDoubleVariable.lo: \
src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libscimatio_algo_la-GetSparseVariable.lo: \
+ src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
libscimatio-algo.la: $(libscimatio_algo_la_OBJECTS) $(libscimatio_algo_la_DEPENDENCIES) $(EXTRA_libscimatio_algo_la_DEPENDENCIES)
$(AM_V_CXXLD)$(CXXLINK) $(libscimatio_algo_la_OBJECTS) $(libscimatio_algo_la_LIBADD) $(LIBS)
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-CreateSparseVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-GetMatlabVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-GetMlistVariable.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-GetSparseVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscimatio_algo_la-matfile_manager.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-ConvertSciVarToMatVar.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-CreateCellVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetCharVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetDoubleVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetIntegerVariable.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetSparseVariable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libscimatio_algo_la-GetStructVariable.Plo@am__quote@
.c.o:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libscimatio_algo_la-GetMlistVariable.lo `test -f 'src/c/GetMlistVariable.c' || echo '$(srcdir)/'`src/c/GetMlistVariable.c
-src/c/libscimatio_algo_la-GetSparseVariable.lo: src/c/GetSparseVariable.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/libscimatio_algo_la-GetSparseVariable.lo -MD -MP -MF src/c/$(DEPDIR)/libscimatio_algo_la-GetSparseVariable.Tpo -c -o src/c/libscimatio_algo_la-GetSparseVariable.lo `test -f 'src/c/GetSparseVariable.c' || echo '$(srcdir)/'`src/c/GetSparseVariable.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libscimatio_algo_la-GetSparseVariable.Tpo src/c/$(DEPDIR)/libscimatio_algo_la-GetSparseVariable.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/c/GetSparseVariable.c' object='src/c/libscimatio_algo_la-GetSparseVariable.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libscimatio_algo_la-GetSparseVariable.lo `test -f 'src/c/GetSparseVariable.c' || echo '$(srcdir)/'`src/c/GetSparseVariable.c
-
sci_gateway/c/libscimatio_la-gw_matio.lo: sci_gateway/c/gw_matio.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sci_gateway/c/libscimatio_la-gw_matio.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscimatio_la-gw_matio.Tpo -c -o sci_gateway/c/libscimatio_la-gw_matio.lo `test -f 'sci_gateway/c/gw_matio.c' || echo '$(srcdir)/'`sci_gateway/c/gw_matio.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscimatio_la-gw_matio.Tpo sci_gateway/c/$(DEPDIR)/libscimatio_la-gw_matio.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscimatio_algo_la-GetDoubleVariable.lo `test -f 'src/cpp/GetDoubleVariable.cpp' || echo '$(srcdir)/'`src/cpp/GetDoubleVariable.cpp
+src/cpp/libscimatio_algo_la-GetSparseVariable.lo: src/cpp/GetSparseVariable.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libscimatio_algo_la-GetSparseVariable.lo -MD -MP -MF src/cpp/$(DEPDIR)/libscimatio_algo_la-GetSparseVariable.Tpo -c -o src/cpp/libscimatio_algo_la-GetSparseVariable.lo `test -f 'src/cpp/GetSparseVariable.cpp' || echo '$(srcdir)/'`src/cpp/GetSparseVariable.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libscimatio_algo_la-GetSparseVariable.Tpo src/cpp/$(DEPDIR)/libscimatio_algo_la-GetSparseVariable.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/cpp/GetSparseVariable.cpp' object='src/cpp/libscimatio_algo_la-GetSparseVariable.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscimatio_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libscimatio_algo_la-GetSparseVariable.lo `test -f 'src/cpp/GetSparseVariable.cpp' || echo '$(srcdir)/'`src/cpp/GetSparseVariable.cpp
+
mostlyclean-libtool:
-rm -f *.lo
<ClCompile Include="src\cpp\GetCharVariable.cpp" />
<ClCompile Include="src\cpp\GetDoubleVariable.cpp" />
<ClCompile Include="src\cpp\GetIntegerVariable.cpp" />
+ <ClCompile Include="src\cpp\GetSparseVariable.cpp" />
<ClCompile Include="src\cpp\GetStructVariable.cpp" />
<ClCompile Include="src\c\CreateBooleanVariable.c" />
<ClCompile Include="src\c\CreateCharVariable.c" />
<ClCompile Include="src\c\DllmainMatio.c" />
<ClCompile Include="src\c\GetMatlabVariable.c" />
<ClCompile Include="src\c\GetMlistVariable.c" />
- <ClCompile Include="src\c\GetSparseVariable.c" />
<ClCompile Include="sci_gateway\c\gw_matio.c" />
<ClCompile Include="src\c\matfile_manager.c" />
</ItemGroup>
<ClCompile Include="src\c\GetMlistVariable.c">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\c\GetSparseVariable.c">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="sci_gateway\c\gw_matio.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\cpp\GetCharVariable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\cpp\GetSparseVariable.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\c\CreateMatlabVariable.h">
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008 - INRIA - Vincent COUVERT
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
- *
- */
-
-#include "GetMatlabVariable.h"
-#include "api_scilab.h"
-#include "scisparse.h"
-
-matvar_t *GetSparseVariable(void *pvApiCtx, int iVar, const char *name, int * parent, int item_position)
-{
- int K = 0;
- int rank = 0;
- size_t* pszDims = NULL;
- int *dims = NULL;
- double *data = NULL;
- matvar_t *createdVar = NULL;
- mat_sparse_t *sparseData = NULL;
- SciSparse scilabSparse;
- int *colIndexes = NULL;
- int *rowIndexes = NULL;
- int * var_addr = NULL;
- int * item_addr = NULL;
- int var_type;
- SciErr sciErr;
-
- if (parent == NULL)
- {
- sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &var_addr);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- sciErr = getVarType(pvApiCtx, var_addr, &var_type);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- }
- else
- {
- sciErr = getListItemAddress(pvApiCtx, parent, item_position, &item_addr);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- sciErr = getVarType(pvApiCtx, item_addr, &var_type);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- }
-
- if (var_type == sci_sparse)
- {
- sparseData = (mat_sparse_t*) MALLOC(sizeof(mat_sparse_t));
- if (sparseData == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
- return FALSE;
- }
-
- rank = 2;
- if ((dims = (int*) MALLOC (sizeof(int) * rank)) == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
- return NULL;
- }
-
- if (isVarComplex(pvApiCtx, var_addr))
- {
- if (parent == NULL)
- {
- getAllocatedComplexSparseMatrix(pvApiCtx, var_addr, &dims[1], &dims[0],
- &scilabSparse.nel, &scilabSparse.mnel,
- &scilabSparse.icol, &scilabSparse.R,
- &scilabSparse.I);
- }
- else
- {
- sciErr = getSparseMatrixInList(pvApiCtx, parent, item_position, &dims[1], &dims[0],
- &scilabSparse.nel, NULL, NULL, NULL);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- scilabSparse.mnel = (int *)MALLOC(dims[1] * sizeof(int));
- if (scilabSparse.mnel == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
-
- FREE(scilabSparse.mnel);
-
- return FALSE;
- }
- scilabSparse.icol = (int *)MALLOC(scilabSparse.nel * sizeof(int));
- if (scilabSparse.icol == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
-
- FREE(scilabSparse.mnel);
- FREE(scilabSparse.icol);
-
- return FALSE;
- }
- scilabSparse.R = (double *)MALLOC(scilabSparse.nel * sizeof(double));
- if (scilabSparse.R == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
-
- FREE(scilabSparse.mnel);
- FREE(scilabSparse.icol);
- FREE(scilabSparse.R);
-
- return FALSE;
- }
- scilabSparse.I = (double *)MALLOC(scilabSparse.nel * sizeof(double));
- if (scilabSparse.I == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
-
- FREE(scilabSparse.mnel);
- FREE(scilabSparse.icol);
- FREE(scilabSparse.R);
- FREE(scilabSparse.I);
-
- return FALSE;
- }
- sciErr = getComplexSparseMatrixInList(pvApiCtx, parent, item_position, &dims[1], &dims[0],
- &scilabSparse.nel, &scilabSparse.mnel,
- &scilabSparse.icol, &scilabSparse.R, &scilabSparse.I);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- }
-
- scilabSparse.it = 1;
-
- }
- else
- {
- if (parent == NULL)
- {
- getAllocatedSparseMatrix(pvApiCtx, var_addr, &dims[1], &dims[0],
- &scilabSparse.nel, &scilabSparse.mnel,
- &scilabSparse.icol, &scilabSparse.R);
- }
- else
- {
- sciErr = getSparseMatrixInList(pvApiCtx, parent, item_position, &dims[1], &dims[0],
- &scilabSparse.nel, NULL, NULL, NULL);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- scilabSparse.mnel = (int *)MALLOC(dims[1] * sizeof(int));
- if (scilabSparse.mnel == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
-
- FREE(scilabSparse.mnel);
-
- return FALSE;
- }
- scilabSparse.icol = (int *)MALLOC(scilabSparse.nel * sizeof(int));
- if (scilabSparse.icol == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
-
- FREE(scilabSparse.mnel);
- FREE(scilabSparse.icol);
-
- return FALSE;
- }
- scilabSparse.R = (double *)MALLOC(scilabSparse.nel * sizeof(double));
- if (scilabSparse.R == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
-
- FREE(scilabSparse.mnel);
- FREE(scilabSparse.icol);
- FREE(scilabSparse.R);
-
- return FALSE;
- }
- sciErr = getSparseMatrixInList(pvApiCtx, parent, item_position, &dims[1], &dims[0],
- &scilabSparse.nel, &scilabSparse.mnel,
- &scilabSparse.icol, &scilabSparse.R);
- if (sciErr.iErr)
- {
- printError(&sciErr, 0);
- return 0;
- }
- }
-
- scilabSparse.it = 0;
- }
-
- scilabSparse.m = dims[1];
- scilabSparse.n = dims[0];
-
- /* colIndexes = (int*) MALLOC(sizeof(int) * (scilabSparse.nel + 1)); */
- colIndexes = (int*) MALLOC(sizeof(int) * (scilabSparse.m + 1));
- if (colIndexes == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
-
- if (scilabSparse.it)
- {
- freeAllocatedComplexSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R, scilabSparse.I);
- }
- else
- {
- freeAllocatedSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R);
- }
-
- return FALSE;
- }
-
- colIndexes[0] = 0;
- /* for (K=0; K<scilabSparse.nel; K++) */
- for (K = 0; K < scilabSparse.m; K++)
- {
- colIndexes[K + 1] = colIndexes[K] + scilabSparse.mnel[K];
- }
-
- rowIndexes = (int*) MALLOC(sizeof(int) * scilabSparse.nel);
- if (rowIndexes == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
-
- if (scilabSparse.it)
- {
- freeAllocatedComplexSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R, scilabSparse.I);
- }
- else
- {
- freeAllocatedSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R);
- }
-
- return FALSE;
- }
-
- for (K = 0; K < scilabSparse.nel; K++)
- {
- rowIndexes[K] = scilabSparse.icol[K] - 1;
- }
-
- if (scilabSparse.it == 0) /* Real sparse */
- {
- if ((data = (double*) MALLOC(sizeof(double) * scilabSparse.nel)) == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
- FREE(rowIndexes);
- FREE(colIndexes);
- if (scilabSparse.it)
- {
- freeAllocatedComplexSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R, scilabSparse.I);
- }
- else
- {
- freeAllocatedSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R);
- }
-
- return 0;
- }
-
- for (K = 0; K < scilabSparse.nel; K++)
- {
- data[K] = scilabSparse.R[K];
- }
- }
- else
- {
- if ((data = (double*) MALLOC(2 * sizeof(double) * scilabSparse.nel)) == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
- FREE(rowIndexes);
- FREE(colIndexes);
- if (scilabSparse.it)
- {
- freeAllocatedComplexSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R, scilabSparse.I);
- }
- else
- {
- freeAllocatedSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R);
- }
-
- return FALSE;
- }
-
- for (K = 0; K < scilabSparse.nel; K++)
- {
- data[K] = scilabSparse.R[K];
- }
-
- for (K = 0; K < scilabSparse.nel; K++)
- {
- data[K + scilabSparse.nel] = scilabSparse.I[K];
- }
- }
-
- /* Create Matlab Sparse matrix data */
- sparseData->nzmax = scilabSparse.nel;
- sparseData->nir = scilabSparse.nel;
- sparseData->ir = rowIndexes;
- /* sparseData->njc = scilabSparse.nel + 1; */
- sparseData->njc = scilabSparse.m + 1;
- sparseData->jc = colIndexes;
- sparseData->ndata = scilabSparse.nel;
- sparseData->data = (void*) data;
-
- pszDims = (size_t*) MALLOC(rank * sizeof(size_t));
- if (pszDims == NULL)
- {
- Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
-
- if (scilabSparse.it)
- {
- freeAllocatedComplexSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R, scilabSparse.I);
- }
- else
- {
- freeAllocatedSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R);
- }
-
- return 0;
- }
-
- for (K = 0; K < rank; K++)
- {
- pszDims[K] = dims[K];
- }
-
- if (scilabSparse.it == 0)
- {
- createdVar = Mat_VarCreate(name, MAT_C_SPARSE, MAT_T_DOUBLE, rank, pszDims, sparseData, 0 | MAT_F_DONT_COPY_DATA);
- }
- else
- {
- createdVar = Mat_VarCreate(name, MAT_C_SPARSE, MAT_T_DOUBLE, rank, pszDims, sparseData, MAT_F_COMPLEX | MAT_F_DONT_COPY_DATA);
-
- if (data)
- {
- FREE(data);
- }
- }
-
- if (dims)
- {
- FREE(dims);
- }
-
- if (pszDims)
- {
- FREE(pszDims);
- }
- }
- else
- {
- Scierror(999, _("%s: Wrong type for first input argument: Sparse matrix expected.\n"), "GetSparseVariable");
- }
-
- if (scilabSparse.it)
- {
- freeAllocatedComplexSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R, scilabSparse.I);
- }
- else
- {
- freeAllocatedSparseMatrix(scilabSparse.mnel, scilabSparse.icol, scilabSparse.R);
- }
-
- return createdVar;
-}
break;
case GenericType::ScilabSparse:
{
- Sparse* pSparse = pIT->getAs<Sparse>();
- if (pSparse->isComplex())
- {
- double* pdReal = new double[isize];
- double* pdImg = new double[isize];
- std::complex<double> dbl;
- for (int i = 0; i < isize; i++)
- {
- dbl = pSparse->getImg(i);
- pdReal[i] = dbl.real();
- pdImg[i] = dbl.imag();
- }
- mat5ComplexData.Re = pdReal;
- mat5ComplexData.Im = pdImg;
- return Mat_VarCreate(name, MAT_C_DOUBLE, MAT_T_DOUBLE, Dims, psize_t, &mat5ComplexData, MAT_F_COMPLEX);
- }
- else
- {
- double* pdReal = new double[isize];
- for (int i = 0; i < isize; i++)
- {
- pdReal[i] = pSparse->get(i);
- }
- return Mat_VarCreate(name, MAT_C_DOUBLE, MAT_T_DOUBLE, Dims, psize_t, pdReal, 0);
- }
+ return GetSparseMatVar(pIT->getAs<Sparse>(), name);
}
break;
case GenericType::ScilabCell:
#include "struct.hxx"
#include "context.hxx"
#include "string.hxx"
+#include "sparse.hxx"
extern "C"
{
matvar_t* GetCharMatVar(types::String* pStr, const char* name);
+matvar_t* GetSparseMatVar(types::Sparse* pSparse, const char* name);
+
#endif /* !__GETMATLABVARIABLE_HXX__ */
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA - Vincent COUVERT
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "GetMatlabVariable.hxx"
+
+extern "C"
+{
+#include "api_scilab.h"
+#include "scisparse.h"
+}
+
+matvar_t *GetSparseVariable(void *pvApiCtx, int iVar, const char *name, int * parent, int item_position)
+{
+
+ types::GatewayStruct* pGS = (types::GatewayStruct*)pvApiCtx;
+ types::typed_list in = *pGS->m_pIn;
+
+ if (in[iVar - 1]->isSparse() == false)
+ {
+ Scierror(999, _("%s: Wrong type for first input argument: Sparse matrix expected.\n"), "GetSparseVariable");
+ return NULL;
+ }
+
+ types::Sparse* pSparse = in[iVar - 1]->getAs<types::Sparse>();
+
+ return GetSparseMatVar(pSparse, name);
+}
+
+matvar_t* GetSparseMatVar(types::Sparse* pSparse, const char *name)
+{
+ int Dims = pSparse->getDims();
+ int* pDims = pSparse->getDimsArray();
+ int isize = pSparse->getSize();
+ size_t* psize_t = NULL;
+ matvar_t * pMatVarOut = NULL;
+
+ if (pSparse->getDims() > 2)
+ {
+ Scierror(999, _("%s: No more memory.\n"), "GetSparseMatVar");
+ return NULL;
+ }
+
+ mat_sparse_t *sparseData = NULL;
+ sparseData = (mat_sparse_t*)MALLOC(sizeof(mat_sparse_t));
+ if (sparseData == NULL)
+ {
+ Scierror(999, _("%s: No more memory.\n"), "GetSparseMatVar");
+ return NULL;
+ }
+
+ int nonZeros = pSparse->nonZeros();
+ int* colPos = new int[nonZeros];
+ int* itemsRow = new int[pSparse->getRows()];
+ pSparse->getNbItemByRow(itemsRow);
+
+ int* colIndexes = (int*)MALLOC(sizeof(int) * (pSparse->getRows() + 1));
+ if (colIndexes == NULL)
+ {
+ FREE(sparseData);
+ Scierror(999, _("%s: No more memory.\n"), "GetSparseMatVar");
+ return NULL;
+ }
+
+ colIndexes[0] = 0;
+
+ for (int K = 0; K < pSparse->getRows(); ++K)
+ {
+ colIndexes[K + 1] = colIndexes[K] + itemsRow[K];
+ }
+
+ int* rowIndexes = (int*)MALLOC(sizeof(int) * nonZeros);
+ if (rowIndexes == NULL)
+ {
+ FREE(sparseData);
+ FREE(colIndexes);
+ Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
+ return NULL;
+ }
+
+ pSparse->getColPos(colPos);
+ for (int K = 0; K < nonZeros; ++K)
+ {
+ rowIndexes[K] = colPos[K] - 1;
+ }
+
+
+ /* Create Matlab Sparse matrix data */
+ sparseData->nzmax = nonZeros;
+ sparseData->nir = nonZeros;
+ sparseData->ir = rowIndexes;
+ /* sparseData->njc = scilabSparse.nel + 1; */
+ sparseData->njc = pSparse->getRows() + 1;
+ sparseData->jc = colIndexes;
+ sparseData->ndata = nonZeros;
+ /* get position data*/
+ int* iPositVal = new int[nonZeros];
+
+ int idx = 0;
+ for (int i = 0; i < pSparse->getRows(); i++)
+ {
+ for (int j = 0; j < itemsRow[i]; j++)
+ {
+ iPositVal[idx] = (colPos[idx] - 1) * pSparse->getRows() + i;
+ ++idx;
+ }
+ }
+
+ psize_t = (size_t*)MALLOC(Dims * sizeof(size_t));
+ if (rowIndexes == NULL)
+ {
+ FREE(sparseData);
+ FREE(rowIndexes);
+ FREE(colIndexes);
+ Scierror(999, _("%s: No more memory.\n"), "GetSparseVariable");
+ return NULL;
+ }
+
+ psize_t[0] = (int)pDims[1];
+ psize_t[1] = (int)pDims[0];
+
+
+
+ if (pSparse->isComplex())
+ {
+ struct mat_complex_split_t* data;
+ double* dataReal = NULL;
+ double* dataImg = NULL;
+ if ((dataReal = (double*)MALLOC(sizeof(double) * nonZeros)) == NULL)
+ {
+ FREE(psize_t);
+ FREE(sparseData);
+ FREE(colIndexes);
+ FREE(rowIndexes);
+ Scierror(999, _("%s: No more memory.\n"), "GetSparseMatVar");
+ return NULL;
+ }
+
+ if ((dataImg = (double*)MALLOC(sizeof(double) * nonZeros)) == NULL)
+ {
+ FREE(dataReal);
+ FREE(psize_t);
+ FREE(sparseData);
+ FREE(colIndexes);
+ FREE(rowIndexes);
+ Scierror(999, _("%s: No more memory.\n"), "GetSparseMatVar");
+ return NULL;
+ }
+
+ if ((data = (mat_complex_split_t*)MALLOC(sizeof(mat_complex_split_t))) == NULL)
+ {
+ FREE(dataImg);
+ FREE(dataReal);
+ FREE(psize_t);
+ FREE(sparseData);
+ FREE(colIndexes);
+ FREE(rowIndexes);
+ Scierror(999, _("%s: No more memory.\n"), "GetSparseMatVar");
+ return NULL;
+ }
+
+ std::complex<double> complexData;
+ for (int K = 0; K < nonZeros; ++K)
+ {
+ complexData = pSparse->getImg(iPositVal[K]);
+ dataReal[K] = complexData.real();
+ dataImg[K] = (-1 * complexData.imag());
+
+ }
+ data->Re = dataReal;
+ data->Im = dataImg;
+
+ sparseData->data = (void*)data;
+
+ pMatVarOut = Mat_VarCreate(name, MAT_C_SPARSE, MAT_T_DOUBLE, Dims, psize_t, sparseData, MAT_F_COMPLEX | MAT_F_DONT_COPY_DATA);
+ }
+ else
+ {
+ double* data = NULL;
+
+ if ((data = (double*)MALLOC(sizeof(double) * nonZeros)) == NULL)
+ {
+ FREE(psize_t);
+ FREE(sparseData);
+ FREE(colIndexes);
+ FREE(rowIndexes);
+ Scierror(999, _("%s: No more memory.\n"), "GetSparseMatVar");
+ return NULL;
+ }
+
+ for (int K = 0; K < nonZeros; ++K)
+ {
+ data[K] = pSparse->getReal(iPositVal[K]);
+ }
+
+
+ sparseData->data = (void*)data;
+
+ pMatVarOut = Mat_VarCreate(name, MAT_C_SPARSE, MAT_T_DOUBLE, Dims, psize_t, sparseData, 0 | MAT_F_DONT_COPY_DATA);
+ }
+
+ FREE(psize_t);
+ return pMatVarOut;
+}