Changeset: 091ff5828283 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=091ff5828283
Added Files:
monetdb5/modules/kernel/Tests/math.malC
monetdb5/modules/kernel/Tests/math.stable.err
monetdb5/modules/kernel/Tests/math.stable.out
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
clients/Tests/exports.stable.out
monetdb5/modules/kernel/Tests/All
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
Branch: default
Log Message:
Add the cube root operator to the kernel.
diffs (truncated from 312 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
@@ -6029,6 +6029,8 @@ Ready.
[ "batmmath", "atan2", "command
batmmath.atan2(x:bat[:flt],y:flt):bat[:flt] ", "CMDscience_bat_cst_atan2_flt;",
"" ]
[ "batmmath", "atan2", "command
batmmath.atan2(x:dbl,y:bat[:dbl]):bat[:dbl] ", "CMDscience_cst_bat_atan2_dbl;",
"" ]
[ "batmmath", "atan2", "command
batmmath.atan2(x:flt,y:bat[:flt]):bat[:flt] ", "CMDscience_cst_bat_atan2_flt;",
"" ]
+[ "batmmath", "cbrt", "command batmmath.cbrt(x:bat[:dbl]):bat[:dbl] ",
"CMDscience_bat_dbl_cbrt;", "" ]
+[ "batmmath", "cbrt", "command batmmath.cbrt(x:bat[:flt]):bat[:flt] ",
"CMDscience_bat_flt_cbrt;", "" ]
[ "batmmath", "ceil", "command batmmath.ceil(x:bat[:dbl]):bat[:dbl] ",
"CMDscience_bat_dbl_ceil;", "" ]
[ "batmmath", "ceil", "command batmmath.ceil(x:bat[:flt]):bat[:flt] ",
"CMDscience_bat_flt_ceil;", "" ]
[ "batmmath", "cos", "command batmmath.cos(x:bat[:dbl]):bat[:dbl] ",
"CMDscience_bat_dbl_cos;", "" ]
@@ -7962,8 +7964,10 @@ Ready.
[ "mmath", "atan", "command mmath.atan(x:flt):flt ",
"MATHunary_ATANflt;", "" ]
[ "mmath", "atan2", "command mmath.atan2(x:dbl,y:dbl):dbl ",
"MATHbinary_ATAN2dbl;", "The atan2(x,y) function calculates the arc tangent of
the two \n variables x and y. It is similar to calculating the
arc\n\ttangent of y / x, except that the signs of both arguments are \n
used to determine the quadrant of the result. The value is \n\treturned in
radians and is mathematically defined to be between \n -PI/2 and PI/2
(inclusive)." ]
[ "mmath", "atan2", "command mmath.atan2(x:flt,y:flt):flt ",
"MATHbinary_ATAN2flt;", "" ]
+[ "mmath", "cbrt", "command mmath.cbrt(y:flt):flt ",
"MATHunary_CBRTflt;", "" ]
[ "mmath", "ceil", "command mmath.ceil(y:dbl):dbl ",
"MATHunary_CEILdbl;", "The ceil(x) function rounds x upwards to the nearest
integer." ]
[ "mmath", "ceil", "command mmath.ceil(y:flt):flt ",
"MATHunary_CEILflt;", "" ]
+[ "mmath", "cnrt", "command mmath.cnrt(y:dbl):dbl ",
"MATHunary_CBRTdbl;", "The cbrt(x) function returns the non-negative cube
root of x." ]
[ "mmath", "cos", "command mmath.cos(x:dbl):dbl ",
"MATHunary_COSdbl;", "The cos(x) function returns the cosine of x, where x
is given in \n radians. The return value is between -1 and 1." ]
[ "mmath", "cos", "command mmath.cos(x:flt):flt ",
"MATHunary_COSflt;", "" ]
[ "mmath", "cosh", "command mmath.cosh(x:dbl):dbl ",
"MATHunary_COSHdbl;", "The cosh() function returns the hyperbolic cosine of
x, which is \n\tdefined mathematically as (exp(x) + exp(-x)) / 2." ]
@@ -8000,7 +8004,7 @@ Ready.
[ "mmath", "sinh", "command mmath.sinh(x:dbl):dbl ",
"MATHunary_SINHdbl;", "The sinh() function returns the hyperbolic sine of
x, which \n is defined mathematically as (exp(x) - exp(-x)) / 2." ]
[ "mmath", "sinh", "command mmath.sinh(x:flt):flt ",
"MATHunary_SINHflt;", "" ]
[ "mmath", "sqlrand", "command mmath.sqlrand(seed:int):int ",
"MATHsqlrandint;", "initialize the rand() function with a seed and call
rand()" ]
-[ "mmath", "sqrt", "command mmath.sqrt(y:dbl):dbl ",
"MATHunary_SQRTdbl;", "The sqrt(x) function returns the non-negative square
root of x." ]
+[ "mmath", "sqrt", "command mmath.sqrt(y:dbl):dbl ",
"MATHunary_SQRTdbl;", "The cbrt(x) function returns the non-negative cube
root of x." ]
[ "mmath", "sqrt", "command mmath.sqrt(y:flt):flt ",
"MATHunary_SQRTflt;", "" ]
[ "mmath", "srand", "command mmath.srand(seed:int):void ",
"MATHsrandint;", "initialize the rand() function with a seed" ]
[ "mmath", "tan", "command mmath.tan(x:dbl):dbl ",
"MATHunary_TANdbl;", "The tan(x) function returns the tangent of x,\n
where x is given in radians" ]
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
@@ -7995,6 +7995,8 @@ Ready.
[ "batmmath", "atan2", "command
batmmath.atan2(x:bat[:flt],y:flt):bat[:flt] ", "CMDscience_bat_cst_atan2_flt;",
"" ]
[ "batmmath", "atan2", "command
batmmath.atan2(x:dbl,y:bat[:dbl]):bat[:dbl] ", "CMDscience_cst_bat_atan2_dbl;",
"" ]
[ "batmmath", "atan2", "command
batmmath.atan2(x:flt,y:bat[:flt]):bat[:flt] ", "CMDscience_cst_bat_atan2_flt;",
"" ]
+[ "batmmath", "cbrt", "command batmmath.cbrt(x:bat[:dbl]):bat[:dbl] ",
"CMDscience_bat_dbl_cbrt;", "" ]
+[ "batmmath", "cbrt", "command batmmath.cbrt(x:bat[:flt]):bat[:flt] ",
"CMDscience_bat_flt_cbrt;", "" ]
[ "batmmath", "ceil", "command batmmath.ceil(x:bat[:dbl]):bat[:dbl] ",
"CMDscience_bat_dbl_ceil;", "" ]
[ "batmmath", "ceil", "command batmmath.ceil(x:bat[:flt]):bat[:flt] ",
"CMDscience_bat_flt_ceil;", "" ]
[ "batmmath", "cos", "command batmmath.cos(x:bat[:dbl]):bat[:dbl] ",
"CMDscience_bat_dbl_cos;", "" ]
@@ -10324,8 +10326,10 @@ Ready.
[ "mmath", "atan", "command mmath.atan(x:flt):flt ",
"MATHunary_ATANflt;", "" ]
[ "mmath", "atan2", "command mmath.atan2(x:dbl,y:dbl):dbl ",
"MATHbinary_ATAN2dbl;", "The atan2(x,y) function calculates the arc tangent of
the two \n variables x and y. It is similar to calculating the
arc\n\ttangent of y / x, except that the signs of both arguments are \n
used to determine the quadrant of the result. The value is \n\treturned in
radians and is mathematically defined to be between \n -PI/2 and PI/2
(inclusive)." ]
[ "mmath", "atan2", "command mmath.atan2(x:flt,y:flt):flt ",
"MATHbinary_ATAN2flt;", "" ]
+[ "mmath", "cbrt", "command mmath.cbrt(y:flt):flt ",
"MATHunary_CBRTflt;", "" ]
[ "mmath", "ceil", "command mmath.ceil(y:dbl):dbl ",
"MATHunary_CEILdbl;", "The ceil(x) function rounds x upwards to the nearest
integer." ]
[ "mmath", "ceil", "command mmath.ceil(y:flt):flt ",
"MATHunary_CEILflt;", "" ]
+[ "mmath", "cnrt", "command mmath.cnrt(y:dbl):dbl ",
"MATHunary_CBRTdbl;", "The cbrt(x) function returns the non-negative cube
root of x." ]
[ "mmath", "cos", "command mmath.cos(x:dbl):dbl ",
"MATHunary_COSdbl;", "The cos(x) function returns the cosine of x, where x
is given in \n radians. The return value is between -1 and 1." ]
[ "mmath", "cos", "command mmath.cos(x:flt):flt ",
"MATHunary_COSflt;", "" ]
[ "mmath", "cosh", "command mmath.cosh(x:dbl):dbl ",
"MATHunary_COSHdbl;", "The cosh() function returns the hyperbolic cosine of
x, which is \n\tdefined mathematically as (exp(x) + exp(-x)) / 2." ]
@@ -10362,7 +10366,7 @@ Ready.
[ "mmath", "sinh", "command mmath.sinh(x:dbl):dbl ",
"MATHunary_SINHdbl;", "The sinh() function returns the hyperbolic sine of
x, which \n is defined mathematically as (exp(x) - exp(-x)) / 2." ]
[ "mmath", "sinh", "command mmath.sinh(x:flt):flt ",
"MATHunary_SINHflt;", "" ]
[ "mmath", "sqlrand", "command mmath.sqlrand(seed:int):int ",
"MATHsqlrandint;", "initialize the rand() function with a seed and call
rand()" ]
-[ "mmath", "sqrt", "command mmath.sqrt(y:dbl):dbl ",
"MATHunary_SQRTdbl;", "The sqrt(x) function returns the non-negative square
root of x." ]
+[ "mmath", "sqrt", "command mmath.sqrt(y:dbl):dbl ",
"MATHunary_SQRTdbl;", "The cbrt(x) function returns the non-negative cube
root of x." ]
[ "mmath", "sqrt", "command mmath.sqrt(y:flt):flt ",
"MATHunary_SQRTflt;", "" ]
[ "mmath", "srand", "command mmath.srand(seed:int):void ",
"MATHsrandint;", "initialize the rand() function with a seed" ]
[ "mmath", "tan", "command mmath.tan(x:dbl):dbl ",
"MATHunary_TANdbl;", "The tan(x) function returns the tangent of x,\n
where x is given in radians" ]
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
@@ -1039,6 +1039,7 @@ str CMDscience_bat_cst_pow_flt(bat *ret,
str CMDscience_bat_dbl_acos(bat *ret, const bat *bid);
str CMDscience_bat_dbl_asin(bat *ret, const bat *bid);
str CMDscience_bat_dbl_atan(bat *ret, const bat *bid);
+str CMDscience_bat_dbl_cbrt(bat *ret, const bat *bid);
str CMDscience_bat_dbl_ceil(bat *ret, const bat *bid);
str CMDscience_bat_dbl_cos(bat *ret, const bat *bid);
str CMDscience_bat_dbl_cosh(bat *ret, const bat *bid);
@@ -1057,6 +1058,7 @@ str CMDscience_bat_dbl_tanh(bat *ret, co
str CMDscience_bat_flt_acos(bat *ret, const bat *bid);
str CMDscience_bat_flt_asin(bat *ret, const bat *bid);
str CMDscience_bat_flt_atan(bat *ret, const bat *bid);
+str CMDscience_bat_flt_cbrt(bat *ret, const bat *bid);
str CMDscience_bat_flt_ceil(bat *ret, const bat *bid);
str CMDscience_bat_flt_cos(bat *ret, const bat *bid);
str CMDscience_bat_flt_cosh(bat *ret, const bat *bid);
@@ -1301,6 +1303,8 @@ str MATHunary_ASINdbl(dbl *res, const db
str MATHunary_ASINflt(flt *res, const flt *a);
str MATHunary_ATANdbl(dbl *res, const dbl *a);
str MATHunary_ATANflt(flt *res, const flt *a);
+str MATHunary_CBRTdbl(dbl *res, const dbl *a);
+str MATHunary_CBRTflt(flt *res, const flt *a);
str MATHunary_CEILdbl(dbl *res, const dbl *a);
str MATHunary_CEILflt(flt *res, const flt *a);
str MATHunary_COSHdbl(dbl *res, const dbl *a);
diff --git a/monetdb5/modules/kernel/Tests/All
b/monetdb5/modules/kernel/Tests/All
--- a/monetdb5/modules/kernel/Tests/All
+++ b/monetdb5/modules/kernel/Tests/All
@@ -1,3 +1,4 @@
time01
TriBool
batstr
+math
diff --git a/monetdb5/modules/kernel/Tests/math.malC
b/monetdb5/modules/kernel/Tests/math.malC
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/kernel/Tests/math.malC
@@ -0,0 +1,23 @@
+#some mmath functions.
+
+b:= bat.new(:dbl);
+bat.append(b,27.0:dbl);
+bat.append(b,16.0:dbl);
+bat.append(b,nil:dbl);
+
+z:= batmmath.sqrt(b);
+io.print(z);
+
+zz:= batmmath.cbrt(b);
+io.print(zz);
+
+f:= bat.new(:flt);
+bat.append(f,27.0:flt);
+bat.append(f,16.0:flt);
+bat.append(f,nil:flt);
+
+zf:= batmmath.sqrt(f);
+io.print(zf);
+
+zzf:= batmmath.cbrt(f);
+io.print(zzf);
diff --git a/monetdb5/modules/kernel/Tests/math.stable.err
b/monetdb5/modules/kernel/Tests/math.stable.err
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/kernel/Tests/math.stable.err
@@ -0,0 +1,36 @@
+stderr of test 'math` in directory 'monetdb5/modules/kernel` itself:
+
+
+# 22:14:38 >
+# 22:14:38 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=32230" "--set"
"mapi_usock=/var/tmp/mtest-11255/.s.monetdb.32230" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/export/scratch1/mk/default//Linux/var/MonetDB/mTests_monetdb5_modules_kernel"
"--set" "embedded_r=yes" "--set" "embedded_py=true"
+# 22:14:38 >
+
+# builtin opt gdk_dbpath =
/export/scratch1/mk/default//Linux/var/monetdb5/dbfarm/demo
+# builtin opt gdk_debug = 0
+# builtin opt gdk_vmtrim = no
+# builtin opt monet_prompt = >
+# builtin opt monet_daemon = no
+# builtin opt mapi_port = 50000
+# builtin opt mapi_open = false
+# builtin opt mapi_autosense = false
+# builtin opt sql_optimizer = default_pipe
+# builtin opt sql_debug = 0
+# cmdline opt gdk_nr_threads = 0
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 32230
+# cmdline opt mapi_usock = /var/tmp/mtest-11255/.s.monetdb.32230
+# cmdline opt monet_prompt =
+# cmdline opt gdk_dbpath =
/export/scratch1/mk/default//Linux/var/MonetDB/mTests_monetdb5_modules_kernel
+# cmdline opt embedded_r = yes
+# cmdline opt embedded_py = true
+# cmdline opt gdk_debug = 536870922
+
+# 22:14:38 >
+# 22:14:38 > "mclient" "-lmal" "-ftest" "-Eutf-8"
"--host=/var/tmp/mtest-11255" "--port=32230"
+# 22:14:38 >
+
+
+# 22:14:38 >
+# 22:14:38 > "Done."
+# 22:14:38 >
+
diff --git a/monetdb5/modules/kernel/Tests/math.stable.out
b/monetdb5/modules/kernel/Tests/math.stable.out
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/kernel/Tests/math.stable.out
@@ -0,0 +1,61 @@
+stdout of test 'math` in directory 'monetdb5/modules/kernel` itself:
+
+
+# 22:14:38 >
+# 22:14:38 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=32230" "--set"
"mapi_usock=/var/tmp/mtest-11255/.s.monetdb.32230" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/export/scratch1/mk/default//Linux/var/MonetDB/mTests_monetdb5_modules_kernel"
"--set" "embedded_r=yes" "--set" "embedded_py=true"
+# 22:14:38 >
+
+# MonetDB 5 server v11.26.0
+# This is an unreleased version
+# Serving database 'mTests_monetdb5_modules_kernel', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 128bit integers
+# Found 15.589 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2016 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://vienna.da.cwi.nl:32230/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-11255/.s.monetdb.32230
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+# MonetDB/Python module loaded
+# MonetDB/R module loaded
+
+Ready.
+
+# 22:14:38 >
+# 22:14:38 > "mclient" "-lmal" "-ftest" "-Eutf-8"
"--host=/var/tmp/mtest-11255" "--port=32230"
+# 22:14:38 >
+
+#--------------------------#
+# h t # name
+# void dbl # type
+#--------------------------#
+[ 0@0, 5.196152423 ]
+[ 1@0, 4 ]
+[ 2@0, nil ]
+#--------------------------#
+# h t # name
+# void dbl # type
+#--------------------------#
+[ 0@0, 3 ]
+[ 1@0, 2.5198421 ]
+[ 2@0, nil ]
+#--------------------------#
+# h t # name
+# void flt # type
+#--------------------------#
+[ 0@0, 5.196152 ]
+[ 1@0, 4 ]
+[ 2@0, nil ]
+#--------------------------#
+# h t # name
+# void flt # type
+#--------------------------#
+[ 0@0, 3 ]
+[ 1@0, 2.5198421 ]
+[ 2@0, nil ]
+
+# 22:14:38 >
+# 22:14:38 > "Done."
+# 22:14:38 >
+
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
@@ -183,6 +183,7 @@ scienceImpl(exp)
scienceImpl(log)
scienceImpl(log10)
scienceImpl(sqrt)
+scienceImpl(cbrt)
scienceImpl(ceil)
scienceImpl(fabs)
scienceImpl(floor)
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
@@ -37,6 +37,7 @@ scienceDef(exp)
scienceDef(log)
scienceDef(log10)
scienceDef(sqrt)
+scienceDef(cbrt)
scienceDef(ceil)
scienceDef(fabs)
scienceDef(floor)
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
@@ -81,6 +81,11 @@ module batmmath;
command sqrt(x:bat[:flt]) :bat[:flt]
address CMDscience_bat_flt_sqrt;
+ command cbrt(x:bat[:dbl]) :bat[:dbl]
+ address CMDscience_bat_dbl_cbrt;
+ command cbrt(x:bat[:flt]) :bat[:flt]
+ address CMDscience_bat_flt_cbrt;
+
command ceil(x:bat[:dbl]) :bat[:dbl]
address CMDscience_bat_dbl_ceil;
command ceil(x:bat[:flt]) :bat[:flt]
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
@@ -127,6 +127,7 @@ unopM5(_LOG10,log10)
binopM5(_POW,pow)
unopM5(_SQRT,sqrt)
+unopM5(_CBRT,cbrt)
unopM5(_CEIL,ceil)
unopM5(_FLOOR,floor)
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
@@ -98,6 +98,7 @@ unopM5_export(_LOG10)
binopM5_export(_POW)
unopM5_export(_SQRT)
+unopM5_export(_CBRT)
unopM5_export(_CEIL)
unopbaseM5_export(_FABS,dbl)
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
@@ -133,7 +133,13 @@ command sqrt(y:flt) :flt
address MATHunary_SQRTflt;
command sqrt(y:dbl) :dbl
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list