Changeset: 14fec096cf65 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=14fec096cf65
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
Branch: Jun2016
Log Message:

Added MAL commands batmmath.pow and batmmath.atan2 with scalar and bat args.
We already had bat and scalar args.


diffs (153 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
@@ -2723,6 +2723,10 @@ command batstr.unicodeAt(s:bat[:str],ind
 address STRbatWChrAt;
 comment get a unicode character (as an int) from a string position.
 
+command batmmath.atan2(x:flt,y:bat[:flt]):bat[:flt] 
+address CMDscience_cst_bat_atan2_flt;
+command batmmath.atan2(x:dbl,y:bat[:dbl]):bat[:dbl] 
+address CMDscience_cst_bat_atan2_dbl;
 command batmmath.atan2(x:bat[:flt],y:flt):bat[:flt] 
 address CMDscience_bat_cst_atan2_flt;
 command batmmath.atan2(x:bat[:dbl],y:dbl):bat[:dbl] 
@@ -2779,6 +2783,10 @@ command batmmath.log(x:bat[:flt]):bat[:f
 address CMDscience_bat_flt_log;
 command batmmath.log(x:bat[:dbl]):bat[:dbl] 
 address CMDscience_bat_dbl_log;
+command batmmath.pow(x:flt,y:bat[:flt]):bat[:flt] 
+address CMDscience_cst_bat_pow_flt;
+command batmmath.pow(x:dbl,y:bat[:dbl]):bat[:dbl] 
+address CMDscience_cst_bat_pow_dbl;
 command batmmath.pow(x:bat[:flt],y:flt):bat[:flt] 
 address CMDscience_bat_cst_pow_flt;
 command batmmath.pow(x:bat[:dbl],y:dbl):bat[:dbl] 
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
@@ -3174,6 +3174,10 @@ command batstr.unicodeAt(s:bat[:str],ind
 address STRbatWChrAt;
 comment get a unicode character (as an int) from a string position.
 
+command batmmath.atan2(x:flt,y:bat[:flt]):bat[:flt] 
+address CMDscience_cst_bat_atan2_flt;
+command batmmath.atan2(x:dbl,y:bat[:dbl]):bat[:dbl] 
+address CMDscience_cst_bat_atan2_dbl;
 command batmmath.atan2(x:bat[:flt],y:flt):bat[:flt] 
 address CMDscience_bat_cst_atan2_flt;
 command batmmath.atan2(x:bat[:dbl],y:dbl):bat[:dbl] 
@@ -3230,6 +3234,10 @@ command batmmath.log(x:bat[:flt]):bat[:f
 address CMDscience_bat_flt_log;
 command batmmath.log(x:bat[:dbl]):bat[:dbl] 
 address CMDscience_bat_dbl_log;
+command batmmath.pow(x:flt,y:bat[:flt]):bat[:flt] 
+address CMDscience_cst_bat_pow_flt;
+command batmmath.pow(x:dbl,y:bat[:dbl]):bat[:dbl] 
+address CMDscience_cst_bat_pow_dbl;
 command batmmath.pow(x:bat[:flt],y:flt):bat[:flt] 
 address CMDscience_bat_cst_pow_flt;
 command batmmath.pow(x:bat[:dbl],y:dbl):bat[:dbl] 
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
@@ -1065,6 +1065,10 @@ str CMDscience_bat_flt_sinh(bat *ret, co
 str CMDscience_bat_flt_sqrt(bat *ret, const bat *bid);
 str CMDscience_bat_flt_tan(bat *ret, const bat *bid);
 str CMDscience_bat_flt_tanh(bat *ret, const bat *bid);
+str CMDscience_cst_bat_atan2_dbl(bat *ret, const dbl *d, const bat *bid);
+str CMDscience_cst_bat_atan2_flt(bat *ret, const flt *d, const bat *bid);
+str CMDscience_cst_bat_pow_dbl(bat *ret, const dbl *d, const bat *bid);
+str CMDscience_cst_bat_pow_flt(bat *ret, const flt *d, const bat *bid);
 str CMDsetHeartbeat(void *res, int *ev);
 str CMDsetName(str *rname, const bat *b, str *name);
 str CMDsetoid(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
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
@@ -128,6 +128,50 @@ str CMDscience_bat_cst_##FUNC##_##TYPE(b
        BBPkeepref(*ret = bn->batCacheid);                                      
                                \
        BBPunfix(b->batCacheid);                                                
                                        \
        return MAL_SUCCEED;                                                     
                                                \
+}                                                                              
                                                                \
+                                                                               
                                                                \
+str CMDscience_cst_bat_##FUNC##_##TYPE(bat *ret, const TYPE *d,                
        \
+                                                                          
const bat *bid)                                      \
+{                                                                              
                                                                \
+       BAT *b, *bn;                                                            
                                                \
+       TYPE *o, *p, *q;                                                        
                                                \
+                                                                               
                                                                \
+       if ((b = BATdescriptor(*bid)) == NULL) {                                
                        \
+               throw(MAL, #TYPE, RUNTIME_OBJECT_MISSING);                      
                        \
+       }                                                                       
                                                                \
+       voidresultBAT(TYPE_##TYPE, "batcalc." #FUNC);                           
                \
+       o = (TYPE *) Tloc(bn, BUNfirst(bn));                                    
                        \
+       p = (TYPE *) Tloc(b, BUNfirst(b));                                      
                                \
+       q = (TYPE *) Tloc(b, BUNlast(b));                                       
                                \
+                                                                               
                                                                \
+       errno = 0;                                                              
                                                        \
+       feclearexcept(FE_ALL_EXCEPT);                                           
                                \
+       if (b->T->nonil) {                                                      
                                                \
+               for (; p < q; o++, p++)                                         
                                        \
+                       *o = FUNC##SUFF(*d, *p);                                
                                        \
+       } else {                                                                
                                                        \
+               for (; p < q; o++, p++)                                         
                                        \
+                       *o = *p == TYPE##_nil ? TYPE##_nil : FUNC##SUFF(*d, 
*p);        \
+       }                                                                       
                                                                \
+       if (errno != 0 ||                                                       
                                                \
+               fetestexcept(FE_INVALID | FE_DIVBYZERO |                        
                        \
+                                        FE_OVERFLOW | FE_UNDERFLOW) != 0) {    
                        \
+               int e = errno;                                                  
                                                \
+               BBPunfix(bn->batCacheid);                                       
                                        \
+               throw(MAL, "batmmath." #FUNC, "Math exception: %s",             
                \
+                         strerror(e));                                         
                                                \
+       }                                                                       
                                                                \
+       BATsetcount(bn, BATcount(b));                                           
                                \
+       bn->tsorted = 0;                                                        
                                                \
+       bn->trevsorted = 0;                                                     
                                                \
+       bn->T->nil = b->T->nil;                                                 
                                        \
+       bn->T->nonil = b->T->nonil;                                             
                                        \
+       BATkey(BATmirror(bn),0);                                                
                                        \
+       if (!(bn->batDirty&2))                                                  
                                        \
+               BATsetaccess(bn, BAT_READ);                                     
                                        \
+       BBPkeepref(*ret = bn->batCacheid);                                      
                                \
+       BBPunfix(b->batCacheid);                                                
                                        \
+       return MAL_SUCCEED;                                                     
                                                \
 }
 
 #define scienceImpl(Operator)                                  \
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
@@ -53,6 +53,10 @@ scienceDef(floor)
 
 batmmath_export str CMDscience_bat_cst_atan2_dbl(bat *ret, const bat *bid, 
const dbl *d);
 batmmath_export str CMDscience_bat_cst_atan2_flt(bat *ret, const bat *bid, 
const flt *d);
+batmmath_export str CMDscience_cst_bat_atan2_dbl(bat *ret, const dbl *d, const 
bat *bid);
+batmmath_export str CMDscience_cst_bat_atan2_flt(bat *ret, const flt *d, const 
bat *bid);
 batmmath_export str CMDscience_bat_cst_pow_dbl(bat *ret, const bat *bid, const 
dbl *d);
 batmmath_export str CMDscience_bat_cst_pow_flt(bat *ret, const bat *bid, const 
flt *d);
+batmmath_export str CMDscience_cst_bat_pow_dbl(bat *ret, const dbl *d, const 
bat *bid);
+batmmath_export str CMDscience_cst_bat_pow_flt(bat *ret, const flt *d, const 
bat *bid);
 #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
@@ -106,7 +106,17 @@ module batmmath;
        command atan2(x:bat[:oid,:flt],y:flt):bat[:oid,:flt] 
        address CMDscience_bat_cst_atan2_flt;
        
+       command atan2(x:dbl,y:bat[:oid,:dbl]):bat[:oid,:dbl] 
+       address CMDscience_cst_bat_atan2_dbl;
+       command atan2(x:flt,y:bat[:oid,:flt]):bat[:oid,:flt] 
+       address CMDscience_cst_bat_atan2_flt;
+       
        command pow(x:bat[:oid,:dbl],y:dbl):bat[:oid,:dbl] 
        address CMDscience_bat_cst_pow_dbl;
        command pow(x:bat[:oid,:flt],y:flt):bat[:oid,:flt] 
        address CMDscience_bat_cst_pow_flt;
+       
+       command pow(x:dbl,y:bat[:oid,:dbl]):bat[:oid,:dbl] 
+       address CMDscience_cst_bat_pow_dbl;
+       command pow(x:flt,y:bat[:oid,:flt]):bat[:oid,:flt] 
+       address CMDscience_cst_bat_pow_flt;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to