* Bug 16303 fixed: log10 now works with hypermatrix 44/21244/9
St├ęphane MOTTELET [Tue, 21 Jan 2020 13:07:42 +0000 (14:07 +0100)]
https://bugzilla.scilab.org/show_bug.cgi?id=16303

Change-Id: Id49265534e7351d85f09bb646e663d80f092b15d

scilab/CHANGES.md
scilab/modules/elementary_functions/Makefile.am
scilab/modules/elementary_functions/Makefile.in
scilab/modules/elementary_functions/includes/elem_func_gw.hxx
scilab/modules/elementary_functions/includes/gw_elementary_functions.h
scilab/modules/elementary_functions/macros/%s_log10.sci [deleted file]
scilab/modules/elementary_functions/sci_gateway/c/sci_log10.c [deleted file]
scilab/modules/elementary_functions/sci_gateway/cpp/elem_func_gw/elem_func_gw.vcxproj
scilab/modules/elementary_functions/sci_gateway/cpp/elem_func_gw/elem_func_gw.vcxproj.filters
scilab/modules/elementary_functions/sci_gateway/cpp/sci_log.cpp
scilab/modules/elementary_functions/tests/nonreg_tests/bug_16303.tst [new file with mode: 0644]

index e4fbfb7..886171f 100644 (file)
@@ -268,3 +268,4 @@ Bug Fixes
 * [#16275](http://bugzilla.scilab.org/show_bug.cgi?id=16275): `fsolve(x0, fun, tol)` no longer took `tol` into account.
 * [#16293](http://bugzilla.scilab.org/show_bug.cgi?id=16293): Some demos run in step-by-step console mode(4) did not focus user's attention to the console to proceed.
 * [#16299](http://bugzilla.scilab.org/show_bug.cgi?id=16299): After `graypolarplot()`, `colorbar()` displayed an empty ungraduated color bar.
+* [#16303](http://bugzilla.scilab.org/show_bug.cgi?id=16303): log10(x) had wrong dimensions when x is an hypermatrix.
index e429925..a9af454 100644 (file)
@@ -281,8 +281,7 @@ GATEWAY_C_SOURCES = \
     sci_gateway/c/sci_testmatrix.c \
     sci_gateway/c/sci_isequalbitwise.c \
     sci_gateway/c/sci_base2dec.c \
-    sci_gateway/c/sci_dec2base.c \
-    sci_gateway/c/sci_log10.c
+    sci_gateway/c/sci_dec2base.c
 
 GATEWAY_CXX_SOURCES =  \
     sci_gateway/cpp/sci_isequal.cpp \
index 021c9af..e07cf1e 100644 (file)
@@ -356,8 +356,7 @@ am__objects_7 = sci_gateway/c/libscielementary_functions_la-sci_number_propertie
        sci_gateway/c/libscielementary_functions_la-sci_testmatrix.lo \
        sci_gateway/c/libscielementary_functions_la-sci_isequalbitwise.lo \
        sci_gateway/c/libscielementary_functions_la-sci_base2dec.lo \
-       sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo \
-       sci_gateway/c/libscielementary_functions_la-sci_log10.lo
+       sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo
 am__objects_8 =  \
        sci_gateway/cpp/libscielementary_functions_la-sci_isequal.lo \
        sci_gateway/cpp/libscielementary_functions_la-elem_func_gw.lo \
@@ -440,7 +439,6 @@ am__maybe_remake_depfiles = depfiles
 am__depfiles_remade = sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_base2dec.Plo \
        sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo \
        sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_isequalbitwise.Plo \
-       sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_log10.Plo \
        sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_number_properties.Plo \
        sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_testmatrix.Plo \
        sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-elem_func_gw.Plo \
@@ -1211,8 +1209,7 @@ GATEWAY_C_SOURCES = \
     sci_gateway/c/sci_testmatrix.c \
     sci_gateway/c/sci_isequalbitwise.c \
     sci_gateway/c/sci_base2dec.c \
-    sci_gateway/c/sci_dec2base.c \
-    sci_gateway/c/sci_log10.c
+    sci_gateway/c/sci_dec2base.c
 
 GATEWAY_CXX_SOURCES = \
     sci_gateway/cpp/sci_isequal.cpp \
@@ -2088,9 +2085,6 @@ sci_gateway/c/libscielementary_functions_la-sci_base2dec.lo:  \
 sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo:  \
        sci_gateway/c/$(am__dirstamp) \
        sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
-sci_gateway/c/libscielementary_functions_la-sci_log10.lo:  \
-       sci_gateway/c/$(am__dirstamp) \
-       sci_gateway/c/$(DEPDIR)/$(am__dirstamp)
 sci_gateway/cpp/$(am__dirstamp):
        @$(MKDIR_P) sci_gateway/cpp
        @: > sci_gateway/cpp/$(am__dirstamp)
@@ -2294,7 +2288,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_base2dec.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_isequalbitwise.Plo@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_log10.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_number_properties.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_testmatrix.Plo@am__quote@ # am--include-marker
 @AMDEP_TRUE@@am__include@ @am__quote@sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-elem_func_gw.Plo@am__quote@ # am--include-marker
@@ -2773,13 +2766,6 @@ sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo: sci_gateway/c/sci_d
 @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_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sci_gateway/c/libscielementary_functions_la-sci_dec2base.lo `test -f 'sci_gateway/c/sci_dec2base.c' || echo '$(srcdir)/'`sci_gateway/c/sci_dec2base.c
 
-sci_gateway/c/libscielementary_functions_la-sci_log10.lo: sci_gateway/c/sci_log10.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_log10.lo -MD -MP -MF sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_log10.Tpo -c -o sci_gateway/c/libscielementary_functions_la-sci_log10.lo `test -f 'sci_gateway/c/sci_log10.c' || echo '$(srcdir)/'`sci_gateway/c/sci_log10.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_log10.Tpo sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_log10.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='sci_gateway/c/sci_log10.c' object='sci_gateway/c/libscielementary_functions_la-sci_log10.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_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sci_gateway/c/libscielementary_functions_la-sci_log10.lo `test -f 'sci_gateway/c/sci_log10.c' || echo '$(srcdir)/'`sci_gateway/c/sci_log10.c
-
 .cpp.o:
 @am__fastdepCXX_TRUE@  $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCXX_TRUE@  $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@@ -3479,7 +3465,6 @@ distclean: distclean-am
                -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_base2dec.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_isequalbitwise.Plo
-       -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_log10.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_number_properties.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_testmatrix.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-elem_func_gw.Plo
@@ -3641,7 +3626,6 @@ maintainer-clean: maintainer-clean-am
                -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_base2dec.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_dec2base.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_isequalbitwise.Plo
-       -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_log10.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_number_properties.Plo
        -rm -f sci_gateway/c/$(DEPDIR)/libscielementary_functions_la-sci_testmatrix.Plo
        -rm -f sci_gateway/cpp/$(DEPDIR)/libscielementary_functions_la-elem_func_gw.Plo
index 753b4b7..5673a12 100644 (file)
@@ -72,6 +72,7 @@ CPP_GATEWAY_PROTOTYPE(sci_isreal);
 CPP_GATEWAY_PROTOTYPE(sci_kron);
 CPP_GATEWAY_PROTOTYPE(sci_linspace);
 CPP_GATEWAY_PROTOTYPE(sci_log);
+CPP_GATEWAY_PROTOTYPE(sci_log10);
 CPP_GATEWAY_PROTOTYPE(sci_log1p);
 CPP_GATEWAY_PROTOTYPE(sci_matrix);
 CPP_GATEWAY_PROTOTYPE(sci_max); // Old name sci_maxi
index 24b0c62..d42d796 100644 (file)
@@ -68,7 +68,7 @@ STACK_GATEWAY_PROTOTYPE(sci_testmatrix);
 //STACK_GATEWAY_PROTOTYPE(sci_triu);
 STACK_GATEWAY_PROTOTYPE(sci_base2dec);
 STACK_GATEWAY_PROTOTYPE(sci_dec2base);
-STACK_GATEWAY_PROTOTYPE(sci_log10);
+//STACK_GATEWAY_PROTOTYPE(sci_log10);
 C_GATEWAY_PROTOTYPE(sci_isvector);
 C_GATEWAY_PROTOTYPE(sci_issquare);
 
diff --git a/scilab/modules/elementary_functions/macros/%s_log10.sci b/scilab/modules/elementary_functions/macros/%s_log10.sci
deleted file mode 100644 (file)
index f724eb7..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) INRIA
-// Copyright (C) DIGITEO - 2011 - 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.
-
-function y = %s_log10(x)
-    [lhs, rhs] = argn(0);
-    if rhs == 0 then
-        error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"log10", 1));
-    end
-    y = log(x) / log(10);
-endfunction
diff --git a/scilab/modules/elementary_functions/sci_gateway/c/sci_log10.c b/scilab/modules/elementary_functions/sci_gateway/c/sci_log10.c
deleted file mode 100644 (file)
index a3658ec..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007 - INRIA - Jean-Baptiste SILVY
- * Copyright (C) 2007 - INRIA - Allan CORNET
- * Copyright (C) 2007 - INRIA - Cong WU
- *
- * 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 "gw_elementary_functions.h"
-#include "api_scilab.h"
-#include "Scierror.h"
-#include "sci_malloc.h"
-#include "localization.h"
-#include "sciprint.h"
-#include "configvariable_interface.h"
-#include "Sciwarning.h"
-
-/*--------------------------------------------------------------------------*/
-int sci_log10(char *fname, void* pvApiCtx)
-{
-    SciErr sciErr;
-    int i = 0;
-    int complex = 0;
-    int check_ieee = 0;
-
-    int* piAddr = NULL;
-    int iType = 0;
-    int iRows = 0;
-    int iCols = 0;
-    double* pIn = NULL;
-    double* pOutR = NULL;
-    double* pOutI = NULL;
-
-    // Wolfram Alpha : Pi / log(10)
-    const double imag = 1.364376353841841347485783625431355770210127483723925399900;
-    // Wolfram Alpha : 1 / log(10)
-    const double inverseLog10 = 0.434294481903251827651128918916605082294397005803666566114;
-
-    int iRhs = nbInputArgument(pvApiCtx);
-
-    CheckInputArgument(pvApiCtx, 1, 1);
-    CheckOutputArgument(pvApiCtx, 0, 1);
-
-    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
-        return 0;
-    }
-
-    sciErr = getVarType(pvApiCtx, piAddr, &iType);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
-        return 0;
-    }
-
-    if (iType != sci_matrix || isVarComplex(pvApiCtx, piAddr))
-    {
-        //manage complex log10 via %s_log macro
-        OverLoad(1);
-        return 0;
-    }
-
-    sciErr = getMatrixOfDouble(pvApiCtx, piAddr, &iRows, &iCols, &pIn);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        return 0;
-    }
-
-    //check values
-    for (i = 0 ; i < iRows * iCols ; ++i)
-    {
-        double d = pIn[i];
-        if (d < 0)
-        {
-            complex = 1;
-        }
-
-        if (d == 0)
-        {
-            check_ieee = 1;
-        }
-    }
-
-    if (check_ieee)
-    {
-        if (getieee() == 0)
-        {
-            Scierror(999, "Singularity of log or tan function.\n");
-            return 0;
-        }
-
-        if (getieee() == 1)
-        {
-            Sciwarning(_("Warning : singularity of 'log' or 'tan' function.\n"));
-        }
-    }
-
-    if (complex)
-    {
-        sciErr = allocComplexMatrixOfDouble(pvApiCtx, iRhs + 1, iRows, iCols, &pOutR, &pOutI);
-        if (sciErr.iErr)
-        {
-            Scierror(999, _("%s: Memory allocation error.\n"), fname);
-            return 0;
-        }
-
-        memset(pOutI, 0x00, iRows * iCols * sizeof(double));
-    }
-    else
-    {
-        sciErr = allocMatrixOfDouble(pvApiCtx, iRhs + 1, iRows, iCols, &pOutR);
-        if (sciErr.iErr)
-        {
-            Scierror(999, _("%s: Memory allocation error.\n"), fname);
-            return 0;
-        }
-    }
-
-
-    for (i = 0 ; i < iRows * iCols ; ++i)
-    {
-        if (pIn[i] < 0)
-        {
-            // log10 = log * 1/log(10)
-            pOutR[i] = log(-pIn[i]) * inverseLog10;
-            pOutI[i] = imag;
-        }
-        else
-        {
-            // log10 = log * 1/log(10)
-            pOutR[i] = log(pIn[i]) * inverseLog10;
-        }
-    }
-
-    AssignOutputVariable(pvApiCtx, 1) = iRhs + 1;
-    ReturnArguments(pvApiCtx);
-    return 0;
-}
-
index adddfa1..be79334 100644 (file)
@@ -208,7 +208,6 @@ lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACH
     <ClCompile Include="..\..\c\sci_base2dec.c" />
     <ClCompile Include="..\..\c\sci_dec2base.c" />
     <ClCompile Include="..\..\c\sci_isequalbitwise.c" />
