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/sub_vector.c
# List of the cpp files
ELEMENTARIES_FUNCTIONS_CXX_SOURCES = \
src/c/libscielementary_functions_algo_la-matrix_generation.lo \
src/c/libscielementary_functions_algo_la-vmul.lo \
src/c/libscielementary_functions_algo_la-add_vector.lo \
- src/c/libscielementary_functions_algo_la-sub_vector.lo \
- src/c/libscielementary_functions_algo_la-convertbase.lo
+ src/c/libscielementary_functions_algo_la-sub_vector.lo
am__objects_5 = src/fortran/wasum.lo src/fortran/dexpm1.lo \
src/fortran/wwdiv.lo src/fortran/wdotcr.lo src/fortran/iset.lo \
src/fortran/franck.lo src/fortran/dwpowe.lo \
src/c/$(DEPDIR)/libscielementary_functions_algo_la-basic_functions.Plo \
src/c/$(DEPDIR)/libscielementary_functions_algo_la-ceil.Plo \
src/c/$(DEPDIR)/libscielementary_functions_algo_la-cmp.Plo \
- src/c/$(DEPDIR)/libscielementary_functions_algo_la-convertbase.Plo \
src/c/$(DEPDIR)/libscielementary_functions_algo_la-cos.Plo \
src/c/$(DEPDIR)/libscielementary_functions_algo_la-cosh.Plo \
src/c/$(DEPDIR)/libscielementary_functions_algo_la-cupro.Plo \
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/sub_vector.c
# List of the cpp files
src/c/$(am__dirstamp) src/c/$(DEPDIR)/$(am__dirstamp)
src/c/libscielementary_functions_algo_la-sub_vector.lo: \
src/c/$(am__dirstamp) src/c/$(DEPDIR)/$(am__dirstamp)
-src/c/libscielementary_functions_algo_la-convertbase.lo: \
- src/c/$(am__dirstamp) src/c/$(DEPDIR)/$(am__dirstamp)
src/fortran/wasum.lo: src/fortran/$(am__dirstamp) \
src/fortran/$(DEPDIR)/$(am__dirstamp)
src/fortran/dexpm1.lo: src/fortran/$(am__dirstamp) \
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscielementary_functions_algo_la-basic_functions.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscielementary_functions_algo_la-ceil.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscielementary_functions_algo_la-cmp.Plo@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscielementary_functions_algo_la-convertbase.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscielementary_functions_algo_la-cos.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscielementary_functions_algo_la-cosh.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libscielementary_functions_algo_la-cupro.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscielementary_functions_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libscielementary_functions_algo_la-sub_vector.lo `test -f 'src/c/sub_vector.c' || echo '$(srcdir)/'`src/c/sub_vector.c
-src/c/libscielementary_functions_algo_la-convertbase.lo: src/c/convertbase.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscielementary_functions_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/libscielementary_functions_algo_la-convertbase.lo -MD -MP -MF src/c/$(DEPDIR)/libscielementary_functions_algo_la-convertbase.Tpo -c -o src/c/libscielementary_functions_algo_la-convertbase.lo `test -f 'src/c/convertbase.c' || echo '$(srcdir)/'`src/c/convertbase.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libscielementary_functions_algo_la-convertbase.Tpo src/c/$(DEPDIR)/libscielementary_functions_algo_la-convertbase.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/c/convertbase.c' object='src/c/libscielementary_functions_algo_la-convertbase.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscielementary_functions_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libscielementary_functions_algo_la-convertbase.lo `test -f 'src/c/convertbase.c' || echo '$(srcdir)/'`src/c/convertbase.c
-
sci_gateway/c/libscielementary_functions_la-sci_number_properties.lo: sci_gateway/c/sci_number_properties.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscielementary_functions_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sci_gateway/c/libscielementary_functions_la-sci_number_properties.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_number_properties.Tpo -c -o sci_gateway/c/libscielementary_functions_la-sci_number_properties.lo `test -f 'sci_gateway/c/sci_number_properties.c' || echo '$(srcdir)/'`sci_gateway/c/sci_number_properties.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_number_properties.Tpo sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_number_properties.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-basic_functions.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-ceil.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-cmp.Plo
- -rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-convertbase.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-cos.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-cosh.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-cupro.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-basic_functions.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-ceil.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-cmp.Plo
- -rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-convertbase.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-cos.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-cosh.Plo
-rm -f src/c/$(DEPDIR)/libscielementary_functions_algo_la-cupro.Plo
return types::Function::Error;
}
+ double max_value = pow(2, 53);
+ double* dbl_in = pDblIn->get();
for (int i = 0; i < pDblIn->getSize(); i++)
{
- if (trunc(pDblIn->get(i)) != pDblIn->get(i))
+ if (trunc(dbl_in[i]) != dbl_in[i])
{
Scierror(999, _("%s: Wrong value(s) for input argument #%d: A matrix of positive integer values expected.\n"), "dec2base", 1);
return types::Function::Error;
}
- if (pDblIn->get(i) > pow(2, 53))
+ if (dbl_in[i] > max_value)
{
Scierror(999, _("%s: Wrong value for input argument #%d: Must be between 0 and 2^53.\n"), "dec2base", 1);
return types::Function::Error;
}
}
- pOut = dectobase(in[0]->getAs<types::Double>(), iParam);
+ pOut = dectobase(pDblIn, iParam);
}
else if (in[0]->isInt())
{
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2011 - DIGITEO - Allan CORNET
- *
- * Copyright (C) 2012 - 2016 - Scilab Enterprises
- *
- * This file is hereby licensed under the terms of the GNU GPL v2.0,
- * pursuant to article 5.3.4 of the CeCILL v.2.1.
- * This file was originally licensed under the terms of the CeCILL v2.1,
- * and continues to be available under such terms.
- * For more information, see the COPYING file which you should have received
- * along with this program.
- *
- */
-/*--------------------------------------------------------------------------*/
-#include <string.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "machine.h" /* bsiz */
-#include "convertbase.h"
-#include "sci_malloc.h"
-#include "freeArrayOfString.h"
-/*--------------------------------------------------------------------------*/
-#define char_a 'a'
-#define char_A 'A'
-#define char_z 'z'
-#define char_Z 'Z'
-#define char_zero '0'
-#define char_nine '9'
-/*--------------------------------------------------------------------------*/
-static char *convertDec2Base(double dValue, int numberbase,
- unsigned int nbDigits, error_convertbase *err);
-/*--------------------------------------------------------------------------*/
-double convertBase2Dec(const char *pStr, int numberbase, error_convertbase *err)
-{
- double result = 0.;
- *err = ERROR_CONVERTBASE_NOK;
-
- if (pStr)
- {
- size_t i = 0;
- size_t len = strlen(pStr);
- for (i = 0; i < len; i++)
- {
- if ((pStr[i] >= char_zero) && (pStr[i] <= char_nine))
- {
- result = (numberbase * result) + (int)pStr[i] - char_zero;
- }
- else if ((pStr[i] >= char_A) && (pStr[i] <= char_Z))
- {
- int vTmp = (int)pStr[i] - char_A + 10;
- if (vTmp > numberbase)
- {
- *err = ERROR_CONVERTBASE_INVALID_REPRESENTATION;
- return 0;
- }
- else
- {
- result = (numberbase * result) + vTmp;
- }
- }
- else if ((pStr[i] >= char_a) && (pStr[i] <= char_z))
- {
- int vTmp = (int)pStr[i] - char_a + 10;
- if ( vTmp > numberbase)
- {
- *err = ERROR_CONVERTBASE_INVALID_REPRESENTATION;
- return 0;
- }
- else
- {
- result = (numberbase * result) + vTmp;
- }
- }
- else
- {
- return 0;
- }
- }
- *err = ERROR_CONVERTBASE_OK;
- }
- return result;
-}
-/*--------------------------------------------------------------------------*/
-static char *convertDec2Base(double dValue, int numberbase,
- unsigned int nbDigits, error_convertbase *err)
-{
- char symbols[37] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- long long int iDec = (long long int) dValue;
- char *convertedValue = NULL;
-
- *err = ERROR_CONVERTBASE_NOK;
- if (iDec == 0)
- {
- convertedValue = (char*)MALLOC(sizeof(char) * 2);
- if (convertedValue)
- {
- strcpy(convertedValue, "0");
- *err = ERROR_CONVERTBASE_OK;
- }
- else
- {
- *err = ERROR_CONVERTBASE_ALLOCATION;
- return NULL;
- }
- }
- else
- {
- int count = 0;
- char chResult[bsiz] = "";
- char *pChResult = chResult;
- while (iDec > 0 && count++ < bsiz)
- {
- *pChResult = symbols[iDec % numberbase];
- pChResult++;
- iDec = iDec / numberbase;
- }
-
- convertedValue = (char*)MALLOC(sizeof(char) * (strlen(chResult) + 1));
- if (convertedValue)
- {
- size_t j = 0;
- size_t i = strlen(chResult);
- int t = !(i % 2) ? 1 : 0;
- int k = 0;
- strcpy(convertedValue, chResult);
- for (j = i - 1; j > (i / 2 - t); j--)
- {
- char ch = chResult[j];
- chResult[j] = chResult[k];
- chResult[k++] = ch;
- }
- strcpy(convertedValue, chResult);
- *err = ERROR_CONVERTBASE_OK;
- }
- else
- {
- *err = ERROR_CONVERTBASE_ALLOCATION;
- return NULL;
- }
- }
-
- if (*err == ERROR_CONVERTBASE_OK)
- {
- size_t lenConvertedValue = strlen(convertedValue);
- if ((nbDigits > lenConvertedValue) && (nbDigits > 0))
- {
- size_t i = 0;
- char *tmp = (char*)MALLOC(sizeof(char) * (nbDigits + 1));
- if (tmp)
- {
- for (i = 0; i < nbDigits - lenConvertedValue; i++)
- {
- tmp[i] = '0';
- }
- tmp[i] = 0;
- strcat(tmp, convertedValue);
- FREE(convertedValue);
- convertedValue = tmp;
- }
- }
- }
-
- return convertedValue;
-}
-/*--------------------------------------------------------------------------*/
-char **convertMatrixOfDec2Base(const double* dValues, int mn,
- int numberbase, unsigned int nbDigits,
- error_convertbase *err)
-{
- char **convertedValues = NULL;
- int i = 0;
- double maxVal = 0.;
-
- for (i = 0; i < mn; i++)
- {
- long long int iValue = (long long int) dValues[i];
-
- /* search max value */
- if (dValues[i] > maxVal)
- {
- maxVal = dValues[i];
- }
-
- /* check if it is an integer value */
- if (dValues[i] != (double)iValue)
- {
- *err = ERROR_CONVERTBASE_NOT_INTEGER_VALUE;
- return NULL;
- }
-
- /* check if it is in the good interval */
- if ((dValues[i] < 0) || (dValues[i] > pow(2, 52)))
- {
- *err = ERROR_CONVERTBASE_NOT_IN_INTERVAL;
- return NULL;
- }
- }
-
- if ((mn > 1) && (numberbase == 2)) /* Only binary base is uniformed about number of digits */
- {
- size_t maxDigits = 0;
- char *maxBaseString = convertDec2Base(maxVal, numberbase, nbDigits, err);
- if (maxBaseString)
- {
- maxDigits = strlen(maxBaseString);
- FREE(maxBaseString);
- if (maxDigits > nbDigits)
- {
- nbDigits = (unsigned int)maxDigits;
- }
- }
- }
-
- convertedValues = (char **)MALLOC(sizeof(char*) * (mn));
- if (convertedValues)
- {
- for (i = 0; i < mn; i++)
- {
- convertedValues[i] = convertDec2Base(dValues[i], numberbase, nbDigits, err);
- if (*err)
- {
- freeArrayOfString(convertedValues, mn);
- return NULL;
- }
- }
- }
- else
- {
- *err = ERROR_CONVERTBASE_ALLOCATION;
- }
- return convertedValues;
-}
-/*--------------------------------------------------------------------------*/
+++ /dev/null
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2011 - DIGITEO - Allan CORNET
- *
- * Copyright (C) 2012 - 2016 - Scilab Enterprises
- *
- * This file is hereby licensed under the terms of the GNU GPL v2.0,
- * pursuant to article 5.3.4 of the CeCILL v.2.1.
- * This file was originally licensed under the terms of the CeCILL v2.1,
- * and continues to be available under such terms.
- * For more information, see the COPYING file which you should have received
- * along with this program.
- *
- */
-/*--------------------------------------------------------------------------*/
-#ifndef __CONVERTBASE_H__
-#define __CONVERTBASE_H__
-
-#include "dynlib_elementary_functions.h"
-
-typedef enum
-{
- ERROR_CONVERTBASE_OK = 0,
- ERROR_CONVERTBASE_NOK = 1,
- ERROR_CONVERTBASE_NOT_INTEGER_VALUE = 2,
- ERROR_CONVERTBASE_NOT_IN_INTERVAL = 3,
- ERROR_CONVERTBASE_ALLOCATION = 4,
- ERROR_CONVERTBASE_INVALID_REPRESENTATION = 5
-} error_convertbase;
-
-/**
-* convert from base b to decimal
-* @param string base
-* @param int base
-* @param[out] int if 0 no error
-* @return converted value (decimal)
-*/
-ELEMENTARY_FUNCTIONS_IMPEXP double convertBase2Dec(const char *pStr, int numberbase, error_convertbase *err);
-
-/**
-* Convert decimal to base N number in string
-* @param[in] array of integer values
-* @param[in] number of elements in dValues array
-* @param[in] number of digits for representation
-* @param[out] error value
-* @return a matrix of string of size mn
-*/
-ELEMENTARY_FUNCTIONS_IMPEXP char **convertMatrixOfDec2Base(const double* dValues, int mn, int numberbase, unsigned int nbDigits, error_convertbase *err);
-
-#endif /* __CONVERTBASE_H__ */
-/*--------------------------------------------------------------------------*/
<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" />
<ClInclude Include="..\cpp\prod.hxx" />
<ClInclude Include="..\cpp\sum.hxx" />
<ClInclude Include="cmp.h" />
- <ClInclude Include="convertbase.h" />
<ClInclude Include="expm.h" />
<ClInclude Include="IsEqualVar.h" />
<ClInclude Include="qsort-char.h" />
<ClCompile Include="atan.c">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="convertbase.c">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="cos.c">
<Filter>Source Files</Filter>
</ClCompile>
<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>