Merge remote-tracking branch 'origin/master' into yasp 64/10064/2
Antoine ELIAS [Wed, 19 Dec 2012 16:24:56 +0000 (17:24 +0100)]
Conflicts:
scilab/modules/api_scilab/api_scilab.vcxproj
scilab/modules/api_scilab/core_Import.def
scilab/modules/api_scilab/src/cpp/api_common.cpp
scilab/modules/api_scilab/src/cpp/api_double.cpp
scilab/modules/api_scilab/src/cpp/api_list.cpp
scilab/modules/cacsd/Makefile.am
scilab/modules/cacsd/Makefile.in
scilab/modules/cacsd/sci_gateway/c/gw_cacsd1.c
scilab/modules/cacsd/sci_gateway/c/gw_slicot.c
scilab/modules/cacsd/sci_gateway/cacsd_gateway.xml
scilab/modules/core/Makefile.in
scilab/modules/core/src/c/getval.c
scilab/modules/development_tools/macros/test_run.sci
scilab/modules/elementary_functions/Makefile.am
scilab/modules/elementary_functions/Makefile.in
scilab/modules/elementary_functions/sci_gateway/c/sci_gsort.c
scilab/modules/elementary_functions/src/c/elementary_functions.vcxproj
scilab/modules/elementary_functions/src/c/elementary_functions.vcxproj.filters
scilab/modules/fileio/tests/unit_tests/meof.dia.ref
scilab/modules/functions/functions.iss
scilab/modules/io/io.iss
scilab/modules/scicos/Makefile.in
scilab/modules/xcos/includes/gw_xcos.h
scilab/modules/xcos/sci_gateway/c/gw_xcos.c

Change-Id: Ia51f71b36871a257323d58087516c13370f9aca3

61 files changed:
1  2 
scilab/bin/scilab
scilab/contrib/Makefile.in
scilab/modules/api_scilab/api_scilab.vcxproj
scilab/modules/api_scilab/api_scilab.vcxproj.filters
scilab/modules/api_scilab/elementary_functions_Import.def
scilab/modules/api_scilab/includes/api_double.h
scilab/modules/api_scilab/src/cpp/api_common.cpp
scilab/modules/api_scilab/src/cpp/api_double.cpp
scilab/modules/api_scilab/src/cpp/api_internal_double.h
scilab/modules/api_scilab/src/cpp/api_list.cpp
scilab/modules/arnoldi/sci_gateway/c/sci_eigs.c
scilab/modules/cacsd/Makefile.am
scilab/modules/cacsd/Makefile.in
scilab/modules/cacsd/includes/gw_slicot.h
scilab/modules/cacsd/sci_gateway/c/gw_cacsd1.c
scilab/modules/cacsd/sci_gateway/c/gw_slicot.c
scilab/modules/cacsd/sci_gateway/c/sci_dhinf.c
scilab/modules/cacsd/sci_gateway/c/sci_hinf.c
scilab/modules/cacsd/sci_gateway/c/sci_linmeq.c
scilab/modules/cacsd/sci_gateway/c/sci_mucomp.c
scilab/modules/cacsd/sci_gateway/c/sci_rankqr.c
scilab/modules/cacsd/sci_gateway/c/sci_rankqr.h
scilab/modules/cacsd/sci_gateway/c/sci_ricc2.c
scilab/modules/cacsd/sci_gateway/c/sci_rrankqr.c
scilab/modules/cacsd/sci_gateway/c/sci_zrankqr.c
scilab/modules/cacsd/src/c/cacsd.vcxproj
scilab/modules/cacsd/src/c/cacsd.vcxproj.filters
scilab/modules/core/includes/callinterf.h
scilab/modules/core/includes/stack2.h
scilab/modules/core/src/c/callinterf.c
scilab/modules/core/src/c/getval.c
scilab/modules/core/src/c/getval.h
scilab/modules/development_tools/macros/test_run.sci
scilab/modules/dynamic_link/src/scripts/Makefile.incl.mak
scilab/modules/elementary_functions/Makefile.am
scilab/modules/elementary_functions/Makefile.in
scilab/modules/elementary_functions/includes/sci_tools.h
scilab/modules/elementary_functions/src/c/elementary_functions.vcxproj
scilab/modules/elementary_functions/src/c/elementary_functions.vcxproj.filters
scilab/modules/fileio/tests/unit_tests/meof.dia.ref
scilab/modules/fileio/tests/unit_tests/meof.tst
scilab/modules/functions/functions.iss
scilab/modules/graphics/src/c/InitObjects.c
scilab/modules/gui/sci_gateway/c/sci_unsetmenu.c
scilab/modules/helptools/data/configuration/scilab_macros.txt
scilab/modules/io/io.iss
scilab/modules/polynomials/sci_gateway/fortran/sci_f_poly.f
scilab/modules/scicos/Makefile.am
scilab/modules/scicos/Makefile.in
scilab/modules/scicos/src/c/scicos.c
scilab/modules/scicos/src/c/scicos.vcxproj
scilab/modules/scicos/src/c/scicos.vcxproj.filters
scilab/modules/spreadsheet/sci_gateway/c/sci_csvTextScan.c
scilab/modules/tclsci/Makefile.am
scilab/modules/tclsci/Makefile.in
scilab/modules/xcos/Makefile.am
scilab/modules/xcos/Makefile.in
scilab/modules/xcos/includes/gw_xcos.h
scilab/modules/xcos/sci_gateway/c/gw_xcos.c
scilab/modules/xcos/sci_gateway/cpp/sci_xcosPalGenerateAllIcons.cpp
scilab/modules/xcos/src/c/xcos.vcxproj

@@@ -855,24 -850,9 +850,23 @@@ do_help(
      echo     "  -profiling-visu : Start Scilab under callgrind (Unix/linux only)."
      echo     "                    define the variable SCILAB_VALGRIND_OPT to add custom arguments to"
      echo     "                    callgrind (and override the existing callgrind arguments)."
-     echo     "  -electric-fence : Start Scilab with the Electric Fence (Unix/linux only)."
      echo     "  -disable-exception-catching : Disable Scilab exception catching system."
      echo     " "
 -    echo     "  All these arguments can be retrieved by the Scilab function sciargs."
 +    echo     "  --parse-file File : Only parse File argument without execution and exit."
 +    echo     "  --parse-trace     : Display bison state machine evolution."
 +    echo     "  --AST-trace       : Display ASCII-art AST to be human readable."
 +    echo     "  --pretty-print    : Display pretty-printed code, standard Scilab syntax."
 +    echo     " "
 +    echo     "Developer Timer arguments:"
 +    echo     "  --AST-timed      : Time each AST node."
 +    echo     "  --timed          : Time global execution."
 +    echo     " "
 +    echo     "Developer Debug arguments:"
 +    echo     "  --no-exec        : Only do Lexing/parsing do not execute instructions."
 +    echo     "  --context-dump   : Display context status."
 +    echo     "  --exec-verbose   : Display command before execute it."
 +    echo     " "
 +    echo     "      All these arguments can be retrieved by the Scilab function sciargs."
      echo     " "
  
      echo     "  Several environment variables can be declared:"
Simple merge
      </ClCompile>
      <PreLinkEvent>
        <Message>Make dependencies</Message>
 -      <Command>cd $(IntDir) &gt;nul
 +      <Command>lib /DEF:"$(ProjectDir)Localization_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)scilocalization.lib" 1&gt;NUL 2&gt;NUL
 +lib /DEF:"$(ProjectDir)Core_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1&gt;NUL 2&gt;NUL
++lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions.lib" 1&gt;NUL 2&gt;NUL
 +cd $(IntDir) &gt;nul
  for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n api_scilab.dll %%f &gt;nul
  copy *.def api_scilabtmp.def &gt;nul
  copy ..\api_scilab_header.def+api_scilabtmp.def  ..\api_scilab_export.def &gt;nul
  del *.def &gt;nul
 -cd .. &gt;nul</Command>
 +cd .. &gt;nul
 +</Command>
      </PreLinkEvent>
      <Link>
-       <AdditionalDependencies>scilocalization.lib;core.lib</AdditionalDependencies>
 -      <AdditionalDependencies>core.lib;string.lib;scilocalization.lib;scilab_windows.lib;core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
++      <AdditionalDependencies>scilocalization.lib;core.lib;elementary_functions.lib</AdditionalDependencies>
        <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
        <ModuleDefinitionFile>api_scilab_export.def</ModuleDefinitionFile>
        <GenerateDebugInformation>true</GenerateDebugInformation>
      </ClCompile>
      <PreLinkEvent>
        <Message>Make dependencies</Message>
 -      <Command>cd $(IntDir) &gt;nul
 +      <Command>lib /DEF:"$(ProjectDir)Localization_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)scilocalization.lib" 1&gt;NUL 2&gt;NUL
 +lib /DEF:"$(ProjectDir)Core_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1&gt;NUL 2&gt;NUL
++lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions.lib" 1&gt;NUL 2&gt;NUL
 +cd $(IntDir) &gt;nul
  for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n api_scilab.dll %%f &gt;nul
  copy *.def api_scilabtmp.def &gt;nul
  copy ..\api_scilab_header.def+api_scilabtmp.def  ..\api_scilab_export.def &gt;nul
  del *.def &gt;nul
 -cd .. &gt;nul</Command>
 +cd .. &gt;nul
 +</Command>
      </PreLinkEvent>
      <Link>
-       <AdditionalDependencies>scilocalization.lib;core.lib</AdditionalDependencies>
 -      <AdditionalDependencies>core.lib;string.lib;scilocalization.lib;scilab_windows.lib;core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
++      <AdditionalDependencies>scilocalization.lib;core.lib;elementary_functions.lib</AdditionalDependencies>
        <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
        <ModuleDefinitionFile>api_scilab_export.def</ModuleDefinitionFile>
        <GenerateDebugInformation>true</GenerateDebugInformation>
      </ClCompile>
      <PreLinkEvent>
        <Message>Make dependencies</Message>
 -      <Command>cd $(IntDir) &gt;nul
 +      <Command>lib /DEF:"$(ProjectDir)Localization_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)scilocalization.lib" 1&gt;NUL 2&gt;NUL
 +lib /DEF:"$(ProjectDir)Core_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1&gt;NUL 2&gt;NUL
++lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions.lib" 1&gt;NUL 2&gt;NUL
 +cd $(IntDir) &gt;nul
  for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n api_scilab.dll %%f &gt;nul
  copy *.def api_scilabtmp.def &gt;nul
  copy ..\api_scilab_header.def+api_scilabtmp.def  ..\api_scilab_export.def &gt;nul
  del *.def &gt;nul
 -cd .. &gt;nul</Command>
 +cd .. &gt;nul
 +</Command>
      </PreLinkEvent>
      <Link>
-       <AdditionalDependencies>scilocalization.lib;core.lib</AdditionalDependencies>
 -      <AdditionalDependencies>core.lib;string.lib;scilocalization.lib;scilab_windows.lib;core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
++      <AdditionalDependencies>scilocalization.lib;core.lib;elementary_functions.lib</AdditionalDependencies>
        <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
        <ModuleDefinitionFile>api_scilab_export.def</ModuleDefinitionFile>
        <GenerateDebugInformation>false</GenerateDebugInformation>
      </ClCompile>
      <PreLinkEvent>
        <Message>Make dependencies</Message>
 -      <Command>cd $(IntDir) &gt;nul
 +      <Command>lib /DEF:"$(ProjectDir)Localization_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)scilocalization.lib" 1&gt;NUL 2&gt;NUL
 +lib /DEF:"$(ProjectDir)Core_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1&gt;NUL 2&gt;NUL
++lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)elementary_functions.lib" 1&gt;NUL 2&gt;NUL
 +cd $(IntDir) &gt;nul
  for %%f in (*.obj) do  ..\..\..\bin\dumpexts -o %%~nf.def -n api_scilab.dll %%f &gt;nul
  copy *.def api_scilabtmp.def &gt;nul
  copy ..\api_scilab_header.def+api_scilabtmp.def  ..\api_scilab_export.def &gt;nul
  del *.def &gt;nul
 -cd .. &gt;nul</Command>
 +cd .. &gt;nul
 +</Command>
      </PreLinkEvent>
      <Link>
-       <AdditionalDependencies>scilocalization.lib;core.lib</AdditionalDependencies>
 -      <AdditionalDependencies>core.lib;string.lib;scilocalization.lib;scilab_windows.lib;core_f.lib;%(AdditionalDependencies)</AdditionalDependencies>
++      <AdditionalDependencies>scilocalization.lib;core.lib;elementary_functions.lib</AdditionalDependencies>
        <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
        <ModuleDefinitionFile>api_scilab_export.def</ModuleDefinitionFile>
        <GenerateDebugInformation>false</GenerateDebugInformation>
      <ResourceCompile Include="src\c\api_scilab.rc" />
    </ItemGroup>
    <ItemGroup>
 -    <None Include="Core_f_Import.def" />
      <None Include="core_import.def" />
++    <None Include="elementary_functions_Import.def" />
      <None Include="locales\api_scilab.pot" />
      <None Include="Localization_Import.def" />
 -    <None Include="Scilab_windows_Import.def" />
 -    <None Include="String_Import.def" />
      <None Include="api_scilab_export.def" />
      <None Include="api_scilab_header.def" />
      <None Include="api_scilab.iss" />
      <None Include="locales\api_scilab.pot">
        <Filter>localization</Filter>
      </None>
 -    <None Include="Core_f_Import.def">
++    <None Include="elementary_functions_Import.def">
+       <Filter>Libraries Dependencies\Imports</Filter>
+     </None>
    </ItemGroup>
  </Project>
index 0000000,0000000..870e2c2
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,5 @@@
++LIBRARY    elementary_functions.dll
++
++
++EXPORTS
++SciToF77
@@@ -35,11 -21,10 +35,12 @@@ extern "C
  #include "call_scilab.h"
  #include "stackinfo.h"
  #include "Scierror.h"