-    <ClCompile Include="..\..\c\sci_log10.c" />
     <ClCompile Include="..\..\c\sci_number_properties.c" />
     <ClCompile Include="..\..\c\sci_testmatrix.c" />
     <ClCompile Include="..\elem_func_gw.cpp" />
@@ -332,4 +331,4 @@ lib /DEF:"$(ProjectDir)elementary_functions_Import.def" /SUBSYSTEM:WINDOWS /MACH
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
index 48d2fb7..e98acf5 100644 (file)
     <ClCompile Include="..\sci_sign.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\c\sci_log10.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\sci_cosh.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="..\sci_bitstring.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\sci_linspace.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\includes\elem_func_gw.hxx">
index c0a6744..779b946 100644 (file)
@@ -26,34 +26,54 @@ extern "C"
 #include "localization.h"
 #include "elem_common.h"
 #include "log.h"
-    int C2F(wlog)(double*, double*, double*, double*);
+int C2F(wlog)(double*, double*, double*, double*);
+int C2F(dscal)(int*, double*, double*, int*);
 }
+
 /*
 clear a;nb = 2500;a = rand(nb, nb);tic();log(a);toc
 clear a;nb = 2500;a = -rand(nb, nb);tic();log(a);toc
 clear a;nb = 2500;a = rand(nb, nb); a = a + a *%i;tic();log(a);toc
 */
 
