Changeset: a116ae0c1407 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a116ae0c1407
Added Files:
monetdb5/modules/kernel/mmath_private.h
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
clients/Tests/exports.stable.out
monetdb5/modules/kernel/batmmath.c
monetdb5/modules/kernel/batmmath.h
monetdb5/modules/kernel/batmmath.mal
monetdb5/modules/kernel/mmath.c
monetdb5/modules/kernel/mmath.h
monetdb5/modules/kernel/mmath.mal
sql/ChangeLog.Apr2019
sql/common/sql_types.c
sql/test/Tests/systemfunctions.stable.out
sql/test/Tests/systemfunctions.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.powerpc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out.powerpc64.int128
Branch: Apr2019
Log Message:
Implemented a two argument log function.
This fixed bug 3416.
diffs (truncated from 41256 to 300 lines):
diff --git a/clients/Tests/MAL-signatures.stable.out
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -8819,10 +8819,18 @@ Ready.
[ "batmmath", "fmod", "pattern batmmath.fmod(x:bat[:dbl], y:dbl,
s:bat[:oid]):bat[:dbl] ", "CMDbatMODsignal;", "" ]
[ "batmmath", "fmod", "pattern batmmath.fmod(x:bat[:flt], y:flt):bat[:flt] ",
"CMDbatMODsignal;", "" ]
[ "batmmath", "fmod", "pattern batmmath.fmod(x:bat[:flt], y:flt,
s:bat[:oid]):bat[:flt] ", "CMDbatMODsignal;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:bat[:dbl], y:dbl):bat[:dbl] ",
"CMDscience_bat_cst_log_dbl;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:bat[:dbl], y:dbl,
s:bat[:oid]):bat[:dbl] ", "CMDscience_bat_cst_log_dbl_cand;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:bat[:flt], y:flt):bat[:flt] ",
"CMDscience_bat_cst_log_flt;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:bat[:flt], y:flt,
s:bat[:oid]):bat[:flt] ", "CMDscience_bat_cst_log_flt_cand;", "" ]
[ "batmmath", "log", "command batmmath.log(x:bat[:dbl]):bat[:dbl] ",
"CMDscience_bat_dbl_log;", "" ]
[ "batmmath", "log", "command batmmath.log(x:bat[:dbl],
s:bat[:oid]):bat[:dbl] ", "CMDscience_bat_dbl_log_cand;", "" ]
[ "batmmath", "log", "command batmmath.log(x:bat[:flt]):bat[:flt] ",
"CMDscience_bat_flt_log;", "" ]
[ "batmmath", "log", "command batmmath.log(x:bat[:flt],
s:bat[:oid]):bat[:flt] ", "CMDscience_bat_flt_log_cand;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:dbl, y:bat[:dbl]):bat[:dbl] ",
"CMDscience_cst_bat_log_dbl;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:dbl, y:bat[:dbl],
s:bat[:oid]):bat[:dbl] ", "CMDscience_cst_bat_log_dbl_cand;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:flt, y:bat[:flt]):bat[:flt] ",
"CMDscience_cst_bat_log_flt;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:flt, y:bat[:flt],
s:bat[:oid]):bat[:flt] ", "CMDscience_cst_bat_log_flt_cand;", "" ]
[ "batmmath", "log10", "command batmmath.log10(x:bat[:dbl]):bat[:dbl]
", "CMDscience_bat_dbl_log10;", "" ]
[ "batmmath", "log10", "command batmmath.log10(x:bat[:dbl],
s:bat[:oid]):bat[:dbl] ", "CMDscience_bat_dbl_log10_cand;", "" ]
[ "batmmath", "log10", "command batmmath.log10(x:bat[:flt]):bat[:flt]
", "CMDscience_bat_flt_log10;", "" ]
@@ -11268,6 +11276,8 @@ Ready.
[ "mmath", "fmod", "pattern mmath.fmod(y:flt, x:flt):flt ",
"CMDvarMODsignal;", "" ]
[ "mmath", "isinf", "command mmath.isinf(d:dbl):int ",
"MATHunary_ISINF;", "The isinf(x) function returns -1 if x represents
negative \n infinity, 1 if x represents positive infinity, and 0
otherwise." ]
[ "mmath", "isnan", "command mmath.isnan(d:dbl):bit ",
"MATHunary_ISNAN;", "The isnan(x) function returns true if x is
'not-a-number' \n (NaN), and false otherwise." ]
+[ "mmath", "log", "command mmath.log(x:dbl, base:dbl):dbl ",
"MATHbinary_LOGdbl;", "The log(x) function returns the logarithm of x in the
given base." ]
+[ "mmath", "log", "command mmath.log(x:flt, base:flt):flt ",
"MATHbinary_LOGflt;", "The log(x) function returns the logarithm of x in the
given base." ]
[ "mmath", "log", "command mmath.log(x:dbl):dbl ",
"MATHunary_LOGdbl;", "The log(x) function returns the natural logarithm of
x." ]
[ "mmath", "log", "command mmath.log(x:flt):flt ",
"MATHunary_LOGflt;", "" ]
[ "mmath", "log10", "command mmath.log10(x:dbl):dbl ",
"MATHunary_LOG10dbl;", "The log10(x) function returns the base-10 logarithm of
x." ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -12547,10 +12547,18 @@ Ready.
[ "batmmath", "fmod", "pattern batmmath.fmod(x:bat[:dbl], y:dbl,
s:bat[:oid]):bat[:dbl] ", "CMDbatMODsignal;", "" ]
[ "batmmath", "fmod", "pattern batmmath.fmod(x:bat[:flt], y:flt):bat[:flt] ",
"CMDbatMODsignal;", "" ]
[ "batmmath", "fmod", "pattern batmmath.fmod(x:bat[:flt], y:flt,
s:bat[:oid]):bat[:flt] ", "CMDbatMODsignal;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:bat[:dbl], y:dbl):bat[:dbl] ",
"CMDscience_bat_cst_log_dbl;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:bat[:dbl], y:dbl,
s:bat[:oid]):bat[:dbl] ", "CMDscience_bat_cst_log_dbl_cand;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:bat[:flt], y:flt):bat[:flt] ",
"CMDscience_bat_cst_log_flt;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:bat[:flt], y:flt,
s:bat[:oid]):bat[:flt] ", "CMDscience_bat_cst_log_flt_cand;", "" ]
[ "batmmath", "log", "command batmmath.log(x:bat[:dbl]):bat[:dbl] ",
"CMDscience_bat_dbl_log;", "" ]
[ "batmmath", "log", "command batmmath.log(x:bat[:dbl],
s:bat[:oid]):bat[:dbl] ", "CMDscience_bat_dbl_log_cand;", "" ]
[ "batmmath", "log", "command batmmath.log(x:bat[:flt]):bat[:flt] ",
"CMDscience_bat_flt_log;", "" ]
[ "batmmath", "log", "command batmmath.log(x:bat[:flt],
s:bat[:oid]):bat[:flt] ", "CMDscience_bat_flt_log_cand;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:dbl, y:bat[:dbl]):bat[:dbl] ",
"CMDscience_cst_bat_log_dbl;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:dbl, y:bat[:dbl],
s:bat[:oid]):bat[:dbl] ", "CMDscience_cst_bat_log_dbl_cand;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:flt, y:bat[:flt]):bat[:flt] ",
"CMDscience_cst_bat_log_flt;", "" ]
+[ "batmmath", "log", "command batmmath.log(x:flt, y:bat[:flt],
s:bat[:oid]):bat[:flt] ", "CMDscience_cst_bat_log_flt_cand;", "" ]
[ "batmmath", "log10", "command batmmath.log10(x:bat[:dbl]):bat[:dbl]
", "CMDscience_bat_dbl_log10;", "" ]
[ "batmmath", "log10", "command batmmath.log10(x:bat[:dbl],
s:bat[:oid]):bat[:dbl] ", "CMDscience_bat_dbl_log10_cand;", "" ]
[ "batmmath", "log10", "command batmmath.log10(x:bat[:flt]):bat[:flt]
", "CMDscience_bat_flt_log10;", "" ]
@@ -15680,6 +15688,8 @@ Ready.
[ "mmath", "fmod", "pattern mmath.fmod(y:flt, x:flt):flt ",
"CMDvarMODsignal;", "" ]
[ "mmath", "isinf", "command mmath.isinf(d:dbl):int ",
"MATHunary_ISINF;", "The isinf(x) function returns -1 if x represents
negative \n infinity, 1 if x represents positive infinity, and 0
otherwise." ]
[ "mmath", "isnan", "command mmath.isnan(d:dbl):bit ",
"MATHunary_ISNAN;", "The isnan(x) function returns true if x is
'not-a-number' \n (NaN), and false otherwise." ]
+[ "mmath", "log", "command mmath.log(x:dbl, base:dbl):dbl ",
"MATHbinary_LOGdbl;", "The log(x) function returns the logarithm of x in the
given base." ]
+[ "mmath", "log", "command mmath.log(x:flt, base:flt):flt ",
"MATHbinary_LOGflt;", "The log(x) function returns the logarithm of x in the
given base." ]
[ "mmath", "log", "command mmath.log(x:dbl):dbl ",
"MATHunary_LOGdbl;", "The log(x) function returns the natural logarithm of
x." ]
[ "mmath", "log", "command mmath.log(x:flt):flt ",
"MATHunary_LOGflt;", "" ]
[ "mmath", "log10", "command mmath.log10(x:dbl):dbl ",
"MATHunary_LOG10dbl;", "The log10(x) function returns the base-10 logarithm of
x." ]
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1054,6 +1054,10 @@ str CMDscience_bat_cst_atan2_dbl(bat *re
str CMDscience_bat_cst_atan2_dbl_cand(bat *ret, const bat *bid, const dbl *d,
const bat *sid);
str CMDscience_bat_cst_atan2_flt(bat *ret, const bat *bid, const flt *d);
str CMDscience_bat_cst_atan2_flt_cand(bat *ret, const bat *bid, const flt *d,
const bat *sid);
+str CMDscience_bat_cst_log_dbl(bat *ret, const bat *bid, const dbl *d);
+str CMDscience_bat_cst_log_dbl_cand(bat *ret, const bat *bid, const dbl *d,
const bat *sid);
+str CMDscience_bat_cst_log_flt(bat *ret, const bat *bid, const flt *d);
+str CMDscience_bat_cst_log_flt_cand(bat *ret, const bat *bid, const flt *d,
const bat *sid);
str CMDscience_bat_cst_pow_dbl(bat *ret, const bat *bid, const dbl *d);
str CMDscience_bat_cst_pow_dbl_cand(bat *ret, const bat *bid, const dbl *d,
const bat *sid);
str CMDscience_bat_cst_pow_flt(bat *ret, const bat *bid, const flt *d);
@@ -1142,6 +1146,10 @@ str CMDscience_cst_bat_atan2_dbl(bat *re
str CMDscience_cst_bat_atan2_dbl_cand(bat *ret, const dbl *d, const bat *bid,
const bat *sid);
str CMDscience_cst_bat_atan2_flt(bat *ret, const flt *d, const bat *bid);
str CMDscience_cst_bat_atan2_flt_cand(bat *ret, const flt *d, const bat *bid,
const bat *sid);
+str CMDscience_cst_bat_log_dbl(bat *ret, const dbl *d, const bat *bid);
+str CMDscience_cst_bat_log_dbl_cand(bat *ret, const dbl *d, const bat *bid,
const bat *sid);
+str CMDscience_cst_bat_log_flt(bat *ret, const flt *d, const bat *bid);
+str CMDscience_cst_bat_log_flt_cand(bat *ret, const flt *d, const bat *bid,
const bat *sid);
str CMDscience_cst_bat_pow_dbl(bat *ret, const dbl *d, const bat *bid);
str CMDscience_cst_bat_pow_dbl_cand(bat *ret, const dbl *d, const bat *bid,
const bat *sid);
str CMDscience_cst_bat_pow_flt(bat *ret, const flt *d, const bat *bid);
@@ -1361,6 +1369,8 @@ MALfcn MANIFOLDtypecheck(Client cntxt, M
str MANUALcreateOverview(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
str MATHbinary_ATAN2dbl(dbl *res, const dbl *a, const dbl *b);
str MATHbinary_ATAN2flt(flt *res, const flt *a, const flt *b);
+str MATHbinary_LOGdbl(dbl *res, const dbl *a, const dbl *b);
+str MATHbinary_LOGflt(flt *res, const flt *a, const flt *b);
str MATHbinary_POWdbl(dbl *res, const dbl *a, const dbl *b);
str MATHbinary_POWflt(flt *res, const flt *a, const flt *b);
str MATHbinary_ROUNDdbl(dbl *res, const dbl *a, const int *b);
diff --git a/monetdb5/modules/kernel/batmmath.c
b/monetdb5/modules/kernel/batmmath.c
--- a/monetdb5/modules/kernel/batmmath.c
+++ b/monetdb5/modules/kernel/batmmath.c
@@ -20,6 +20,7 @@
#include "batmmath.h"
#include "gdk_cand.h"
#include <fenv.h>
+#include "mmath_private.h"
#ifndef FE_INVALID
#define FE_INVALID 0
#endif
@@ -394,3 +395,5 @@ scienceBinaryImpl(atan2,dbl,)
scienceBinaryImpl(atan2,flt,f)
scienceBinaryImpl(pow,dbl,)
scienceBinaryImpl(pow,flt,f)
+scienceBinaryImpl(log,dbl,bs)
+scienceBinaryImpl(log,flt,bsf)
diff --git a/monetdb5/modules/kernel/batmmath.h
b/monetdb5/modules/kernel/batmmath.h
--- a/monetdb5/modules/kernel/batmmath.h
+++ b/monetdb5/modules/kernel/batmmath.h
@@ -45,20 +45,18 @@ scienceDef(ceil)
scienceDef(fabs)
scienceDef(floor)
-mal_export str CMDscience_bat_cst_atan2_dbl(bat *ret, const bat *bid, const
dbl *d);
-mal_export str CMDscience_bat_cst_atan2_dbl_cand(bat *ret, const bat *bid,
const dbl *d, const bat *sid);
-mal_export str CMDscience_bat_cst_atan2_flt(bat *ret, const bat *bid, const
flt *d);
-mal_export str CMDscience_bat_cst_atan2_flt_cand(bat *ret, const bat *bid,
const flt *d, const bat *sid);
-mal_export str CMDscience_cst_bat_atan2_dbl(bat *ret, const dbl *d, const bat
*bid);
-mal_export str CMDscience_cst_bat_atan2_dbl_cand(bat *ret, const dbl *d, const
bat *bid, const bat *sid);
-mal_export str CMDscience_cst_bat_atan2_flt(bat *ret, const flt *d, const bat
*bid);
-mal_export str CMDscience_cst_bat_atan2_flt_cand(bat *ret, const flt *d, const
bat *bid, const bat *sid);
-mal_export str CMDscience_bat_cst_pow_dbl(bat *ret, const bat *bid, const dbl
*d);
-mal_export str CMDscience_bat_cst_pow_dbl_cand(bat *ret, const bat *bid, const
dbl *d, const bat *sid);
-mal_export str CMDscience_bat_cst_pow_flt(bat *ret, const bat *bid, const flt
*d);
-mal_export str CMDscience_bat_cst_pow_flt_cand(bat *ret, const bat *bid, const
flt *d, const bat *sid);
-mal_export str CMDscience_cst_bat_pow_dbl(bat *ret, const dbl *d, const bat
*bid);
-mal_export str CMDscience_cst_bat_pow_dbl_cand(bat *ret, const dbl *d, const
bat *bid, const bat *sid);
-mal_export str CMDscience_cst_bat_pow_flt(bat *ret, const flt *d, const bat
*bid);
-mal_export str CMDscience_cst_bat_pow_flt_cand(bat *ret, const flt *d, const
bat *bid, const bat *sid);
+#define scienceBinaryDef(F)
\
+mal_export str CMDscience_bat_cst_##F##_dbl(bat *ret, const bat *bid, const
dbl *d); \
+mal_export str CMDscience_bat_cst_##F##_dbl_cand(bat *ret, const bat *bid,
const dbl *d, const bat *sid); \
+mal_export str CMDscience_bat_cst_##F##_flt(bat *ret, const bat *bid, const
flt *d); \
+mal_export str CMDscience_bat_cst_##F##_flt_cand(bat *ret, const bat *bid,
const flt *d, const bat *sid); \
+mal_export str CMDscience_cst_bat_##F##_dbl(bat *ret, const dbl *d, const bat
*bid); \
+mal_export str CMDscience_cst_bat_##F##_dbl_cand(bat *ret, const dbl *d, const
bat *bid, const bat *sid); \
+mal_export str CMDscience_cst_bat_##F##_flt(bat *ret, const flt *d, const bat
*bid); \
+mal_export str CMDscience_cst_bat_##F##_flt_cand(bat *ret, const flt *d, const
bat *bid, const bat *sid);
+
+scienceBinaryDef(atan2)
+scienceBinaryDef(pow)
+scienceBinaryDef(log)
+
#endif /* _BATMATH_H */
diff --git a/monetdb5/modules/kernel/batmmath.mal
b/monetdb5/modules/kernel/batmmath.mal
--- a/monetdb5/modules/kernel/batmmath.mal
+++ b/monetdb5/modules/kernel/batmmath.mal
@@ -141,6 +141,24 @@ module batmmath;
command log2(x:bat[:flt],s:bat[:oid]) :bat[:flt]
address CMDscience_bat_flt_log2_cand;
+ command log(x:bat[:dbl],y:dbl):bat[:dbl]
+ address CMDscience_bat_cst_log_dbl;
+ command log(x:bat[:dbl],y:dbl,s:bat[:oid]):bat[:dbl]
+ address CMDscience_bat_cst_log_dbl_cand;
+ command log(x:bat[:flt],y:flt):bat[:flt]
+ address CMDscience_bat_cst_log_flt;
+ command log(x:bat[:flt],y:flt,s:bat[:oid]):bat[:flt]
+ address CMDscience_bat_cst_log_flt_cand;
+
+ command log(x:dbl,y:bat[:dbl]):bat[:dbl]
+ address CMDscience_cst_bat_log_dbl;
+ command log(x:dbl,y:bat[:dbl],s:bat[:oid]):bat[:dbl]
+ address CMDscience_cst_bat_log_dbl_cand;
+ command log(x:flt,y:bat[:flt]):bat[:flt]
+ address CMDscience_cst_bat_log_flt;
+ command log(x:flt,y:bat[:flt],s:bat[:oid]):bat[:flt]
+ address CMDscience_cst_bat_log_flt_cand;
+
command sqrt(x:bat[:dbl]) :bat[:dbl]
address CMDscience_bat_dbl_sqrt;
command sqrt(x:bat[:dbl],s:bat[:oid]) :bat[:dbl]
diff --git a/monetdb5/modules/kernel/mmath.c b/monetdb5/modules/kernel/mmath.c
--- a/monetdb5/modules/kernel/mmath.c
+++ b/monetdb5/modules/kernel/mmath.c
@@ -20,6 +20,7 @@
#include "monetdb_config.h"
#include "mmath.h"
#include <fenv.h>
+#include "mmath_private.h"
#ifndef FE_INVALID
#define FE_INVALID 0
#endif
@@ -34,6 +35,18 @@
#define radians(x) ((x) * 3.14159265358979323846 / 180.0)
#define degrees(x) ((x) * 180.0 / 3.14159265358979323846)
+double
+logbs(double x, double base)
+{
+ return log(x) / log(base);
+}
+
+float
+logbsf(float x, float base)
+{
+ return logf(x) / logf(base);
+}
+
#define unopbaseM5(NAME, FUNC, TYPE)
\
str
\
MATHunary##NAME##TYPE(TYPE *res , const TYPE *a)
\
@@ -162,6 +175,8 @@ unopM5(_LOG,log)
unopM5(_LOG10,log10)
unopM5(_LOG2,log2)
+binopM5(_LOG,logbs)
+
binopM5(_POW,pow)
unopM5(_SQRT,sqrt)
#ifdef HAVE_CBRT
diff --git a/monetdb5/modules/kernel/mmath.h b/monetdb5/modules/kernel/mmath.h
--- a/monetdb5/modules/kernel/mmath.h
+++ b/monetdb5/modules/kernel/mmath.h
@@ -44,6 +44,7 @@ unopM5_export(_EXP)
unopM5_export(_LOG)
unopM5_export(_LOG10)
unopM5_export(_LOG2)
+binopM5_export(_LOG)
binopM5_export(_POW)
unopM5_export(_SQRT)
diff --git a/monetdb5/modules/kernel/mmath.mal
b/monetdb5/modules/kernel/mmath.mal
--- a/monetdb5/modules/kernel/mmath.mal
+++ b/monetdb5/modules/kernel/mmath.mal
@@ -116,6 +116,13 @@ command log(x:dbl) :dbl
address MATHunary_LOGdbl
comment "The log(x) function returns the natural logarithm of x.";
+command log(x:flt,base:flt) :flt
+address MATHbinary_LOGflt
+comment "The log(x) function returns the logarithm of x in the given base.";
+command log(x:dbl,base:dbl) :dbl
+address MATHbinary_LOGdbl
+comment "The log(x) function returns the logarithm of x in the given base.";
+
command log10(x:flt) :flt
address MATHunary_LOG10flt;
command log10(x:dbl) :dbl
diff --git a/monetdb5/modules/kernel/mmath_private.h
b/monetdb5/modules/kernel/mmath_private.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/kernel/mmath_private.h
@@ -0,0 +1,12 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
+ */
+
+/* return the logarigthm of the first argument with the second
+ * argument as base */
+extern double logbs(double, double);
+extern float logbsf(float, float);
diff --git a/sql/ChangeLog.Apr2019 b/sql/ChangeLog.Apr2019
--- a/sql/ChangeLog.Apr2019
+++ b/sql/ChangeLog.Apr2019
@@ -2,6 +2,8 @@
# This file is updated with Maddlog
* Tue Jan 22 2019 Sjoerd Mullender <[email protected]>
+- Implemented a two argument function log which calculates the logarithm
+ of the first argument using the second argument as base.
- Next to the functions log (natural logarithm) and log10 (base 10
logarithm), there is now also log2 (base 2 logarithm).
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -1955,6 +1955,7 @@ sqltypeinit( sql_allocator *sa)
sql_create_func(sa, "sqrt", "mmath", "sqrt", *t, NULL, *t,
SCALE_FIX);
sql_create_func(sa, "exp", "mmath", "exp", *t, NULL, *t,
SCALE_FIX);
sql_create_func(sa, "log", "mmath", "log", *t, NULL, *t,
SCALE_FIX);
+ sql_create_func(sa, "log", "mmath", "log", *t, *t, *t,
SCALE_FIX);
sql_create_func(sa, "log10", "mmath", "log10", *t, NULL, *t,
SCALE_FIX);
sql_create_func(sa, "log2", "mmath", "log2", *t, NULL, *t,
SCALE_FIX);
}
diff --git a/sql/test/Tests/systemfunctions.stable.out
b/sql/test/Tests/systemfunctions.stable.out
--- a/sql/test/Tests/systemfunctions.stable.out
+++ b/sql/test/Tests/systemfunctions.stable.out
@@ -993,8 +993,14 @@ Ready.
[ "sys", "locate", 3, "int", "" ]
[ "sys", "log", 0, "real", "log" ]
[ "sys", "log", 1, "real", "" ]
+[ "sys", "log", 0, "real", "log" ]
+[ "sys", "log", 1, "real", "" ]
+[ "sys", "log", 2, "real", "" ]
[ "sys", "log", 0, "double", "log" ]
[ "sys", "log", 1, "double", "" ]
+[ "sys", "log", 0, "double", "log" ]
+[ "sys", "log", 1, "double", "" ]
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list