+ #include "sciprint.h"
  #include "localization.h"
  #include "MALLOC.h"
 +}
  
 +static int api_fake_int; //only for compatibility with Scilab 5 stack functions
  /*Global structure for scilab 5.x*/
  extern "C"
  {
@@@ -333,6 -269,21 +337,21 @@@ SciErr getVarAddressFromPosition(void *
      SciErr sciErr;
      sciErr.iErr = 0;
      sciErr.iMsgCount = 0;
+     sciErr = getinternalVarAddress(_pvCtx, _iVar, _piAddress);
+     //sciprint("type : %d(%c)\n", (*_piAddress)[0], intersci_.ntypes[_iVar - 1]);
+     //update variable state to "read
 -    intersci_.ntypes[_iVar - 1] = '$';
++    //intersci_.ntypes[_iVar - 1] = '$';
+     return sciErr;
+ }
+ /*--------------------------------------------------------------------------*/
+ static SciErr getinternalVarAddress(void *_pvCtx, int _iVar, int **_piAddress)
+ {
+     SciErr sciErr;
+     sciErr.iErr = 0;
+     sciErr.iMsgCount = 0;
      int iAddr = 0;
      int iValType = 0;
  
          return sciErr;
      }
  
 -    iAddr = iadr(*Lstk(Top - Rhs + _iVar));
 -    iValType = *istk(iAddr);
 -    if (iValType < 0)
 +    GatewayStruct* pStr = (GatewayStruct*)_pvCtx;
 +    typed_list in = *pStr->m_pIn;
 +    int*    piRetCount = pStr->m_piRetCount;
 +
 +    /* we accept a call to getVarAddressFromPosition after a create... call */
 +    if(_iVar > in.size())
      {
 -        iAddr = iadr(*istk(iAddr + 1));
 +        //manage case where _iVar > in.size(), then look in out to get recent create variable.
 +        addErrorMessage(&sciErr, API_ERROR_INVALID_POSITION, _("%s: bad call to %s! (1rst argument).\n"), pStr->m_pstName, "getVarAddressFromPosition");
 +        return sciErr;
      }
  
 -    *_piAddress = istk(iAddr);
 +    *_piAddress = (int*)in[_iVar - 1];
      return sciErr;
  }
  /*--------------------------------------------------------------------------*/
  SciErr getVarNameFromPosition(void *_pvCtx, int _iVar, char *_pstName)
  {
@@@ -1475,16 -1374,28 +1495,25 @@@ int checkNamedVarFormat(void* _pvCtx, c
      int iRet = 1;
  
      // check pointer
-     if (_pstName == NULL) iRet = 0;
+     if (_pstName == NULL)
+     {
+         iRet = 0;
+     }
  
 -    // check length _pstName =< nlgh
 -    if ((strlen(_pstName) == 0 || strlen(_pstName) > nlgh))
 -    {
 -        iRet = 0;
 -    }
 +    // check length _pstName <> 0
 +    if (strlen(_pstName) == 0) iRet = 0;
  
      // forbidden characters
-     if (strpbrk(_pstName, FORBIDDEN_CHARS) != NULL) iRet = 0;
+     if (strpbrk(_pstName, FORBIDDEN_CHARS) != NULL)
+     {
+         iRet = 0;
+     }
  
      // variable does not begin by a digit
-     if (isdigit(_pstName[0])) iRet = 0;
+     if (isdigit(_pstName[0]))
+     {
+         iRet = 0;
+     }
  
      // check that we have only ascii characters
      for (int i = 0; i < (int)strlen(_pstName); i++)
@@@ -26,13 -18,11 +26,14 @@@ extern "C
  #include "api_internal_common.h"
  #include "api_internal_double.h"
  #include "localization.h"
 +#include "elem_common.h"
++#include "sci_tools.h"
 +    extern int C2F(entier)(int *n, double *d__, int *s);
 +    extern int C2F(icopy)(int *, int *, int *, int *, int *);
 +}
  
 -#include "call_scilab.h"
 +using namespace types;
  
 -extern int C2F(entier)(int *n, double *d__, int *s);
 -extern int C2F(icopy)(int *, int *, int *, int *, int *);
  /*******************************/
  /*   double matrix functions   */
  /*******************************/
@@@ -101,8 -90,8 +105,7 @@@ SciErr getComplexMatrixOfDoubleAsIntege
      SciErr sciErr;
      double* pdblReal = NULL;
      double* pdblImg  = NULL;
-     sciErr = getCommonMatrixOfDouble(_pvCtx, _piAddress, 1, _piRows, _piCols, &pdblReal, &pdblImg);
 -    int iSize = 0;
+     sciErr = getCommonMatrixOfDouble(_pvCtx, _piAddress, 'i', 1, _piRows, _piCols, &pdblReal, &pdblImg);
      if (sciErr.iErr)
      {
          return sciErr;
@@@ -295,6 -280,54 +297,26 @@@ SciErr allocCommonMatrixOfDouble(void* 
      return sciErr;
  }
  
+ SciErr allocComplexZMatrixOfDouble(void* _pvCtx, int _iVar, int _iRows, int _iCols, const doublecomplex** _pdblData)
+ {
+     SciErr sciErr;
+     sciErr.iErr = 0;
+     sciErr.iMsgCount = 0;
+     double* pdblReal = NULL;
+     double* pdblImg = NULL;
+     sciErr = allocComplexMatrixOfDouble(_pvCtx, _iVar, _iRows, _iCols, &pdblReal, &pdblImg);
+     if (sciErr.iErr)
+     {
+         return sciErr;
+     }
+     //warning convert double* to doublecomplex*
+     *_pdblData = (doublecomplex*)pdblReal;
 -    //strore storage information to putlhsvar
 -    intersci_.ntypes[_iVar - 1] = 'z';
 -    return sciErr;
 -}
 -
 -SciErr fillCommonMatrixOfDouble(void* _pvCtx, int* _piAddress, int _iComplex, int _iRows, int _iCols, double** _pdblReal, double** _pdblImg)
 -{
 -    SciErr sciErr;
 -    sciErr.iErr = 0;
 -    sciErr.iMsgCount = 0;
 -    _piAddress[0]             = sci_matrix;
 -    _piAddress[1]             = Min(_iRows, _iRows * _iCols);
 -    _piAddress[2]             = Min(_iCols, _iRows * _iCols);
 -    _piAddress[3]             = _iComplex;
 -
 -
 -    if (_pdblReal != NULL)
 -    {
 -        *_pdblReal            = (double*)(_piAddress + 4);
 -    }
 -
 -    if (_iComplex != 0 && _pdblImg != NULL)
 -    {
 -        *_pdblImg     = *_pdblReal + _iRows * _iCols;
 -    }
 -
+     return sciErr;
+ }
  SciErr createMatrixOfDouble(void* _pvCtx, int _iVar, int _iRows, int _iCols, const double* _pdblReal)
  {
      SciErr sciErr;
@@@ -13,8 -13,9 +13,8 @@@
  #define __INTERNAL_DOUBLE_API__
  
  //internal double functions
- SciErr getCommonMatrixOfDouble(void* _pvCtx, int* _piAddress, int _iComplex, int* _piRows, int* _piCols, double** _pdblReal, double** _pdblImg);
+ SciErr getCommonMatrixOfDouble(void* _pvCtx, int* _piAddress, char _cType, int _iComplex, int* _piRows, int* _piCols, double** _pdblReal, double** _pdblImg);
  SciErr allocCommonMatrixOfDouble(void* _pvCtx, int _iVar, char _cType, int _iComplex, int _iRows, int _iCols, double** _pdblReal, double** _pdblImg);
 -SciErr fillCommonMatrixOfDouble(void* _pvCtx, int* _piAddress, int _iComplex, int _iRows, int _iCols, double** _pdblReal, double** _pdblImg);
  SciErr createCommonNamedMatrixOfDouble(void* _pvCtx, const char* _pstName, int _iComplex, int _iRows, int _iCols, const double* _pdblReal, const double* _pdblImg);
  SciErr readCommonNamedMatrixOfDouble(void* _pvCtx, const char* _pstName, int _iComplex, int* _piRows, int* _piCols, double* _pdblReal, double* _pdblImg);
  
@@@ -151,15 -152,18 +152,15 @@@ src/fortran/calsca.f 
  src/fortran/qitz.f \
  src/fortran/front.f
  
- GATEWAY_C_SOURCES = sci_gateway/c/sci_arl2.c \
+ GATEWAY_C_SOURCES = \
+ sci_gateway/c/sci_arl2.c \
 -sci_gateway/c/sci_gspec.c \
  sci_gateway/c/sci_rtitr.c \
  sci_gateway/c/sci_ereduc.c \
  sci_gateway/c/sci_ppol.c \
  sci_gateway/c/sci_tzer.c \
  sci_gateway/c/sci_contr.c \
  sci_gateway/c/sci_fstair.c \
 -sci_gateway/c/sci_gschur.c \
  sci_gateway/c/sci_residu.c \
--sci_gateway/c/gw_slicot.c \
  sci_gateway/c/gw_cacsd0.c \
  sci_gateway/c/sci_freq.c \
  sci_gateway/c/gw_cacsd1.c \
@@@ -167,12 -173,16 +170,15 @@@ sci_gateway/c/sci_zrankqr.c 
  sci_gateway/c/sci_ltitr.c \
  sci_gateway/c/sci_ldiv.c \
  sci_gateway/c/gw_cacsd2.c \
- sci_gateway/c/gw_cacsd3.c
- #sci_gateway/c/sci_gschur.c => obsolete
- #sci_gateway/c/sci_gspec.c => obsolete
+ sci_gateway/c/gw_cacsd3.c \
+ sci_gateway/c/sci_dhinf.c \
+ sci_gateway/c/sci_hinf.c \
+ sci_gateway/c/sci_linmeq.c \
+ sci_gateway/c/sci_mucomp.c \
+ sci_gateway/c/sci_ricc2.c
  
- GATEWAY_FORTRAN_SOURCES = sci_gateway/fortran/sci_f_hinf.f \
- sci_gateway/fortran/sci_f_zrankqr.f \
 -
+ GATEWAY_FORTRAN_SOURCES = \
  sci_gateway/fortran/sci_f_tzer.f \
  sci_gateway/fortran/sci_f_residu.f \
  sci_gateway/fortran/sci_f_sylv.f \
@@@ -184,25 -193,19 +189,18 @@@ sci_gateway/fortran/sci_f_sident.f 
  sci_gateway/fortran/sci_f_lyap.f \
  sci_gateway/fortran/sci_f_rtitr.f \
  sci_gateway/fortran/sci_f_sorder.f \
- sci_gateway/fortran/sci_f_mucomp.f \
  sci_gateway/fortran/sci_f_ltitr.f \
- sci_gateway/fortran/sci_f_dhinf.f \
- sci_gateway/fortran/sci_f_ricc2.f \
  sci_gateway/fortran/sci_f_arl2.f \
 -sci_gateway/fortran/sci_f_gschur.f \
  sci_gateway/fortran/sci_f_ereduc.f \
  sci_gateway/fortran/sci_f_findbd.f \
--sci_gateway/fortran/sci_f_fstair.f \
- sci_gateway/fortran/sci_f_linmeq.f \
- sci_gateway/fortran/sci_f_rankqr.f
- #sci_gateway/fortran/sci_f_gschur.f => obsolete
- #sci_gateway/fortran/sci_f_gspec.f => obsolete
 -sci_gateway/fortran/sci_f_gspec.f
++sci_gateway/fortran/sci_f_fstair.f
  
 -libscicacsd_la_CPPFLAGS= -I$(srcdir)/includes/ \
 -                      -I$(top_srcdir)/libs/MALLOC/includes/ \
 +libscicacsd_la_CPPFLAGS=      -I$(srcdir)/includes/ \
 +                      -I$(top_srcdir)/modules/output_stream/includes/ \
 +                      -I$(top_srcdir)/modules/elementary_functions/includes/ \
                        -I$(top_srcdir)/modules/api_scilab/includes/ \
 +                      -I$(top_srcdir)/modules/operations/includes/ \
                        -I$(top_srcdir)/modules/localization/includes/ \
 -                      -I$(top_srcdir)/modules/output_stream/includes/ \
                        $(AM_CPPFLAGS)
  
  if MAINTAINER_MODE
@@@ -163,22 -162,24 +163,22 @@@ libscicacsd_algo_la_OBJECTS = $(am_libs
  @MAINTAINER_MODE_FALSE@am_libscicacsd_algo_la_rpath =
  @MAINTAINER_MODE_TRUE@am_libscicacsd_algo_la_rpath =
  libscicacsd_la_DEPENDENCIES = libscicacsd-algo.la
- am__objects_3 = sci_f_hinf.lo sci_f_zrankqr.lo sci_f_tzer.lo \
-       sci_f_residu.lo sci_f_sylv.lo sci_f_ppol.lo sci_f_freq.lo \
-       sci_f_ldiv.lo sci_f_ricc.lo sci_f_sident.lo sci_f_lyap.lo \
-       sci_f_rtitr.lo sci_f_sorder.lo sci_f_mucomp.lo sci_f_ltitr.lo \
-       sci_f_dhinf.lo sci_f_ricc2.lo sci_f_arl2.lo sci_f_ereduc.lo \
-       sci_f_findbd.lo sci_f_fstair.lo sci_f_linmeq.lo \
-       sci_f_rankqr.lo
+ am__objects_3 = sci_f_tzer.lo sci_f_residu.lo sci_f_sylv.lo \
+       sci_f_ppol.lo sci_f_freq.lo sci_f_ldiv.lo sci_f_sident.lo \
+       sci_f_lyap.lo sci_f_rtitr.lo sci_f_sorder.lo sci_f_ltitr.lo \
 -      sci_f_arl2.lo sci_f_gschur.lo sci_f_ereduc.lo sci_f_findbd.lo \
 -      sci_f_fstair.lo sci_f_gspec.lo
 -am__objects_4 = libscicacsd_la-sci_arl2.lo libscicacsd_la-sci_gspec.lo \
 -      libscicacsd_la-sci_rtitr.lo libscicacsd_la-sci_ereduc.lo \
 -      libscicacsd_la-sci_ppol.lo libscicacsd_la-sci_tzer.lo \
 -      libscicacsd_la-sci_contr.lo libscicacsd_la-sci_fstair.lo \
 -      libscicacsd_la-sci_gschur.lo libscicacsd_la-sci_residu.lo \
 -      libscicacsd_la-gw_slicot.lo libscicacsd_la-gw_cacsd0.lo \
 -      libscicacsd_la-sci_freq.lo libscicacsd_la-gw_cacsd1.lo \
 -      libscicacsd_la-sci_rankqr.lo libscicacsd_la-sci_rrankqr.lo \
 -      libscicacsd_la-sci_zrankqr.lo libscicacsd_la-sci_ltitr.lo \
 -      libscicacsd_la-sci_ldiv.lo libscicacsd_la-gw_cacsd2.lo \
 -      libscicacsd_la-gw_cacsd3.lo libscicacsd_la-sci_dhinf.lo \
 -      libscicacsd_la-sci_hinf.lo libscicacsd_la-sci_linmeq.lo \
 -      libscicacsd_la-sci_mucomp.lo libscicacsd_la-sci_ricc2.lo
++      sci_f_arl2.lo sci_f_ereduc.lo sci_f_findbd.lo sci_f_fstair.lo
 +am__objects_4 = libscicacsd_la-sci_arl2.lo libscicacsd_la-sci_rtitr.lo \
 +      libscicacsd_la-sci_ereduc.lo libscicacsd_la-sci_ppol.lo \
 +      libscicacsd_la-sci_tzer.lo libscicacsd_la-sci_contr.lo \
 +      libscicacsd_la-sci_fstair.lo libscicacsd_la-sci_residu.lo \
-       libscicacsd_la-gw_slicot.lo libscicacsd_la-gw_cacsd0.lo \
-       libscicacsd_la-sci_freq.lo libscicacsd_la-gw_cacsd1.lo \
-       libscicacsd_la-sci_rankqr.lo libscicacsd_la-sci_ltitr.lo \
-       libscicacsd_la-sci_ldiv.lo libscicacsd_la-gw_cacsd2.lo \
-       libscicacsd_la-gw_cacsd3.lo
++      libscicacsd_la-gw_cacsd0.lo libscicacsd_la-sci_freq.lo \
++      libscicacsd_la-gw_cacsd1.lo libscicacsd_la-sci_rankqr.lo \
++      libscicacsd_la-sci_rrankqr.lo libscicacsd_la-sci_zrankqr.lo \
++      libscicacsd_la-sci_ltitr.lo libscicacsd_la-sci_ldiv.lo \
++      libscicacsd_la-gw_cacsd2.lo libscicacsd_la-gw_cacsd3.lo \
++      libscicacsd_la-sci_dhinf.lo libscicacsd_la-sci_hinf.lo \
++      libscicacsd_la-sci_linmeq.lo libscicacsd_la-sci_mucomp.lo \
++      libscicacsd_la-sci_ricc2.lo
  am_libscicacsd_la_OBJECTS = $(am__objects_3) $(am__objects_4)
  libscicacsd_la_OBJECTS = $(am_libscicacsd_la_OBJECTS)
  libscicacsd_la_LINK = $(LIBTOOL) --tag=F77 $(AM_LIBTOOLFLAGS) \
@@@ -478,8 -473,8 +478,9 @@@ target_alias = @target_alias
  top_build_prefix = @top_build_prefix@
  top_builddir = @top_builddir@
  top_srcdir = @top_srcdir@
 +yacc_present = @yacc_present@
- SLICOT_FORTRAN_SOURCES = src/slicot/sb04pd.f \
+ SLICOT_FORTRAN_SOURCES = \
+ src/slicot/sb04pd.f \
  src/slicot/ib01ad.f \
  src/slicot/tb01wd.f \
  src/slicot/ib01py.f \
@@@ -626,15 -621,18 +627,15 @@@ src/fortran/calsca.f 
  src/fortran/qitz.f \
  src/fortran/front.f
  
- GATEWAY_C_SOURCES = sci_gateway/c/sci_arl2.c \
+ GATEWAY_C_SOURCES = \
+ sci_gateway/c/sci_arl2.c \
 -sci_gateway/c/sci_gspec.c \
  sci_gateway/c/sci_rtitr.c \
  sci_gateway/c/sci_ereduc.c \
  sci_gateway/c/sci_ppol.c \
  sci_gateway/c/sci_tzer.c \
  sci_gateway/c/sci_contr.c \
  sci_gateway/c/sci_fstair.c \
 -sci_gateway/c/sci_gschur.c \
  sci_gateway/c/sci_residu.c \
--sci_gateway/c/gw_slicot.c \
  sci_gateway/c/gw_cacsd0.c \
  sci_gateway/c/sci_freq.c \
  sci_gateway/c/gw_cacsd1.c \
@@@ -659,25 -660,19 +663,18 @@@ sci_gateway/fortran/sci_f_sident.f 
  sci_gateway/fortran/sci_f_lyap.f \
  sci_gateway/fortran/sci_f_rtitr.f \
  sci_gateway/fortran/sci_f_sorder.f \
- sci_gateway/fortran/sci_f_mucomp.f \
  sci_gateway/fortran/sci_f_ltitr.f \
- sci_gateway/fortran/sci_f_dhinf.f \
- sci_gateway/fortran/sci_f_ricc2.f \
  sci_gateway/fortran/sci_f_arl2.f \
 -sci_gateway/fortran/sci_f_gschur.f \
  sci_gateway/fortran/sci_f_ereduc.f \
  sci_gateway/fortran/sci_f_findbd.f \
--sci_gateway/fortran/sci_f_fstair.f \
- sci_gateway/fortran/sci_f_linmeq.f \
- sci_gateway/fortran/sci_f_rankqr.f
 -sci_gateway/fortran/sci_f_gspec.f
++sci_gateway/fortran/sci_f_fstair.f
  
- #sci_gateway/fortran/sci_f_gschur.f => obsolete
- #sci_gateway/fortran/sci_f_gspec.f => obsolete
  libscicacsd_la_CPPFLAGS = -I$(srcdir)/includes/ \
 -                      -I$(top_srcdir)/libs/MALLOC/includes/ \
 +                      -I$(top_srcdir)/modules/output_stream/includes/ \
 +                      -I$(top_srcdir)/modules/elementary_functions/includes/ \
                        -I$(top_srcdir)/modules/api_scilab/includes/ \
 +                      -I$(top_srcdir)/modules/operations/includes/ \
                        -I$(top_srcdir)/modules/localization/includes/ \
 -                      -I$(top_srcdir)/modules/output_stream/includes/ \
                        $(AM_CPPFLAGS)
  
  @MAINTAINER_MODE_TRUE@pkglib_LTLIBRARIES = libscicacsd.la
@@@ -871,14 -866,20 +868,17 @@@ distclean-compile
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-gw_cacsd1.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-gw_cacsd2.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-gw_cacsd3.Plo@am__quote@
--@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-gw_slicot.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_arl2.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_contr.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_dhinf.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_ereduc.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_freq.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_fstair.Plo@am__quote@
 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_gschur.Plo@am__quote@
 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_gspec.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_hinf.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_ldiv.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_linmeq.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_ltitr.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_mucomp.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_ppol.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_rankqr.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicacsd_la-sci_residu.Plo@am__quote@
@@@ -962,13 -980,13 +965,6 @@@ libscicacsd_la-sci_residu.lo: sci_gatew
  @AMDEP_TRUE@@am__fastdepCC_FALSE@     DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  @am__fastdepCC_FALSE@ $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicacsd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libscicacsd_la-sci_residu.lo `test -f 'sci_gateway/c/sci_residu.c' || echo '$(srcdir)/'`sci_gateway/c/sci_residu.c
  
--libscicacsd_la-gw_slicot.lo: sci_gateway/c/gw_slicot.c
--@am__fastdepCC_TRUE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicacsd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libscicacsd_la-gw_slicot.lo -MD -MP -MF $(DEPDIR)/libscicacsd_la-gw_slicot.Tpo -c -o libscicacsd_la-gw_slicot.lo `test -f 'sci_gateway/c/gw_slicot.c' || echo '$(srcdir)/'`sci_gateway/c/gw_slicot.c
--@am__fastdepCC_TRUE@  $(am__mv) $(DEPDIR)/libscicacsd_la-gw_slicot.Tpo $(DEPDIR)/libscicacsd_la-gw_slicot.Plo
--@AMDEP_TRUE@@am__fastdepCC_FALSE@     source='sci_gateway/c/gw_slicot.c' object='libscicacsd_la-gw_slicot.lo' libtool=yes @AMDEPBACKSLASH@
--@AMDEP_TRUE@@am__fastdepCC_FALSE@     DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
--@am__fastdepCC_FALSE@ $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicacsd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libscicacsd_la-gw_slicot.lo `test -f 'sci_gateway/c/gw_slicot.c' || echo '$(srcdir)/'`sci_gateway/c/gw_slicot.c
--
  libscicacsd_la-gw_cacsd0.lo: sci_gateway/c/gw_cacsd0.c
  @am__fastdepCC_TRUE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicacsd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libscicacsd_la-gw_cacsd0.lo -MD -MP -MF $(DEPDIR)/libscicacsd_la-gw_cacsd0.Tpo -c -o libscicacsd_la-gw_cacsd0.lo `test -f 'sci_gateway/c/gw_cacsd0.c' || echo '$(srcdir)/'`sci_gateway/c/gw_cacsd0.c
  @am__fastdepCC_TRUE@  $(am__mv) $(DEPDIR)/libscicacsd_la-gw_cacsd0.Tpo $(DEPDIR)/libscicacsd_la-gw_cacsd0.Plo
@@@ -1529,12 -1581,9 +1556,6 @@@ sci_f_findbd.lo: sci_gateway/fortran/sc
  sci_f_fstair.lo: sci_gateway/fortran/sci_f_fstair.f
        $(LIBTOOL)  --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o sci_f_fstair.lo `test -f 'sci_gateway/fortran/sci_f_fstair.f' || echo '$(srcdir)/'`sci_gateway/fortran/sci_f_fstair.f
  
- sci_f_linmeq.lo: sci_gateway/fortran/sci_f_linmeq.f
-       $(LIBTOOL)  --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o sci_f_linmeq.lo `test -f 'sci_gateway/fortran/sci_f_linmeq.f' || echo '$(srcdir)/'`sci_gateway/fortran/sci_f_linmeq.f
- sci_f_rankqr.lo: sci_gateway/fortran/sci_f_rankqr.f
-       $(LIBTOOL)  --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o sci_f_rankqr.lo `test -f 'sci_gateway/fortran/sci_f_rankqr.f' || echo '$(srcdir)/'`sci_gateway/fortran/sci_f_rankqr.f
 -sci_f_gspec.lo: sci_gateway/fortran/sci_f_gspec.f
 -      $(LIBTOOL)  --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o sci_f_gspec.lo `test -f 'sci_gateway/fortran/sci_f_gspec.f' || echo '$(srcdir)/'`sci_gateway/fortran/sci_f_gspec.f
 -
  mostlyclean-libtool:
        -rm -f *.lo
  
diff --cc scilab/modules/cacsd/includes/gw_slicot.h
index e9736f5,e9736f5..0000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,24 -1,24 +1,0 @@@
--
--/*
-- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-- * Copyright (C) INRIA - Allan CORNET
-- * 
-- * 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-en.txt
-- *
-- */
--
--/*--------------------------------------------------------------------------*/ 
--#ifndef __GW_SLICOT_H__
--#define __GW_SLICOT_H__
--/*--------------------------------------------------------------------------*/
--#include "dynlib_cacsd.h"
--/*--------------------------------------------------------------------------*/
--CACSD_IMPEXP int gw_slicot(void);
--/*--------------------------------------------------------------------------*/
--#endif /*  __GW_SLICOT_H__ */
--/*--------------------------------------------------------------------------*/
--
  /*--------------------------------------------------------------------------*/
  #include "gw_cacsd1.h"
  #include "callFunctionFromGateway.h"
 -#include "api_scilab.h"
 -#include "MALLOC.h"
 -/*--------------------------------------------------------------------------*/
 -static gw_generic_table Tab[] =
 -{
 -    {C2F(scilyap), "lyap"},
 -    {C2F(scisylv), "sylv"}
 -};
  /*--------------------------------------------------------------------------*/
- static gw_generic_table Tab[] =
- {
-       {C2F(scilyap),"lyap"},
-       {C2F(scisylv),"sylv"},
-       {C2F(intricc),"ricc"}
- };
- /*--------------------------------------------------------------------------*/
  int gw_cacsd1(void)
  {
 -    if (pvApiCtx == NULL)
 -    {
 -        pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
 -    }
 -
 -    pvApiCtx->pstName = (char*)Tab[Fin - 1].name;
 -    callFunctionFromGateway(Tab, SIZE_CURRENT_GENERIC_TABLE(Tab));
 -    return 0;
 +      return 0;
  }
  /*--------------------------------------------------------------------------*/
diff --cc scilab/modules/cacsd/sci_gateway/c/gw_slicot.c
index 0a9db08,50f01e9..0000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,88 -1,95 +1,0 @@@
--
--/*
-- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-- * Copyright (C) INRIA - Allan CORNET
-- *
-- * 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-en.txt
-- *
-- */
--
--#ifdef _MSC_VER
--#pragma warning(disable: 4113)
--#endif
--/*--------------------------------------------------------------------------*/
--#include <math.h>
--#include <string.h>
--/*--------------------------------------------------------------------------*/
--#ifdef _MSC_VER
--#include <Windows.h>
--#include "ExceptionMessage.h"
--#endif
--#include "machine.h"
--#include "../../../mexlib/includes/mex.h"
--#include "../../../mexlib/includes/sci_gateway.h"
--#include "sci_rankqr.h"
--#include "sci_contr.h"
--#include "gw_slicot.h"
--#include "api_scilab.h"
- /*--------------------------------------------------------------------------*/
- #ifndef __DEF_MXARRAY__
- #define __DEF_MXARRAY__
- typedef int mxArray;
- #endif
- typedef int Gatefunc (int nlhs,mxArray *plhs[],int nrhs,mxArray *prhs[]);
- /* fortran subroutines */
- extern Gatefunc C2F(sident);
- extern Gatefunc C2F(sorder);
- extern Gatefunc C2F(findbd);
- extern Gatefunc C2F(intmucomp);
- extern Gatefunc C2F(intricc2);
- extern Gatefunc C2F(inthinf);
- extern Gatefunc C2F(intdhinf);
- extern Gatefunc C2F(intlinmeq);
- /*--------------------------------------------------------------------------*/
- #ifndef __DEF_TABLE_STRUCT__
- #define __DEF_TABLE_STRUCT__
- typedef int (*GatefuncH) (int nlhs,mxArray *plhs[],int nrhs, mxArray *prhs[]);
- typedef int (*FGatefuncH) (int *nlhs,mxArray *plhs[],int *nrhs, mxArray *prhs[]);
- typedef int (*Myinterfun) (char *, GatefuncH F);
- typedef int (*GT) ();
- typedef struct table_struct {
-     Myinterfun f;    /** interface **/
-     GT F;     /** function **/
-     char *name;      /** its name **/
-   } GenericTable;
- #endif
- int fortran_mex_gateway (char *fname, FGatefuncH F);
- static GenericTable Tab[]={
-     {(Myinterfun) NULL, C2F(sident),"sident"}, // was fortran_mex_gateway
-   {(Myinterfun) NULL, C2F(sorder),"sorder"}, // was fortran_mex_gateway
-   {(Myinterfun) NULL, C2F(findbd),"findbd"}, // was fortran_mex_gateway
-   {(Myinterfun) sci_gateway, intrankqr,"rankqr"},
-   {(Myinterfun) sci_gateway, intab01od,"contr"},
-   {(Myinterfun) sci_gateway, C2F(intmucomp),"mucomp"},
-   {(Myinterfun) sci_gateway, C2F(intricc2),"pet_ricc"},
-   {(Myinterfun) sci_gateway, C2F(inthinf),"hinf"},
-   {(Myinterfun) sci_gateway, C2F(intdhinf),"dhinf"},
-   {(Myinterfun) sci_gateway, C2F(intlinmeq),"linmeq"}
- };
- /*--------------------------------------------------------------------------*/
- /*--------------------------------------------------------------------------*/
- int gw_slicot(void)
- {
-       return 0;
- }
- /*--------------------------------------------------------------------------*/
 -#include "MALLOC.h"
 -/*--------------------------------------------------------------------------*/
 -#ifndef __DEF_MXARRAY__
 -#define __DEF_MXARRAY__
 -typedef int mxArray;
 -typedef int Gatefunc (int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]);
 -#endif
 -/* fortran subroutines */
 -extern Gatefunc C2F(sident);
 -extern Gatefunc C2F(sorder);
 -extern Gatefunc C2F(findbd);
 -extern Gatefunc sci_ricc2;
 -extern Gatefunc sci_hinf;
 -extern Gatefunc sci_dhinf;
 -extern Gatefunc sci_linmeq;
 -extern Gatefunc sci_mucomp;
 -extern Gatefunc sci_rankqr;
 -
 -/*--------------------------------------------------------------------------*/
 -static GenericTable Tab[] =
 -{
 -    {(Myinterfun) fortran_mex_gateway, C2F(sident), "sident"},
 -    {(Myinterfun) fortran_mex_gateway, C2F(sorder), "sorder"},
 -    {(Myinterfun) fortran_mex_gateway, C2F(findbd), "findbd"},
 -    {(Myinterfun) sci_gateway, sci_rankqr, "rankqr"},
 -    {(Myinterfun) sci_gateway, intab01od, "contr"},
 -    {(Myinterfun) sci_gateway, sci_mucomp, "mucomp"},
 -    {(Myinterfun) sci_gateway, sci_ricc2, "pet_ricc"},
 -    {(Myinterfun) sci_gateway, sci_hinf, "hinf"},
 -    {(Myinterfun) sci_gateway, sci_dhinf, "dhinf"},
 -    {(Myinterfun) sci_gateway, sci_linmeq, "linmeq"}
 -};
 -/*--------------------------------------------------------------------------*/
 -int gw_slicot(void)
 -{
 -    Rhs = Max(0, Rhs);
 -
 -    if (pvApiCtx == NULL)
 -    {
 -        pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
 -    }
 -
 -    pvApiCtx->pstName = (char*)Tab[Fin - 1].name;
 -
 -#ifdef _MSC_VER
 -#ifndef _DEBUG
 -    _try
 -    {
 -        (*(Tab[Fin - 1].f))((char*)Tab[Fin - 1].name, Tab[Fin - 1].F);
 -    }
 -    _except (EXCEPTION_EXECUTE_HANDLER)
 -    {
 -        ExceptionMessage(GetExceptionCode(), Tab[Fin - 1].name);
 -    }
 -#else
 -    (*(Tab[Fin - 1].f))(Tab[Fin - 1].name, Tab[Fin - 1].F);
 -#endif
 -#else
 -    (*(Tab[Fin - 1].f))(Tab[Fin - 1].name, Tab[Fin - 1].F);
 -#endif
 -    return 0;
 -}
 -/*--------------------------------------------------------------------------*/
 -
index 0000000,7daf75f..312dad8
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,429 +1,428 @@@
+ /*
+  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+  * Copyright (C) 2012 - Scilab Enterprises - Cedric DELAMARRE
+  *
+  * 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-en.txt
+  *
+  */
 -#include "gw_slicot.h"
+ #include "api_scilab.h"
+ #include "Scierror.h"
+ #include "localization.h"
+ extern int C2F(sb10dd)();
+ extern double C2F(dlamch)();
+ // [Ak,Bk,Ck,Dk,RCOND]=dhinf(A,B,C,D,ncon,nmeas,gamma)
 -int sci_dhinf(char *fname, unsigned long fname_len)
++int sci_dhinf(char *fname, void* pvApiCtx)
+ {
+     SciErr sciErr;
+     int* piAddrlA   = NULL;
+     double* lA      = NULL;
+     int* piAddrlB   = NULL;
+     double* lB      = NULL;
+     int* piAddrlC   = NULL;
+     double* lC      = NULL;
+     int* piAddrlD   = NULL;
+     double* lD      = NULL;
+     double* lAK     = NULL;
+     double* lBK     = NULL;
+     double* lCK     = NULL;
+     double* lDK     = NULL;
+     double* lRCOND  = NULL;
+     int* piAddr5    = NULL;
+     int* lNCON      = NULL;
+     int* piAddr6    = NULL;
+     int* lNMEAS     = NULL;
+     int* piAddrlGAMMA = NULL;
+     double* lGAMMA  = NULL;
+     double* lX      = NULL;
+     double* lZ      = NULL;
+     int* lIWORK     = NULL;
+     int* lBWORK     = NULL;
+     double* lDWORK  = NULL;
+     double GAMMA = 0;
+     double TOL   = 0;
+     double EPS   = 0;
+     int NCON     = 0;
+     int NMEAS    = 0;
+     int LINTWORK = 0;
+     int LWORKMIN = 0;
+     int MA = 0, NA = 0;
+     int MB = 0, NB = 0;
+     int MC = 0, NC = 0;
+     int MD = 0, ND = 0;
+     int M1 = 0, N1 = 0;
+     int M2 = 0, N2 = 0;
+     int M3 = 0, N3 = 0;
+     int N = 0;
+     int M = 0;
+     int R = 0;
+     int Q = 0;
+     int minrhs = 7;
+     int maxrhs = 7;
+     int minlhs = 4;
+     int maxlhs = 5;
+     int iZero  = 0;
+     int iOne   = 1;
+     int iEight = 8;
+     int i2N    = 0;
+     int info   = 0;
+     CheckInputArgument(pvApiCtx, minrhs, maxrhs);
+     CheckOutputArgument(pvApiCtx, minlhs, maxlhs);
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrlA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 1.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlA, &MA, &NA, &lA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 1);
+         return 1;
+     }
+     if (MA != NA)
+     {
+         Scierror(999, _("%s: A must be a square matrix.\n"), fname);
+         return 1;
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrlB);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 2.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlB, &MB, &NB, &lB);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 2);
+         return 1;
+     }
+     if (MA != MB)
+     {
+         Scierror(999, _("%s: A and B must have equal number of rows.\n"), fname);
+         return 1;
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddrlC);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 3.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlC, &MC, &NC, &lC);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 3);
+         return 1;
+     }
+     if (NA != NC)
+     {
+         Scierror(999, _("%s: A and C must have equal number of columns.\n"), fname);
+         return 1;
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddrlD);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 4.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlD, &MD, &ND, &lD);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 4);
+         return 1;
+     }
+     if (NB != ND)
+     {
+         Scierror(999, _("%s: B and D must have equal number of columns.\n"), fname);
+         return 1;
+     }
+     if (MC != MD)
+     {
+         Scierror(999, _("%s: C and D must have equal number of rows.\n"), fname);
+         return 1;
+     }
+     N = MA;
+     M = NB;
+     R = MC;
+     if (N == 0 || M == 0 || R == 0)
+     {
+         sciErr = allocMatrixOfDouble(pvApiCtx, 5, iZero, iZero, &lAK);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, 6, iZero, iZero, &lBK);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, 7, iZero, iZero, &lCK);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, 8, iZero, iZero, &lDK);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, 9, iZero, iZero, &lRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         AssignOutputVariable(pvApiCtx, 1) = 5;
+         AssignOutputVariable(pvApiCtx, 2) = 6;
+         AssignOutputVariable(pvApiCtx, 3) = 7;
+         AssignOutputVariable(pvApiCtx, 4) = 8;
+         AssignOutputVariable(pvApiCtx, 5) = 9;
+         return 0;
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 5, &piAddr5);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 5.
+     sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddr5, &M1, &N1, &lNCON);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 5);
+         return 1;
+     }
+     if (M1 != 1 || N1 != 1 )
+     {
+         Scierror(999, _("%s: NCON must be a scalar.\n"), fname);
+         return 1;
+     }
+     NCON = *lNCON;
+     sciErr = getVarAddressFromPosition(pvApiCtx, 6, &piAddr6);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 6.
+     sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddr6, &M2, &N2, &lNMEAS);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 6);
+         return 1;
+     }
+     if (M2 != 1 || N2 != 1 )
+     {
+         Scierror(999, _("%s: NMEAS must be a scalar.\n"), fname);
+         return 1;
+     }
+     NMEAS = *lNMEAS;
+     sciErr = getVarAddressFromPosition(pvApiCtx, 7, &piAddrlGAMMA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 7.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlGAMMA, &M3, &N3, &lGAMMA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 7);
+         return 1;
+     }
+     if (M3 != 1 || N3 != 1 )
+     {
+         Scierror(999, _("%s: GAMMA must be a scalar.\n"), fname);
+         return 1;
+     }
+     GAMMA = *lGAMMA;
+     EPS = C2F(dlamch)("e", 1L);
+     TOL = sqrt(EPS);
+     sciErr = allocMatrixOfDouble(pvApiCtx, 8, N, N, &lAK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 9, N, NMEAS, &lBK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 10, NCON, N, &lCK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 11, NCON, NMEAS, &lDK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 12, N, N, &lX);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 13, N, N, &lZ);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 14, iEight, iOne, &lRCOND);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     LINTWORK = Max(2 * Max(NCON, N), Max(M, Max(NCON + NMEAS, N * N)));
+     sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, 15, LINTWORK, iOne, &lIWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     i2N = 2 * N;
+     sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, 16, i2N, iOne, &lBWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     Q = Max( M - NCON, Max(NCON, Max(R - NMEAS, NMEAS)));
+     LWORKMIN =  Max((N + Q) * (N + Q + 6),
+                     13 * N * N + M * M + 2 * Q * Q + N * (M + Q) +
+                     Max(M * (M + 7 * N), 2 * Q * (8 * N + M + 2 * Q)) +
+                     6 * N +
+                     Max(14 * N + 23, Max(16 * N, Max(2 * N + Max(M, 2 * Q) , 3 * Max(M, 2 * Q)))));
+     sciErr = allocMatrixOfDouble(pvApiCtx, 17, iOne, LWORKMIN, &lDWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     C2F(sb10dd)(&N, &M, &R, &NCON, &NMEAS, &GAMMA, lA, &N,
+                 lB, &N, lC, &R, lD, &R, lAK,
+                 &N, lBK, &N, lCK, &NCON, lDK,
+                 &NCON, lX, &N, lZ, &N, lRCOND, &TOL,
+                 lIWORK, lDWORK, &LWORKMIN, lBWORK, &info);
+     if (info != 0)
+     {
+         Scierror(999, _("%s: SB10DD exit with info = %d.\n"), fname, info);
+         return 1;
+     }
+     AssignOutputVariable(pvApiCtx, 1) = 8;
+     AssignOutputVariable(pvApiCtx, 2) = 9;
+     AssignOutputVariable(pvApiCtx, 3) = 10;
+     AssignOutputVariable(pvApiCtx, 4) = 11;
+     if (nbOutputArgument(pvApiCtx) == 5)
+     {
+         AssignOutputVariable(pvApiCtx, 5) = 14;
+     }
+     return 0;
+ }
index 0000000,c89c4d8..b01d18a
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,409 +1,408 @@@
+ /*
+  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+  * Copyright (//) 2012 - Scilab Enterprises - Cedric DELAMARRE
+  *
+  * 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-en.txt
+  *
+  */
 -#include "gw_slicot.h"
