summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c50
1 files changed, 48 insertions, 2 deletions
diff --git a/functions.c b/functions.c
index 68dcbe7..e3020f9 100644
--- a/functions.c
+++ b/functions.c
@@ -70,7 +70,7 @@ fndyad dyadfunctiondefs[] = {
fnPower, /* * */
fnLogarithm, /* ⍟ */
0, /* ⌹ */
- 0, /* ○ */
+ fnCircular, /* ○ */
fnBinomial, /* ! */
fnDeal, /* ? */
fnResidue, /* | */
@@ -982,6 +982,52 @@ SCALAR_FUNCTION_2(fnLogarithm, 1, left->type,
break;
)
+SCALAR_FUNCTION_2(fnCircular, 1, AtypeFloat,
+ case AtypeFloat:{
+ double v = right->floatdata[i];
+ double r = 0;
+ switch((vlong)left->floatdata[i]){
+ case 0:
+ r = sqrt(1-v*v);
+ break;
+ case 1:
+ r = sin(v);
+ break;
+ case -1:
+ r = asin(v);
+ break;
+ case 2:
+ r = cos(v);
+ break;
+ case -2:
+ r = acos(v);
+ break;
+ case 3:
+ r = tan(v);
+ break;
+ case -3:
+ r = atan(v);
+ break;
+ case 4:
+ r = sqrt(1+v*v);
+ break;
+ case -4:
+ if(v == 0)
+ throwerror(nil, EDomain);
+ if(v == -1)
+ r = 0;
+ else
+ r = (v+1)*sqrt((v-1)/(v+1));
+ break;
+ default:
+ throwerror(nil, EDomain);
+ }
+ res->floatdata[i] = r;
+ }
+ break;
+)
+
+
SCALAR_FUNCTION_2(fnBinomial, 0, AtypeFloat,
case AtypeInt:
if(left->intdata[i] > right->intdata[i])
@@ -1845,4 +1891,4 @@ indexOfHelper(Array *left, Array *right, int interval)
freearray(rightshape);
freearray(right);
return result;
-} \ No newline at end of file
+}