+types::Function::ReturnValue log_or_log10(types::typed_list &in, int _iRetCount, types::typed_list &out, bool bLog10);
+
 /*--------------------------------------------------------------------------*/
+
 types::Function::ReturnValue sci_log(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
+    return log_or_log10(in, _iRetCount, out, false);
+}
+
+types::Function::ReturnValue sci_log10(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    return log_or_log10(in, _iRetCount, out, true);
+}
+
+/*--------------------------------------------------------------------------*/
+
+types::Function::ReturnValue log_or_log10(types::typed_list &in, int _iRetCount, types::typed_list &out, bool bLog10)
+{
+    double inverseLog10 = 0.434294481903251827651128918916605082294397005803666566114;
+    auto fname = bLog10 ? "log10" : "log";
+
     int iAlert = 1;
 
     if (in.size() != 1)
     {
-        Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), "log", 1);
+        Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), fname, 1);
         return types::Function::Error;
     }
 
     if (_iRetCount > 1)
     {
-        Scierror(78, _("%s: Wrong number of output argument(s): %d expected.\n"), "log", 1);
+        Scierror(78, _("%s: Wrong number of output argument(s): %d expected.\n"), fname, 1);
         return types::Function::Error;
     }
 
     if (in[0]->isDouble() == false)
     {
-        std::wstring wstFuncName = L"%" + in[0]->getShortTypeStr() + L"_log";
+        std::wstring wstFuncName = L"%" + in[0]->getShortTypeStr() + (bLog10 ? L"_log10" : L"_log");
         return Overload::call(wstFuncName, in, _iRetCount, out);
     }
 