+ #include "api_scilab.h"
+ #include "Scierror.h"
+ #include "localization.h"
+ extern int C2F(sb10fd)();
+ extern double C2F(dlamch)();
+ // [Ak,Bk,Ck,Dk,RCOND]=hinf(A,B,C,D,ncon,nmeas,gamma)
 -int sci_hinf(char *fname, unsigned long fname_len)
++int sci_hinf(char *fname, void* pvApiCtx)
+ {
+     SciErr sciErr;
+     int* piAddrlA   = NULL;
+     double* lA      = NULL;
+     int* piAddrlB   = NULL;
+     double* lB      = NULL;
+     int* piAddrlC   = NULL;
+     double* lC      = NULL;
+     int* piAddrlD   = NULL;
+     double* lD      = NULL;
+     double* lAK     = NULL;
+     double* lBK     = NULL;
+     double* lCK     = NULL;
+     double* lDK     = NULL;
+     double* lRCOND  = NULL;
+     int* lNCON      = NULL;
+     int* lNMEAS     = NULL;
+     double* lGAMMA  = NULL;
+     int* lIWORK     = NULL;
+     int* lBWORK     = NULL;
+     double* lDWORK  = NULL;
+     int* piAddrlGAMMA   = NULL;
+     int* piAddrlNCON    = NULL;
+     int* piAddrlNMEAS   = NULL;
+     double GAMMA = 0;
+     double TOL   = 0;
+     double EPS   = 0;
+     int NCON     = 0;
+     int NMEAS    = 0;
+     int LINTWORK = 0;
+     int LWORKMIN = 0;
+     int MA = 0, NA = 0;
+     int MB = 0, NB = 0;
+     int MC = 0, NC = 0;
+     int MD = 0, ND = 0;
+     int M1 = 0, N1 = 0;
+     int M2 = 0, N2 = 0;
+     int M3 = 0, N3 = 0;
+     int N;
+     int M;
+     int R;
+     int Q;
+     int minrhs = 7;
+     int maxrhs = 7;
+     int minlhs = 4;
+     int maxlhs = 5;
+     int iZero = 0;
+     int iOne  = 1;
+     int iFor  = 4;
+     int i2N   = 0;
+     int info  = 0;
+     CheckInputArgument(pvApiCtx, minrhs, maxrhs);
+     CheckOutputArgument(pvApiCtx, minlhs, maxlhs);
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrlA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 1.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlA, &MA, &NA, &lA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 1);
+         return 1;
+     }
+     if (MA != NA)
+     {
+         Scierror(999, _("%s: A must be a square matrix.\n"), fname);
+         return 1;
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrlB);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 2.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlB, &MB, &NB, &lB);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 2);
+         return 1;
+     }
+     if (MA != MB)
+     {
+         Scierror(999, _("%s: A and B must have equal number of rows.\n"), fname);
+         return 1;
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddrlC);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 3.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlC, &MC, &NC, &lC);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 3);
+         return 1;
+     }
+     if (NA != NC)
+     {
+         Scierror(999, _("%s: A and // must have equal number of columns.\n"), fname);
+         return 1;
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddrlD);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 4.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlD, &MD, &ND, &lD);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 4);
+         return 1;
+     }
+     if (NB != ND)
+     {
+         Scierror(999, _("%s: B and D must have equal number of columns.\n"), fname);
+         return 1;
+     }
+     if (MC != MD)
+     {
+         Scierror(999, _("%s: // and D must have equal number of rows.\n"), fname);
+         return 1;
+     }
+     N = MA;
+     M = NB;
+     R = MC;
+     if (N == 0 || M == 0 || R == 0)
+     {
+         sciErr = allocMatrixOfDouble(pvApiCtx, 5, iZero, iZero, &lAK);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, 6, iZero, iZero, &lBK);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, 7, iZero, iZero, &lCK);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, 8, iZero, iZero, &lDK);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, 9, iZero, iZero, &lRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         AssignOutputVariable(pvApiCtx, 1) = 5;
+         AssignOutputVariable(pvApiCtx, 2) = 6;
+         AssignOutputVariable(pvApiCtx, 3) = 7;
+         AssignOutputVariable(pvApiCtx, 4) = 8;
+         AssignOutputVariable(pvApiCtx, 5) = 9;
+         return 0;
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 5, &piAddrlNCON);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 5.
+     sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrlNCON, &M1, &N1, &lNCON);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 5);
+         return 1;
+     }
+     if (M1 != 1 || N1 != 1)
+     {
+         Scierror(999, _("%s: NCON must be a scalar.\n"), fname);
+         return 1;
+     }
+     NCON = *lNCON;
+     sciErr = getVarAddressFromPosition(pvApiCtx, 6, &piAddrlNMEAS);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 6.
+     sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrlNMEAS, &M2, &N2, &lNMEAS);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 6);
+         return 1;
+     }
+     if (M2 != 1 || N2 != 1)
+     {
+         Scierror(999, _("%s: NMEAS must be a scalar.\n"), fname);
+         return 1;
+     }
+     NMEAS = *lNMEAS;
+     sciErr = getVarAddressFromPosition(pvApiCtx, 7, &piAddrlGAMMA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 7.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlGAMMA, &M3, &N3, &lGAMMA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 7);
+         return 1;
+     }
+     if (M3 != 1 || N3 != 1)
+     {
+         Scierror(999, _("%s: GAMMA must be a scalar.\n"), fname);
+         return 1;
+     }
+     GAMMA = *lGAMMA;
+     EPS = C2F(dlamch)("e", 1L);
+     TOL = sqrt(EPS);
+     sciErr = allocMatrixOfDouble(pvApiCtx, 8, N, N, &lAK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 9, N, NMEAS, &lBK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 10, NCON, N, &lCK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 11, NCON, NMEAS, &lDK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 12, iFor, iOne, &lRCOND);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     LINTWORK = Max(2 * Max(N, Max(M - NCON, Max(R - NMEAS, NCON))), N * N);
+     sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, 13, LINTWORK, iOne, &lIWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     i2N = 2 * N;
+     sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, 14, i2N, iOne, &lBWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     Q = Max(M - NCON, Max(NCON, Max(R - NMEAS, NMEAS)));
+     LWORKMIN =  2 * Q * ( 3 * Q + 2 * N ) +
+                 Max(1,
+                     Max(( N + Q ) * ( N + Q + 6),
+                         Max(Q * ( Q + Max(N, Max(Q, 5)) + 1),
+                             2 * N * (N + 2 * Q) + Max( 1,
+                                     Max(4 * Q * Q + Max(2 * Q, 3 * N * N + Max( 2 * N * Q, 10 * N * N + 12 * N + 5 )),
+                                         Q * ( 3 * N + 3 * Q + Max( 2 * N, 4 * Q + Max(N, Q))))))));
+     sciErr = allocMatrixOfDouble(pvApiCtx, 15, iOne, LWORKMIN, &lDWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     C2F(sb10fd)(&N, &M, &R, &NCON, &NMEAS, &GAMMA, lA, &N,
+                 lB, &N, lC, &R, lD, &R, lAK,
+                 &N, lBK, &N, lCK, &NCON, lDK,
+                 &NCON, lRCOND, &TOL, lIWORK,
+                 lDWORK, &LWORKMIN, lBWORK, &info);
+     if (info != 0)
+     {
+         Scierror(999, _("%s: SB10FD exit with info = %d.\n"), fname, info);
+         return 1;
+     }
+     AssignOutputVariable(pvApiCtx, 1) = 8;
+     AssignOutputVariable(pvApiCtx, 2) = 9;
+     AssignOutputVariable(pvApiCtx, 3) = 10;
+     AssignOutputVariable(pvApiCtx, 4) = 11;
+     if (nbOutputArgument(pvApiCtx) == 5)
+     {
+         AssignOutputVariable(pvApiCtx, 5) = 14;
+     }
+     return 0;
+ }
index 0000000,06aab3b..7142991
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,1237 +1,1235 @@@
+ /*
+  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+  * Copyright (C) 2012 - Scilab Enterprises - Cedric DELAMARRE
+  *
+  * 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-en.txt
+  *
+  */
+ // INTLINMEQ.F - Gateway function for solving Sylvester and Lyapunov matrix
+ //            equations using SLICOT routines SB04MD, SB04ND, SB04PD,
+ //            SB04QD, SB04RD, SB03MD, and SB03OD.
+ //
+ // Copyright INRIA 2001
+ // Scilab syntax
+ //   [X(,sep)] = linmeq(task,A(,B),C,flag,trans(,schur))
+ //
+ //   task = 1 :      [X] = linmeq(1,A,B,C,flag,trans,schur)
+ //   task = 2 :  [X,sep] = linmeq(2,A,C,flag,trans)
+ //                   [X] = linmeq(2,A,C,flag,trans)
+ //   task = 3 :      [X] = linmeq(3,A,C,flag,trans)
+ //
+ // Purpose:
+ //   To solve the Sylvester and Lyapunov linear matrix equations
+ //
+ //   task = 1:
+ //
+ //         op(A)*X + X*op(B) = C,                          (1a)
+ //
+ //         op(A)*X*op(B) + X = C,                          (1b)
+ //
+ //   task = 2:
+ //
+ //         op(A)'*X + X*op(A) = C,                         (2a)
+ //
+ //         op(A)'*X*op(A) - X = C,                         (2b)
+ //
+ //   task = 3:
+ //
+ //         op(A)'*(op(X)'*op(X)) + (op(X)'*op(X))*op(A) =
+ //                               -  op(//)'*op(//),          (3a)
+ //
+ //         op(A)'*(op(X)'*op(X))*op(A) - op(X)'*op(X) =
+ //                                     - op(//)'*op(//),     (3b)
+ //
+ //   where op(M) = M, if trans = 0, and op(M) = M', if trans = 1.
+ //
+ // Input parameters:
+ //   task  - integer option to determine the equation type:
+ //           = 1 : solve the Sylvester equation (1a) or (1b);
+ //           = 2 : solve the Lyapunov equation (2a) or (2b);
+ //           = 3 : solve for the Cholesky factor op(X) the Lyapunov
+ //                 equation (3a) or (3b).
+ //   A     - real coefficient N-by-N matrix.
+ //           When task = 3, matrix A must be stable.
+ //   B     - another real coefficient M-by-M matrix for
+ //           equations (1a) or (1b).
+ //   C     - right hand side matrix.
+ //           task = 1 : // is N-by-M;
+ //           task = 2 : // is N-by-N symmetric;
+ //           task = 3 : op(//) is P-by-N.
+ //   flag  - (optional) integer vector of length 3 or 2 containing
+ //           options.
+ //           task = 1 : flag has length 3
+ //                flag(1) = 0 : solve the continuous-time equation (1a);
+ //                              otherwise, solve the discrete-time
+ //                              equation (1b).
+ //                flag(2) = 1 : A is (quasi) upper triangular;
+ //                          2 : A is upper Hessenberg;
+ //                              otherwise, A is in general form.
+ //                flag(3) = 1 : B is (quasi) upper triangular;
+ //                          2 : B is upper Hessenberg;
+ //                              otherwise, B is in general form.
+ //           task = 2 : flag has length 2
+ //                flag(1) = 0 : solve continuous-time equation (2a);
+ //                              otherwise, solve discrete-time
+ //                              equation (2b).
+ //                flag(2) = 1 : A is (quasi) upper triangular;
+ //                              otherwise, A is in general form.
+ //           task = 3 : flag has length 2
+ //                flag(1) = 0 : solve continuous-time equation (3a);
+ //                              otherwise, solve discrete-time
+ //                              equation (3b).
+ //                flag(2) = 1 : A is (quasi) upper triangular;
+ //                              otherwise, A is in general form.
+ //           Default:    flag(1) = 0, flag(2) = 0 (, flag(3) = 0).
+ //   trans - (optional) integer specifying a transposition option.
+ //           trans = 0 : solve the equations (1) - (3) with op(M) = M.
+ //           trans = 1 : solve the equations (1) - (3) with op(M) = M'.
+ //           trans = 2 : solve the equations (1) with op(A) = A',
+ //                                                    op(B) = B.
+ //           trans = 3 : solve the equations (1) with op(A) = A,
+ //                                                    op(B) = B'.
+ //           Default:    trans = 0.
+ //   schur - (optional) integer specifying whether the Hessenberg-Schur
+ //           or Schur method should be used.
+ //           Available for task = 1.
+ //           schur = 1 : Hessenberg-Schur method (one matrix is reduced
+ //                       to Schur form).
+ //           schur = 2 : Schur method (two matrices are reduced to Schur
+ //                       form).
+ //           Default:    schur = 1.
+ //
+ // Output parameters:
+ //   X     - solution of the equation (or its Cholesky factor for (3)).
+ //   sep   - (optional) estimator of Sep(op(A),-op(A)') for (2.a) or
+ //           Sepd(A,A') for (2.b).
+ //
+ // Comments:
+ //   1. For equation (1a) or (1b), when schur = 1, the Hessenberg-Schur
+ //      method is used, reducing one matrix to Hessenberg form and the
+ //      other one to a real Schur form.
+ //      Otherwise, both matrices are reduced to real Schur forms.
+ //      If one or both matrices are already reduced to Schur/Hessenberg
+ //      forms, this could be specified by flag(2) and flag(3).
+ //      For general matrices, the Hessenberg-Schur method could be
+ //      significantly more efficient than the Schur method.
+ //   2. For equation (3a) or (3b), the computed matrix X is the Cholesky
+ //      factor of the solution, i.e., the real solution is op(X)'*op(X),
+ //      where X is an N-by-N upper triangular matrix.
+ //
+ // References:
+ //   This interface is based on the SLICOT routines:
+ //   SB04PD, SB04MD, SB04QD, DTRSYL, SB04PY, SB04ND, SB04RD, SB03MD, SB03OD
+ //
+ //
+ // Revisions:
+ //   Adapted from the Slicot Matlab Mexfile by S. Steer Oct 2001
+ //
+ // **********************************************************************
 -#include "gw_slicot.h"
+ #include "api_scilab.h"
+ #include "Scierror.h"
+ #include "localization.h"
+ #include "sciprint.h"
++#include "elem_common.h"
+ extern int C2F(lsame)();
+ extern int C2F(dlacpy)();
+ extern int C2F(dlaset)();
+ extern int C2F(dswap)();
+ extern int C2F(dtrsyl)();
+ extern int C2F(sb03md)();
+ extern int C2F(sb03od)();
+ extern int C2F(sb04md)();
+ extern int C2F(sb04nd)();
+ extern int C2F(sb04pd)();
+ extern int C2F(sb04py)();
+ extern int C2F(sb04qd)();
+ extern int C2F(sb04rd)();
 -int sci_linmeq(char *fname, unsigned long fname_len)
