rewrite hypermat api for scilab 6 49/16849/3
Antoine ELIAS [Thu, 16 Jul 2015 09:40:57 +0000 (11:40 +0200)]
Change-Id: Id0e28ea774f51a019266f58bddcfacd84d15b03b

19 files changed:
scilab/modules/api_scilab/Makefile.am
scilab/modules/api_scilab/Makefile.in
scilab/modules/api_scilab/api_scilab.vcxproj
scilab/modules/api_scilab/api_scilab.vcxproj.filters
scilab/modules/api_scilab/help/en_US/hypermat/B_getHypermatOfDouble.xml [new file with mode: 0644]
scilab/modules/api_scilab/help/en_US/hypermat/C_getHypermatOfInt.xml [new file with mode: 0644]
scilab/modules/api_scilab/help/ja_JP/hypermat/B_getHypermatOfDouble.xml [new file with mode: 0644]
scilab/modules/api_scilab/help/ja_JP/hypermat/C_getHypermatOfInt.xml [new file with mode: 0644]
scilab/modules/api_scilab/includes/api_hypermat.h [new file with mode: 0644]
scilab/modules/api_scilab/includes/api_scilab.h
scilab/modules/api_scilab/src/cpp/api_hypermat.cpp [new file with mode: 0644]
scilab/modules/api_scilab/tests/unit_tests/hypermatExample.c [new file with mode: 0644]
scilab/modules/api_scilab/tests/unit_tests/hypermatExample.dia.ref [new file with mode: 0644]
scilab/modules/api_scilab/tests/unit_tests/hypermatExample.tst [new file with mode: 0644]
scilab/modules/api_scilab/tests/unit_tests/hypermatIntExample.c [new file with mode: 0644]
scilab/modules/api_scilab/tests/unit_tests/hypermatIntExample.dia.ref [new file with mode: 0644]
scilab/modules/api_scilab/tests/unit_tests/hypermatIntExample.tst [new file with mode: 0644]
scilab/modules/ast/includes/types/singlepoly.hxx
scilab/modules/ast/src/cpp/types/singlepoly.cpp

index 657cf2a..845ca79 100644 (file)
@@ -18,6 +18,7 @@ API_SCILAB_CXX_SOURCES = \
     src/cpp/api_pointer.cpp \
     src/cpp/api_handle.cpp \
     src/cpp/api_error.cpp \
+    src/cpp/api_hypermat.cpp \
     src/cpp/returnProperty.cpp \
     src/cpp/returnPropertyList.cpp \
     src/cpp/api_optional.cpp \
index ea3ae5e..0922897 100644 (file)
@@ -180,6 +180,7 @@ am__objects_1 = src/cpp/libsciapi_scilab_la-api_boolean.lo \
        src/cpp/libsciapi_scilab_la-api_pointer.lo \
        src/cpp/libsciapi_scilab_la-api_handle.lo \
        src/cpp/libsciapi_scilab_la-api_error.lo \
+       src/cpp/libsciapi_scilab_la-api_hypermat.lo \
        src/cpp/libsciapi_scilab_la-returnProperty.lo \
        src/cpp/libsciapi_scilab_la-returnPropertyList.lo \
        src/cpp/libsciapi_scilab_la-api_optional.lo \
@@ -566,6 +567,7 @@ API_SCILAB_CXX_SOURCES = \
     src/cpp/api_pointer.cpp \
     src/cpp/api_handle.cpp \
     src/cpp/api_error.cpp \
+    src/cpp/api_hypermat.cpp \
     src/cpp/returnProperty.cpp \
     src/cpp/returnPropertyList.cpp \
     src/cpp/api_optional.cpp \
@@ -840,6 +842,8 @@ src/cpp/libsciapi_scilab_la-api_handle.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libsciapi_scilab_la-api_error.lo: src/cpp/$(am__dirstamp) \
        src/cpp/$(DEPDIR)/$(am__dirstamp)
+src/cpp/libsciapi_scilab_la-api_hypermat.lo: src/cpp/$(am__dirstamp) \
+       src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libsciapi_scilab_la-returnProperty.lo:  \
        src/cpp/$(am__dirstamp) src/cpp/$(DEPDIR)/$(am__dirstamp)
 src/cpp/libsciapi_scilab_la-returnPropertyList.lo:  \