@@ -74,14 +94,14 @@ types::Function::ReturnValue sci_log(types::typed_list &in, int _iRetCount, type
             {
                 if (ConfigVariable::getIeee() == 0)
                 {
-                    Scierror(999, _("%s: Wrong value for input argument #%d : Singularity of the function.\n"), "log", 1);
+                    Scierror(999, _("%s: Wrong value for input argument #%d : Singularity of the function.\n"), fname, 1);
                     return types::Function::Error;
                 }
                 else if (ConfigVariable::getIeee() == 1)
                 {
                     if (ConfigVariable::getWarningMode())
                     {
-                        sciprint(_("%ls: Warning: Wrong value for input argument #%d : Singularity of the function.\n"), "log", 1);
+                        sciprint(_("%ls: Warning: Wrong value for input argument #%d : Singularity of the function.\n"), fname, 1);
                     }
                 }
 
@@ -90,6 +110,13 @@ types::Function::ReturnValue sci_log(types::typed_list &in, int _iRetCount, type
 
             C2F(wlog)(pInR + i, pInI + i, pOutR + i, pOutI + i);
         }
+
+        if (bLog10)
+        {
+            int iOne = 1;
+            C2F(dscal)(&size, &inverseLog10, pOutR, &iOne);
+            C2F(dscal)(&size, &inverseLog10, pOutI, &iOne);
+        }
     }
     else
     {
@@ -100,16 +127,17 @@ types::Function::ReturnValue sci_log(types::typed_list &in, int _iRetCount, type
             {
                 if (ConfigVariable::getIeee() == 0)
                 {
-                    Scierror(999, _("%s: Wrong value for input argument #%d : Singularity of the function.\n"), "log", 1);
+                    Scierror(999, _("%s: Wrong value for input argument #%d : Singularity of the function.\n"), fname, 1);
                     return types::Function::Error;
                 }
                 else if (ConfigVariable::getIeee() == 1)
                 {
                     if (ConfigVariable::getWarningMode())
                     {
-                        sciprint(_("%ls: Warning: Wrong value for input argument #%d : Singularity of the function.\n"), "log", 1);
+                        sciprint(_("%ls: Warning: Wrong value for input argument #%d : Singularity of the function.\n"), fname, 1);
                     }
                 }
+
                 iAlert = 0;
             }
             else if (pInR[i] < 0)
@@ -128,6 +156,13 @@ types::Function::ReturnValue sci_log(types::typed_list &in, int _iRetCount, type
             {
                 C2F(wlog)(pInR + i, &zero, pOutR + i, pOutI + i);
             }
+
+            if (bLog10)
+            {
+                int iOne = 1;
+                C2F(dscal)(&size, &inverseLog10, pOutR, &iOne);
+                C2F(dscal)(&size, &inverseLog10, pOutI, &iOne);
+            }
         }
         else
         {
@@ -135,6 +170,12 @@ types::Function::ReturnValue sci_log(types::typed_list &in, int _iRetCount, type
             {
                 pOutR[i] = std::log(pInR[i]);
             }
+
+            if (bLog10)
+            {
+                int iOne = 1;
+                C2F(dscal)(&size, &inverseLog10, pOutR, &iOne);
+            }
         }
     }
 
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_16303.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_16303.tst
new file mode 100644 (file)
index 0000000..a431788
--- /dev/null
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2020 - St├ęphane MOTTELET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+//
+// <-- Non-regression test for bug 16303 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/16303
+//
+// <-- Short Description -->
+// log10(x) has wrong dimensions when x is an hypermatrix
+
+x = rand(2,3,4);
+assert_checkequal(size(log10(x)),[2,3,4])
\ No newline at end of file