++int sci_linmeq(char *fname, void* pvApiCtx)
+ {
+     SciErr sciErr;
+     int* piAddrNA       = NULL;
+     double* lA          = NULL;
+     int* piAddrNB       = NULL;
+     double* lB          = NULL;
+     int* piAddrNC       = NULL;
+     double* lC          = NULL;
+     int* piAddrilTASK   = NULL;
+     int* ilTASK         = NULL;
+     int* piAddrilTRANS  = NULL;
+     int* ilTRANS        = NULL;
+     int* piAddrilSCHUR  = NULL;
+     int* ilSCHUR        = NULL;
+     int* piAddrilFLAG   = NULL;
+     int* ilFLAG         = NULL;
+     double* lDWORK  = NULL;
+     int* lIWORK     = NULL;
+     double* lU   = NULL;
+     double* lV   = NULL;
+     double* lWI  = NULL;
+     double* lWR  = NULL;
+     double* lCC  = NULL;
+     double* lSEP = NULL;
 -    char* tmpbuf[bsiz];
 -
+     // .. Parameters ..
+     double ONE  = 1.;
+     double ZERO = 0.;
+     int iOne    = 1;
+     // .. Scalar parameters used by SLICOT subroutines ..
+     char DICO = 0 , FACT = 0 , FACTA = 0 , FACTB = 0 , JOB = 0 , SCHU = 0 , TRANA = 0 , TRANB = 0 , ULA = 0 , ULB = 0;
+     int INFO = 0, ISGN = 0, LDA = 0, LDB = 0, LDC = 0, LDU = 0, LDV = 0, NDWORK = 0, M = 0, N = 0, P = 0;
+     double FERR = 0., SCALE = 0., SEP = 0., TOL = 0.;
+     // .. Local variables and constant dimension arrays ..
+     BOOL PERTRB = FALSE;
+     int FLAG[3] = {0, 0, 0};
+     int IB = 0, IP = 0, LDW1 = 0, LDW2 = 0, NIWORK = 0, MXMN = 0, NM = 0, NSCHUR = 0, TASK = 0, TRANS = 0;
+     double TEMP = 0.;
+     int Mt = 0, Nt = 0;
+     int MA = 0, NA = 0;
+     int MB = 0, NB = 0;
+     int MC = 0, NC = 0;
+     int i = 0;
+     int j = 0;
+     int iNbvars = Rhs;
+     // Check for proper number of arguments.
+     CheckInputArgument(pvApiCtx, 3, 7);
+     CheckOutputArgument(pvApiCtx, 1, 2);
+     // Check dimensions of input parameters and read/set scalar parameters.
+     //   task
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrilTASK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrilTASK, &Mt, &Nt, &ilTASK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, IP);
+         return 1;
+     }
+     if (Mt != 1 || Nt != 1)
+     {
+         Scierror(999, _("%s: TASK must be a scalar.\n"), fname);
+         return 1;
+     }
+     TASK = *ilTASK;
+     if (TASK < 1 || TASK > 3)
+     {
+         Scierror(999, _("%s: TASK has 1, 2 or 3 the only admissible values.\n"), fname);
+         return 1;
+     }
+     if (TASK == 1)
+     {
+         if (nbInputArgument(pvApiCtx) < 4)
+         {
+             Scierror(999, _("%s: TASK = 1 : LINMEQ requires at least 4 input arguments.\n"), fname);
+             return 1;
+         }
+         IP = 6;
+     }
+     else
+     {
+         IP = 5;
+     }
+     //   trans
+     if (nbInputArgument(pvApiCtx) >= IP)
+     {
+         sciErr = getVarAddressFromPosition(pvApiCtx, IP, &piAddrilTRANS);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position IP.
+         sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrilTRANS, &Mt, &Nt, &ilTRANS);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, IP);
+             return 1;
+         }
+         if (Mt != 1 || Nt != 1)
+         {
+             Scierror(999, _("%s: TRANS must be a scalar.\n"), fname);
+             return 1;
+         }
+         TRANS = *ilTRANS;
+     }
+     if (TASK == 1 && (TRANS < 0 || TRANS > 3))
+     {
+         Scierror(999, _("%s: TRANS has 0, 1, 2 or 3 the only admissible values.\n"), fname);
+         return 1;
+     }
+     else if (TASK != 1 && (TRANS < 0 || TRANS > 1))
+     {
+         Scierror(999, _("%s: TRANS has 0 or 1 the only admissible values.\n"), fname);
+         return 1;
+     }
+     //   schur
+     if (TASK == 1)
+     {
+         NSCHUR = 1;
+         if (nbInputArgument(pvApiCtx) == IP + 1)
+         {
+             sciErr = getVarAddressFromPosition(pvApiCtx, IP + 1, &piAddrilSCHUR);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 return 1;
+             }
+             // Retrieve a matrix of double at position IP + 1.
+             sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrilSCHUR, &Mt, &Nt, &ilSCHUR);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, IP + 1);
+                 return 1;
+             }
+             if (Mt != 1 || Nt != 1)
+             {
+                 Scierror(999, _("%s: SCHUR must be a scalar.\n"), fname);
+                 return 1;
+             }
+             NSCHUR = *(int*)(ilSCHUR);
+             if (NSCHUR < 1 || NSCHUR > 2)
+             {
+                 Scierror(999, _("%s: SCHUR has 1 or 2 the only admissible values.\n"), fname);
+                 return 1;
+             }
+         }
+     }
+     //   A(NxN), (B(MxM),) C(NxM), or C(NxN), or op(C)(PxN)
+     sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrNA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 2.
+     if (isVarComplex(pvApiCtx, piAddrNA))
+     {
+         Scierror(999, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, 2);
+         return 1;
+     }
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrNA, &MA, &NA, &lA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: Real or complex matrix expected.\n"), fname, 2);
+         return 1;
+     }
+     if (MA != NA)
+     {
+         Scierror(999, _("%s: Wrong size for input argument #%d: A square matrix expected.\n"), fname, 2);
+         return 1;
+     }
+     N = MA;
+     if (TASK == 1)
+     {
+         sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddrNB);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position 3.
+         if (isVarComplex(pvApiCtx, piAddrNB))
+         {
+             Scierror(999, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, 3);
+             return 1;
+         }
+         sciErr = getMatrixOfDouble(pvApiCtx, piAddrNB, &MB, &NB, &lB);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(202, _("%s: Wrong type for argument %d: Real or complex matrix expected.\n"), fname, 3);
+             return 1;
+         }
+         if (MB != NB)
+         {
+             Scierror(999, _("%s: Wrong size for input argument #%d: A square matrix expected.\n"), fname, 3);
+             return 1;
+         }
+         sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddrNC);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position 4.
+         if (isVarComplex(pvApiCtx, piAddrNC))
+         {
+             Scierror(999, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, 4);
+             return 1;
+         }
+         sciErr = getMatrixOfDouble(pvApiCtx, piAddrNC, &MC, &NC, &lC);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(202, _("%s: Wrong type for argument %d: Real or complex matrix expected.\n"), fname, 4);
+             return 1;
+         }
+         if (MC != N)
+         {
+             Scierror(999, _("%s: Wrong column size for input argument #%d: Same column size of input argument #%d expected.\n"), fname, 4, 2);
+             return 1;
+         }
+         M = NC;
+         AssignOutputVariable(pvApiCtx, 1) = 4;
+     }
+     else
+     {
+         sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddrNC);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position 3.
+         if (isVarComplex(pvApiCtx, piAddrNC))
+         {
+             Scierror(999, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, 3);
+             return 1;
+         }
+         sciErr = getMatrixOfDouble(pvApiCtx, piAddrNC, &MC, &NC, &lC);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(202, _("%s: Wrong type for argument %d: Real or complex matrix expected.\n"), fname, 3);
+             return 1;
+         }
+         //      if (TASK == 3){
+         if (TRANS == 0)
+         {
+             P = MC;
+             if (NC != N)
+             {
+                 Scierror(999, _("%s: Wrong row size for input argument #%d: Same row size of input argument #%d expected.\n"), fname, 3, 2);
+                 return 1;
+             }
+         }
+         else
+         {
+             if (MC != N)
+             {
+                 Scierror(999, _("%s: Wrong row size for input argument #%d: Same row size of input argument #%d expected.\n"), fname, 3, 2);
+                 return 1;
+             }
+             P = NC;
+         }
+         //      }
+         AssignOutputVariable(pvApiCtx, 1) = 3;
+     }
+     if (TASK == 1)
+     {
+         IP = 5;
+     }
+     else
+     {
+         IP = 4;
+     }
+     if (nbInputArgument(pvApiCtx) >= IP)
+     {
+         //   flag
+         sciErr = getVarAddressFromPosition(pvApiCtx, IP, &piAddrilFLAG);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position IP.
+         sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrilFLAG, &Mt, &Nt, &ilFLAG);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, IP);
+             return 1;
+         }
+         if (TASK == 1)
+         {
+             if (Mt * Nt > 3)
+             {
+                 Scierror(999, _("%s: Wrong size for input argument #%d: At most 3 elements expected.\n"), fname, IP);
+                 return 1;
+             }
+         }
+         else
+         {
+             if (Mt * Nt > 2)
+             {
+                 Scierror(999, _("%s: Wrong size for input argument #%d: At most 2 elements expected.\n"), fname, IP);
+                 return 1;
+             }
+         }
+         for (i = 0; i < Mt * Nt; i++)
+         {
+             FLAG[i] = ilFLAG[i];
+         }
+     }
+     // Determine the lenghts of working arrays.
+     // Use a larger value for NDWORK for enabling calls of block algorithms
+     // in DGEES, and possibly in DGEHRD, DGEQRF, DGERQF, SB04PD.
+     LDA = Max(1, N);
+     if (TASK == 1)
+     {
+         LDB = Max(1, M);
+         if (NSCHUR == 2)
+         {
+             if (FLAG[1] == 1)
+             {
+                 LDW1 = 0;
+                 LDW2 = 0;
+             }
+             else
+             {
+                 LDW1 = 1 + 2 * N;
+                 LDW2 = 3 * N;
+             }
+             IB = 0;
+             if (FLAG[2] != 1)
+             {
+                 IB = 2 * M;
+                 if (FLAG[1] == 1)
+                 {
+                     IB++;
+                 }
+                 LDW2 = Max(LDW2, IB + 3 * M);
+             }
+             LDW2 = Max(LDW2, IB + 2 * N);
+             NDWORK = Max(1, LDW1 + LDW2);
+         }
+         else
+         {
+             if (FLAG[1] * FLAG[2] == 1)
+             {
+                 NIWORK = 0;
+                 if (FLAG[0] != 0)
+                 {
+                     NDWORK = 2 * N;
+                 }
+                 else
+                 {
+                     NDWORK = 0;
+                 }
+             }
+             else if (FLAG[1] * FLAG[2] == 2)
+             {
+                 MXMN = Max(M, N);
+                 NIWORK = 2 * MXMN;
+                 NDWORK = 2 * MXMN * (4 + 2 * MXMN);
+             }
+             else
+             {
+                 NIWORK = 4 * N;
+                 NDWORK = Max(1, Max(5 * M, N + M));
+                 if (FLAG[0] == 0)
+                 {
+                     NDWORK = Max(NDWORK, 2 * N * N + 8 * N);
+                 }
+                 else
+                 {
+                     NDWORK = Max(NDWORK, 2 * N * N + 9 * N);
+                 }
+             }
+         }
+         NM = M;
+     }
+     else if (TASK == 2)
+     {
+         NDWORK = Max(1, Max(N * N , 3 * N));
+         if (nbOutputArgument(pvApiCtx) == 2)
+         {
+             NDWORK = Max(NDWORK, 2 * N * N);
+             if (FLAG[0] != 0)
+             {
+                 NDWORK = Max(NDWORK, 2 * (N * N + N));
+             }
+         }
+         NM = N;
+     }
+     if (TASK != 3)
+     {
+         LDC = LDA;
+     }
+     else
+     {
+         if (TRANS == 0)
+         {
+             LDC = Max(1, Max(N, P));
+         }
+         else
+         {
+             LDC = LDA;
+         }
+         MXMN = Min(P, N);
+         NDWORK = Max(1, 4 * N + MXMN);
+         NM = N;
+     }
+     // Allocate variable dimension local arrays.
+     if (TASK == 1)
+     {
+         sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, NDWORK, iOne, &lDWORK);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         if (NSCHUR == 2)
+         {
+             if (FLAG[1] == 1)
+             {
+                 FACTA = 'S';
+                 LDU = 1;
+                 sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, LDU, iOne, &lU);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                     return 1;
+                 }
+             }
+             else
+             {
+                 FACTA = 'N';
+                 LDU = LDA;
+                 sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, LDU, N, &lU);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                     return 1;
+                 }
+             }
+             if (FLAG[2] == 1)
+             {
+                 FACTB = 'S';
+                 LDV = 1;
+                 sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, LDV, iOne, &lV);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                     return 1;
+                 }
+             }
+             else
+             {
+                 FACTB = 'N';
+                 LDV = LDB;
+                 sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, LDV, M, &lV);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                     return 1;
+                 }
+             }
+         }
+         else
+         {
+             SCHU = 'N';
+             sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, ++iNbvars, NIWORK, iOne, &lIWORK);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                 return 1;
+             }
+             if (FLAG[1] == 1)
+             {
+                 if (FLAG[2] == 1)
+                 {
+                     SCHU = 'S';
+                 }
+                 else if (FLAG[2] == 2)
+                 {
+                     SCHU = 'A';
+                 }
+             }
+             else if (FLAG[1] == 2 && FLAG[2] == 1)
+             {
+                 SCHU = 'B';
+             }
+             if (C2F(lsame)(&SCHU , "N"))
+             {
+                 LDU = LDB;
+                 sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, LDU, M, &lU);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                     return 1;
+                 }
+             }
+         }
+     }
+     else if (TASK == 2)
+     {
+         LDU = LDA;
+         sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, LDU, N, &lU);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, NDWORK, iOne, &lDWORK);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, N, iOne, &lWI);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, N, iOne, &lWR);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         if (nbOutputArgument(pvApiCtx) == 1)
+         {
+             sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, ++iNbvars, iOne, iOne, &lIWORK);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                 return 1;
+             }
+         }
+         else
+         {
+             int NN = N * N;
+             sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, ++iNbvars, NN, iOne, &lIWORK);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                 return 1;
+             }
+         }
+     }
+     else
+     {
+         LDU = LDA;
+         sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, LDU, N, &lU);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, NDWORK, iOne, &lDWORK);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, N, iOne, &lWI);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, N, iOne, &lWR);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+     }
+     // Do the actual computations.
+     if (TASK == 1)
+     {
+         if (NSCHUR == 2)
+         {
+             if (TRANS == 0)
+             {
+                 TRANA = 'N';
+                 TRANB = 'N';
+             }
+             else if (TRANS == 1)
+             {
+                 TRANA = 'T';
+                 TRANB = 'T';
+             }
+             else if (TRANS == 2)
+             {
+                 TRANA = 'T';
+                 TRANB = 'N';
+             }
+             else if (TRANS == 3)
+             {
+                 TRANA = 'N';
+                 TRANB = 'T';
+             }
+             if (FLAG[0] != 0)
+             {
+                 DICO = 'D';
+             }
+             else
+             {
+                 DICO = 'C';
+             }
+             ISGN = 1;
+             C2F(sb04pd)(&DICO, &FACTA, &FACTB, &TRANA, &TRANB, &ISGN, &N, &M,
+                         lA, &LDA, lU, &LDU, lB, &LDB, lV, &LDV,
+                         lC, &LDC, &SCALE, lDWORK, &NDWORK, &INFO);
+         }
+         else
+         {
+             if (TRANS == 0)
+             {
+                 if (C2F(lsame)(&SCHU , "S"))
+                 {
+                     TRANA = 'N';
+                     TRANB = 'N';
+                 }
+                 else
+                 {
+                     ULA = 'U';
+                     ULB = 'U';
+                 }
+             }
+             else if (TRANS == 1)
+             {
+                 if (C2F(lsame)(&SCHU , "S"))
+                 {
+                     TRANA = 'T';
+                     TRANB = 'T';
+                 }
+                 else
+                 {
+                     ULA = 'L';
+                     ULB = 'L';
+                     for (j = 1; j < N; j++)
+                     {
+                         C2F(dswap)(&j, lA + j * LDA, &iOne, lA + j, &LDA);
+                     }
+                     for (j = 1; j < M; j++)
+                     {
+                         C2F(dswap)(&j, lB + j * LDB, &iOne, lB + j, &LDB);
+                     }
+                 }
+             }
+             else if (TRANS == 2)
+             {
+                 if (C2F(lsame)(&SCHU , "S"))
+                 {
+                     TRANA = 'T';
+                     TRANB = 'N';
+                 }
+                 else
+                 {
+                     ULA = 'L';
+                     ULB = 'U';
+                     for (j = 1; j < N; j++)
+                     {
+                         C2F(dswap)(&j, lA + j * LDA, &iOne, lA + j, &LDA);
+                     }
+                 }
+             }
+             else if (TRANS == 3)
+             {
+                 if (C2F(lsame)(&SCHU , "S"))
+                 {
+                     TRANA = 'N';
+                     TRANB = 'T';
+                 }
+                 else
+                 {
+                     ULA = 'U';
+                     ULB = 'L';
+                     for (j = 1; j < M; j++)
+                     {
+                         C2F(dswap)(&j, lB + j * LDB, &iOne, lB + j, &LDB);
+                     }
+                 }
+             }
+             if (C2F(lsame)(&SCHU , "N"))
+             {
+                 SCALE = ONE;
+                 if (FLAG[0] == 0)
+                 {
+                     int i = 0;
+                     C2F(sb04md)(&N, &M, lA, &LDA, lB, &LDB, lC,
+                                 &LDC, lU, &LDU, lIWORK, lDWORK, &NDWORK, &INFO);
+                 }
+                 else
+                 {
+                     C2F(sb04qd)(&N, &M, lA, &LDA, lB, &LDB, lC,
+                                 &LDC , lU, &LDU, lIWORK, lDWORK, &NDWORK, &INFO);
+                 }
+             }
+             else if (C2F(lsame)(&SCHU , "S"))
+             {
+                 if (FLAG[0] == 0)
+                 {
+                     C2F(dtrsyl)(&TRANA, &TRANB, &iOne, &N, &M, lA, &LDA,
+                                 lB, &LDB, lC, &LDC, &SCALE, &INFO);
+                 }
+                 else
+                 {
+                     C2F(sb04py)(&TRANA, &TRANB, &iOne, &N, &M, lA, &LDA,
+                                 lB, &LDB, lC, &LDC, &SCALE, lDWORK, &INFO);
+                 }
+             }
+             else
+             {
+                 SCALE = ONE;
+                 TOL = ZERO;
+                 //              Default tolerance (epsilon_machine) is used.
+                 if (FLAG[0] == 0)
+                 {
+                     C2F(sb04nd)(&SCHU, &ULA, &ULB, &N, &M, lA, &LDA,
+                                 lB, &LDB, lC, &LDC, &TOL, lIWORK,
+                                 lDWORK, &NDWORK, &INFO);
+                 }
+                 else
+                 {
+                     C2F(sb04rd)(&SCHU, &ULA, &ULB, &N, &M, lA, &LDA,
+                                 lB, &LDB, lC, &LDC, &TOL, lIWORK,
+                                 lDWORK, &NDWORK, &INFO);
+                 }
+             }
+         }
+     }
+     else
+     {
+         if (FLAG[0] == 0)
+         {
+             DICO = 'C';
+         }
+         else
+         {
+             DICO = 'D';
+         }
+         if (FLAG[1] != 1)
+         {
+             FACT = 'N';
+         }
+         else
+         {
+             FACT = 'F';
+             C2F(dlaset)("F", &N, &N, &ZERO, &ONE, lU, &LDU);
+         }
+         if (TRANS == 0)
+         {
+             TRANA = 'N';
+         }
+         else
+         {
+             TRANA = 'T';
+         }
+         if (TASK == 2)
+         {
+             if (nbOutputArgument(pvApiCtx) == 2)
+             {
+                 JOB = 'B';
+             }
+             else
+             {
+                 JOB = 'X';
+             }
+             if (MC < LDC)
+             {
+                 int NMC = N * MC;
+                 sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, LDC, N, &lCC);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                     return 1;
+                 }
+                 C2F(dcopy)(&NMC, lC, &iOne, lCC, &iOne);
+                 C2F(sb03md)(&DICO, &JOB, &FACT, &TRANA, &N, lA, &LDA,
+                             lU, &LDU, lCC, &LDC, &SCALE, &SEP, &FERR, lWR,
+                             lWI, lIWORK, lDWORK, &NDWORK, &INFO);
+                 C2F(dcopy)(&NMC, lCC, &iOne, lC, &iOne);
+             }
+             else
+             {
+                 C2F(sb03md)(&DICO, &JOB, &FACT, &TRANA, &N, lA, &LDA,
+                             lU, &LDU, lC, &LDC, &SCALE, &SEP, &FERR, lWR,
+                             lWI, lIWORK, lDWORK, &NDWORK, &INFO);
+             }
+         }
+         else
+         {
+             C2F(sb03od)(&DICO, &FACT, &TRANA, &N, &P, lA, &LDA, lU,
+                         &LDU, lC, &LDC, &SCALE, lWR, lWI, lDWORK,
+                         &NDWORK, &INFO);
+         }
+     }
+     // form output
 -    PERTRB =  (TASK == 1 && (INFO == N + M + 1 || (FLAG[1] * FLAG[2] == 1 & INFO == 1))) ||
++    PERTRB =  (TASK == 1 && (INFO == N + M + 1 || (FLAG[1] * FLAG[2] == 1 && INFO == 1))) ||
+               (TASK == 2 && INFO == N + 1) || (TASK == 3 && INFO == 1);
+     if (INFO == 0 || PERTRB)
+     {
+         if (nbOutputArgument(pvApiCtx) >= 1)
+         {
+             if (TASK == 3)
+             {
+                 if (TRANS == 0 && P > N)
+                 {
+                     C2F(dlacpy)("U", &N, &N, lC, &LDC, lC, &LDA);
+                 }
+                 if (N > 1)
+                 {
+                     int Nm1 = N - 1;
+                     C2F(dlaset)("L", &Nm1, &Nm1, &ZERO, &ZERO, (lC + 1), &LDA);
+                 }
+             }
+         }
+         if (TASK == 2)
+         {
+             if (nbOutputArgument(pvApiCtx) >= 2)
+             {
+                 if (N == ZERO)
+                 {
+                     SEP = ZERO;
+                 }
+                 sciErr = allocMatrixOfDouble(pvApiCtx, ++iNbvars, iOne, iOne, &lSEP);
+                 if (sciErr.iErr)
+                 {
+                     printError(&sciErr, 0);
+                     Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                     return 1;
+                 }
+                 *lSEP = SEP;
+                 AssignOutputVariable(pvApiCtx, 2) = iNbvars;
+             }
+         }
+     }
+     // Error and warning handling.
+     if (INFO > 0)
+     {
+         if (TASK == 1)
+         {
+             if (NSCHUR == 2)
+             {
+                 //     .        messages from SB04PD
+                 if (INFO <= M + N)
+                 {
+                     //     .           Failure when computing eigenvalues
+                     Scierror(999, _("%s: Convergence problem...\n"), fname);
+                 }
+                 else if (INFO > M + N)
+                 {
+                     //     .           Equation is singular
+                     Scierror(999, _("%s: Problem is singular.\n"), fname);
+                 }
+                 return 1;
+             }
+             else
+             {
+                 if (C2F(lsame)(&SCHU , "N"))
+                 {
+                     //     .           messages from SB04MD or SB04QD
+                     if (INFO <= M)
+                     {
+                         //     .              Failure when computing eigenvalues
+                         Scierror(999, _("%s: Convergence problem...\n"), fname);
+                     }
+                     else if (INFO > M)
+                     {
+                         //     .              Equation is singular
+                         Scierror(999, _("%s: Problem is singular.\n"), fname);
+                     }
+                 }
+                 else
+                 {
+                     //     .           Equation is singular
+                     Scierror(999, _("%s: Problem is singular.\n"), fname);
+                 }
+                 return 1;
+             }
+         }
+         else if (TASK == 2)
+         {
+             if (INFO <= N)
+             {
+                 //     .        Failure when computing eigenvalues
+                 Scierror(999, _("%s: Convergence problem...\n"), fname);
+             }
+             else if (INFO > N)
+             {
+                 //     .        Equation is singular
+                 Scierror(999, _("%s: Problem is singular.\n"), fname);
+             }
+             return 1;
+         }
+         else if (TASK == 3)
+         {
+             if (INFO == 1)
+             {
+                 //     .        Equation is singular
+                 Scierror(999, _("%s: Problem is singular.\n"), fname);
+             }
+             else if (INFO == 2 || INFO == 3)
+             {
+                 if (C2F(lsame)(&DICO, "C"))
+                 {
+                     //     .        Matrix is not stable (cont)
+                     Scierror(999, _("%s: Wrong value for argument %d: eigenvalues must have negative real parts.\n"), fname, 1);
+                 }
+                 else
+                 {
+                     Scierror(999, _("%s: Wrong value for argument %d: eigenvalues modulus must be less than one.\n"), fname, 1);
+                 }
+             }
+             else if (INFO == 4 || INFO == 5)
+             {
+                 //     .        not a schur form
+                 Scierror(999, _("%s: Wrong value for argument %d: eigenvalues modulus must be less than one.\n"), fname, 1);
+             }
+             else if (INFO == 6)
+             {
+                 //     .        Failure when computing eigenvalues
+                 Scierror(999, _("%s: Convergence problem...\n"), fname);
+             }
+             return 1;
+         }
+     }
+     else if (INFO < 0)
+     {
+         //     .  message displayed by slicot or lapack
+         Scierror(999, " ");
+     }
+     if ((INFO == 0 || PERTRB) && SCALE != ONE)
+     {
+         if (TASK <= 2)
+         {
+             TEMP = SCALE;
+         }
+         else
+         {
+             TEMP = SCALE * SCALE;
+         }
+     }
+     if (INFO != 0 && PERTRB == FALSE)
+     {
+         Scierror(999, _("%s: Warning: the right hand sides were scaled by %lf to avoid overflow."), fname, TEMP);
+         return 1;
+     }
+     else if (SCALE != ONE)
+     {
+         sciprint(_("%s: Warning: the right hand sides were scaled by %lf to avoid overflow."), fname, TEMP);
+     }
+     if (PERTRB)
+     {
+         sciprint(_("%s: Warning: the equation is (almost) singular. Perturbed values have been used."), fname);
+     }
+     return 0;
+ }
index 0000000,a9ff96a..7b95818
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,279 +1,278 @@@
+ /*
+  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+  * Copyright (C) 2012 - Scilab Enterprises - Cedric DELAMARRE
+  *
+  * 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-en.txt
+  *
+  */
 -#include "gw_slicot.h"
+ #include "api_scilab.h"
+ #include "Scierror.h"
+ #include "localization.h"
+ extern int C2F(ab13md)();
+ //     [bound,D,G] = mucomp(Z,K,T)
+ //     [bound,D] = mucomp(Z,K,T)
+ //     bound = mucomp(Z,K,T)
 -int sci_mucomp(char *fname, unsigned long fname_len)