@@ -886,6 +890,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciapi_scilab_la-api_error.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciapi_scilab_la-api_handle.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciapi_scilab_la-api_handle_cpp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciapi_scilab_la-api_hypermat.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciapi_scilab_la-api_int.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciapi_scilab_la-api_int_cpp.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/cpp/$(DEPDIR)/libsciapi_scilab_la-api_list.Plo@am__quote@
@@ -1009,6 +1014,13 @@ src/cpp/libsciapi_scilab_la-api_error.lo: src/cpp/api_error.cpp
 @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) $(libsciapi_scilab_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libsciapi_scilab_la-api_error.lo `test -f 'src/cpp/api_error.cpp' || echo '$(srcdir)/'`src/cpp/api_error.cpp
 
+src/cpp/libsciapi_scilab_la-api_hypermat.lo: src/cpp/api_hypermat.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciapi_scilab_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libsciapi_scilab_la-api_hypermat.lo -MD -MP -MF src/cpp/$(DEPDIR)/libsciapi_scilab_la-api_hypermat.Tpo -c -o src/cpp/libsciapi_scilab_la-api_hypermat.lo `test -f 'src/cpp/api_hypermat.cpp' || echo '$(srcdir)/'`src/cpp/api_hypermat.cpp
+@am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libsciapi_scilab_la-api_hypermat.Tpo src/cpp/$(DEPDIR)/libsciapi_scilab_la-api_hypermat.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     $(AM_V_CXX)source='src/cpp/api_hypermat.cpp' object='src/cpp/libsciapi_scilab_la-api_hypermat.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) $(libsciapi_scilab_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/libsciapi_scilab_la-api_hypermat.lo `test -f 'src/cpp/api_hypermat.cpp' || echo '$(srcdir)/'`src/cpp/api_hypermat.cpp
+
 src/cpp/libsciapi_scilab_la-returnProperty.lo: src/cpp/returnProperty.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciapi_scilab_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/libsciapi_scilab_la-returnProperty.lo -MD -MP -MF src/cpp/$(DEPDIR)/libsciapi_scilab_la-returnProperty.Tpo -c -o src/cpp/libsciapi_scilab_la-returnProperty.lo `test -f 'src/cpp/returnProperty.cpp' || echo '$(srcdir)/'`src/cpp/returnProperty.cpp
 @am__fastdepCXX_TRUE@  $(AM_V_at)$(am__mv) src/cpp/$(DEPDIR)/libsciapi_scilab_la-returnProperty.Tpo src/cpp/$(DEPDIR)/libsciapi_scilab_la-returnProperty.Plo
index f0cb0b3..57e87c3 100644 (file)
@@ -308,6 +308,7 @@ cd .. >nul
     <ClCompile Include="src\cpp\api_error.cpp" />
     <ClCompile Include="src\cpp\api_handle.cpp" />
     <ClCompile Include="src\cpp\api_handle_cpp.cpp" />
+    <ClCompile Include="src\cpp\api_hypermat.cpp" />
     <ClCompile Include="src\cpp\api_int.cpp" />
     <ClCompile Include="src\cpp\api_int_cpp.cpp" />
     <ClCompile Include="src\cpp\api_list.cpp" />
@@ -335,6 +336,7 @@ cd .. &gt;nul
     <ClInclude Include="includes\api_error.h" />
     <ClInclude Include="includes\api_handle.h" />
     <ClInclude Include="includes\api_handle.hxx" />
+    <ClInclude Include="includes\api_hypermat.h" />
     <ClInclude Include="includes\api_int.h" />
     <ClInclude Include="includes\api_int.hxx" />
     <ClInclude Include="includes\api_list.hxx" />
index 6c38b00..2a5599b 100644 (file)
     <ClCompile Include="src\cpp\api_list_cpp.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\cpp\api_hypermat.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="includes\api_boolean.h">
     <ClInclude Include="includes\api_list.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="includes\api_hypermat.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="src\c\api_scilab.rc">
diff --git a/scilab/modules/api_scilab/help/en_US/hypermat/B_getHypermatOfDouble.xml b/scilab/modules/api_scilab/help/en_US/hypermat/B_getHypermatOfDouble.xml
new file mode 100644 (file)
index 0000000..d477a83
--- /dev/null
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013  - Scilab Enterprises - Calixte DENIZET
+ * 
+ * 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
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="getHypermatOfDouble" xml:lang="en">
+    <refnamediv>
+        <refname>getHypermatOfDouble</refname>
+        <refpurpose>
+            Get a hypermatrix of double variable.
+        </refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Calling Sequence</title>
+        <synopsis>SciErr getHypermatOfDouble(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, double* _pdblReal)</synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>_pvCtx</term>
+                <listitem>
+                    <para>
+                        Scilab environment pointer, pass in "pvApiCtx" provided by api_scilab.h.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_piAddress</term>
+                <listitem>
+                    <para>
+                        Address of the Scilab variable.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_dims</term>
+                <listitem>
+                    <para>
+                        the hypermatrix dimensions.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_ndims</term>
+                <listitem>
+                    <para>
+                        the number of dimensions.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_pdblReal</term>
+                <listitem>
+                    <para>
+                        Double values.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Return value</title>
+        <para>A SciErr struct, the field iErr would contain the error number (0 if no error).</para>
+    </refsection>
+    <refsection>
+        <title>Gateway Source</title>
+        <programlisting role="code_gateway">
+            <![CDATA[ 
+#include "api_scilab.h"
+
+int hypermatExample(char *fname,void* pvApiCtx)
+{
+    SciErr sciErr;
+    int* piAddr = NULL;
+    int iType   = 0;
+    int iRet    = 0;
+
+    CheckInputArgument(pvApiCtx, 1, 1);
+    CheckOutputArgument(pvApiCtx, 0, 1);
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 0;
+    }
+
+    if (isEmptyMatrix(pvApiCtx, piAddr))
+    {
+        iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
+        if (iRet)
+        {
+            return iRet;
+        }
+
+        AssignOutputVariable(pvApiCtx, 1) = 0;
+    }
+    else if (isHypermatType(pvApiCtx, piAddr))
+    {
+        int * dims = NULL;
+        int ndims;
+        double* pdblReal = NULL;
+        double* pdblImg = NULL;
+
+        if (isHypermatComplex(pvApiCtx, piAddr))
+        {
+            sciErr = getComplexHypermatOfDouble(pvApiCtx, piAddr, &dims, &ndims, &pdblReal, &pdblImg);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+
+            sciErr = createComplexHypermatOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, pdblReal, pdblImg);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+        }
+        else
+        {
+            sciErr = getHypermatOfDouble(pvApiCtx, piAddr, &dims, &ndims, &pdblReal);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+
+            sciErr = createHypermatOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, pdblReal);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+        }
+
+        AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+    }
+
+    return 0;
+}]]>
+        </programlisting>
+    </refsection>
+    <refsection>
+        <title>Scilab test script</title>
+        <programlisting role="code_scilab"><![CDATA[ 
+a = hypermat([1 2 3], ones(1,6));
+b = a + %i*hypermat([1 2 3], 1:6);
+
+hypermatExample(a) == a
+hypermatExample(b) == b
+ ]]></programlisting>
+    </refsection>
+</refentry>
diff --git a/scilab/modules/api_scilab/help/en_US/hypermat/C_getHypermatOfInt.xml b/scilab/modules/api_scilab/help/en_US/hypermat/C_getHypermatOfInt.xml
new file mode 100644 (file)
index 0000000..f4edf24
--- /dev/null
@@ -0,0 +1,292 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013  - Scilab Enterprises - Calixte DENIZET
+ * 
+ * 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
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="getHypermatOfInt" xml:lang="en">
+    <refnamediv>
+        <refname>getHypermatOfInt</refname>
+        <refpurpose>
+            Get a hypermatrix of integer variable.
+        </refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Calling Sequence</title>
+        <synopsis>SciErr getHypermatOfInt8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, char* _pcData)</synopsis>
+        <synopsis>SciErr getHypermatOfUnsignedInt8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned char* _pucData)</synopsis>
+        <synopsis>SciErr getHypermatOfInt16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, short* _psData)</synopsis>
+        <synopsis>SciErr getHypermatOfUnsignedInt16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned short* _pusData)</synopsis>
+        <synopsis>SciErr getHypermatOfInt32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piData)</synopsis>
+        <synopsis>SciErr getHypermatOfUnsignedInt32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned int* _puiData)</synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>_pvCtx</term>
+                <listitem>
+                    <para>
+                        Scilab environment pointer, pass in "pvApiCtx" provided by api_scilab.h.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_piAddress</term>
+                <listitem>
+                    <para>
+                        Address of the Scilab variable.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_dims</term>
+                <listitem>
+                    <para>
+                        the hypermatrix dimensions.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_ndims</term>
+                <listitem>
+                    <para>
+                        the number of dimensions.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_p*Data</term>
+                <listitem>
+                    <para>
+                        the data.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Return value</title>
+        <para>A SciErr struct, the field iErr would contain the error number (0 if no error).</para>
+    </refsection>
+    <refsection>
+        <title>Gateway Source</title>
+        <programlisting role="code_gateway">
+            <![CDATA[ 
+#include "api_scilab.h"
+#include "localization.h"
+
+int hypermatIntExample(char *fname, void* pvApiCtx)
+{
+    SciErr sciErr;
+    int* piAddr = NULL;
+    int iType   = 0;
+    int iRet    = 0;
+
+    CheckInputArgument(pvApiCtx, 1, 1);
+    CheckOutputArgument(pvApiCtx, 0, 1);
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 0;
+    }
+
+    if (isEmptyMatrix(pvApiCtx, piAddr))
+    {
+        iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
+        if (iRet)
+        {
+            return iRet;
+        }
+
+        AssignOutputVariable(pvApiCtx, 1) = 0;
+    }
+    else if (isHypermatType(pvApiCtx, piAddr))
+    {
+        int * dims = NULL;
+        int ndims;
+        void * data = NULL;
+        int htype = 0;
+        int precision;
+
+        sciErr = getHypermatType(pvApiCtx, piAddr, &htype);
+        if (sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            return sciErr.iErr;
+        }
+
+        if (htype == sci_ints)
+        {
+            sciErr = getHypermatOfIntegerPrecision(pvApiCtx, piAddr, &precision);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+
+            switch (precision)
+            {
+            case SCI_INT8:
+                sciErr = getHypermatOfInteger8(pvApiCtx, piAddr, &dims, &ndims, (char*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+
+                sciErr = createHypermatOfInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const char*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_UINT8:
+                sciErr = getHypermatOfUnsignedInteger8(pvApiCtx, piAddr, &dims, &ndims, (unsigned char*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+
+                sciErr = createHypermatOfUnsignedInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned char*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_INT16:
+                sciErr = getHypermatOfInteger16(pvApiCtx, piAddr, &dims, &ndims, (short*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+
+                sciErr = createHypermatOfInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const short*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_UINT16:
+                sciErr = getHypermatOfUnsignedInteger16(pvApiCtx, piAddr, &dims, &ndims, (unsigned short*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+
+                sciErr = createHypermatOfUnsignedInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned short*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_INT32:
+                sciErr = getHypermatOfInteger32(pvApiCtx, piAddr, &dims, &ndims, (int*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+
+                sciErr = createHypermatOfInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const int*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_UINT32:
+                sciErr = getHypermatOfUnsignedInteger32(pvApiCtx, piAddr, &dims, &ndims, (unsigned int*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+
+                sciErr = createHypermatOfUnsignedInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned int*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            }
+            case SCI_INT64:
+                sciErr = getHypermatOfInteger64(pvApiCtx, piAddr, &dims, &ndims, (long long*)&data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+
+                sciErr = createHypermatOfInteger64(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const long long*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_UINT64:
+                sciErr = getHypermatOfUnsignedInteger64(pvApiCtx, piAddr, &dims, &ndims, (unsigned long long*)&data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+
+                sciErr = createHypermatOfUnsignedInteger64(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned long long*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            }
+        }
+        else
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: An integer expected.\n"), fname, 1);
+            return 1;
+        }
+
+        AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+    }
+
+    return 0;
+}]]>
+        </programlisting>
+    </refsection>
+    <refsection>
+        <title>Scilab test script</title>
+        <programlisting role="code_scilab"><![CDATA[ 
+a = hypermat([1 2 3], int8(1:6));
+b = hypermat([1 2 3], uint8(1:6));
+c = hypermat([1 2 3], int16(1:6));
+d = hypermat([1 2 3], uint16(1:6));
+e = hypermat([1 2 3], int32(1:6));
+f = hypermat([1 2 3], uint32(1:6));
+
+hypermatExampleInt(a) == a
+hypermatExampleInt(b) == b
+hypermatExampleInt(c) == c
+hypermatExampleInt(d) == d
+hypermatExampleInt(e) == e
+hypermatExampleInt(f) == f
+ ]]></programlisting>
+    </refsection>
+</refentry>
diff --git a/scilab/modules/api_scilab/help/ja_JP/hypermat/B_getHypermatOfDouble.xml b/scilab/modules/api_scilab/help/ja_JP/hypermat/B_getHypermatOfDouble.xml
new file mode 100644 (file)
index 0000000..5718cb3
--- /dev/null
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013  - Scilab Enterprises - Calixte DENIZET
+ * 
+ * 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
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="getHypermatOfDouble" xml:lang="ja">
+    <refnamediv>
+        <refname>getHypermatOfDouble</refname>
+        <refpurpose>
+            double変数のハイパー行列を取得.
+        </refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>呼び出し手順</title>
+        <synopsis>SciErr getHypermatOfDouble(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, double* _pdblReal)</synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>引数</title>
+        <variablelist>
+            <varlistentry>
+                <term>_pvCtx</term>
+                <listitem>
+                    <para>
+                        Scilab環境ポインタ, api_scilab.h により定義された "pvApiCtx"で指定.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_piAddress</term>
+                <listitem>
+                    <para>
+                        Scilab 変数のアドレス.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_dims</term>
+                <listitem>
+                    <para>
+                        ハイパー行列の次元
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_ndims</term>
+                <listitem>
+                    <para>
+                        次元の数.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_pdblReal</term>
+                <listitem>
+                    <para>
+                        double値.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>戻り値</title>
+        <para>SciErr構造体, フィールド iErr は
+            エラー番号を保持します (エラーがない場合は 0).
+        </para>
+    </refsection>
+    <refsection>
+        <title>ゲートウェイのソース</title>
+        <programlisting role="code_gateway">
+            <![CDATA[ 
+#include "api_scilab.h"
+
+int hypermatExample(char *fname, void* pvApiCtx)
+{
+    SciErr sciErr;
+    int* piAddr = NULL;
+    int iType   = 0;
+    int iRet    = 0;
+    CheckInputArgument(pvApiCtx, 1, 1);
+    CheckOutputArgument(pvApiCtx, 0, 1);
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 0;
+    }
+    if (isEmptyMatrix(pvApiCtx, piAddr))
+    {
+        iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
+        if (iRet)
+        {
+            return iRet;
+        }
+        AssignOutputVariable(pvApiCtx, 1) = 0;
+    }
+    else if (isHypermatType(pvApiCtx, piAddr))
+    {
+        int * dims = NULL;
+        int ndims;
+        double* pdblReal = NULL;
+        double* pdblImg = NULL;
+        if (isHypermatComplex(pvApiCtx, piAddr))
+        {
+            sciErr = getComplexHypermatOfDouble(pvApiCtx, piAddr, &dims, &ndims, &pdblReal, &pdblImg);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+            sciErr = createComplexHypermatOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, pdblReal, pdblImg);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+        }
+        else
+        {
+            sciErr = getHypermatOfDouble(pvApiCtx, piAddr, &dims, &ndims, &pdblReal);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+            sciErr = createHypermatOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, pdblReal);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+        }
+        AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+    }
+    return 0;
+}]]>
+        </programlisting>
+    </refsection>
+    <refsection>
+        <title>Scilab テストスクリプト</title>
+        <programlisting role="code_scilab"><![CDATA[ 
+a = hypermat([1 2 3], ones(1,6));
+b = a + %i*hypermat([1 2 3], 1:6);
+hypermatExample(a) == a
+hypermatExample(b) == b
+ ]]></programlisting>
+    </refsection>
+</refentry>
diff --git a/scilab/modules/api_scilab/help/ja_JP/hypermat/C_getHypermatOfInt.xml b/scilab/modules/api_scilab/help/ja_JP/hypermat/C_getHypermatOfInt.xml
new file mode 100644 (file)
index 0000000..6f5b92a
--- /dev/null
@@ -0,0 +1,278 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013  - Scilab Enterprises - Calixte DENIZET
+ * 
+ * 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
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="getHypermatOfInt" xml:lang="ja">
+    <refnamediv>
+        <refname>getHypermatOfInt</refname>
+        <refpurpose>
+            整数変数のハイパー行列を取得.
+        </refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>呼び出し手順</title>
+        <synopsis>SciErr getHypermatOfInt8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, char* _pcData)</synopsis>
+        <synopsis>SciErr getHypermatOfUnsignedInt8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned char* _pucData)</synopsis>
+        <synopsis>SciErr getHypermatOfInt16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, short* _psData)</synopsis>
+        <synopsis>SciErr getHypermatOfUnsignedInt16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned short* _pusData)</synopsis>
+        <synopsis>SciErr getHypermatOfInt32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piData)</synopsis>
+        <synopsis>SciErr getHypermatOfUnsignedInt32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned int* _puiData)</synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>引数</title>
+        <variablelist>
+            <varlistentry>
+                <term>_pvCtx</term>
+                <listitem>
+                    <para>
+                        Scilab環境ポインタ, api_scilab.h により定義された "pvApiCtx"で指定.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_piAddress</term>
+                <listitem>
+                    <para>
+                        Scilab変数のアドレス.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_dims</term>
+                <listitem>
+                    <para>
+                        ハイパー行列の次元.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_ndims</term>
+                <listitem>
+                    <para>
+                        次元の数.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>_p*Data</term>
+                <listitem>
+                    <para>
+                        データ.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>戻り値</title>
+        <para>SciErr構造体, フィールド iErr は
+            エラー番号を保持します (エラーがない場合は 0).
+        </para>
+    </refsection>
+    <refsection>
+        <title>ゲートウェイのソース</title>
+        <programlisting role="code_gateway">
+            <![CDATA[ 
+#include "api_scilab.h"
+#include "localization.h"
+
+int hypermatIntExample(char *fname,void* pvApiCtx)
+{
+    SciErr sciErr;
+    int* piAddr = NULL;
+    int iType   = 0;
+    int iRet    = 0;
+    CheckInputArgument(pvApiCtx, 1, 1);
+    CheckOutputArgument(pvApiCtx, 0, 1);
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 0;
+    }
+    if (isEmptyMatrix(pvApiCtx, piAddr))
+    {
+        iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
+        if (iRet)
+        {
+            return iRet;
+        }
+        AssignOutputVariable(pvApiCtx, 1) = 0;
+    }
+    else if (isHypermatType(pvApiCtx, piAddr))
+    {
+        int * dims = NULL;
+        int ndims;
+        void * data = NULL;
+        int htype = 0;
+        int precision;
+        sciErr = getHypermatType(pvApiCtx, piAddr, &htype);
+        if (sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            return sciErr.iErr;
+        }
+        if (htype == sci_ints)
+        {
+            sciErr = getHypermatOfIntegerPrecision(pvApiCtx, piAddr, &precision);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+            switch (precision)
+            {
+            case SCI_INT8:
+                sciErr = getHypermatOfInteger8(pvApiCtx, piAddr, &dims, &ndims, (char*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                sciErr = createHypermatOfInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const char*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_UINT8:
+                sciErr = getHypermatOfUnsignedInteger8(pvApiCtx, piAddr, &dims, &ndims, (unsigned char*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                sciErr = createHypermatOfUnsignedInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned char*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_INT16:
+                sciErr = getHypermatOfInteger16(pvApiCtx, piAddr, &dims, &ndims, (short*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                sciErr = createHypermatOfInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const short*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_UINT16:
+                sciErr = getHypermatOfUnsignedInteger16(pvApiCtx, piAddr, &dims, &ndims, (unsigned short*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                sciErr = createHypermatOfUnsignedInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned short*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_INT32:
+                sciErr = getHypermatOfInteger32(pvApiCtx, piAddr, &dims, &ndims, (int*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                sciErr = createHypermatOfInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const int*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_UINT32:
+                sciErr = getHypermatOfUnsignedInteger32(pvApiCtx, piAddr, &dims, &ndims, (unsigned int*)&data);
+                if(sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                sciErr = createHypermatOfUnsignedInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned int*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            }
+            case SCI_INT64:
+                sciErr = getHypermatOfInteger64(pvApiCtx, piAddr, &dims, &ndims, (long long*)&data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+
+                sciErr = createHypermatOfInteger64(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const long long*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            case SCI_UINT64:
+                sciErr = getHypermatOfUnsignedInteger64(pvApiCtx, piAddr, &dims, &ndims, (unsigned long long*)&data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+
+                sciErr = createHypermatOfUnsignedInteger64(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned long long*)data);
+                if (sciErr.iErr)
+                {
+                    printError(&sciErr, 0);
+                    return sciErr.iErr;
+                }
+                break;
+            }
+        }
+        else
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: An integer expected.\n"), fname, 1);
+            return 1;
+        }
+        AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+    }
+    return 0;
+}]]>
+        </programlisting>
+    </refsection>
+    <refsection>
+        <title>Scilab テストスクリプト</title>
+        <programlisting role="code_scilab"><![CDATA[ 
+a = hypermat([1 2 3], int8(1:6));
+b = hypermat([1 2 3], uint8(1:6));
+c = hypermat([1 2 3], int16(1:6));
+d = hypermat([1 2 3], uint16(1:6));
+e = hypermat([1 2 3], int32(1:6));
+f = hypermat([1 2 3], uint32(1:6));
+hypermatExampleInt(a) == a
+hypermatExampleInt(b) == b
+hypermatExampleInt(c) == c
+hypermatExampleInt(d) == d
+hypermatExampleInt(e) == e
+hypermatExampleInt(f) == f
+ ]]></programlisting>
+    </refsection>
+</refentry>
diff --git a/scilab/modules/api_scilab/includes/api_hypermat.h b/scilab/modules/api_scilab/includes/api_hypermat.h
new file mode 100644 (file)
index 0000000..5ef6a49
--- /dev/null
@@ -0,0 +1,351 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises - Calixte DENIZET
+ *
+ * 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
+ */
+
+#ifndef __HYPERMAT_API__
+#define __HYPERMAT_API__
+
+#if !defined(__INTERNAL_API_SCILAB__)
+#error Do not include api_hypermat.h. Include api_scilab.h instead.
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "api_common.h"
+#include "doublecomplex.h"
+
+/**************************************/
+/*   Hypermatrices matrix functions   */
+/**************************************/
+
+/**
+ * Check if the variable type is double
+ * @param[in] _piAddress variable address
+ * @return 1 for true and 0 for false
+ */
+int isHypermatType(void* _pvCtx, int* _piAddress);
+
+/**
+ * Check if the variable is complex
+ * @param[in] _piAddress variable address
+ * @return 1 for true and 0 for false
+ */
+int isHypermatComplex(void* _pvCtx, int* _piAddress);
+
+/**
+ * Get the base type
+ * @param[in] _piAddress variable address
+ * @param[out] _piType return the base type
+ */
+SciErr getHypermatType(void *_pvCtx, int *_piAddress, int *_piType);
+
+/**
+ * Get integer precision ( SCI_xINTx )
+ * @param[in] _piAddress variable address
+ * @param[out] _piPrecison return integer precision ( SCI_xINTx )
+ */
+SciErr getHypermatOfIntegerPrecision(void *_pvCtx, int *_piAddress, int *_piPrecision);
+
+/**
+ * Get the hypermatrix dimensions
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ */
+SciErr getHypermatDimensions(void *_pvCtx, int *_piAddress, int **_dims, int *_ndims);
+
+/**
+ * Get polynomial variable name
+ * @param[in] _piAddress variable address
+ * @param[out] _pstVarName return variable name of polynomials
+ * @param[out] _piVarNameLen return length of _pstVarName
+ * @return if the operation succeeded ( 0 ) or not ( !0 )
+ */
+SciErr getHypermatPolyVariableName(void* _pvCtx, int* _piAddress, char* _pstVarName, int* _piVarNameLen);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _piNbCoef return number of polynomial coefficients for each element
+ * @param[out] _pdblReal return real coefficients
+ */
+SciErr getHypermatOfPoly(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piNbCoef, double** _pdblReal);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _piNbCoef return number of polynomial coefficients for each element
+ * @param[out] _pdblReal return real coefficients
+ * @param[out] _pdblImg return imaginary coefficients
+ */
+SciErr getComplexHypermatOfPoly(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _piLength return strings lengths
+ * @param[out] _pstStrings return the strings data
+ */
+SciErr getHypermatOfString(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piLength, char** _pstStrings);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _piLength return strings lengths
+ * @param[out] _pwstStrings return the strings data
+ */
+SciErr getHypermatOfWideString(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piLength, wchar_t** _pwstStrings);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _pdblReal return the double data
+ */
+SciErr getHypermatOfDouble(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, double** _pdblReal);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _pdblReal return the real data
+ * @param[out] _pdblImg return the imaginary data
+ */
+SciErr getComplexHypermatOfDouble(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, double** _pdblReal, double** _pdblImg);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _pucData8 return the unsigned char data
+ */
+SciErr getHypermatOfUnsignedInteger8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned char** _pucData8);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _pcData8 return the char data
+ */
+SciErr getHypermatOfInteger8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, char** _pcData8);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _pusData16 return the unsigned short data
+ */
+SciErr getHypermatOfUnsignedInteger16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned short** _pusData16);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _psData16 return the short data
+ */
+SciErr getHypermatOfInteger16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, short** _psData16);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _puiData32 return the unsigned int data
+ */
+SciErr getHypermatOfUnsignedInteger32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned int** _puiData32);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _piData32 return the int data
+ */
+SciErr getHypermatOfInteger32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int** _piData32);
+
+/**
+* Get the hypermatrix dimensions and data
+* @param[in] _piAddress variable address
+* @param[out] _dims return the dimensions
+* @param[out] _ndims return the number of dimensions
+* @param[out] _pllData64 return the int data
+*/
+SciErr getHypermatOfInteger64(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, long long** _pllData64);
+
+/**
+* Get the hypermatrix dimensions and data
+* @param[in] _piAddress variable address
+* @param[out] _dims return the dimensions
+* @param[out] _ndims return the number of dimensions
+* @param[out] _pullData64 return the int data
+*/
+SciErr getHypermatOfUnsignedInteger64(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned long long** _pullData64);
+
+/**
+ * Get the hypermatrix dimensions and data
+ * @param[in] _piAddress variable address
+ * @param[out] _dims return the dimensions
+ * @param[out] _ndims return the number of dimensions
+ * @param[out] _piBool return the boolean data
+ */
+SciErr getHypermatOfBoolean(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int** _piBool);
+
+/**
+ * Create a polynomial hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _pstVarName polynomial variable name
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _piNbCoef number of polynomial coefficients for each element
+ * @param[in] _pdblReal pointer to real coefficients
+ */
+SciErr createHypermatOfPoly(void* _pvCtx, int _iVar, char* _pstVarName, int *_dims, int _ndims, const int* _piNbCoef, const double* const* _pdblReal);
+
+/**
+ * Create a complex polynomial hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _pstVarName polynomial variable name
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _piNbCoef number of polynomial coefficients for each element
+ * @param[in] _pdblReal pointer to real coefficients
+ * @param[in] _pdblImg pointer to imaginary coefficients
+ */
+SciErr createComplexHypermatOfPoly(void* _pvCtx, int _iVar, char* _pstVarName, int *_dims, int _ndims, const int* _piNbCoef, const double* const* _pdblReal, const double* const* _pdblImg);
+
+/**
+ * Create a double hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _pdblReal pointer to real data
+ */
+SciErr createHypermatOfDouble(void* _pvCtx, int _iVar, int *_dims, int _ndims, const double* _pdblReal);
+SciErr allocHypermatOfDouble(void *_pvCtx, int _iVar, int * _dims, int _ndims, double** _pdblReal);
+
+/**
+ * Create a complex hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _pdblReal pointer to real data
+ */
+SciErr createComplexHypermatOfDouble(void* _pvCtx, int _iVar, int *_dims, int _ndims, const double* _pdblReal, const double* _pdblImg);
+
+/**
+ * Create a boolean hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _piBool pointer to boolean data
+ */
+SciErr createHypermatOfBoolean(void* _pvCtx, int _iVar, int *_dims, int _ndims, const int* _piBool);
+
+/**
+ * Create a string hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _pstStrings pointer to string data
+ */
+SciErr createHypermatOfString(void* _pvCtx, int _iVar, int *_dims, int _ndims, const char* const* _pstStrings);
+
+/**
+ * Create a int8 hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _pcData8 pointer to char data
+ */
+SciErr createHypermatOfInteger8(void* _pvCtx, int _iVar, int *_dims, int _ndims, const char* _pcData8);
+
+/**
+ * Create a uint8 hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _pucData8 pointer to unsigned char data
+ */
+SciErr createHypermatOfUnsignedInteger8(void* _pvCtx, int _iVar, int *_dims, int _ndims, const unsigned char* _pucData8);
+
+/**
+ * Create a int16 hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _psData16 pointer to short data
+ */
+SciErr createHypermatOfInteger16(void* _pvCtx, int _iVar, int *_dims, int _ndims, const short* _psData16);
+
+/**
+ * Create a uint16 hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _pusData16 pointer to unsigned short data
+ */
+SciErr createHypermatOfUnsignedInteger16(void* _pvCtx, int _iVar, int *_dims, int _ndims, const unsigned short* _pusData16);
+
+/**
+ * Create a int32 hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _piData32 pointer to int data
+ */
+SciErr createHypermatOfInteger32(void* _pvCtx, int _iVar, int *_dims, int _ndims, const int* _piData32);
+
+/**
+ * Create a uint32 hypermatrix
+ * @param[in] _iVar variable number
+ * @param[in] _dims the dimensions
+ * @param[in] _ndims the number of dimensions
+ * @param[in] _puiData32 pointer to unsigned int data
+ */
+SciErr createHypermatOfUnsignedInteger32(void* _pvCtx, int _iVar, int *_dims, int _ndims, const unsigned int* _puiData32);
+
+/**
+* Create a int64 hypermatrix
+* @param[in] _iVar variable number
+* @param[in] _dims the dimensions
+* @param[in] _ndims the number of dimensions
+* @param[in] _pllData64 pointer to unsigned int data
+*/
+SciErr createHypermatOfInteger64(void *_pvCtx, int _iVar, int * _dims, int _ndims, const long long* _pllData64);
+
+/**
+* Create a uint64 hypermatrix
+* @param[in] _iVar variable number
+* @param[in] _dims the dimensions
+* @param[in] _ndims the number of dimensions
+* @param[in] _pullData64 pointer to unsigned int data
+*/
+SciErr createHypermatOfUnsignedInteger64(void *_pvCtx, int _iVar, int * _dims, int _ndims, const unsigned long long* _pullData64);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __HYPERMAT_API__ */
index 5f98382..5a15044 100644 (file)
@@ -42,6 +42,7 @@
 #include "api_list.h"
 #include "api_error.h"
 #include "api_handle.h"
+#include "api_hypermat.h"
 #include "api_optional.h"
 
 #undef __INTERNAL_API_SCILAB__
diff --git a/scilab/modules/api_scilab/src/cpp/api_hypermat.cpp b/scilab/modules/api_scilab/src/cpp/api_hypermat.cpp
new file mode 100644 (file)
index 0000000..8f5ae1c
--- /dev/null
@@ -0,0 +1,976 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2013 - Scilab Enterprises - Calixte DENIZET
+*
+* 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
+*
+* Please note that piece of code will be rewrited for the Scilab 6 family
+* However, the API (profile of the functions in the header files) will be
+* still available and supported in Scilab 6.
+*/
+
+#include <stdio.h>
+#include "double.hxx"
+#include "bool.hxx"
+#include "string.hxx"
+#include "int.hxx"
+#include "polynom.hxx"
+#include "gatewaystruct.hxx"
+
+extern "C"
+{
+#include "api_scilab.h"
+#include "api_internal_common.h"
+#include "api_internal_double.h"
+#include "localization.h"
+
+#include "call_scilab.h"
+}
+
+int isHypermatType(void* _pvCtx, int* _piAddress)
+{
+    types::InternalType* it = (types::InternalType*)_piAddress;
+    if (it->isGenericType() == false)
+    {
+        return 0;
+    }
+
+    types::GenericType* gt = it->getAs<types::GenericType>();
+    if (gt->getDims() < 3)
+    {
+        return 0;
+    }
+
+    return 1;
+}
+
+int isHypermatComplex(void* _pvCtx, int* _piAddress)
+{
+    types::InternalType* it = (types::InternalType*)_piAddress;
+    if (it->isGenericType() == false)
+    {
+        return 0;
+    }
+
+    types::GenericType* gt = it->getAs<types::GenericType>();
+    if (gt->isComplex())
+    {
+        return 1;
+    }
+
+    return 0;
+}
+
+SciErr getHypermatType(void *_pvCtx, int *_piAddress, int *_piType)
+{
+    return getVarType(_pvCtx, _piAddress, _piType);
+}
+
+SciErr getHypermatOfIntegerPrecision(void *_pvCtx, int *_piAddress, int *_piPrecision)
+{
+    return getMatrixOfIntegerPrecision(_pvCtx, _piAddress, _piPrecision);
+}
+
+SciErr getHypermatDimensions(void *_pvCtx, int *_piAddress, int **_dims, int *_ndims)
+{
+    SciErr sciErr = sciErrInit();
+    types::InternalType* it = (types::InternalType*)_piAddress;
+    if (it->isGenericType() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_NOT_MATRIX_TYPE, _("%s: matrix argument expected"), "getHypermatDimensions");
+        return sciErr;
+    }
+
+    types::GenericType* gt = it->getAs<types::GenericType>();
+    *_ndims = gt->getDims();
+    *_dims = gt->getDimsArray();
+    return sciErr;
+}
+
+static int getHypermatEntries(void* _pvCtx, int* _piAddress, void** _piEntriesAddress)
+{
+    types::InternalType* it = (types::InternalType*)_piAddress;
+    if (it->isGenericType() == false)
+    {
+        return 1;
+    }
+
+    switch (it->getType())
+    {
+        case types::InternalType::ScilabDouble:
+        {
+            *_piEntriesAddress = it->getAs<types::Double>();
+            break;
+        }
+        case types::InternalType::ScilabBool:
+        {
+            *_piEntriesAddress = it->getAs<types::Bool>();
+            break;
+        }
+        case types::InternalType::ScilabString:
+        {
+            *_piEntriesAddress = it->getAs<types::String>();
+            break;
+        }
+        case types::InternalType::ScilabPolynom:
+        {
+            *_piEntriesAddress = it->getAs<types::Polynom>();
+            break;
+        }
+        case types::InternalType::ScilabInt8:
+        {
+            *_piEntriesAddress = it->getAs<types::Int8>();
+            break;
+        }
+        case types::InternalType::ScilabInt16:
+        {
+            *_piEntriesAddress = it->getAs<types::Int16>();
+            break;
+        }
+        case types::InternalType::ScilabInt32:
+        {
+            *_piEntriesAddress = it->getAs<types::Int32>();
+            break;
+        }
+        case types::InternalType::ScilabInt64:
+        {
+            *_piEntriesAddress = it->getAs<types::Int64>();
+            break;
+        }
+        case types::InternalType::ScilabUInt8:
+        {
+            *_piEntriesAddress = it->getAs<types::UInt8>();
+            break;
+        }
+        case types::InternalType::ScilabUInt16:
+        {
+            *_piEntriesAddress = it->getAs<types::UInt16>();
+            break;
+        }
+        case types::InternalType::ScilabUInt32:
+        {
+            *_piEntriesAddress = it->getAs<types::UInt32>();
+            break;
+        }
+        case types::InternalType::ScilabUInt64:
+        {
+            *_piEntriesAddress = it->getAs<types::UInt64>();
+            break;
+        }
+        default:
+        {
+            *_piEntriesAddress = NULL;
+            break;
+        }
+    }
+
+    return 0;
+}
+
+SciErr getHypermatOfDouble(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, double** _pdblReal)
+{
+    SciErr sciErr = sciErrInit();
+    void* entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isDouble() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_GET_DOUBLE, _("%s: Unable to get argument #%d"), "getHypermatOfDouble", getRhsFromAddress(_pvCtx, _piAddress));
+    }
+
+    types::Double* d = (types::Double*)entries;
+    *_dims = d->getDimsArray();
+    *_ndims = d->getDims();
+    *_pdblReal = d->get();
+    return sciErr;
+}
+
+SciErr getComplexHypermatOfDouble(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, double** _pdblReal, double** _pdblImg)
+{
+    SciErr sciErr = sciErrInit();
+    void* entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isDouble() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_GET_DOUBLE, _("%s: Unable to get argument #%d"), "getHypermatOfDouble", getRhsFromAddress(_pvCtx, _piAddress));
+    }
+
+    types::Double* d = (types::Double*)entries;
+    *_dims = d->getDimsArray();
+    *_ndims = d->getDims();
+    *_pdblReal = d->get();
+    *_pdblImg = d->getImg();
+    return sciErr;
+}
+
+SciErr getHypermatPolyVariableName(void* _pvCtx, int* _piAddress, char* _pstVarName, int* _piVarNameLen)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isPoly() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatPolyVariableName");
+        return sciErr;
+    }
+
+    types::Polynom* p = (types::Polynom*)entries;
+    std::wstring var = p->getVariableName();
+
+    char* varname = wide_string_to_UTF8(var.data());
+    *_piVarNameLen = static_cast<int>(strlen(varname));
+
+    if (_pstVarName)
+    {
+        strcpy(_pstVarName, varname);
+    }
+
+    FREE(varname);
+    return sciErr;
+}
+
+SciErr getHypermatOfPoly(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piNbCoef, double** _pdblReal)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isPoly() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfPoly");
+        return sciErr;
+    }
+
+    types::Polynom* p = (types::Polynom*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+
+    if (_piNbCoef == NULL)
+    {
+        return sciErr;
+    }
+
+    p->getSizes(_piNbCoef);
+
+    if (_pdblReal == NULL)
+    {
+        return sciErr;
+    }
+
+    int size = p->getSize();
+    types::SinglePoly** s = p->get();
+
+    for (int i = 0; i < size; i++)
+    {
+        memcpy(_pdblReal[i], s[i]->get(), sizeof(double) * s[i]->getSize());
+    }
+
+    return sciErr;
+}
+
+SciErr getComplexHypermatOfPoly(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isPoly() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getComplexHypermatOfPoly");
+        return sciErr;
+    }
+
+    types::Polynom* p = (types::Polynom*)entries;
+
+    if (p->isComplex() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_COMPLEXITY, _("%s: Bad call to get a non complex matrix"), "getComplexHypermatOfPoly");
+        return sciErr;
+    }
+
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+
+    if (_piNbCoef == NULL)
+    {
+        return sciErr;
+    }
+
+    p->getSizes(_piNbCoef);
+
+    if (_pdblReal == NULL)
+    {
+        return sciErr;
+    }
+
+    int size = p->getSize();
+    types::SinglePoly** s = p->get();
+
+    for (int i = 0; i < size; i++)
+    {
+        memcpy(_pdblReal[i], s[i]->get(), sizeof(double) * s[i]->getSize());
+        memcpy(_pdblImg[i], s[i]->getImg(), sizeof(double) * s[i]->getSize());
+    }
+
+    return sciErr;
+}
+
+SciErr getHypermatOfString(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piLength, char** _pstStrings)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isString() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfString");
+        return sciErr;
+    }
+
+    types::String* p = (types::String*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+    int size = p->getSize();
+
+    if (_piLength == NULL)
+    {
+        return sciErr;
+    }
+
+
+    if (_pstStrings == NULL || *_pstStrings == NULL)
+    {
+        wchar_t** s = p->get();
+        for (int i = 0; i < size; i++)
+        {
+            char* c = wide_string_to_UTF8(s[i]);
+            _piLength[i] = (int)strlen(c);
+            FREE(c);
+        }
+    }
+    else
+    {
+        wchar_t** s = p->get();
+        for (int i = 0; i < size; i++)
+        {
+            if (_pstStrings[i] == NULL)
+            {
+                addErrorMessage(&sciErr, API_ERROR_INVALID_SUBSTRING_POINTER, _("%s: Invalid argument address"), "getHypermatOfString");
+                return sciErr;
+            }
+
+            char* c = wide_string_to_UTF8(s[i]);
+            strcpy(_pstStrings[i], c);
+            FREE(c);
+        }
+    }
+
+    return sciErr;
+}
+
+SciErr getHypermatOfWideString(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piLength, wchar_t** _pwstStrings)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isString() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfWideString");
+        return sciErr;
+    }
+
+    types::String* p = (types::String*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+    int size = p->getSize();
+
+    if (_piLength == NULL)
+    {
+        return sciErr;
+    }
+
+
+    if (_pwstStrings == NULL || *_pwstStrings == NULL)
+    {
+        wchar_t** s = p->get();
+        for (int i = 0; i < size; i++)
+        {
+            _piLength[i] = (int)wcslen(s[i]);
+        }
+    }
+    else
+    {
+        wchar_t** s = p->get();
+        for (int i = 0; i < size; i++)
+        {
+            if (_pwstStrings[i] == NULL)
+            {
+                addErrorMessage(&sciErr, API_ERROR_INVALID_SUBSTRING_POINTER, _("%s: Invalid argument address"), "getHypermatOfWideString");
+                return sciErr;
+            }
+
+            wcscpy(_pwstStrings[i], s[i]);
+        }
+    }
+
+    return sciErr;
+}
+
+SciErr getHypermatOfInteger8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, char** _pcData8)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isInt8() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfInteger8");
+        return sciErr;
+    }
+
+    types::Int8* p = (types::Int8*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+    *_pcData8 = p->get();
+    return sciErr;
+}
+
+SciErr getHypermatOfUnsignedInteger8(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned char** _pucData8)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isUInt8() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfUnsignedInteger8");
+        return sciErr;
+    }
+
+    types::UInt8* p = (types::UInt8*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+    *_pucData8 = p->get();
+    return sciErr;
+}
+
+SciErr getHypermatOfInteger16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, short** _psData16)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isInt16() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfInteger16");
+        return sciErr;
+    }
+
+    types::Int16* p = (types::Int16*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+    *_psData16 = p->get();
+    return sciErr;
+}
+
+SciErr getHypermatOfUnsignedInteger16(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned short** _pusData16)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isUInt16() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfUnsignedInteger16");
+        return sciErr;
+    }
+
+    types::UInt16* p = (types::UInt16*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+    *_pusData16 = p->get();
+    return sciErr;
+}
+
+SciErr getHypermatOfInteger32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int** _piData32)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isInt32() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfInteger32");
+        return sciErr;
+    }
+
+    types::Int32* p = (types::Int32*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+    *_piData32 = p->get();
+    return sciErr;
+}
+
+SciErr getHypermatOfUnsignedInteger32(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned int** _puiData32)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isUInt32() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfUnsignedInteger32");
+        return sciErr;
+    }
+
+    types::UInt32* p = (types::UInt32*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+    *_puiData32 = p->get();
+    return sciErr;
+}
+
+SciErr getHypermatOfInteger64(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, long long** _pllData64)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isInt64() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfInteger64");
+        return sciErr;
+    }
+
+    types::Int64* p = (types::Int64*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+    *_pllData64 = p->get();
+    return sciErr;
+}
+
+SciErr getHypermatOfUnsignedInteger64(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, unsigned long long** _pullData64)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isUInt64() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfUnsignedInteger64");
+        return sciErr;
+    }
+
+    types::UInt64* p = (types::UInt64*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+    *_pullData64 = p->get();
+    return sciErr;
+}
+
+SciErr getHypermatOfBoolean(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int** _piBool)
+{
+    SciErr sciErr = sciErrInit();
+    void * entries = NULL;
+
+    int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
+
+    if (ret || entries == NULL || ((types::InternalType*)entries)->isBool() == false)
+    {
+        addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfBoolean");
+        return sciErr;
+    }
+
+    types::Bool* p = (types::Bool*)entries;
+    *_dims = p->getDimsArray();
+    *_ndims = p->getDims();
+    *_piBool = p->get();
+    return sciErr;
+}
+
+SciErr createHypermatOfString(void *_pvCtx, int _iVar, int * _dims, int _ndims, const char* const* _pstStrings)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::String* p = new types::String(_ndims, _dims);
+    int size = p->getSize();
+
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    for (int i = 0; i < size; ++i)
+    {
+        wchar_t* w = to_wide_string(_pstStrings[i]);
+        p->set(i, w);
+        FREE(w);
+    }
+
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createHypermatOfPoly(void *_pvCtx, int _iVar, char* _pstVarName, int * _dims, int _ndims, const int* _piNbCoef, const double* const* _pdblReal)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    wchar_t* w = to_wide_string(_pstVarName);
+    types::Polynom* p = new types::Polynom(w, _ndims, _dims, _piNbCoef);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    types::SinglePoly** s = p->get();
+
+    for (int i = 0; i < size; ++i)
+    {
+        s[i]->setCoef(_pdblReal[i], NULL);
+    }
+
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createComplexHypermatOfPoly(void *_pvCtx, int _iVar, char* _pstVarName, int * _dims, int _ndims, const int* _piNbCoef, const double* const* _pdblReal, const double* const* _pdblImg)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    wchar_t* w = to_wide_string(_pstVarName);
+    types::Polynom* p = new types::Polynom(w, _ndims, _dims, _piNbCoef);
+    p->setComplex(true);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    types::SinglePoly** s = p->get();
+
+    for (int i = 0; i < size; ++i)
+    {
+        s[i]->setCoef(_pdblReal[i], _pdblImg[i]);
+    }
+
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr allocHypermatOfDouble(void *_pvCtx, int _iVar, int * _dims, int _ndims, double** _pdblReal)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::Double* p = new types::Double(_ndims, _dims);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    *_pdblReal = p->get();
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createHypermatOfDouble(void *_pvCtx, int _iVar, int * _dims, int _ndims, const double * _pdblReal)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::Double* p = new types::Double(_ndims, _dims);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    p->set(_pdblReal);
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createComplexHypermatOfDouble(void *_pvCtx, int _iVar, int * _dims, int _ndims, const double * _pdblReal, const double * _pdblImg)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::Double* p = new types::Double(_ndims, _dims, true);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    p->set(_pdblReal);
+    p->setImg(_pdblImg);
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createHypermatOfBoolean(void *_pvCtx, int _iVar, int * _dims, int _ndims, const int * _piBool)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::Bool* p = new types::Bool(_ndims, _dims);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    p->set(_piBool);
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createHypermatOfInteger8(void *_pvCtx, int _iVar, int * _dims, int _ndims, const char * _pcData8)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::Int8* p = new types::Int8(_ndims, _dims);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    p->set(_pcData8);
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createHypermatOfUnsignedInteger8(void *_pvCtx, int _iVar, int * _dims, int _ndims, const unsigned char * _pucData8)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::UInt8* p = new types::UInt8(_ndims, _dims);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    p->set(_pucData8);
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createHypermatOfInteger16(void *_pvCtx, int _iVar, int * _dims, int _ndims, const short * _psData16)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::Int16* p = new types::Int16(_ndims, _dims);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    p->set(_psData16);
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createHypermatOfUnsignedInteger16(void *_pvCtx, int _iVar, int * _dims, int _ndims, const unsigned short * _pusData16)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::UInt16* p = new types::UInt16(_ndims, _dims);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    p->set(_pusData16);
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createHypermatOfInteger32(void *_pvCtx, int _iVar, int * _dims, int _ndims, const int * _piData32)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::Int32* p = new types::Int32(_ndims, _dims);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    p->set(_piData32);
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createHypermatOfUnsignedInteger32(void *_pvCtx, int _iVar, int * _dims, int _ndims, const unsigned int * _puiData32)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::UInt32* p = new types::UInt32(_ndims, _dims);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    p->set(_puiData32);
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createHypermatOfInteger64(void *_pvCtx, int _iVar, int * _dims, int _ndims, const long long* _pllData64)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::Int64* p = new types::Int64(_ndims, _dims);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    p->set(_pllData64);
+    out[rhs - 1] = p;
+    return sciErr;
+}
+
+SciErr createHypermatOfUnsignedInteger64(void *_pvCtx, int _iVar, int * _dims, int _ndims, const unsigned long long* _pullData64)
+{
+    SciErr sciErr = sciErrInit();
+    types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
+    types::typed_list in = *pStr->m_pIn;
+    types::InternalType** out = pStr->m_pOut;
+    int rhs = _iVar - *getNbInputArgument(_pvCtx);
+
+    types::UInt64* p = new types::UInt64(_ndims, _dims);
+
+    int size = p->getSize();
+    if (size == 0)
+    {
+        delete p;
+        out[rhs - 1] = types::Double::Empty();
+        return sciErr;
+    }
+
+    p->set(_pullData64);
+    out[rhs - 1] = p;
+    return sciErr;
+}
diff --git a/scilab/modules/api_scilab/tests/unit_tests/hypermatExample.c b/scilab/modules/api_scilab/tests/unit_tests/hypermatExample.c
new file mode 100644 (file)
index 0000000..ef7d358
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises
+ *
+ * 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 "api_scilab.h"
+#include "localization.h"
+
+int hypermatExample(char *fname, void* pvApiCtx)
+{
+    SciErr sciErr;
+    int* piAddr = NULL;
+    int iType   = 0;
+    int iRet    = 0;
+
+    CheckInputArgument(pvApiCtx, 1, 1);
+    CheckOutputArgument(pvApiCtx, 0, 1);
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 0;
+    }
+
+    if (isEmptyMatrix(pvApiCtx, piAddr))
+    {
+        iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
+        if (iRet)
+        {
+            return iRet;
+        }
+
+        AssignOutputVariable(pvApiCtx, 1) = 0;
+    }
+    else if (isHypermatType(pvApiCtx, piAddr))
+    {
+        int * dims = NULL;
+        int ndims;
+        double* pdblReal = NULL;
+        double* pdblImg = NULL;
+
+        if (isHypermatComplex(pvApiCtx, piAddr))
+        {
+            sciErr = getComplexHypermatOfDouble(pvApiCtx, piAddr, &dims, &ndims, &pdblReal, &pdblImg);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+
+            sciErr = createComplexHypermatOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, pdblReal, pdblImg);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+        }
+        else
+        {
+            sciErr = getHypermatOfDouble(pvApiCtx, piAddr, &dims, &ndims, &pdblReal);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+
+            sciErr = createHypermatOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, pdblReal);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+        }
+
+        AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+    }
+
+    return 0;
+}
diff --git a/scilab/modules/api_scilab/tests/unit_tests/hypermatExample.dia.ref b/scilab/modules/api_scilab/tests/unit_tests/hypermatExample.dia.ref
new file mode 100644 (file)
index 0000000..e65a3f2
--- /dev/null
@@ -0,0 +1,17 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises 
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/hypermatExample"));
+cd(pathconvert(TMPDIR+"/hypermatExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/hypermatExample.c",pathconvert(TMPDIR+"/hypermatExample/hypermatExample.c",%F));
+ilib_build("gw_hypermatExample",["hypermatExample","hypermatExample"],"hypermatExample.c",[],"","","");
+exec("loader.sce");
+a = hypermat([1 2 3], ones(1,6));
+b = a + %i*hypermat([1 2 3], 1:6);
+assert_checkequal(hypermatExample(a), a);
+assert_checkequal(hypermatExample(b), b);
diff --git a/scilab/modules/api_scilab/tests/unit_tests/hypermatExample.tst b/scilab/modules/api_scilab/tests/unit_tests/hypermatExample.tst
new file mode 100644 (file)
index 0000000..6fed9cc
--- /dev/null
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/hypermatExample"));
+cd(pathconvert(TMPDIR+"/hypermatExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/hypermatExample.c",pathconvert(TMPDIR+"/hypermatExample/hypermatExample.c",%F));
+ilib_build("gw_hypermatExample",["hypermatExample","hypermatExample"],"hypermatExample.c",[],"","","");
+exec("loader.sce");
+
+a = hypermat([1 2 3], ones(1,6));
+b = a + %i*hypermat([1 2 3], 1:6);
+
+assert_checkequal(hypermatExample(a), a);
+assert_checkequal(hypermatExample(b), b);
diff --git a/scilab/modules/api_scilab/tests/unit_tests/hypermatIntExample.c b/scilab/modules/api_scilab/tests/unit_tests/hypermatIntExample.c
new file mode 100644 (file)
index 0000000..8a20e2d
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises
+ *
+ * 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 <api_scilab.h>
+#include "localization.h"
+
+int hypermatIntExample(char *fname, void* pvApiCtx)
+{
+    SciErr sciErr;
+    int* piAddr = NULL;
+    int iType   = 0;
+    int iRet    = 0;
+
+    CheckInputArgument(pvApiCtx, 1, 1);
+    CheckOutputArgument(pvApiCtx, 0, 1);
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        return 0;
+    }
+
+    if (isEmptyMatrix(pvApiCtx, piAddr))
+    {
+        iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
+        if (iRet)
+        {
+            return iRet;
+        }
+
+        AssignOutputVariable(pvApiCtx, 1) = 0;
+    }
+    else if (isHypermatType(pvApiCtx, piAddr))
+    {
+        int * dims = NULL;
+        int ndims;
+        void * data = NULL;
+        int htype = 0;
+        int precision;
+
+        sciErr = getHypermatType(pvApiCtx, piAddr, &htype);
+        if (sciErr.iErr)
+        {
+            printError(&sciErr, 0);
+            return sciErr.iErr;
+        }
+
+        if (htype == sci_ints)
+        {
+            sciErr = getHypermatOfIntegerPrecision(pvApiCtx, piAddr, &precision);
+            if (sciErr.iErr)
+            {
+                printError(&sciErr, 0);
+                return sciErr.iErr;
+            }
+
+            switch (precision)
+            {
+                case SCI_INT8:
+                    sciErr = getHypermatOfInteger8(pvApiCtx, piAddr, &dims, &ndims, (char*)&data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+
+                    sciErr = createHypermatOfInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const char*)data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+                    break;
+                case SCI_UINT8:
+                    sciErr = getHypermatOfUnsignedInteger8(pvApiCtx, piAddr, &dims, &ndims, (unsigned char*)&data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+
+                    sciErr = createHypermatOfUnsignedInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned char*)data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+                    break;
+                case SCI_INT16:
+                    sciErr = getHypermatOfInteger16(pvApiCtx, piAddr, &dims, &ndims, (short*)&data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+
+                    sciErr = createHypermatOfInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const short*)data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+                    break;
+                case SCI_UINT16:
+                    sciErr = getHypermatOfUnsignedInteger16(pvApiCtx, piAddr, &dims, &ndims, (unsigned short*)&data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+
+                    sciErr = createHypermatOfUnsignedInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned short*)data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+                    break;
+                case SCI_INT32:
+                    sciErr = getHypermatOfInteger32(pvApiCtx, piAddr, &dims, &ndims, (int*)&data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+
+                    sciErr = createHypermatOfInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const int*)data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+                    break;
+                case SCI_UINT32:
+                    sciErr = getHypermatOfUnsignedInteger32(pvApiCtx, piAddr, &dims, &ndims, (unsigned int*)&data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+
+                    sciErr = createHypermatOfUnsignedInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned int*)data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+                    break;
+                case SCI_INT64:
+                    sciErr = getHypermatOfInteger64(pvApiCtx, piAddr, &dims, &ndims, (long long*)&data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+
+                    sciErr = createHypermatOfInteger64(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const long long*)data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+                    break;
+                case SCI_UINT64:
+                    sciErr = getHypermatOfUnsignedInteger64(pvApiCtx, piAddr, &dims, &ndims, (unsigned long long*)&data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+
+                    sciErr = createHypermatOfUnsignedInteger64(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned long long*)data);
+                    if (sciErr.iErr)
+                    {
+                        printError(&sciErr, 0);
+                        return sciErr.iErr;
+                    }
+                    break;
+            }
+        }
+        else
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: An integer expected.\n"), fname, 1);
+            return 1;
+        }
+
+        AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+    }
+
+    return 0;
+}
diff --git a/scilab/modules/api_scilab/tests/unit_tests/hypermatIntExample.dia.ref b/scilab/modules/api_scilab/tests/unit_tests/hypermatIntExample.dia.ref
new file mode 100644 (file)
index 0000000..95e27cf
--- /dev/null
@@ -0,0 +1,29 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises 
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/hypermatIntExample"));
+cd(pathconvert(TMPDIR+"/hypermatIntExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/hypermatIntExample.c",pathconvert(TMPDIR+"/hypermatIntExample/hypermatIntExample.c",%F));
+ilib_build("gw_hypermatIntExample",["hypermatIntExample","hypermatIntExample"],"hypermatIntExample.c",[],"","","");
+exec("loader.sce");
+a = hypermat([1 2 3], int8(1:6));
+b = hypermat([1 2 3], uint8(1:6));
+c = hypermat([1 2 3], int16(1:6));
+d = hypermat([1 2 3], uint16(1:6));
+e = hypermat([1 2 3], int32(1:6));
+f = hypermat([1 2 3], uint32(1:6));
+g = hypermat([1 2 3], int64(1:6));
+h = hypermat([1 2 3], uint64(1:6));
+assert_checkequal(hypermatIntExample(a), a);
+assert_checkequal(hypermatIntExample(b), b);
+assert_checkequal(hypermatIntExample(c), c);
+assert_checkequal(hypermatIntExample(d), d);
+assert_checkequal(hypermatIntExample(e), e);
+assert_checkequal(hypermatIntExample(f), f);
+assert_checkequal(hypermatIntExample(g), g);
+assert_checkequal(hypermatIntExample(h), h);
diff --git a/scilab/modules/api_scilab/tests/unit_tests/hypermatIntExample.tst b/scilab/modules/api_scilab/tests/unit_tests/hypermatIntExample.tst
new file mode 100644 (file)
index 0000000..fd14500
--- /dev/null
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/hypermatIntExample"));
+cd(pathconvert(TMPDIR+"/hypermatIntExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/hypermatIntExample.c",pathconvert(TMPDIR+"/hypermatIntExample/hypermatIntExample.c",%F));
+ilib_build("gw_hypermatIntExample",["hypermatIntExample","hypermatIntExample"],"hypermatIntExample.c",[],"","","");
+exec("loader.sce");
+
+a = hypermat([1 2 3], int8(1:6));
+b = hypermat([1 2 3], uint8(1:6));
+c = hypermat([1 2 3], int16(1:6));
+d = hypermat([1 2 3], uint16(1:6));
+e = hypermat([1 2 3], int32(1:6));
+f = hypermat([1 2 3], uint32(1:6));
+g = hypermat([1 2 3], int64(1:6));
+h = hypermat([1 2 3], uint64(1:6));
+
+assert_checkequal(hypermatIntExample(a), a);
+assert_checkequal(hypermatIntExample(b), b);
+assert_checkequal(hypermatIntExample(c), c);
+assert_checkequal(hypermatIntExample(d), d);
+assert_checkequal(hypermatIntExample(e), e);
+assert_checkequal(hypermatIntExample(f), f);
+assert_checkequal(hypermatIntExample(g), g);
+assert_checkequal(hypermatIntExample(h), h);
index 3c39f31..ff3b282 100644 (file)
@@ -51,7 +51,7 @@ public :
     int                     getRank();
     bool                    setRank(int _iRank, bool bSave = false);
     bool                    setCoef(Double *_poPow);
-    bool                    setCoef(double *_pdblCoefR, double *_pdblCoefI);
+    bool                    setCoef(const double *_pdblCoefR, const double *_pdblCoefI);
     bool                    evaluate(double _dblInR, double _dblInI, double *_pdblOutR, double *_pdblOutI);
     void                    updateRank(void);
 
index a540bf7..d0bc009 100644 (file)
@@ -235,7 +235,7 @@ bool SinglePoly::setCoef(Double* _pdblCoefR)
     return setCoef(pInR, pInI);
 }
 
-bool SinglePoly::setCoef(double* _pdblCoefR, double* _pdblCoefI)
+bool SinglePoly::setCoef(const double* _pdblCoefR, const double* _pdblCoefI)
 {
     if (_pdblCoefI != NULL && isComplex() == false)
     {