++int sci_mucomp(char *fname, void* pvApiCtx)
+ {
+     SciErr sciErr;
+     int* piAddrlK   = NULL;
+     int* lK         = NULL;
+     int* piAddrlT   = NULL;
+     int* lT         = NULL;
+     double* lBOUND  = NULL;
+     double* lD      = NULL;
+     double* lG      = NULL;
+     double* lX      = NULL;
+     int* lIWORK     = NULL;
+     double* lRWORK  = NULL;
+     int* piAddrlZ           = NULL;
+     doublecomplex* lZ       = NULL;
+     doublecomplex* lZWORK   = NULL;
+     int LRWORK = 0, LZWRKMIN = 0;
+     int M  = 0, N  = 0;
+     int M1 = 0, N1 = 0;
+     int M2 = 0, N2 = 0;
+     int INFO = 0;
+     int minrhs = 3;
+     int maxrhs = 3;
+     int minLhs = 1;
+     int maxLhs = 3;
+     int iOne  = 1;
+     int iSize = 0;
+     CheckInputArgument(pvApiCtx, minrhs, maxrhs);
+     CheckOutputArgument(pvApiCtx, minLhs, maxLhs);
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrlZ);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 1.
+     sciErr = getComplexZMatrixOfDouble(pvApiCtx, piAddrlZ, &M, &N, &lZ);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A complex expected.\n"), fname, 1);
+         return 1;
+     }
+     if (M != N)
+     {
+         Scierror(999, _("%s: Wrong size for input argument #%d: A square matrix expected.\n"), fname, 2);
+         return 1;
+     }
+     if (N == 0)
+     {
+         if (nbOutputArgument(pvApiCtx) == 1)
+         {
+             sciErr = allocMatrixOfDouble(pvApiCtx, 2, N, iOne, &lBOUND);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                 return 1;
+             }
+             AssignOutputVariable(pvApiCtx, 1) = 2;
+             return 0;
+         }
+         else if (nbOutputArgument(pvApiCtx) == 2)
+         {
+             sciErr = allocMatrixOfDouble(pvApiCtx, 2, N, iOne, &lBOUND);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                 return 1;
+             }
+             sciErr = allocMatrixOfDouble(pvApiCtx, 3, N, iOne, &lD);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                 return 1;
+             }
+             AssignOutputVariable(pvApiCtx, 1) = 2;
+             AssignOutputVariable(pvApiCtx, 2) = 3;
+             return 0;
+         }
+         else if (nbOutputArgument(pvApiCtx) == 3)
+         {
+             sciErr = allocMatrixOfDouble(pvApiCtx, 2, N, iOne, &lBOUND);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                 return 1;
+             }
+             sciErr = allocMatrixOfDouble(pvApiCtx, 3, N, iOne, &lD);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                 return 1;
+             }
+             sciErr = allocMatrixOfDouble(pvApiCtx, 4, N, iOne, &lG);
+             if (sciErr.iErr)
+             {
+                 printError(&sciErr, 0);
+                 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+                 return 1;
+             }
+             AssignOutputVariable(pvApiCtx, 1) = 2;
+             AssignOutputVariable(pvApiCtx, 2) = 3;
+             AssignOutputVariable(pvApiCtx, 3) = 4;
+             return 0;
+         }
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrlK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 2.
+     sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrlK, &M1, &N1, &lK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 2);
+         return 1;
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddrlT);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 3.
+     sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrlT, &M2, &N2, &lT);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 3);
+         return 1;
+     }
+     if (M1 * N1 != M2 * N2)
+     {
+         Scierror(999, _("%s: Wrong size for input arguments #%d and #%d: Same size expected.\n"), fname, 2);
+         return 1;
+     }
+     M = M1 * N1;
+     sciErr = allocMatrixOfDouble(pvApiCtx, 4, iOne, iOne, &lBOUND);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 5, N, iOne, &lD);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, 6, N, iOne, &lG);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     iSize = 2 * N - 1;
+     sciErr = allocMatrixOfDouble(pvApiCtx, 7, iSize, iOne, &lX);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     iSize = 4 * N - 2;
+     sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, 8, iSize, iOne, &lIWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     LRWORK = 2 * N * N * N + 9 * N * N +  44 * N - 11;
+     sciErr = allocMatrixOfDouble(pvApiCtx, 9, LRWORK, iOne, &lRWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     LZWRKMIN = 6 * N * N * N + 12 * N * N + 12 * N - 3;
+     sciErr = allocComplexZMatrixOfDouble(pvApiCtx, 10, iOne, LZWRKMIN, &lZWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     C2F(ab13md)("N", &N, lZ, &N, &M, lK, lT,
+                 lX, lBOUND, lD, lG, lIWORK,
+                 lRWORK, &LRWORK, lZWORK, &LZWRKMIN, &INFO);
+     if (INFO != 0)
+     {
+         Scierror(999, _("%s: AB13MD exit with info = %d.\n"), fname, INFO);
+         return 1;
+     }
+     if (nbOutputArgument(pvApiCtx) == 1)
+     {
+         AssignOutputVariable(pvApiCtx, 1) = 4;
+     }
+     else if (nbOutputArgument(pvApiCtx) == 2)
+     {
+         AssignOutputVariable(pvApiCtx, 1) = 4;
+         AssignOutputVariable(pvApiCtx, 2) = 5;
+     }
+     else if (nbOutputArgument(pvApiCtx) == 3)
+     {
+         AssignOutputVariable(pvApiCtx, 1) = 4;
+         AssignOutputVariable(pvApiCtx, 2) = 5;
+         AssignOutputVariable(pvApiCtx, 3) = 6;
+     }
+     return 0;
+ }
   *
   */
  
- /*--------------------------------------------------------------------------*/ 
+ /*--------------------------------------------------------------------------*/
  #include <string.h>
- #include "stack-c.h"
+ #include "api_scilab.h"
+ #include "Scierror.h"
+ #include "localization.h"
  #include "sci_rankqr.h"
- /*--------------------------------------------------------------------------*/ 
- extern int C2F(intmb03od)(char *fname, unsigned long fname_len);
- extern int C2F(intzb03od)(char *fname, unsigned long fname_len);
- /*--------------------------------------------------------------------------*/ 
- int intrankqr(char* fname)
 -#include "gw_slicot.h"
+ /*--------------------------------------------------------------------------*/
 -int sci_rankqr(char* fname, unsigned long fname_len)
++int sci_rankqr(char* fname, void* pvApiCtx)
  {
-       int *header1;
-       int Cmplx;int ret;
+     SciErr sciErr;
+     int* piAddr = 0;
+     int ret = 0;
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
  
-       header1 = (int *) GetData(1);
-       Cmplx=header1[3];
-       if (Cmplx==0) {
-               ret = C2F(intmb03od)("rankqr",6L);
-               return 0; } 
-       else
-       {
-               ret = C2F(intzb03od)("rankqr",6L);
-               return 0; } 
+     if (isVarComplex(pvApiCtx, piAddr))
+     {
 -        ret = sci_zrankqr("rankqr", 6L);
++        ret = sci_zrankqr("rankqr", pvApiCtx);
+         return ret;
+     }
+     else
+     {
 -        ret = sci_rrankqr("rankqr", 6L);
++        ret = sci_rrankqr("rankqr", pvApiCtx);
+         return ret;
+     }
  }
- /*--------------------------------------------------------------------------*/ 
+ /*--------------------------------------------------------------------------*/
@@@ -15,7 -15,8 +15,8 @@@
  #ifndef __SCI_RANKQR__
  #define __SCI_RANKQR__
  
- int intrankqr(char* fname);
 -int sci_rrankqr(char* fname, unsigned long fname_len);
 -int sci_zrankqr(char* fname, unsigned long fname_len);
++int sci_rrankqr(char* fname, void* pvApiCtx);
++int sci_zrankqr(char* fname, void* pvApiCtx);
  
  #endif /* __SCI_RANKQR__ */
- /*--------------------------------------------------------------------------*/ 
+ /*--------------------------------------------------------------------------*/
index 0000000,9f5606b..5ac3a05
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,369 +1,370 @@@
+ /*
+  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+  * Copyright (C) 2012 - Scilab Enterprises - Cedric DELAMARRE
+  *
+  * 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-en.txt
+  *
+  */
++#include <string.h>
+ #include "sci_rankqr.h"
+ #include "api_scilab.h"
+ #include "Scierror.h"
+ #include "localization.h"
+ extern int C2F(riccsl)();
+ extern int C2F(riccms)();
+ extern int C2F(ricdsl)();
+ extern int C2F(ricdmf)();
 -int sci_ricc2(char *fname, unsigned long fname_len)
++int sci_ricc2(char *fname, void* pvApiCtx)
+ {
+     SciErr sciErr;
+     int* piAddrlA   = NULL;
+     double* lA      = NULL;
+     int* piAddrlD   = NULL;
+     double* lD      = NULL;
+     int* piAddrlC   = NULL;
+     double* lC      = NULL;
+     char* lTYPE     = NULL;
+     char* lMETHOD   = NULL;
+     double* lX      = NULL;
+     double* lWR     = NULL;
+     double* lWI     = NULL;
+     double* lRCOND  = NULL;
+     double* lFERR   = NULL;
+     int* lIWORK     = NULL;
+     int* lBWORK     = NULL;
+     double* lDWORK  = NULL;
+     int* piAddrlTYPE = NULL;
+     int* piAddrlMETHOD = NULL;
+     BOOL WANTC = 0, WANTD = 0, WSCHUR = 0, WSIGN = 0, WINVF = 0;
+     int minrhs = 4;
+     int maxrhs = 5;
+     int minLhs = 1;
+     int maxLhs = 3;
+     int N = 0, LWORKMIN = 0, INFO = 0;
+     int MA = 0, NA = 0;
+     int MC = 0, NC = 0;
+     int MD = 0, ND = 0;
+     int M1 = 0, N1 = 0;
+     int iOne = 1, iSize = 0, k = 0;
+     CheckInputArgument(pvApiCtx, minrhs, maxrhs);
+     CheckOutputArgument(pvApiCtx, minLhs, maxLhs);
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrlA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 1.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlA, &MA, &NA, &lA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 1);
+         return 1;
+     }
+     if (MA != NA)
+     {
+         Scierror(999, _("%s: A must be a square matrix.\n"), fname);
+         return 1;
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrlD);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 2.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlD, &MD, &ND, &lD);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 2);
+         return 1;
+     }
+     if (MD != ND)
+     {
+         Scierror(999, _("%s: D must be a square matrix.\n"), fname);
+         return 1;
+     }
+     sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddrlC);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 3.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrlC, &MC, &NC, &lC);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, 3);
+         return 1;
+     }
+     if (MC != NC)
+     {
+         Scierror(999, _("%s: C must be a square matrix.\n"), fname);
+         return 1;
+     }
+     if (MA != MC || MC != MD || MA != MD)
+     {
+         Scierror(999, _("%s: The matrices A, C and D must have the same order.\n"), fname);
+         return 1;
+     }
+     N = MA;
+     sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddrlTYPE);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 4.
+     if (getAllocatedSingleString(pvApiCtx, piAddrlTYPE, &lTYPE))
+     {
+         Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 4);
+         return 1;
+     }
+     WANTC = (strcmp((lTYPE), "cont") == 0 || strcmp((lTYPE), "CONT") == 0);
+     WANTD = (strcmp((lTYPE), "disc") == 0 || strcmp((lTYPE), "DISC") == 0);
+     freeAllocatedSingleString(lTYPE);
+     if (WANTC == FALSE && WANTD == FALSE)
+     {
+         Scierror(999, _("%s: Wrong value for input argument #%d: Type must be continuous or discrete.\n"), fname, 4);
+         return 1;
+     }
+     k = 5;
+     WSCHUR = TRUE;
+     if (nbInputArgument(pvApiCtx) == 5)
+     {
+         sciErr = getVarAddressFromPosition(pvApiCtx, 5, &piAddrlMETHOD);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position 5.
+         if (getAllocatedSingleString(pvApiCtx, piAddrlMETHOD, &lMETHOD))
+         {
+             Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, 5);
+             return 1;
+         }
+         WSCHUR = (strcmp((lMETHOD), "schr") == 0 || strcmp((lMETHOD), "SCHR") == 0);
+         if (WANTC)
+         {
+             WSIGN  = (strcmp((lMETHOD), "sign") == 0 || strcmp((lMETHOD), "SIGN") == 0);
+             if (WSCHUR == FALSE && WSIGN == FALSE)
+             {
+                 freeAllocatedSingleString(lMETHOD);
+                 Scierror(999, _("%s: Wrong value for input argument #%d: Method must be schur or sign.\n"), fname, 5);
+                 return 1;
+             }
+         }
+         else
+         {
+             WSIGN  = (strcmp((lMETHOD), "invf") == 0 || strcmp((lMETHOD), "INVF") == 0);
+             if (WSCHUR == FALSE && WINVF == FALSE)
+             {
+                 freeAllocatedSingleString(lMETHOD);
+                 Scierror(999, _("%s: Wrong value for input argument #%d: Method must be schur or invf.\n"), fname, 5);
+                 return 1;
+             }
+         }
+         k = 6;
+         freeAllocatedSingleString(lMETHOD);
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, k, N, N, &lX);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, k + 1, N, iOne, &lWR);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, k + 2, N, iOne, &lWI);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, k + 3, iOne, iOne, &lRCOND);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, k + 4, iOne, iOne, &lFERR);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     iSize = Max(2 * N, N * N);
+     sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, k + 5, iOne, iSize, &lIWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     iSize = 2 * N;
+     sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, k + 6, iOne, iSize, &lBWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     if (WANTC)
+     {
+         if (WSCHUR)
+         {
+             LWORKMIN = 9 * N * N + 4 * N + Max(1, 6 * N);
+         }
+         else if (WSIGN)
+         {
+             LWORKMIN = 9 * N * N + 7 * N + 1;
+         }
+     }
+     else
+     {
+         if (WSCHUR)
+         {
+             LWORKMIN = 12 * N * N + 22 * N + Max(16, 4 * N);
+         }
+         else if (WINVF)
+         {
+             LWORKMIN = 28 * N * N + 2 * N + Max(1, 2 * N);
+         }
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, k + 7, iOne, LWORKMIN, &lDWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     if (WANTC)
+     {
+         if (WSCHUR)
+         {
+             C2F(riccsl)("N", &N, lA, &N, "U", lC, &N, lD,
+                         &N, lX, &N, lWR, lWI, lRCOND,
+                         lFERR, lDWORK, &LWORKMIN, lIWORK,
+                         lBWORK, &INFO);
+             if (INFO != 0)
+             {
+                 Scierror(999, _("%s: RICCSL exit with info = %d.\n"), fname, INFO);
+                 return 1;
+             }
+         }
+         else if (WSIGN)
+         {
+             C2F(riccms)("N", &N, lA, &N, "U", lC, &N, lD,
+                         &N, lX, &N, lWR, lWI, lRCOND,
+                         lFERR, lDWORK, &LWORKMIN, lIWORK, &INFO);
+             if (INFO != 0)
+             {
+                 Scierror(999, _("%s: RICCMS exit with info = %d.\n"), fname, INFO);
+                 return 1;
+             }
+         }
+     }
+     else
+     {
+         if (WSCHUR)
+         {
+             C2F(ricdsl)("N", &N, lA, &N, "U", lC, &N, lD,
+                         &N, lX, &N, lWR, lWI, lRCOND,
+                         lFERR, lDWORK, &LWORKMIN, lIWORK,
+                         lBWORK, &INFO);
+             if (INFO != 0)
+             {
+                 Scierror(999, _("%s: RICDSL exit with info = %d.\n"), fname, INFO);
+                 return 1;
+             }
+         }
+         else if (WINVF)
+         {
+             C2F(ricdmf)("N", &N, lA, &N, "U", lC, &N, lD,
+                         &N, lX, &N, lWR, lWI, lRCOND,
+                         lFERR, lDWORK, &LWORKMIN, lIWORK, &INFO);
+             if (INFO != 0)
+             {
+                 Scierror(999, _("%s: RICDMF exit with info = %d.\n"), fname, INFO);
+                 return 1;
+             }
+         }
+     }
+     if (nbOutputArgument(pvApiCtx) == 1)
+     {
+         AssignOutputVariable(pvApiCtx, 1) = k;
+     }
+     else if (nbOutputArgument(pvApiCtx) == 2)
+     {
+         AssignOutputVariable(pvApiCtx, 1) = k;
+         AssignOutputVariable(pvApiCtx, 2) = k + 3;
+     }
+     else if (nbOutputArgument(pvApiCtx) == 3)
+     {
+         AssignOutputVariable(pvApiCtx, 1) = k;
+         AssignOutputVariable(pvApiCtx, 2) = k + 3;
+         AssignOutputVariable(pvApiCtx, 3) = k + 4;
+     }
+     return 0;
+ }
index 0000000,5eb8f5d..6bf3e40
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,316 +1,316 @@@
+ /*
+  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+  * Copyright (C) 2012 - Scilab Enterprises - Cedric DELAMARRE
+  *
+  * 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-en.txt
+  *
+  */
+ #include "sci_rankqr.h"
+ #include "api_scilab.h"
+ #include "Scierror.h"
+ #include "localization.h"
+ extern int C2F(icopy)();
+ extern int C2F(dcopy)();
+ extern int C2F(mb03od)();
+ extern int C2F(dorgqr)();
 -int sci_rrankqr(char *fname, unsigned long fname_len)
++int sci_rrankqr(char *fname, void* pvApiCtx)
+ {
+     SciErr sciErr;
+     int* piAddrptrA     = NULL;
+     double* ptrA        = NULL;
+     int* piAddrptrRCOND = NULL;
+     double* ptrRCOND    = NULL;
+     int* ptrJPVT        = NULL;
+     int* piAddrptrJPVT  = NULL;
+     double* ptrSVAL     = NULL;
+     double* ptrTAU      = NULL;
+     int* ptrRANK        = NULL;
+     double* ptrR        = NULL;
+     double* ptrQ        = NULL;
+     double* ptrDWORK    = NULL;
+     int minrhs = 1;
+     int maxrhs = 3;
+     int minlhs = 1;
+     int maxlhs = 5;
+     char JOBQR      = 'Q';
+     double SLVMAX   = 0.;
+     double RCONDdef = 0.;
+     double ZERO     = 0.;
+     int A       = 1;
+     int RCOND   = 2;
+     int JPVT    = 3;
+     int SVAL    = 4;
+     int TAU     = 5;
+     int RANK    = 6;
+     int R       = 7;
+     int Q       = 8;
+     int DWORK   = 9;
+     int LDWORKMIN = 0, LDA = 0, INFO = 0, IRANK = 0, IR = 0;
+     int II = 0, NB = 0, NB1 = 0, IR1 = 0;
+     int mR = 0, nR = 0;
+     int mJ = 0, nJ = 0;
+     int M  = 0, N  = 0;
+     int iZero = 0, iOne = 1, iThree = 3;
+     int i = 0, iMin = 0, iSize = 0;
+     CheckOutputArgument(pvApiCtx, minlhs, maxlhs);
+     CheckInputArgument(pvApiCtx, minrhs, maxrhs);
+     sciErr = getVarAddressFromPosition(pvApiCtx, A, &piAddrptrA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position A.
+     sciErr = getMatrixOfDouble(pvApiCtx, piAddrptrA, &M, &N, &ptrA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, A);
+         return 1;
+     }
+     if (nbInputArgument(pvApiCtx) == 1)
+     {
+         // rankqr(A)
+         // create RCOND=0.0,JPVT=[0,..,0]
+         sciErr = allocMatrixOfDouble(pvApiCtx, RCOND, iOne, iOne, &ptrRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         *ptrRCOND = RCONDdef;
+         sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, JPVT, iOne, N, &ptrJPVT);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         C2F(icopy)(&N, &iZero, &iZero, ptrJPVT, &iOne);
+     }
+     else if (nbInputArgument(pvApiCtx) == 2)
+     {
+         // rankqr(A,RCOND)
+         // get RCOND, create JPVT=[0,..,0]
+         sciErr = getVarAddressFromPosition(pvApiCtx, RCOND, &piAddrptrRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position RCOND.
+         sciErr = getMatrixOfDouble(pvApiCtx, piAddrptrRCOND, &mR, &nR, &ptrRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, RCOND);
+             return 1;
+         }
+         if (mR * nR != 1)
+         {
+             Scierror(999, _("%s: Wrong size for input argument #%d: A scalar expected.\n"), fname, RCOND);
+             return 1;
+         }
+         sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, JPVT, iOne, N, &ptrJPVT);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         C2F(icopy)(&N, &iZero, &iZero, ptrJPVT, &iOne);
+     }
+     else if (nbInputArgument(pvApiCtx) == 3)
+     {
+         // rankqr(A,RCOND,JPVT)
+         // get  RCOND, JPVT
+         sciErr = getVarAddressFromPosition(pvApiCtx, RCOND, &piAddrptrRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position RCOND.
+         sciErr = getMatrixOfDouble(pvApiCtx, piAddrptrRCOND, &mR, &nR, &ptrRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, RCOND);
+             return 1;
+         }
+         if (mR * nR != 1)
+         {
+             Scierror(999, _("%s: Wrong size for input argument #%d: A scalar expected.\n"), fname, RCOND);
+             return 1;
+         }
+         sciErr = getVarAddressFromPosition(pvApiCtx, JPVT, &piAddrptrJPVT);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position JPVT.
+         sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrptrJPVT, &mJ, &nJ, &ptrJPVT);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, JPVT);
+             return 1;
+         }
+         if (mJ * nJ != N)
+         {
+             Scierror(999, _("%s: Wrong size for input argument #%d: Same column dimension as input argument #%d expected.\n"), fname, JPVT, A);
+             return 1;
+         }
+     }
+     // Creating  SVAL,TAU,RANK,R,Q,DWORK
+     sciErr = allocMatrixOfDouble(pvApiCtx, SVAL, iOne, iThree, &ptrSVAL);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     iMin = Min(M, N);
+     sciErr = allocMatrixOfDouble(pvApiCtx, TAU, iOne, iMin, &ptrTAU);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, RANK, iOne, iOne, &ptrRANK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, R, M, N, &ptrR);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDouble(pvApiCtx, Q, M, M, &ptrQ);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     LDWORKMIN = Max(1, 3 * N);
+     sciErr = allocMatrixOfDouble(pvApiCtx, DWORK, iOne, LDWORKMIN, &ptrDWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     LDA = Max(1, M);
+     C2F(mb03od)(&JOBQR, &M, &N, ptrA, &LDA, ptrJPVT,
+                 ptrRCOND, &SLVMAX, ptrTAU, ptrRANK,
+                 ptrSVAL, ptrDWORK, &INFO);
+     if (INFO != 0)
+     {
+         Scierror(999, _("%s: MB03OD exit with info = %d.\n"), fname, INFO);
+         return 1;
+     }
+     //  Save R (=current A)
+     iSize = M * N;
+     C2F(dcopy)(&iSize, (ptrA), &iOne, (ptrR), &iOne);
+     //  Set to zero lower trapezoidal part of R:
+     IRANK = *ptrRANK;
+     IR = IRANK - M;
+     for (i = 0; i < N; i++)
+     {
+         II = II + 1;
+         NB = M - IRANK;
+         IR = IR + M;
+         NB1 = NB;
+         IR1 = IR;
+         if ((i + 1) < IRANK)
+         {
+             IR1 = IR - (IRANK - (i + 1));
+             NB1 = NB + (IRANK - (i + 1));
+         }
+         C2F(dcopy)(&NB1, &ZERO, &iZero, (ptrR + IR1), &iOne);
+     }
+     // Make Q
+     if (M <= N)
+     {
+         // A is fat
+         C2F(dorgqr)(&M, &M, &M, ptrA, &LDA, ptrTAU, ptrDWORK, &LDWORKMIN, &INFO);
+         iSize = M * M;
+         C2F(dcopy)(&iSize, ptrA, &iOne, ptrQ, &iOne);
+     }
+     else
+     {
+         // A is tall => Q=[A,0]
+         iSize = M * N;
+         C2F(dcopy)(&iSize, ptrA, &iOne, ptrQ, &iOne);
+         iSize = M * (M - N);
+         C2F(dcopy)(&iSize, &ZERO, &iZero, (ptrQ + M * N), &iOne);
+         iMin = Min(M, N);
+         C2F(dorgqr)(&M, &M, &iMin, ptrQ, &LDA, ptrTAU, ptrDWORK, &LDWORKMIN, &INFO);
+     }
+     if (INFO != 0)
+     {
+         Scierror(999, _("%s: DORGQR exit with info = %d.\n"), fname, INFO);
+         return 1;
+     }
+     // [Q,R,JPVT,RANK,SVAL]=rankqr(A,[RCOND,JPVT])
+     AssignOutputVariable(pvApiCtx, 1) = Q;
+     AssignOutputVariable(pvApiCtx, 2) = R;
+     AssignOutputVariable(pvApiCtx, 3) = JPVT;
+     AssignOutputVariable(pvApiCtx, 4) = RANK;
+     AssignOutputVariable(pvApiCtx, 5) = SVAL;
+     return 0;
+ }
index 0000000,cdaff11..2bea32e
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,335 +1,335 @@@
+ /*
+  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+  * Copyright (C) 2012 - Scilab Enterprises - Cedric DELAMARRE
+  *
+  * 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-en.txt
+  *
+  */
+ #include "sci_rankqr.h"
+ #include "api_scilab.h"
+ #include "Scierror.h"
+ #include "localization.h"
+ extern int C2F(icopy)();
+ extern int C2F(zcopy)();
+ extern int C2F(zb03od)();
+ extern int C2F(zungqr)();
 -int sci_zrankqr(char *fname, unsigned long fname_len)
++int sci_zrankqr(char *fname, void* pvApiCtx)
+ {
+     SciErr sciErr;
+     int* piAddrptrRCOND = NULL;
+     double* ptrRCOND    = NULL;
+     int* piAddrptrJPVT  = NULL;
+     int* ptrJPVT        = NULL;
+     double* ptrSVAL     = NULL;
+     int* ptrRANK        = NULL;
+     double* ptrRWORK    = NULL;
+     int* piAddrptrA     = NULL;
+     int* piAddrptrTAU   = NULL;
+     int* piAddrptrR     = NULL;
+     int* piAddrptrQ     = NULL;
+     int* piAddrptrDWORK = NULL;
+     doublecomplex* ptrA     = NULL;
+     doublecomplex* ptrTAU   = NULL;
+     doublecomplex* ptrR     = NULL;
+     doublecomplex* ptrQ     = NULL;
+     doublecomplex* ptrDWORK = NULL;
+     int minrhs = 1;
+     int maxrhs = 3;
+     int minlhs = 1;
+     int maxlhs = 5;
+     char JOBQR      = 'Q';
+     double SLVMAX   = 0.;
+     double RCONDdef = 0.;
+     int A       = 1;
+     int RCOND   = 2;
+     int JPVT    = 3;
+     int SVAL    = 4;
+     int TAU     = 5;
+     int RANK    = 6;
+     int R       = 7;
+     int Q       = 8;
+     int RWORK   = 9;
+     int DWORK   = 10;
+     int LDWORKMIN = 0, LDA = 0, INFO = 0, IRANK = 0, IR = 0;
+     int II = 0, NB = 0, NB1 = 0, IR1 = 0;
+     int mR = 0, nR = 0;
+     int mJ = 0, nJ = 0;
+     int M  = 0, N  = 0;
+     int iZero = 0, iOne = 1, iThree = 3;
+     int i = 0, iMin = 0, iSize = 0;
+     doublecomplex ZERO;
+     ZERO.r = 0.;
+     ZERO.i = 0.;
+     CheckOutputArgument(pvApiCtx, minlhs, maxlhs);
+     CheckInputArgument(pvApiCtx, minrhs, maxrhs);
+     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrptrA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         return 1;
+     }
+     // Retrieve a matrix of double at position 1.
+     sciErr = getComplexZMatrixOfDouble(pvApiCtx, piAddrptrA, &M, &N, &ptrA);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(202, _("%s: Wrong type for argument %d: A complex expected.\n"), fname, 1);
+         return 1;
+     }
+     if (nbInputArgument(pvApiCtx) == 1)
+     {
+         // rankqr(A)
+         // create RCOND=0.0,JPVT=[0,..,0]
+         sciErr = allocMatrixOfDouble(pvApiCtx, RCOND, iOne, iOne, &ptrRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         *ptrRCOND = RCONDdef;
+         sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, JPVT, iOne, N, &ptrJPVT);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         C2F(icopy)(&N, &iZero, &iZero, (int*)(ptrJPVT), &iOne);
+     }
+     else if (nbInputArgument(pvApiCtx) == 2)
+     {
+         // rankqr(A,RCOND)
+         // get RCOND, create JPVT=[0,..,0]
+         sciErr = getVarAddressFromPosition(pvApiCtx, RCOND, &piAddrptrRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position RCOND.
+         sciErr = getMatrixOfDouble(pvApiCtx, piAddrptrRCOND, &mR, &nR, &ptrRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, RCOND);
+             return 1;
+         }
+         if (mR * nR != 1)
+         {
+             Scierror(999, _("%s: Wrong size for input argument #%d: A scalar expected.\n"), fname, RCOND);
+             return 1;
+         }
+         sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, JPVT, iOne, N, &ptrJPVT);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(999, _("%s: Memory allocation error.\n"), fname);
+             return 1;
+         }
+         C2F(icopy)(&N, &iZero, &iZero, (int*)(ptrJPVT), &iOne);
+     }
+     else if (nbInputArgument(pvApiCtx) == 3)
+     {
+         // rankqr(A,RCOND,JPVT)
+         // get  RCOND, JPVT
+         sciErr = getVarAddressFromPosition(pvApiCtx, RCOND, &piAddrptrRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position RCOND.
+         sciErr = getMatrixOfDouble(pvApiCtx, piAddrptrRCOND, &mR, &nR, &ptrRCOND);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, RCOND);
+             return 1;
+         }
+         if (mR * nR != 1)
+         {
+             Scierror(999, _("%s: Wrong size for input argument #%d: A scalar expected.\n"), fname, RCOND);
+             return 1;
+         }
+         sciErr = getVarAddressFromPosition(pvApiCtx, JPVT, &piAddrptrJPVT);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             return 1;
+         }
+         // Retrieve a matrix of double at position JPVT.
+         sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddrptrJPVT, &mJ, &nJ, &ptrJPVT);
+         if (sciErr.iErr)
+         {
+             printError(&sciErr, 0);
+             Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, JPVT);
+             return 1;
+         }
+         if (mJ * nJ != N)
+         {
+             Scierror(999, _("%s: Wrong size for input argument #%d: Same column dimension as input argument #%d expected.\n"), fname, JPVT, A);
+             return 1;
+         }
+     }
+     // Creating  SVAL,TAU,RANK,R,Q,RWORK,DWORK
+     sciErr = allocMatrixOfDouble(pvApiCtx, SVAL, iOne, iThree, &ptrSVAL);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     iMin = Min(M, N);
+     sciErr = allocComplexZMatrixOfDouble(pvApiCtx, TAU, iOne, iMin, &ptrTAU);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, RANK, iOne, iOne, &ptrRANK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocComplexZMatrixOfDouble(pvApiCtx, R, M, N, &ptrR);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     sciErr = allocComplexZMatrixOfDouble(pvApiCtx, Q, M, M, &ptrQ);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     iSize = 2 * N;
+     sciErr = allocMatrixOfDouble(pvApiCtx, RWORK, iOne, iSize, &ptrRWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     LDWORKMIN = Max(1, 3 * N);
+     sciErr = allocComplexZMatrixOfDouble(pvApiCtx, DWORK, iOne, LDWORKMIN, &ptrDWORK);
+     if (sciErr.iErr)
+     {
+         printError(&sciErr, 0);
+         Scierror(999, _("%s: Memory allocation error.\n"), fname);
+         return 1;
+     }
+     LDA = Max(1, M);
+     C2F(zb03od)(&JOBQR, &M, &N, ptrA, &LDA, ptrJPVT,
+                 ptrRCOND, &SLVMAX, ptrTAU, ptrRANK,
+                 ptrSVAL, ptrDWORK, &LDWORKMIN, ptrRWORK, &INFO);
+     if (INFO != 0)
+     {
+         Scierror(999, _("%s: ZB03OD exit with info = %d.\n"), fname, INFO);
+         return 1;
+     }
+     //  Save R (=current A)
+     iSize = M * N;
+     C2F(zcopy)(&iSize, ptrA, &iOne, ptrR, &iOne);
+     //  Set to zero lower trapezoidal part of R:
+     IRANK = *ptrRANK;
+     IR = IRANK - M;
+     for (i = 0; i < N; i++)
+     {
+         II = II + 1;
+         NB = M - IRANK;
+         IR = IR + M;
+         NB1 = NB;
+         IR1 = IR;
+         if ((i + 1) < IRANK)
+         {
+             IR1 = IR - (IRANK - (i + 1));
+             NB1 = NB + (IRANK - (i + 1));
+         }
+         C2F(zcopy)(&NB1, &ZERO, &iZero, (ptrR + IR1), &iOne);
+     }
+     // Make Q
+     if (M <= N)
+     {
+         // A is fat
+         C2F(zungqr)(&M, &M, &M, ptrA, &LDA, ptrTAU, ptrDWORK, &LDWORKMIN, &INFO);
+         iSize = M * M;
+         C2F(zcopy)(&iSize, ptrA, &iOne, ptrQ, &iOne);
+     }
+     else
+     {
+         // A is tall => Q=[A,0]
+         iSize = M * N;
+         C2F(zcopy)(&iSize, ptrA, &iOne, ptrQ, &iOne);
+         iSize = M * (M - N);
+         C2F(zcopy)(&iSize, &ZERO, &iZero, (ptrQ + M * N), &iOne);
+         iMin = Min(M, N);
+         C2F(zungqr)(&M, &M, &iMin, ptrQ, &LDA, ptrTAU, ptrDWORK, &LDWORKMIN, &INFO);
+     }
+     if (INFO != 0)
+     {
+         Scierror(999, _("%s: ZUNGQR exit with info = %d.\n"), fname, INFO);
+         return 1;
+     }
+     // [Q,R,JPVT,RANK,SVAL]=rankqr(A,[RCOND,JPVT])
+     AssignOutputVariable(pvApiCtx, 1) = Q;
+     AssignOutputVariable(pvApiCtx, 2) = R;
+     AssignOutputVariable(pvApiCtx, 3) = JPVT;
+     AssignOutputVariable(pvApiCtx, 4) = RANK;
+     AssignOutputVariable(pvApiCtx, 5) = SVAL;
+     return 0;
+ }
@@@ -76,7 -76,7 +76,7 @@@
    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
      <ClCompile>
        <Optimization>Disabled</Optimization>
-       <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;../../../operations/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
 -      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
++      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;../../../operations/includes;../../../elementary_functions/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
        <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;CACSD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
        <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
        <WarningLevel>Level3</WarningLevel>
@@@ -107,7 -105,7 +107,7 @@@ lib /DEF:"$(ProjectDir)mexlib_Import.de
      </Midl>
      <ClCompile>
        <Optimization>Disabled</Optimization>
-       <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;../../../operations/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
 -      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
++      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;../../../operations/includes;../../../elementary_functions/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
        <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;CACSD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
        <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
        <WarningLevel>Level3</WarningLevel>
@@@ -136,7 -132,7 +136,7 @@@ lib /DEF:"$(ProjectDir)mexlib_Import.de
      <ClCompile>
        <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
        <WholeProgramOptimization>false</WholeProgramOptimization>
-       <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;../../../operations/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
 -      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
++      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;../../../operations/includes;../../../elementary_functions/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
        <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;CACSD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
        <StringPooling>true</StringPooling>
        <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@@ -172,7 -166,7 +172,7 @@@ lib /DEF:"$(ProjectDir)mexlib_Import.de
      <ClCompile>
        <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
        <WholeProgramOptimization>false</WholeProgramOptimization>
-       <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;../../../operations/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
 -      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
++      <AdditionalIncludeDirectories>.;../../includes;../../../../libs/MALLOC/includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../cacsd/includes;../../../api_scilab/includes;../../../operations/includes;../../../elementary_functions/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
        <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;CACSD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
        <StringPooling>true</StringPooling>
        <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@@ -207,7 -206,7 +214,6 @@@ lib /DEF:"$(ProjectDir)mexlib_Import.de
      <ClCompile Include="..\..\sci_gateway\c\gw_cacsd1.c" />
      <ClCompile Include="..\..\sci_gateway\c\gw_cacsd2.c" />
      <ClCompile Include="..\..\sci_gateway\c\gw_cacsd3.c" />
--    <ClCompile Include="..\..\sci_gateway\c\gw_slicot.c" />
      <ClCompile Include="..\..\sci_gateway\c\sci_arl2.c" />
      <ClCompile Include="..\..\sci_gateway\c\sci_contr.c" />
      <ClCompile Include="..\..\sci_gateway\c\sci_ereduc.c" />
      <ClInclude Include="..\..\includes\gw_cacsd1.h" />
      <ClInclude Include="..\..\includes\gw_cacsd2.h" />
      <ClInclude Include="..\..\includes\gw_cacsd3.h" />
--    <ClInclude Include="..\..\includes\gw_slicot.h" />
      <ClInclude Include="..\..\sci_gateway\c\sci_contr.h" />
      <ClInclude Include="..\..\sci_gateway\c\sci_rankqr.h" />
    </ItemGroup>
@@@ -38,9 -38,9 +38,6 @@@
      <ClCompile Include="..\..\sci_gateway\c\gw_cacsd3.c">
        <Filter>Source Files</Filter>
      </ClCompile>
--    <ClCompile Include="..\..\sci_gateway\c\gw_slicot.c">
--      <Filter>Source Files</Filter>
--    </ClCompile>
      <ClCompile Include="..\..\sci_gateway\c\sci_arl2.c">
        <Filter>Source Files</Filter>
      </ClCompile>
      <ClInclude Include="..\..\includes\gw_cacsd3.h">
        <Filter>Header Files</Filter>
      </ClInclude>
--    <ClInclude Include="..\..\includes\gw_slicot.h">
--      <Filter>Header Files</Filter>
--    </ClInclude>
      <ClInclude Include="..\..\sci_gateway\c\sci_contr.h">
        <Filter>Header Files</Filter>
      </ClInclude>
  /* 24  gw_user2(); RESERVED to gw_user (see callinter.h) */
  #include "gw_user2.h"
  /* 25 */                                              #include "../../gui/includes/gw_gui.h"
 -/* 26 */                                              #include "../../differential_equations/includes/gw_differential_equations2.h"
 +/* 26 *///                                            #include "../../differential_equations/includes/gw_differential_equations2.h"
  /* 27 */                                              #include "../../sparse/includes/gw_sparse.h"
--/* 28 */                                              #include "../../cacsd/includes/gw_slicot.h"
 -/* 29 */                                              #include "../../differential_equations/includes/gw_differential_equations3.h"
 -/* 30 */                                              #include "../../differential_equations/includes/gw_differential_equations4.h"
++/* 28 */                                              //#include "../../cacsd/includes/gw_slicot.h"
 +/* 29 *///                                            #include "../../differential_equations/includes/gw_differential_equations3.h"
 +/* 30 *///                                            #include "../../differential_equations/includes/gw_differential_equations4.h"
  /* 31 */                                      #include "dynamic_gateways.h"   /* functions */
 -/* 32 */                                              #include "../../differential_equations/includes/gw_differential_equations6.h"
 +/* 32 *///                                            #include "../../differential_equations/includes/gw_differential_equations6.h"
  /* 33 */                        #include "../../output_stream/includes/gw_output_stream.h"
  /* 34 */                                              #include "../../fileio/includes/gw_fileio.h"
  /* 35 */                                              #include "dynamic_gateways.h" /* arnoldi */
@@@ -26,7 -26,7 +26,7 @@@
   * @param size size of the array
   * @param lda
   */
--void SciToF77(double *ptr, int size, int lda);
++//void SciToF77(double *ptr, int size, int lda);
  
  /**
   * Convert an Fortran array of double to a Scilab format
@@@ -59,16 -59,16 +59,16 @@@ static OpTab Interfaces[INTERFACES_MAX
      /* 20  */ {gw_cacsd3},
      /* 21  */ {gw_string},
      /* 22  */ {gw_dynamic_symbolic},
 -    /* 23  */ {gw_boolean},
 +    /* 23  */ {NULL}, //gw_boolean
      /* 24  */ {gw_user2}, /* RESERVED (see callinter.h) */
      /* 25  */ {gw_gui},
 -    /* 26  */ {gw_differential_equations2},
 +    /* 26  */ {NULL}, //gw_differential_equations2
      /* 27  */ {gw_sparse},
--    /* 28  */ {gw_slicot},
 -    /* 29  */ {gw_differential_equations3},
 -    /* 30  */ {gw_differential_equations4},
 -    /* 31  */ {gw_dynamic_functions},
 -    /* 32  */ {gw_differential_equations6},
++    /* 28  */ {NULL}, //gw_slicot
 +    /* 29  */ {NULL}, //gw_differential_equations3
 +    /* 30  */ {NULL}, //gw_differential_equations4
 +    /* 31  */ {NULL}, //gw_dynamic_functions
 +    /* 32  */ {NULL}, //gw_differential_equations6
      /* 33  */ {gw_output_stream},
      /* 34  */ {gw_fileio},
      /* 35  */ {gw_dynamic_arnoldi},
  extern int C2F(fortrangetch)();
  
  
- int C2F(getval)(double *s, int *dotdet)
+ int C2F(getval)(double *s, int *dotdet, int *opt)
  {
 -    /* Initialized constants */
 -    static double toto = 0.;
 -    static double c10 = 10.;
 -
 -    /* Local variables */
 -    static int expo;
 -    static int code0;
 -    static int i, k;
 -    static int digit[25], ndgrec;
 -    static int detdot;
 -    static int ndgexp, expcor, sgnexp;
 -    static char string[31];
 -    static int ndg;
 +    ///* Initialized constants */
 +    //static double toto = 0.;
 +    //static double c10 = 10.;
  
 -    /* System generated locals */
 -    static double d1;
 -    int i1;
 +    ///* Local variables */
 +    //static int expo;
 +    //static int code0;
 +    //static int i, k;
 +    //static int digit[25], ndgrec;
 +    //static int detdot;
 +    //static int ndgexp, expcor, sgnexp;
 +    //static char string[31];
 +    //static int ndg;
  
 -    Fin = 0;
 -    /*     beginning of the code */
 -    detdot = *dotdet;
 -    ndg = 0;
 -    ndgrec = 0;
 -    if (! detdot)
 -    {
 -        /*  1) got the int part of the mantissa of the pattern
 -          1-a) may be there is some 0 at the beginning */
 -        while (C2F(com).char1 == 0)
 -        {
 -            C2F(fortrangetch)();
 -        }
 -        /* 1-b) now record the digits (inside the digit array)
 -           (but we record a maximum of ndgmax digits)*/
 -        while (abs(C2F(com).char1) <= 9)
 -        {
 -            ++ndg;
 -            if (ndgrec < 25)
 -            {
 -                ++ndgrec;
 -                digit[ndgrec - 1] = C2F(com).char1;
 -            }
 -            C2F(fortrangetch)();
 -        }
 -        /*1-c) at this point we have detected something which is not a digit
 -               may be a point, may be a d,D,e,E, or something else
 -               here we only test for the dot and let the others cases
 -           to be treated after ... */
 -        if (abs(C2F(com).char1) == dot)
 -        {
 -            detdot = TRUE;
 -            C2F(fortrangetch)();
 -            if (opt == 0 && getWarningMode())
 -            {
 -                if ((abs(C2F(com).char1) == slash) || (abs(C2F(com).char1) == bchar_slash))
 -                {
 -                    int v = 0;
 +    ///* System generated locals */
 +    //static double d1;
 +    //int i1;
  
 -                    for (i = 0; i < ndgrec; ++i)
 -                    {
 -                        v = v * 10 + digit[i];
 -                    }
 -                    if (abs(C2F(com).char1) == slash)
 -                        sciprint(_("%s: \"%d.%s ...\" is interpreted as \"%d.0%s ...\". Use \"%d .%s ...\" for element wise operation \n") ,
 -                                 "Warning", v, "/", v, "/", v, "/");
 -                    else
 -                        sciprint(_("%s: \"%d.%s ...\" is interpreted as \"%d.0%s ...\". Use \"%d .%s ...\" for element wise operation \n") ,
 -                                 "Warning", v, "\\", v, "\\", v, "\\");
 -                }
 -            }
 -        }
 -    }
 -    /*first correction for the (future) exponent : if the first part
 -      of the string have more then ndgmax digits we have to add
 -      ndg - ndgrec (else we have expcor=0) */
 -    expcor = ndg - ndgrec;
 -    if (detdot)
 -    {
 -        /*2) got the "fractionnal" part of the "mantissa" */
 -        if (ndgrec == 0)
 -        {
 -            /*we have not passed throw the part 1) or only zeros have been met
 -            and may be the number start with .000xxx : so clean up those 0 */
 -            while (C2F(com).char1 == 0)
 -            {
 -                --expcor;
 -                C2F(fortrangetch)();
 -            }
 -        }
 -        /*now we begin to record the digits */
 -        while (abs(C2F(com).char1) <= 9)
 -        {
 -            if (ndgrec < 25)
 -            {
 -                ++ndgrec;
 -                --expcor;
 -                digit[ndgrec - 1] = C2F(com).char1;
 -            }
 -            C2F(fortrangetch)();
 -        }
 -    }
 -    /*3) at this point the "mantissa" of the string decimal number
 -      must be recorded, now detect the exponent */
 -    expo = 0;
 -    ndgexp = 0;
 -    sgnexp = plus;
 -    if (abs(C2F(com).char1) == D || abs(C2F(com).char1) == E)
 -    {
 -        /*the string have an exponent part (which, in Scilab, may be empty or
 -          may had only a sign ! => expo = 0) */
 -        C2F(fortrangetch)();
 -        if (C2F(com).char1 == minus || C2F(com).char1 == plus)
 -        {
 -            sgnexp = C2F(com).char1;
 -            C2F(fortrangetch)();
 -        }
 -        else
 -        {
 -            sgnexp = plus;
 -        }
 -        /*may be the exponent start by some 0 */
 -        while (C2F(com).char1 == 0)
 -        {
 -            C2F(fortrangetch)();
 -        }
 -        /*now form the exponent : the var ndgexp is here
 -          to treat spurious int overflow ... */
 -        while (abs(C2F(com).char1) <= 9)
 -        {
 -            expo = expo * 10 + C2F(com).char1;
 -            ++ndgexp;
 -            C2F(fortrangetch)();
 -        }
 -    }
 -    /*4) Now we can form the double float number s
 -      4-1/ only zeros in the mantissa */
 -    if (ndgrec == 0)
 -    {
 -        /*no digits have been recorded : this is the case
 -          when the mantissa part is of the form [000][.][000]
 -          the number is 0 */
 -        *s = 0.;
 -        return 0;
 -    }
 -    /*4-2/ ndgexp is to large => the exponent expo is perhaps badly
 -      computed (int "overflow") or in all cases the
 -      exponent is too large (positive or negative) such that it result
 -      (for s) in an overflow or underflow depending the exponent sign */
 -    if (ndgexp >= NDEMAX)
 -    {
 -        if (sgnexp == minus)  /*underflow */
 -        {
 -            *s = 0.;
 -        }
 -        else    /*overflow : got an inf ... */
 -        {
 -            *s = 1. / (toto - toto);
 -        }
 -        return 0;
 -    }
 -    /*4-3/ now build the final exponent */
 -    if (sgnexp == plus)
 -    {
 -        expo += expcor;
 -    }
 -    else
 -    {
 -        expo = -expo + expcor;
 -    }
 -    /*4-4/ here some tests to avoid unnecessary call to  "strtod"
 -      Now we have a number s of the form  d_1 d_2 ... d_ndgrec 10^expo
 -      which is equal to d_1 . d_2 ... d_ndgrec 10^(expo + ndgrec - 1)
 -      with d_1 .ne. 0
 -      so it comes :  s >= 10^(expo + ndgrec - 1)
 -      s <= 10^(expo + ndgrec)
 +    //Fin = 0;
 +    ///*     beginning of the code */
 +    //detdot = *dotdet;
 +    //ndg = 0;
 +    //ndgrec = 0;
 +    //if (! detdot)
 +    //{
 +    //    /*  1) got the int part of the mantissa of the pattern
 +    //      1-a) may be there is some 0 at the beginning */
 +    //    while (C2F(com).char1 == 0)
 +    //    {
 +    //        C2F(fortrangetch)();
 +    //    }
 +    //    /* 1-b) now record the digits (inside the digit array)
 +    //       (but we record a maximum of ndgmax digits)*/
 +    //    while (abs(C2F(com).char1) <= 9)
 +    //    {
 +    //        ++ndg;
 +    //        if (ndgrec < 25)
 +    //        {
 +    //            ++ndgrec;
 +    //            digit[ndgrec - 1] = C2F(com).char1;
 +    //        }
 +    //        C2F(fortrangetch)();
 +    //    }
 +    //    /*1-c) at this point we have detected something which is not a digit
 +    //           may be a point, may be a d,D,e,E, or something else
 +    //           here we only test for the dot and let the others cases
 +    //       to be treated after ... */
 +    //    if (abs(C2F(com).char1) == dot)
 +    //    {
 +    //        detdot = TRUE;
 +    //        C2F(fortrangetch)();
 +    //        if (getWarningMode())
 +    //        {
 +    //            if ((abs(C2F(com).char1) == slash) || (abs(C2F(com).char1) == bchar_slash))
 +    //            {
 +    //                int v = 0;
 +    //                for (i = 0; i < ndgrec; ++i)
 +    //                {
 +    //                    v = v * 10 + digit[i];
 +    //                }
 +    //                if (abs(C2F(com).char1) == slash)
 +    //                    sciprint(_("%s: \"%d.%s ...\" is interpreted as \"%d.0%s ...\". Use \"%d .%s ...\" for element wise operation \n") ,
 +    //                             "Warning", v, "/", v, "/", v, "/");
 +    //                else
 +    //                    sciprint(_("%s: \"%d.%s ...\" is interpreted as \"%d.0%s ...\". Use \"%d .%s ...\" for element wise operation \n") ,
 +    //                             "Warning", v, "\\", v, "\\", v, "\\");
 +    //            }
 +    //        }
 +    //    }
 +    //}
 +    ///*first correction for the (future) exponent : if the first part
 +    //  of the string have more then ndgmax digits we have to add
 +    //  ndg - ndgrec (else we have expcor=0) */
 +    //expcor = ndg - ndgrec;
 +    //if (detdot)
 +    //{
 +    //    /*2) got the "fractionnal" part of the "mantissa" */
 +    //    if (ndgrec == 0)
 +    //    {
 +    //        /*we have not passed throw the part 1) or only zeros have been met
 +    //        and may be the number start with .000xxx : so clean up those 0 */
 +    //        while (C2F(com).char1 == 0)
 +    //        {
 +    //            --expcor;
 +    //            C2F(fortrangetch)();
 +    //        }
 +    //    }
 +    //    /*now we begin to record the digits */
 +    //    while (abs(C2F(com).char1) <= 9)
 +    //    {
 +    //        if (ndgrec < 25)
 +    //        {
 +    //            ++ndgrec;
 +    //            --expcor;
 +    //            digit[ndgrec - 1] = C2F(com).char1;
 +    //        }
 +    //        C2F(fortrangetch)();
 +    //    }
 +    //}
 +    ///*3) at this point the "mantissa" of the string decimal number
 +    //  must be recorded, now detect the exponent */
 +    //expo = 0;
 +    //ndgexp = 0;
 +    //sgnexp = plus;
 +    //if (abs(C2F(com).char1) == D || abs(C2F(com).char1) == E)
 +    //{
 +    //    /*the string have an exponent part (which, in Scilab, may be empty or
 +    //      may had only a sign ! => expo = 0) */
 +    //    C2F(fortrangetch)();
 +    //    if (C2F(com).char1 == minus || C2F(com).char1 == plus)
 +    //    {
 +    //        sgnexp = C2F(com).char1;
 +    //        C2F(fortrangetch)();
 +    //    }
 +    //    else
 +    //    {
 +    //        sgnexp = plus;
 +    //    }
 +    //    /*may be the exponent start by some 0 */
 +    //    while (C2F(com).char1 == 0)
 +    //    {
 +    //        C2F(fortrangetch)();
 +    //    }
 +    //    /*now form the exponent : the var ndgexp is here
 +    //      to treat spurious int overflow ... */
 +    //    while (abs(C2F(com).char1) <= 9)
 +    //    {
 +    //        expo = expo * 10 + C2F(com).char1;
 +    //        ++ndgexp;
 +    //        C2F(fortrangetch)();
 +    //    }
 +    //}
 +    ///*4) Now we can form the double float number s
 +    //  4-1/ only zeros in the mantissa */
 +    //if (ndgrec == 0)
 +    //{
 +    //    /*no digits have been recorded : this is the case
 +    //      when the mantissa part is of the form [000][.][000]
 +    //      the number is 0 */
 +    //    *s = 0.;
 +    //    return 0;
 +    //}
 +    ///*4-2/ ndgexp is to large => the exponent expo is perhaps badly
 +    //  computed (int "overflow") or in all cases the
 +    //  exponent is too large (positive or negative) such that it result
 +    //  (for s) in an overflow or underflow depending the exponent sign */
 +    //if (ndgexp >= NDEMAX)
 +    //{
 +    //    if (sgnexp == minus)  /*underflow */
 +    //    {
 +    //        *s = 0.;
 +    //    }
 +    //    else    /*overflow : got an inf ... */
 +    //    {
 +    //        *s = 1. / (toto - toto);
 +    //    }
 +    //    return 0;
 +    //}
 +    ///*4-3/ now build the final exponent */
 +    //if (sgnexp == plus)
 +    //{
 +    //    expo += expcor;
 +    //}
 +    //else
 +    //{
 +    //    expo = -expo + expcor;
 +    //}
 +    ///*4-4/ here some tests to avoid unnecessary call to  "strtod"
 +    //  Now we have a number s of the form  d_1 d_2 ... d_ndgrec 10^expo
 +    //  which is equal to d_1 . d_2 ... d_ndgrec 10^(expo + ndgrec - 1)
 +    //  with d_1 .ne. 0
 +    //  so it comes :  s >= 10^(expo + ndgrec - 1)
 +    //  s <= 10^(expo + ndgrec)
  
 -      Suppose given EXPMAX such that  10^EXPMAX > max positive float number
 -      and EXPMIN such that  10^EXPMIN < min positive float number
 +    //  Suppose given EXPMAX such that  10^EXPMAX > max positive float number
 +    //  and EXPMIN such that  10^EXPMIN < min positive float number
  
 -      then if  expo + ndgrec - 1 >= EXPMAX then overflow occurs necessarily
 -      and  if  expo + ndgrec <= EXPMIN then underflow occurs
 +    //  then if  expo + ndgrec - 1 >= EXPMAX then overflow occurs necessarily
 +    //  and  if  expo + ndgrec <= EXPMIN then underflow occurs
  
 -      On IEEE 754 we have : max positive float num = (approx) 1.8E+308
 -      min positive float num = (approx) 4.9EEXPMIN
 -      (if denormalised number are used)
 +    //  On IEEE 754 we have : max positive float num = (approx) 1.8E+308
 +    //  min positive float num = (approx) 4.9EEXPMIN
 +    //  (if denormalised number are used)
  
 -      So that EXPMAX = 309
 -      and  EXPMIN = -324  are OK (but larger limits are possible to take
 -      into account others f.p. arithmetics)
 -      Note that after the test (with these values) the exponent have a
 -      maximum of 3 (decimals) digits */
 -    if (expo + ndgrec - 1 >= EXPMAX)  /*overflow : got an inf ... */
 -    {
 -        *s = 1. / (toto - toto);
 -        return 0;
 -    }
 -    if (expo + ndgrec <= EXPMIN)   /*underflow : got an 0 */
 -    {
 -        *s = 0.;
 -        return 0;
 -    }
 -    /*4-5/ Now the usual case where we can get the near floating point
 -      without any problem */
 -    if (ndgrec <= DGLIM && abs(expo) <= EXPLIM)
 -    {
 -        *s = 0.;
 -        i1 = ndgrec;
 -        for (i = 1; i <= i1; ++i)
 -        {
 -            *s = *s * 10. + digit[i - 1];
 -        }
 -        if (expo < 0)
 -        {
 -            d1 = -expo;
 -            *s /= pow(c10, d1);
 -        }
 -        else
 -        {
 -            d1 = expo;
 -            *s *= pow(c10, d1);
 -        }
 -        return 0;
 -    }
 -    /*4-6/ The other easy case where we can compute s :
 -      if expo = EXPLIM + k  but [int part]*10^k < max_int_coded_in_double
 -      then it is OK (retrieve k in the exponent and multiply the int
 -      part by 10^k and do the same job as previus) */
 -    if (expo > EXPLIM && expo - EXPLIM + ndgrec <= DGLIM)
 -    {
 -        *s = 0.;
 -        i1 = ndgrec;
 -        for (i = 1; i <= i1; ++i)
 -        {
 -            *s = *s * 10. + digit[i - 1];
 -        }
 -        /*peut etre dangereux avec des options d'optimisation ?
 -          (le compilo peut etre tente d'ecrire directement s = s*10**expo
 -          ce qui detruit le truc ...) */
 -        /*         s = s*10.d0**(expo-EXPLIM)
 -               s = s*10.d0**EXPLIM*/
 +    //  So that EXPMAX = 309
 +    //  and  EXPMIN = -324  are OK (but larger limits are possible to take
 +    //  into account others f.p. arithmetics)
 +    //  Note that after the test (with these values) the exponent have a
 +    //  maximum of 3 (decimals) digits */
 +    //if (expo + ndgrec - 1 >= EXPMAX)  /*overflow : got an inf ... */
 +    //{
 +    //    *s = 1. / (toto - toto);
 +    //    return 0;
 +    //}
 +    //if (expo + ndgrec <= EXPMIN)   /*underflow : got an 0 */
 +    //{
 +    //    *s = 0.;
 +    //    return 0;
 +    //}
 +    ///*4-5/ Now the usual case where we can get the near floating point
 +    //  without any problem */
 +    //if (ndgrec <= DGLIM && abs(expo) <= EXPLIM)
 +    //{
 +    //    *s = 0.;
 +    //    i1 = ndgrec;
 +    //    for (i = 1; i <= i1; ++i)
 +    //    {
 +    //        *s = *s * 10. + digit[i - 1];
 +    //    }
 +    //    if (expo < 0)
 +    //    {
 +    //        d1 = -expo;
 +    //        *s /= pow(c10, d1);
 +    //    }
 +    //    else
 +    //    {
 +    //        d1 = expo;
 +    //        *s *= pow(c10, d1);
 +    //    }
 +    //    return 0;
 +    //}
 +    ///*4-6/ The other easy case where we can compute s :
 +    //  if expo = EXPLIM + k  but [int part]*10^k < max_int_coded_in_double
 +    //  then it is OK (retrieve k in the exponent and multiply the int
 +    //  part by 10^k and do the same job as previus) */
 +    //if (expo > EXPLIM && expo - EXPLIM + ndgrec <= DGLIM)
 +    //{
 +    //    *s = 0.;
 +    //    i1 = ndgrec;
 +    //    for (i = 1; i <= i1; ++i)
 +    //    {
 +    //        *s = *s * 10. + digit[i - 1];
 +    //    }
 +    //    /*peut etre dangereux avec des options d'optimisation ?
 +    //      (le compilo peut etre tente d'ecrire directement s = s*10**expo
 +    //      ce qui detruit le truc ...) */
 +    //    /*         s = s*10.d0**(expo-EXPLIM)
 +    //           s = s*10.d0**EXPLIM*/
  
 -        d1 = (double)(expo - EXPLIM);
 -        *s *= pow(c10, d1);
 -        d1 = (double) EXPLIM;
 -        *s *= pow(c10, d1);
 +    //    d1 = (double)(expo - EXPLIM);
 +    //    *s *= pow(c10, d1);
 +    //    d1 = (double) EXPLIM;
 +    //    *s *= pow(c10, d1);
  
 -        return 0;
 -    }
 -    /*4-7/ else use langage routines to do the job
 -      the overhead is a retranslation into a string... */
 -    code0 = '0';
 -    i1 = ndgrec;
 -    for (i = 1; i <= i1; ++i)
 -    {
 -        *(unsigned char *)&string[i - 1] = (char) (digit[i - 1] + code0);
 -    }
 -    i1 = ndgrec;
 -    if (expo < 0)
 -    {
 -        sprintf(string + i1, ".e-%d", abs(expo));
 -    }
 -    else
 -    {
 -        sprintf(string + i1, ".e+%d", abs(expo));
 -    }
 -    k = ndgrec + 4;
 -    *s = strtod(string, NULL);
 +    //    return 0;
 +    //}
 +    ///*4-7/ else use langage routines to do the job
 +    //  the overhead is a retranslation into a string... */
 +    //code0 = '0';
 +    //i1 = ndgrec;
 +    //for (i = 1; i <= i1; ++i)
 +    //{
 +    //    *(unsigned char *)&string[i - 1] = (char) (digit[i - 1] + code0);
 +    //}
 +    //i1 = ndgrec;
 +    //if (expo < 0)
 +    //{
 +    //    sprintf(string + i1, ".e-%d", abs(expo));
 +    //}
 +    //else
 +    //{
 +    //    sprintf(string + i1, ".e+%d", abs(expo));
 +    //}
 +    //k = ndgrec + 4;
 +    //*s = strtod(string, NULL);
      return 0;
  }
  
Simple merge
@@@ -160,11 -160,13 +160,14 @@@ function test_run_result = test_run(var
  
        if params.reference <> "list" then
          status.detailled_failures   = [status.detailled_failures; result.detailled_failures];
 -        status.testsuites(size(status.testsuites,"*")+1) = result.testsuite
 +        //status.testsuites(size(status.testsuites,"*")+1) = result.testsuite
-         status.test_count           = status.test_count + result.test_count;
++
+         status.test_skipped_count   = status.test_skipped_count + result.test_skipped_count;
+         // Do not take in account skipped tests
+         status.test_count           = status.test_count + result.test_count - status.test_skipped_count;
          status.test_passed_count    = status.test_passed_count + result.test_passed_count;
          status.test_failed_count    = status.test_failed_count + result.test_failed_count;
-         status.test_skipped_count   = status.test_skipped_count + result.test_skipped_count;
          status.totalTime            = status.totalTime + result.totalTime;
          printf("\n");
        else
        status.test_count   = status.test_count + result.test_count;
        if params.reference <> "list" then
          status.detailled_failures       = [status.detailled_failures; result.detailled_failures];
 -        status.testsuites(size(status.testsuites,"*")+1) = result.testsuite
 +        //status.testsuites(size(status.testsuites,"*")+1) = result.testsuite
+         status.test_skipped_count   = status.test_skipped_count + result.test_skipped_count;
          status.test_passed_count    = status.test_passed_count + result.test_passed_count;
          status.test_failed_count    = status.test_failed_count + result.test_failed_count;
-         status.test_skipped_count   = status.test_skipped_count + result.test_skipped_count;
          status.totalTime            = status.totalTime + result.totalTime;
          printf("\n");
        else
          status.test_count           = status.test_count + result.test_count;
      if params.reference <> "list" then
        status.totalTime            = result.totalTime;
        status.detailled_failures   = [status.detailled_failures; result.detailled_failures];
-       //status.testsuites(size(status.testsuites,"*")+1) = result.testsuite
 -      status.testsuites(size(status.testsuites,"*")+1) = result.testsuite
 +      status.test_count           = status.test_count + result.test_count;
+       status.test_skipped_count   = status.test_skipped_count + result.test_skipped_count;
+       // Do not take in account skipped tests
+       status.test_count           = status.test_count + result.test_count - status.test_skipped_count;
        status.test_passed_count    = status.test_passed_count + result.test_passed_count;
        status.test_failed_count    = status.test_failed_count + result.test_failed_count;
-       status.test_skipped_count   = status.test_skipped_count + result.test_skipped_count;
      else
        status.test_count           = status.test_count + result.test_count;
        status.list                 = [status.list; result.list];
  #
  # This file is distributed under the same license as the Scilab package.
  
 -
  ELEMENTARIES_FUNCTIONS_C_SOURCES = \
-     src/c/sci_tools.c \
-     src/c/finite.c \
-     src/c/vfinite.c \
-     src/c/cmp.c \
-     src/c/vceil.c \
-     src/c/xerhlt.c \
-     src/c/vfloor.c \
-     src/c/vfrexp.c \
-     src/c/scidcopy.c \
-     src/c/int2db.c \
-     src/c/rea2db.c \
-     src/c/qsort.c \
-     src/c/qsort-char.c \
-     src/c/qsort-double.c \
-     src/c/qsort-int.c \
-     src/c/qsort-short.c \
-     src/c/qsort-string.c \
-     src/c/basic_functions.c \
-     src/c/abs.c \
-     src/c/acos.c \
-     src/c/asin.c \
-     src/c/atan.c \
-     src/c/cos.c \
-     src/c/cosh.c \
-     src/c/sin.c \
-     src/c/sinh.c \
-     src/c/tan.c \
-     src/c/exp.c \
-     src/c/expm.c \
-     src/c/log.c \
-     src/c/sqrt.c \
-     src/c/cupro.c \
-     src/c/sign.c \
-     src/c/ceil.c \
-     src/c/eye.c \
-     src/c/dmsum.c \
-     src/c/dsearch.c \
-     src/c/floor.c \
-     src/c/mprod.c \
-     src/c/pythag.c \
-     src/c/matrix_generation.c \
-     src/c/vmul.c \
-     src/c/add_vector.c \
-     src/c/sub_vector.c \
-     src/c/convertbase.c
++src/c/sci_tools.c \
+ src/c/finite.c \
+ src/c/vfinite.c \
+ src/c/cmp.c \
+ src/c/vceil.c \
+ src/c/xerhlt.c \
+ src/c/vfloor.c \
+ src/c/vfrexp.c \
+ src/c/scidcopy.c \
+ src/c/int2db.c \
+ src/c/rea2db.c \
 -src/c/idmax.c \
 -src/c/idmin.c \
 -src/c/gsort.c \
+ src/c/qsort.c \
+ src/c/qsort-char.c \
+ src/c/qsort-double.c \
+ src/c/qsort-int.c \
+ src/c/qsort-short.c \
+ src/c/qsort-string.c \
 -src/c/IsEqualVar.c \
++src/c/basic_functions.c \
++src/c/abs.c \
++src/c/acos.c \
++src/c/asin.c \
++src/c/atan.c \
++src/c/cos.c \
++src/c/cosh.c \
++src/c/sin.c \
++src/c/sinh.c \
++src/c/tan.c \
++src/c/exp.c \
++src/c/expm.c \
++src/c/log.c \
++src/c/sqrt.c \
++src/c/cupro.c \
++src/c/sign.c \
++src/c/ceil.c \
++src/c/eye.c \
++src/c/dmsum.c \
++src/c/dsearch.c \
++src/c/floor.c \
++src/c/mprod.c \
++src/c/pythag.c \
++src/c/matrix_generation.c \
++src/c/vmul.c \
++src/c/add_vector.c \
++src/c/sub_vector.c \
+ src/c/convertbase.c
  
  # List of the cpp files
 -ELEMENTARIES_FUNCTIONS_CXX_SOURCES =
 +ELEMENTARIES_FUNCTIONS_CXX_SOURCES = \
 +    src/cpp/getmode.cpp \
 +    src/cpp/cumsum.cpp \
 +    src/cpp/cumprod.cpp \
 +    src/cpp/diag.cpp \
 +    src/cpp/gsort.cpp \
 +    src/cpp/prod.cpp \
 +    src/cpp/sum.cpp \
 +    src/cpp/max.cpp \
 +    src/cpp/min.cpp
  
 -SLATEC_SOURCES = src/fortran/slatec/zwrsk.f \
 -src/fortran/slatec/d9b0mp.f \
 -src/fortran/slatec/d9b1mp.f \
 -src/fortran/slatec/d9knus.f \
 -src/fortran/slatec/d9lgmc.f \
 -src/fortran/slatec/dasyik.f \
 -src/fortran/slatec/dasyjy.f \
 -src/fortran/slatec/dbdiff.f \
 -src/fortran/slatec/dbesi0.f \
 -src/fortran/slatec/dbesi1.f \
 -src/fortran/slatec/dbesi.f \
 -src/fortran/slatec/dbesj0.f \
 -src/fortran/slatec/dbesj1.f \
 -src/fortran/slatec/dbesj.f \
 -src/fortran/slatec/dbesk0.f \
 -src/fortran/slatec/dbesk1.f \
 -src/fortran/slatec/dbesk.f \
 -src/fortran/slatec/dbesy0.f \
 -src/fortran/slatec/dbesy1.f \
 -src/fortran/slatec/dbesy.f \
 -src/fortran/slatec/dbkias.f \
 -src/fortran/slatec/dbkisr.f \
 -src/fortran/slatec/dbsi0e.f \
 -src/fortran/slatec/dbsi1e.f \
 -src/fortran/slatec/dbsk0e.f \
 -src/fortran/slatec/dbsk1e.f \
 -src/fortran/slatec/dbskes.f \
 -src/fortran/slatec/dbskin.f \
 -src/fortran/slatec/dbsknu.f \
 -src/fortran/slatec/dbsynu.f \
 -src/fortran/slatec/dcsevl.f \
 -src/fortran/slatec/dexint.f \
 -src/fortran/slatec/dgamlm.f \
 -src/fortran/slatec/dgamln.f \
 -src/fortran/slatec/dgamma.f \
 -src/fortran/slatec/dgamrn.f \
 -src/fortran/slatec/dhkseq.f \
 -src/fortran/slatec/djairy.f \
 -src/fortran/slatec/dpsixn.f \
 -src/fortran/slatec/dxlegf.f \
 -src/fortran/slatec/dyairy.f \
 -src/fortran/slatec/fdump.f \
 -src/fortran/slatec/gamma.f \
 -src/fortran/slatec/initds.f \
 -src/fortran/slatec/j4save.f \
 -src/fortran/slatec/xercnt.f \
 -src/fortran/slatec/xermsg.f \
 -src/fortran/slatec/xerprn.f \
 -src/fortran/slatec/xersve.f \
 -src/fortran/slatec/xgetua.f \
 -src/fortran/slatec/zabs.f \
 -src/fortran/slatec/zacai.f \
 -src/fortran/slatec/zacon.f \
 -src/fortran/slatec/zairy.f \
 -src/fortran/slatec/zasyi.f \
 -src/fortran/slatec/zbesh.f \
 -src/fortran/slatec/zbesi.f \
 -src/fortran/slatec/zbesj.f \
 -src/fortran/slatec/zbesk.f \
 -src/fortran/slatec/zbesy.f \
 -src/fortran/slatec/zbinu.f \
 -src/fortran/slatec/zbknu.f \
 -src/fortran/slatec/zbuni.f \
 -src/fortran/slatec/zbunk.f \
 -src/fortran/slatec/zdiv.f \
 -src/fortran/slatec/zexp.f \
 -src/fortran/slatec/zkscl.f \
 -src/fortran/slatec/zlog.f \
 -src/fortran/slatec/zmlri.f \
 -src/fortran/slatec/zmlt.f \
 -src/fortran/slatec/zrati.f \
 -src/fortran/slatec/zs1s2.f \
 -src/fortran/slatec/zseri.f \
 -src/fortran/slatec/zshch.f \
 -src/fortran/slatec/zsqrt.f \
 -src/fortran/slatec/zuchk.f \
 -src/fortran/slatec/zunhj.f \
 -src/fortran/slatec/zuni1.f \
 -src/fortran/slatec/zuni2.f \
 -src/fortran/slatec/zunik.f \
 -src/fortran/slatec/zunk1.f \
 -src/fortran/slatec/zunk2.f \
 -src/fortran/slatec/zuoik.f \
 -src/fortran/slatec/dlngam.f \
 -src/fortran/slatec/balanc.f \
 -src/fortran/slatec/dtensbs.f \
 -src/fortran/slatec/pchim.f
 +SLATEC_SOURCES = \
 +    src/fortran/slatec/zwrsk.f \
 +    src/fortran/slatec/d9b0mp.f \
 +    src/fortran/slatec/d9b1mp.f \
 +    src/fortran/slatec/d9knus.f \
 +    src/fortran/slatec/d9lgmc.f \
 +    src/fortran/slatec/dasyik.f \
 +    src/fortran/slatec/dasyjy.f \
 +    src/fortran/slatec/dbdiff.f \
 +    src/fortran/slatec/dbesi0.f \
 +    src/fortran/slatec/dbesi1.f \
 +    src/fortran/slatec/dbesi.f \
 +    src/fortran/slatec/dbesj0.f \
 +    src/fortran/slatec/dbesj1.f \
 +    src/fortran/slatec/dbesj.f \
 +    src/fortran/slatec/dbesk0.f \
 +    src/fortran/slatec/dbesk1.f \
 +    src/fortran/slatec/dbesk.f \
 +    src/fortran/slatec/dbesy0.f \
 +    src/fortran/slatec/dbesy1.f \
 +    src/fortran/slatec/dbesy.f \
 +    src/fortran/slatec/dbkias.f \
 +    src/fortran/slatec/dbkisr.f \
 +    src/fortran/slatec/dbsi0e.f \
 +    src/fortran/slatec/dbsi1e.f \
 +    src/fortran/slatec/dbsk0e.f \
 +    src/fortran/slatec/dbsk1e.f \
 +    src/fortran/slatec/dbskes.f \
 +    src/fortran/slatec/dbskin.f \
 +    src/fortran/slatec/dbsknu.f \
 +    src/fortran/slatec/dbsynu.f \
 +    src/fortran/slatec/dcsevl.f \
 +    src/fortran/slatec/dexint.f \
 +    src/fortran/slatec/dgamlm.f \
 +    src/fortran/slatec/dgamln.f \
 +    src/fortran/slatec/dgamma.f \
 +    src/fortran/slatec/dgamrn.f \
 +    src/fortran/slatec/dhkseq.f \
 +    src/fortran/slatec/djairy.f \
 +    src/fortran/slatec/dpsixn.f \
 +    src/fortran/slatec/dxlegf.f \
 +    src/fortran/slatec/dyairy.f \
 +    src/fortran/slatec/fdump.f \
 +    src/fortran/slatec/gamma.f \
 +    src/fortran/slatec/initds.f \
 +    src/fortran/slatec/j4save.f \
 +    src/fortran/slatec/xercnt.f \
 +    src/fortran/slatec/xermsg.f \
 +    src/fortran/slatec/xerprn.f \
 +    src/fortran/slatec/xersve.f \
 +    src/fortran/slatec/xgetua.f \
 +    src/fortran/slatec/zabs.f \
 +    src/fortran/slatec/zacai.f \
 +    src/fortran/slatec/zacon.f \
 +    src/fortran/slatec/zairy.f \
 +    src/fortran/slatec/zasyi.f \
 +    src/fortran/slatec/zbesh.f \
 +    src/fortran/slatec/zbesi.f \
 +    src/fortran/slatec/zbesj.f \
 +    src/fortran/slatec/zbesk.f \
 +    src/fortran/slatec/zbesy.f \
 +    src/fortran/slatec/zbinu.f \
 +    src/fortran/slatec/zbknu.f \
 +    src/fortran/slatec/zbuni.f \
 +    src/fortran/slatec/zbunk.f \
 +    src/fortran/slatec/zdiv.f \
 +    src/fortran/slatec/zexp.f \
 +    src/fortran/slatec/zkscl.f \
 +    src/fortran/slatec/zlog.f \
 +    src/fortran/slatec/zmlri.f \
 +    src/fortran/slatec/zmlt.f \
 +    src/fortran/slatec/zrati.f \
 +    src/fortran/slatec/zs1s2.f \
 +    src/fortran/slatec/zseri.f \
 +    src/fortran/slatec/zshch.f \
 +    src/fortran/slatec/zsqrt.f \
 +    src/fortran/slatec/zuchk.f \
 +    src/fortran/slatec/zunhj.f \
 +    src/fortran/slatec/zuni1.f \
 +    src/fortran/slatec/zuni2.f \
 +    src/fortran/slatec/zunik.f \
 +    src/fortran/slatec/zunk1.f \
 +    src/fortran/slatec/zunk2.f \
 +    src/fortran/slatec/zuoik.f \
 +    src/fortran/slatec/dlngam.f \
 +    src/fortran/slatec/balanc.f \
 +    src/fortran/slatec/dtensbs.f \
 +    src/fortran/slatec/pchim.f
  
 -LINPACK_SOURCES =    src/fortran/linpack/dgesl.f \
 +LINPACK_SOURCES = \
 +    src/fortran/linpack/dgesl.f \
        src/fortran/linpack/wpade.f \
        src/fortran/linpack/util.f \
        src/fortran/linpack/dgefa.f \
@@@ -384,10 -369,10 +384,11 @@@ libdummy_elementary_functions_la_SOURCE
  libdummy_elementary_functions_la_CPPFLAGS = -I$(srcdir)/includes/ \
      -I$(top_srcdir)/modules/core/includes/ \
      $(AM_CPPFLAGS)
 -      
 +
  
  # Includes need for the compilation
--libscielementary_functions_la_CPPFLAGS = -I$(srcdir)/includes/ \
++libscielementary_functions_la_CPPFLAGS = \
++    -I$(srcdir)/includes/ \
        -I$(srcdir)/src/cpp/ \
        -I$(srcdir)/src/c/ \
        -I$(top_srcdir)/libs/MALLOC/includes/ \
@@@ -614,53 -571,28 +614,53 @@@ target_alias = @target_alias
  top_build_prefix = @top_build_prefix@
  top_builddir = @top_builddir@
  top_srcdir = @top_srcdir@
 +yacc_present = @yacc_present@
  ELEMENTARIES_FUNCTIONS_C_SOURCES = \
-     src/c/sci_tools.c \
-     src/c/finite.c \
-     src/c/vfinite.c \
-     src/c/cmp.c \
-     src/c/vceil.c \
-     src/c/xerhlt.c \
-     src/c/vfloor.c \
-     src/c/vfrexp.c \
-     src/c/scidcopy.c \
-     src/c/int2db.c \
-     src/c/rea2db.c \
-     src/c/qsort.c \
-     src/c/qsort-char.c \
-     src/c/qsort-double.c \
-     src/c/qsort-int.c \
-     src/c/qsort-short.c \
-     src/c/qsort-string.c \
-     src/c/basic_functions.c \
-     src/c/abs.c \
-     src/c/acos.c \
-     src/c/asin.c \
-     src/c/atan.c \
-     src/c/cos.c \
-     src/c/cosh.c \
-     src/c/sin.c \
-     src/c/sinh.c \
-     src/c/tan.c \
-     src/c/exp.c \
-     src/c/expm.c \
-     src/c/log.c \
-     src/c/sqrt.c \
-     src/c/cupro.c \
-     src/c/sign.c \
-     src/c/ceil.c \
-     src/c/eye.c \
-     src/c/dmsum.c \
-     src/c/dsearch.c \
-     src/c/floor.c \
-     src/c/mprod.c \
-     src/c/pythag.c \
-     src/c/matrix_generation.c \
-     src/c/vmul.c \
-     src/c/add_vector.c \
-     src/c/sub_vector.c \
-     src/c/convertbase.c
++src/c/sci_tools.c \
+ src/c/finite.c \
+ src/c/vfinite.c \
+ src/c/cmp.c \
+ src/c/vceil.c \
+ src/c/xerhlt.c \
+ src/c/vfloor.c \
+ src/c/vfrexp.c \
+ src/c/scidcopy.c \
+ src/c/int2db.c \
+ src/c/rea2db.c \
 -src/c/idmax.c \
 -src/c/idmin.c \
 -src/c/gsort.c \
+ src/c/qsort.c \
+ src/c/qsort-char.c \
+ src/c/qsort-double.c \
+ src/c/qsort-int.c \
+ src/c/qsort-short.c \
+ src/c/qsort-string.c \
 -src/c/IsEqualVar.c \
++src/c/basic_functions.c \
++src/c/abs.c \
++src/c/acos.c \
++src/c/asin.c \
++src/c/atan.c \
++src/c/cos.c \
++src/c/cosh.c \
++src/c/sin.c \
++src/c/sinh.c \
++src/c/tan.c \
++src/c/exp.c \
++src/c/expm.c \
++src/c/log.c \
++src/c/sqrt.c \
++src/c/cupro.c \
++src/c/sign.c \
++src/c/ceil.c \
++src/c/eye.c \
++src/c/dmsum.c \
++src/c/dsearch.c \
++src/c/floor.c \
++src/c/mprod.c \
++src/c/pythag.c \
++src/c/matrix_generation.c \
++src/c/vmul.c \
++src/c/add_vector.c \
++src/c/sub_vector.c \
+ src/c/convertbase.c
  
  
  # List of the cpp files
@@@ -1000,7 -939,7 +1000,8 @@@ libdummy_elementary_functions_la_CPPFLA
  
  
  # Includes need for the compilation
--libscielementary_functions_la_CPPFLAGS = -I$(srcdir)/includes/ \
++libscielementary_functions_la_CPPFLAGS = \
++    -I$(srcdir)/includes/ \
        -I$(srcdir)/src/cpp/ \
        -I$(srcdir)/src/c/ \
        -I$(top_srcdir)/libs/MALLOC/includes/ \
index 6893880,0000000..d6a391f
mode 100644,000000..100644
--- /dev/null
@@@ -1,43 -1,0 +1,43 @@@
 +/*
 + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 + * Copyright (C) 1997 - INRIA
 + * Copyright (C) 2010 - DIGITEO - Allan CORNET
 + * 
 + * 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-en.txt
 + *
 + */
 +
 +#ifndef __SCI_TOOLS_H__
 +#define __SCI_TOOLS_H__
 +
 +#include "machine.h"
 +#include "dynlib_elementary_functions.h"
 +
 +#define DATA_TYPE_SCALAR     1
 +
 +#define TYPE_DOUBLE  0
 +#define TYPE_COMPLEX 1
 +
 +/* valid for Real or Complex matrix */
 +#define TYPE(ptr)   (((int*) (ptr))[-1])
 +#define NB_COL(ptr) (((int*) (ptr))[-2])
 +#define NB_ROW(ptr) (((int*) (ptr))[-3])
 +#define DATA_TYPE(ptr) (((int*) (ptr))[-4])
 +
 +#define SET_DATA_TYPE_SCALAR(ptr)  (((int*) (ptr))[-4] = DATA_TYPE_SCALAR)
 +#define SET_TYPE_DOUBLE(ptr)  (((int*) (ptr))[-1] = TYPE_DOUBLE)
 +#define SET_TYPE_COMPLEX(ptr) (((int*) (ptr))[-1] = TYPE_COMPLEX)
 +#define SET_NB_COL(ptr,m) (((int*) (ptr))[-2] = (m))
 +#define SET_NB_ROW(ptr,n) (((int*) (ptr))[-3] = (n))
 +
- ELEMENTARY_FUNCTIONS_IMPEXP void (SciToF77)(double *ptr, int size, int lda);
- ELEMENTARY_FUNCTIONS_IMPEXP void (F77ToSci)(double *ptr, int size, int lda);
++ELEMENTARY_FUNCTIONS_IMPEXP void SciToF77(double *ptr, int size, int lda);
++ELEMENTARY_FUNCTIONS_IMPEXP void F77ToSci(double *ptr, int size, int lda);
 +
 +ELEMENTARY_FUNCTIONS_IMPEXP void double2z(double *ptr, double *ptr77z, int size, int lda);
 +ELEMENTARY_FUNCTIONS_IMPEXP void z2double(double *ptrz, double *ptrsci, int size, int lda);
 +
 +#endif /* __SCI_TOOLS_H__ */
@@@ -202,36 -190,13 +202,38 @@@ lib /DEF:"$(ProjectDir)cacsd_f_Import.d
      </Link>
    </ItemDefinitionGroup>
    <ItemGroup>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_base2dec.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_dec2base.c" />
++    <ClCompile Include="..\..\sci_gateway\c\sci_chinesehat.c" />
++    <ClCompile Include="..\..\sci_gateway\c\sci_spones.c" />
 +    <ClCompile Include="..\cpp\cumprod.cpp" />
 +    <ClCompile Include="..\cpp\cumsum.cpp" />
 +    <ClCompile Include="..\cpp\diag.cpp" />
 +    <ClCompile Include="..\cpp\getmode.cpp" />
 +    <ClCompile Include="..\cpp\gsort.cpp" />
 +    <ClCompile Include="..\cpp\max.cpp" />
 +    <ClCompile Include="..\cpp\min.cpp" />
 +    <ClCompile Include="..\cpp\prod.cpp" />
 +    <ClCompile Include="..\cpp\sum.cpp" />
 +    <ClCompile Include="abs.c" />
 +    <ClCompile Include="acos.c" />
 +    <ClCompile Include="add_vector.c" />
 +    <ClCompile Include="asin.c" />
 +    <ClCompile Include="atan.c" />
 +    <ClCompile Include="basic_functions.c" />
 +    <ClCompile Include="ceil.c" />
      <ClCompile Include="cmp.c" />
      <ClCompile Include="convertbase.c" />
 +    <ClCompile Include="cos.c" />
 +    <ClCompile Include="cosh.c" />
 +    <ClCompile Include="cupro.c" />
      <ClCompile Include="DllmainElementary_functions.c" />
 +    <ClCompile Include="dmsum.c" />
 +    <ClCompile Include="dsearch.c" />
 +    <ClCompile Include="exp.c" />
 +    <ClCompile Include="expm.c" />
 +    <ClCompile Include="eye.c" />
 +    <ClCompile Include="f2c_workaround.c" />
      <ClCompile Include="finite.c" />
 -    <ClCompile Include="gsort.c" />
 +    <ClCompile Include="floor.c" />
      <ClCompile Include="..\..\sci_gateway\c\gw_elementary_functions.c" />
      <ClCompile Include="idmax.c" />
      <ClCompile Include="idmin.c" />
      <ClCompile Include="qsort-string.c" />
      <ClCompile Include="qsort.c" />
      <ClCompile Include="rea2db.c" />
-     <ClCompile Include="..\..\sci_gateway\c\sci_chinesehat.c" />
-     <ClCompile Include="..\..\sci_gateway\c\sci_spones.c" />
-     <ClCompile Include="sci_tools.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_abs.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_acos.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_asin.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_atan.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_ceil.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_chinesehat.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_clean.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_conj.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_cos.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_cumprod.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_cumsum.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_diag.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_dsearch.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_exp.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_expm.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_eye.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_floor.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_frexp.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_gsort.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_imag.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_imult.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_int.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_isequal.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_isequalbitwise.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_isreal.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_kron.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_log.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_log1p.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_matrix.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_maxi.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_nearfloat.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_number_properties.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_ones.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_prod.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_rand.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_rat.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_real.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_round.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_sign.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_sin.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_size.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_spones.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_sqrt.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_sum.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_tan.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_testmatrix.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_tril.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_triu.c" />
 -    <ClCompile Include="..\..\sci_gateway\c\sci_zeros.c" />
      <ClCompile Include="scidcopy.c" />
++    <ClCompile Include="sci_tools.c" />
 +    <ClCompile Include="sign.c" />
 +    <ClCompile Include="sin.c" />
 +    <ClCompile Include="sinh.c" />
 +    <ClCompile Include="sqrt.c" />
 +    <ClCompile Include="sub_vector.c" />
 +    <ClCompile Include="tan.c" />
      <ClCompile Include="unsfdcopy.c">
        <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Disabled</Optimization>
        <FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Size</FavorSizeOrSpeed>
      <ClInclude Include="..\..\includes\idmax.h" />
      <ClInclude Include="..\..\includes\idmin.h" />
      <ClInclude Include="..\..\includes\int2db.h" />
 +    <ClInclude Include="..\..\includes\log.h" />
 +    <ClInclude Include="..\..\includes\pythag.h" />
      <ClInclude Include="..\..\includes\rea2b.h" />
      <ClInclude Include="..\..\includes\rea2db.h" />
-     <ClInclude Include="..\..\includes\sci_tools.h" />
      <ClInclude Include="..\..\includes\scidcopy.h" />
++    <ClInclude Include="..\..\includes\sci_tools.h" />
 +    <ClInclude Include="..\..\includes\sign.h" />
 +    <ClInclude Include="..\..\includes\sin.h" />
 +    <ClInclude Include="..\..\includes\sqrt.h" />
 +    <ClInclude Include="..\..\includes\tan.h" />
      <ClInclude Include="..\..\includes\unsfdcopy.h" />
      <ClInclude Include="..\..\includes\vfinite.h" />
      <ClInclude Include="..\..\includes\xerhlt.h" />
      </Filter>
    </ItemGroup>
    <ItemGroup>
 -    <ClCompile Include="cmp.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="DllmainElementary_functions.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="finite.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="gsort.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\gw_elementary_functions.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="idmax.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="idmin.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="int2db.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="IsEqualVar.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="qsort-char.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="qsort-double.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="qsort-int.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="qsort-short.c">
 +    <ClCompile Include="add_vector.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="qsort-string.c">
 -      <Filter>Source Files</Filter>
 -    </ClCompile>
 -    <ClCompile Include="qsort.c">
 +    <ClCompile Include="basic_functions.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="rea2db.c">
 +    <ClCompile Include="ceil.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_abs.c">
 +    <ClCompile Include="cmp.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_acos.c">
 +    <ClCompile Include="cupro.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_asin.c">
 +    <ClCompile Include="DllmainElementary_functions.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_atan.c">
 +    <ClCompile Include="dmsum.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_ceil.c">
 +    <ClCompile Include="dsearch.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_chinesehat.c">
 +    <ClCompile Include="eye.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_clean.c">
 +    <ClCompile Include="finite.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_conj.c">
 +    <ClCompile Include="floor.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_cos.c">
 +    <ClCompile Include="..\..\sci_gateway\c\gw_elementary_functions.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_cumprod.c">
 +    <ClCompile Include="idmax.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_cumsum.c">
 +    <ClCompile Include="idmin.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_diag.c">
 +    <ClCompile Include="int2db.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_dsearch.c">
 +    <ClCompile Include="matrix_generation.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_exp.c">
 +    <ClCompile Include="mprod.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_expm.c">
 +    <ClCompile Include="qsort-char.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_eye.c">
 +    <ClCompile Include="qsort-double.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_floor.c">
 +    <ClCompile Include="qsort-int.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_frexp.c">
 +    <ClCompile Include="qsort-short.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_gsort.c">
 +    <ClCompile Include="qsort-string.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_imag.c">
 +    <ClCompile Include="qsort.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_imult.c">
 +    <ClCompile Include="rea2db.c">
        <Filter>Source Files</Filter>
      </ClCompile>
-     <ClCompile Include="..\..\sci_gateway\c\sci_chinesehat.c">
-       <Filter>Source Files</Filter>
-     </ClCompile>
-     <ClCompile Include="..\..\sci_gateway\c\sci_spones.c">
-       <Filter>Source Files</Filter>
-     </ClCompile>
-     <ClCompile Include="sci_tools.c">
-       <Filter>Source Files</Filter>
-     </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_int.c">
 +    <ClCompile Include="scidcopy.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_isequal.c">
 +    <ClCompile Include="sub_vector.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_isequalbitwise.c">
 +    <ClCompile Include="unsfdcopy.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_isreal.c">
 +    <ClCompile Include="vceil.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_kron.c">
 +    <ClCompile Include="vfinite.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_log.c">
 +    <ClCompile Include="vfloor.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_log1p.c">
 +    <ClCompile Include="vfrexp.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_matrix.c">
 +    <ClCompile Include="vmul.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_maxi.c">
 +    <ClCompile Include="xerhlt.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_nearfloat.c">
 +    <ClCompile Include="abs.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_number_properties.c">
 +    <ClCompile Include="acos.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_ones.c">
 +    <ClCompile Include="asin.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_prod.c">
 +    <ClCompile Include="atan.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_rand.c">
 +    <ClCompile Include="convertbase.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_rat.c">
 +    <ClCompile Include="cos.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_real.c">
 +    <ClCompile Include="cosh.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_round.c">
 +    <ClCompile Include="exp.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_sign.c">
 +    <ClCompile Include="expm.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_sin.c">
 +    <ClCompile Include="f2c_workaround.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_size.c">
 +    <ClCompile Include="log.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_spones.c">
 +    <ClCompile Include="pythag.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_sqrt.c">
 +    <ClCompile Include="sign.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_sum.c">
 +    <ClCompile Include="sin.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_tan.c">
 +    <ClCompile Include="sinh.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_testmatrix.c">
 +    <ClCompile Include="sqrt.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_tril.c">
 +    <ClCompile Include="tan.c">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_triu.c">
 +    <ClCompile Include="..\cpp\cumprod.cpp">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_zeros.c">
 +    <ClCompile Include="..\cpp\cumsum.cpp">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="scidcopy.c">
 +    <ClCompile Include="..\cpp\diag.cpp">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="unsfdcopy.c">
 +    <ClCompile Include="..\cpp\getmode.cpp">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="vceil.c">
 +    <ClCompile Include="..\cpp\gsort.cpp">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="vfinite.c">
 +    <ClCompile Include="..\cpp\max.cpp">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="vfloor.c">
 +    <ClCompile Include="..\cpp\min.cpp">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="vfrexp.c">
 +    <ClCompile Include="..\cpp\sum.cpp">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="xerhlt.c">
 +    <ClCompile Include="..\cpp\prod.cpp">
        <Filter>Source Files</Filter>
      </ClCompile>
 -    <ClCompile Include="convertbase.c">
++    <ClCompile Include="..\..\sci_gateway\c\sci_chinesehat.c">
+       <Filter>Source Files</Filter>
+     </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_base2dec.c">
++    <ClCompile Include="..\..\sci_gateway\c\sci_spones.c">
+       <Filter>Source Files</Filter>
+     </ClCompile>
 -    <ClCompile Include="..\..\sci_gateway\c\sci_dec2base.c">
++    <ClCompile Include="sci_tools.c">
+       <Filter>Source Files</Filter>
+     </ClCompile>
    </ItemGroup>
    <ItemGroup>
      <ClInclude Include="..\..\includes\dynlib_elementary_functions.h">
      <ClInclude Include="vfrexp.h">
        <Filter>Header Files</Filter>
      </ClInclude>
 +    <ClInclude Include="convertbase.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\..\includes\abs.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\..\includes\cos.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\..\includes\elem_common.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\..\includes\exp.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\..\includes\log.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\..\includes\pythag.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\..\includes\sign.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\..\includes\sin.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\..\includes\sqrt.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\..\includes\tan.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\..\includes\getmode.hxx">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\cpp\cumprod.hxx">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\cpp\cumsum.hxx">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\cpp\diag.hxx">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\cpp\gsort.hxx">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\cpp\max.hxx">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\cpp\min.hxx">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="expm.h">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\cpp\sum.hxx">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="..\cpp\prod.hxx">
 +      <Filter>Header Files</Filter>
 +    </ClInclude>
++    <ClInclude Include="..\..\includes\sci_tools.h">
++      <Filter>Header Files</Filter>
++    </ClInclude>
    </ItemGroup>
    <ItemGroup>
      <None Include="elementary_functions_f_Import.def">
@@@ -1,27 -1,14 +1,22 @@@
 +
  // =============================================================================
 +
  // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 +
  // Copyright (C) 2009 - DIGITEO - Allan CORNET
 +
  //
 +
  //  This file is distributed under the same license as the Scilab package.
 +
  // =============================================================================
- // <-- JVM NOT MANDATORY -->
- w=1;
+ // <-- CLI SHELL MODE -->
  //ouvrir le fichier 
  FLN = 'SCI/modules/fileio/tests/unit_tests/text.txt';
 -fd = mopen(FLN,'rt'); 
 +
 +fd = mopen(FLN,'rt');
  i = 0;
 +
  while ~meof(fd) do
     mfscanf(1, fd, "%c");
     i = i + 1;
@@@ -20,7 -20,8 +20,9 @@@
  ;
  Source: bin\{#FUNCTIONS}.dll; DestDir: {app}\bin; Components: {#COMPN_SCILAB}
  Source: bin\{#FUNCTIONS}_f.dll; DestDir: {app}\bin; Components: {#COMPN_SCILAB}
 +Source: bin\{#FUNCTIONS}_gw.dll; DestDir: {app}\bin; Components: {#COMPN_SCILAB}
+ Source: bin\{#FUNCTIONS}.lib; DestDir: {app}\bin; Components: {#COMPN_SCILAB}
+ Source: bin\{#FUNCTIONS}_f.lib; DestDir: {app}\bin; Components: {#COMPN_SCILAB}
  ;
  Source: modules\{#FUNCTIONS}\license.txt; DestDir: {app}\modules\{#FUNCTIONS}; Components: {#COMPN_SCILAB}
  ;
@@@ -20,7 -20,8 +20,9 @@@
  ;
  Source: bin\{#IO}.dll; DestDir: {app}\bin; Components: {#COMPN_SCILAB}
  Source: bin\{#IO}_f.dll; DestDir: {app}\bin; Components: {#COMPN_SCILAB}
 +Source: bin\{#IO}_gw.dll; DestDir: {app}\bin; Components: {#COMPN_SCILAB}
+ Source: bin\{#IO}.lib; DestDir: {app}\bin; Components: {#COMPN_SCILAB}
+ Source: bin\{#IO}_f.lib; DestDir: {app}\bin; Components: {#COMPN_SCILAB}
  ;
  Source: modules\{#IO}\license.txt; DestDir: {app}\modules\{#IO}; Components: {#COMPN_SCILAB}
  ;
Simple merge
@@@ -171,10 -169,10 +171,10 @@@ am__libsciscicos_algo_la_SOURCES_DIST 
        src/c/il_state.c src/c/il_sim.c src/c/createblklist.c \
        src/c/var2sci.c src/c/copyvarfromlistentry.c \
        src/c/MlistGetFieldNumber.c src/c/extractblklist.c \
-       src/fortran/scitovv.f src/fortran/vvtosci.f \
 -      src/c/lsodar.c src/fortran/scitovv.f \
 -      src/fortran/vvtosci.f src/fortran/skipvars.f \
 -      src/fortran/coselm.f src/fortran/scitod.f src/fortran/sctree.f \
 -      src/fortran/scierr.f src/fortran/ftree2.f src/fortran/ftree3.f \
++      src/c/lsodar.c src/fortran/scitovv.f src/fortran/vvtosci.f \
 +      src/fortran/skipvars.f src/fortran/coselm.f \
 +      src/fortran/scitod.f src/fortran/sctree.f src/fortran/scierr.f \
 +      src/fortran/ftree2.f src/fortran/ftree3.f \
        src/fortran/list2vars.f src/fortran/ftree4.f \
        src/fortran/scitoi.f src/fortran/scifunc.f
  @XCOS_TRUE@am__objects_1 = libsciscicos_algo_la-tree.lo \
@@@ -1235,6 -1220,6 +1237,7 @@@ distclean-compile
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciscicos_algo_la-il_sim.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciscicos_algo_la-il_state.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciscicos_algo_la-import.Plo@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciscicos_algo_la-lsodar.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciscicos_algo_la-sciblk2.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciscicos_algo_la-sciblk4.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsciscicos_algo_la-scicos.Plo@am__quote@
@@@ -1433,10 -1418,17 +1436,17 @@@ libsciscicos_algo_la-extractblklist.lo
  @am__fastdepCC_TRUE@  $(am__mv) $(DEPDIR)/libsciscicos_algo_la-extractblklist.Tpo $(DEPDIR)/libsciscicos_algo_la-extractblklist.Plo
  @AMDEP_TRUE@@am__fastdepCC_FALSE@     source='src/c/extractblklist.c' object='libsciscicos_algo_la-extractblklist.lo' libtool=yes @AMDEPBACKSLASH@
  @AMDEP_TRUE@@am__fastdepCC_FALSE@     DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 -@am__fastdepCC_FALSE@ $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsciscicos_algo_la-extractblklist.lo `test -f 'src/c/extractblklist.c' || echo '$(srcdir)/'`src/c/extractblklist.c
 +@am__fastdepCC_FALSE@ $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsciscicos_algo_la_CFLAGS) $(CFLAGS) -c -o libsciscicos_algo_la-extractblklist.lo `test -f 'src/c/extractblklist.c' || echo '$(srcdir)/'`src/c/extractblklist.c
  
+ libsciscicos_algo_la-lsodar.lo: src/c/lsodar.c
 -@am__fastdepCC_TRUE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsciscicos_algo_la-lsodar.lo -MD -MP -MF $(DEPDIR)/libsciscicos_algo_la-lsodar.Tpo -c -o libsciscicos_algo_la-lsodar.lo `test -f 'src/c/lsodar.c' || echo '$(srcdir)/'`src/c/lsodar.c
++@am__fastdepCC_TRUE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsciscicos_algo_la_CFLAGS) $(CFLAGS) -MT libsciscicos_algo_la-lsodar.lo -MD -MP -MF $(DEPDIR)/libsciscicos_algo_la-lsodar.Tpo -c -o libsciscicos_algo_la-lsodar.lo `test -f 'src/c/lsodar.c' || echo '$(srcdir)/'`src/c/lsodar.c
+ @am__fastdepCC_TRUE@  $(am__mv) $(DEPDIR)/libsciscicos_algo_la-lsodar.Tpo $(DEPDIR)/libsciscicos_algo_la-lsodar.Plo
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@     source='src/c/lsodar.c' object='libsciscicos_algo_la-lsodar.lo' libtool=yes @AMDEPBACKSLASH@
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@     DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 -@am__fastdepCC_FALSE@ $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libsciscicos_algo_la-lsodar.lo `test -f 'src/c/lsodar.c' || echo '$(srcdir)/'`src/c/lsodar.c
++@am__fastdepCC_FALSE@ $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsciscicos_algo_la_CFLAGS) $(CFLAGS) -c -o libsciscicos_algo_la-lsodar.lo `test -f 'src/c/lsodar.c' || echo '$(srcdir)/'`src/c/lsodar.c
  libsciscicos_la-noscicos.lo: src/c/noscicos/noscicos.c
 -@am__fastdepCC_TRUE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libsciscicos_la-noscicos.lo -MD -MP -MF $(DEPDIR)/libsciscicos_la-noscicos.Tpo -c -o libsciscicos_la-noscicos.lo `test -f 'src/c/noscicos/noscicos.c' || echo '$(srcdir)/'`src/c/noscicos/noscicos.c
 +@am__fastdepCC_TRUE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libsciscicos_la_CFLAGS) $(CFLAGS) -MT libsciscicos_la-noscicos.lo -MD -MP -MF $(DEPDIR)/libsciscicos_la-noscicos.Tpo -c -o libsciscicos_la-noscicos.lo `test -f 'src/c/noscicos/noscicos.c' || echo '$(srcdir)/'`src/c/noscicos/noscicos.c
  @am__fastdepCC_TRUE@  $(am__mv) $(DEPDIR)/libsciscicos_la-noscicos.Tpo $(DEPDIR)/libsciscicos_la-noscicos.Plo
  @AMDEP_TRUE@@am__fastdepCC_FALSE@     source='src/c/noscicos/noscicos.c' object='libsciscicos_la-noscicos.lo' libtool=yes @AMDEPBACKSLASH@
  @AMDEP_TRUE@@am__fastdepCC_FALSE@     DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
  #include "dynlib_xcos.h"
  /*--------------------------------------------------------------------------*/
  XCOS_IMPEXP int gw_xcos(void);
 -
  /*--------------------------------------------------------------------------*/
 -int sci_Xcos(char *fname, unsigned long l);
 -int sci_xcosNotify(char *fname, unsigned long l);
 -int sci_warnBlockByUID(char *fname, unsigned long l);
 -int sci_closeXcosFromScilab(char *fname, unsigned long l);
 -int sci_xcosDiagramToScilab(char *fname, unsigned long l);
 -int sci_xcosDiagramOpen(char *fname, unsigned long l);
 -int sci_xcosDiagramClose(char *fname, unsigned long l);
 -int sci_xcosPalLoad(char *fname, unsigned long l);
 -int sci_xcosPalCategoryAdd(char *fname, unsigned long l);
 -int sci_xcosPalDelete(char *fname, unsigned long l);
 -int sci_xcosPalMove(char *fname, unsigned long l);
 -int sci_xcosPalEnable(char *fname, unsigned long l);
 -int sci_xcosPalDisable(char *fname, unsigned long l);
 -int sci_xcosPalGenerateIcon(char *fname, unsigned long l);
 -int sci_xcosConfigureXmlFile(char *fname, unsigned long l);
 -int sci_xcosAddToolsMenu(char *fname, unsigned long l);
 -int sci_xcosUpdateBlock(char *fname, unsigned long l);
 -int sci_loadXcos(char *fname, unsigned long l);
 -int sci_xcosSimulationStarted(char *fname, unsigned long l);
 -int sci_xcosPalGenerateAllIcons(char *fname, unsigned long l);
 +XCOS_IMPEXP int sci_Xcos(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosNotify(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_warnBlockByUID(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_closeXcosFromScilab(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosDiagramToScilab(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosDiagramOpen(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosDiagramClose(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosPalLoad(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosPalCategoryAdd(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosPalDelete(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosPalMove(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosPalEnable(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosPalDisable(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosPalGenerateIcon(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosConfigureXmlFile(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosAddToolsMenu(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosUpdateBlock(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_loadXcos(char *fname, void *pvApiCtx);
 +XCOS_IMPEXP int sci_xcosSimulationStarted(char *fname, void *pvApiCtx);
++XCOS_IMPEXP int sci_xcosPalGenerateAllIcons(char *fname, void *pvApiCtx);
  
  /*--------------------------------------------------------------------------*/
  /**
   *
   */
  /*--------------------------------------------------------------------------*/
 +#include <string.h>
  #include "gw_xcos.h"
 -#include "api_scilab.h"
 -#include "MALLOC.h"
  #include "callFunctionFromGateway.h"
  #include "BOOL.h"
 -#include "scilabmode.h"
 -#include "localization.h"
 -#include "Scierror.h"
 -#include "BOOL.h"
 -#include "loadOnUseClassPath.h"
  /*--------------------------------------------------------------------------*/
  static BOOL loadedDep = FALSE;
--
--/*--------------------------------------------------------------------------*/
--static gw_generic_table Tab[] =
--{
-     {sci_Xcos, ""}, //xcos"},
-     {sci_warnBlockByUID, ""}, //warnBlockByUID"},
-     {sci_closeXcosFromScilab, ""}, //closeXcos"},
-     {sci_xcosDiagramToScilab, ""}, //xcosDiagramToScilab"},
-     {sci_xcosPalLoad, ""}, //xcosPalLoad"},
-     {sci_xcosPalCategoryAdd, ""}, //xcosPalCategoryAdd"},
-     {sci_xcosPalDelete, ""}, //xcosPalDelete"},
-     {sci_xcosPalMove, ""}, //xcosPalMove"},
-     {sci_xcosPalEnable, ""}, //xcosPalEnable"},
-     {sci_xcosPalDisable, ""}, //xcosPalDisable"},
-     {sci_xcosPalGenerateIcon, ""}, //xcosPalGenerateIcon"},
-     {sci_xcosConfigureXmlFile, ""}, //xcosConfigureXmlFile"},
-     {sci_xcosAddToolsMenu, ""}, //xcosAddToolsMenu"},
-     {sci_xcosUpdateBlock, ""}, //xcosUpdateBlock"},
-     {sci_loadXcos, ""}, //loadXcos"}
-     {sci_xcosSimulationStarted, ""} //xcosSimulationStarted"}
- };
- /*--------------------------------------------------------------------------*/
- int gw_xcos(void)
- {
-     return 0;
- }
 -    {sci_Xcos, "xcos"},
 -    {sci_warnBlockByUID, "warnBlockByUID"},
 -    {sci_closeXcosFromScilab, "closeXcos"},
 -    {sci_xcosDiagramToScilab, "xcosDiagramToScilab"},
 -    {sci_xcosPalLoad, "xcosPalLoad"},
 -    {sci_xcosPalCategoryAdd, "xcosPalCategoryAdd"},
 -    {sci_xcosPalDelete, "xcosPalDelete"},
 -    {sci_xcosPalMove, "xcosPalMove"},
 -    {sci_xcosPalEnable, "xcosPalEnable"},
 -    {sci_xcosPalDisable, "xcosPalDisable"},
 -    {sci_xcosPalGenerateIcon, "xcosPalGenerateIcon"},
 -    {sci_xcosConfigureXmlFile, "xcosConfigureXmlFile"},
 -    {sci_xcosAddToolsMenu, "xcosAddToolsMenu"},
 -    {sci_xcosUpdateBlock, "xcosUpdateBlock"},
 -    {sci_loadXcos, "loadXcos"},
 -    {sci_xcosSimulationStarted, "xcosSimulationStarted"},
 -    {sci_xcosPalGenerateAllIcons, "xcosPalGenerateAllIcons"}
 -};
 -
 -/*--------------------------------------------------------------------------*/
 -int gw_xcos(void)
 -{
 -    Rhs = Max(0, Rhs);
 -
 -    if (getScilabMode() == SCILAB_NWNI)
 -    {
 -        Scierror(999, _("Scilab '%s' module disabled in -nogui or -nwni mode.\n"), "xcos");
 -        return 0;
 -    }
 -
 -    if (!loadedDep              // never reload
 -            && Tab[Fin - 1].f != sci_closeXcosFromScilab)   // do not load on close
 -    {
 -        loadOnUseClassPath("Xcos");
 -        loadedDep = TRUE;
 -    }
 -
 -
 -    if (pvApiCtx == NULL)
 -    {
 -        pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
 -    }
 -
 -    pvApiCtx->pstName = (char*)Tab[Fin - 1].name;
 -    callFunctionFromGateway(Tab, SIZE_CURRENT_GENERIC_TABLE(Tab));
 -    return 0;
 -}
 -
  /*--------------------------------------------------------------------------*/
  int xcosStarted(void)
  {
      return loadedDep;
  }
--
  /*--------------------------------------------------------------------------*/
index 0000000,4762a80..5e11aee
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,65 +1,65 @@@
+ /*
+  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+  * Copyright (C) DIGITEO - 2010-2010 - ClĂ©ment DAVID <clement.david@scilab.org>
+  *
+  * 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-en.txt
+  *
+  */
+ #include "Palette.hxx"
+ #include "GiwsException.hxx"
+ #include "xcosUtilities.hxx"
+ extern "C"
+ {
+ #include "gw_xcos.h"
+ #include "api_scilab.h"
+ #include "localization.h"
+ #include "Scierror.h"
+ #include "freeArrayOfString.h"
+ #include "MALLOC.h"
+ #include "getScilabJavaVM.h"
+ }
+ using namespace org_scilab_modules_xcos_palette;
 -int sci_xcosPalGenerateAllIcons(char *fname, unsigned long fname_len)
++int sci_xcosPalGenerateAllIcons(char *fname, void* pvApiCtx)
+ {
+     CheckInputArgument(pvApiCtx, 1, 1);
+     CheckOutputArgument(pvApiCtx, 0, 1);
+     char **path = NULL;
+     int pathLength = 0;
+     /* path setup */
+     if (readVectorString(pvApiCtx, 1, &path, &pathLength, fname))
+     {
+         return 0;
+     }
+     /* Call the java implementation */
+     try
+     {
+         Palette::generateAllImages(getScilabJavaVM(), path, pathLength);
+     }
+     catch (GiwsException::JniCallMethodException &exception)
+     {
+         Scierror(999, "%s: %s\n", fname, exception.getJavaDescription().c_str());
+     }
+     catch (GiwsException::JniException &exception)
+     {
+         Scierror(999, "%s: %s\n", fname, exception.whatStr().c_str());
+     }
+     freeArrayOfString(path, pathLength);
+     AssignOutputVariable(pvApiCtx, 1) = 0;
+     ReturnArguments(pvApiCtx);
+     return 0;
+ }