diff options
author | Karen Sargsyan <karsar@ibms.sinica.edu.tw> | 2016-05-22 15:32:40 +0800 |
---|---|---|
committer | Karen Sargsyan <karsar@ibms.sinica.edu.tw> | 2016-05-22 15:32:40 +0800 |
commit | 87a6ab4f9ac7b2b2c0438a724bfe971ec9231714 (patch) | |
tree | 5f93f594307574fd32f2bc165b3dfa7715c627a8 | |
parent | 22527df1714c83e968913dabba4ba3ec81adc20c (diff) |
asin, acos, atan, atan2 added
-rw-r--r-- | include/urweb/urweb_cpp.h | 4 | ||||
-rw-r--r-- | lib/js/urweb.js | 16 | ||||
-rw-r--r-- | lib/ur/basis.urs | 4 | ||||
-rw-r--r-- | src/c/urweb.c | 16 | ||||
-rw-r--r-- | src/settings.sml | 5 | ||||
-rw-r--r-- | tests/math.ur | 8 |
6 files changed, 52 insertions, 1 deletions
diff --git a/include/urweb/urweb_cpp.h b/include/urweb/urweb_cpp.h index 2d834568..588b363a 100644 --- a/include/urweb/urweb_cpp.h +++ b/include/urweb/urweb_cpp.h @@ -394,6 +394,10 @@ uw_Basis_float uw_Basis_sin(struct uw_context *, uw_Basis_float); uw_Basis_float uw_Basis_cos(struct uw_context *, uw_Basis_float); uw_Basis_float uw_Basis_log(struct uw_context *, uw_Basis_float); uw_Basis_float uw_Basis_exp(struct uw_context *, uw_Basis_float); +uw_Basis_float uw_Basis_asin(struct uw_context *, uw_Basis_float); +uw_Basis_float uw_Basis_acos(struct uw_context *, uw_Basis_float); +uw_Basis_float uw_Basis_atan(struct uw_context *, uw_Basis_float); +uw_Basis_float uw_Basis_atan2(struct uw_context *, uw_Basis_float, uw_Basis_float); uw_Basis_string uw_Basis_atom(struct uw_context *, uw_Basis_string); uw_Basis_string uw_Basis_css_url(struct uw_context *, uw_Basis_string); diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 7842775b..55925df5 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -135,6 +135,22 @@ function log(n){ function exp(n){ return Math.exp(n); } + +function asin(n){ + return Math.asin(n); +} +function acos(n){ + return Math.acos(n); +} + +function atan(n){ + return Math.atan(n); +} + +function atan2(n, m){ + return Math.atan2(n, m); +} + // Time, represented as counts of microseconds since the epoch var time_format = "%c"; diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index 45a17eb1..c1ee28b3 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -160,6 +160,10 @@ val sin : float -> float val cos : float -> float val log : float -> float val exp : float -> float +val asin : float -> float +val acos : float -> float +val atan : float -> float +val atan2 : float -> float -> float (** * Time *) diff --git a/src/c/urweb.c b/src/c/urweb.c index edf55f21..c6f6220c 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -4541,6 +4541,22 @@ uw_Basis_float uw_Basis_exp(uw_context ctx, uw_Basis_float n) { return exp(n); } +uw_Basis_float uw_Basis_asin(uw_context ctx, uw_Basis_float n) { + return asin(n); +} + +uw_Basis_float uw_Basis_acos(uw_context ctx, uw_Basis_float n) { + return acos(n); +} + +uw_Basis_float uw_Basis_atan(uw_context ctx, uw_Basis_float n) { + return atan(n); +} + +uw_Basis_float uw_Basis_atan2(uw_context ctx, uw_Basis_float n, uw_Basis_float m) { + return atan2(n, m); +} + uw_Basis_string uw_Basis_atom(uw_context ctx, uw_Basis_string s) { char *p; diff --git a/src/settings.sml b/src/settings.sml index c0b5e0e6..4b326da8 100644 --- a/src/settings.sml +++ b/src/settings.sml @@ -342,7 +342,10 @@ val jsFuncsBase = basisM [("alert", "alert"), ("cos", "cos"), ("log", "log"), ("exp", "exp"), - + ("asin", "asin"), + ("acos", "acos"), + ("atan", "atan"), + ("atan2", "atan2"), ("now", "now"), ("timeToString", "showTime"), diff --git a/tests/math.ur b/tests/math.ur index 8892fffe..5f8843de 100644 --- a/tests/math.ur +++ b/tests/math.ur @@ -11,4 +11,12 @@ fun main () = return <xml><body> {[(log 0.1)]} <button value="Exp of 0.1!" onclick={fn _ => alert (show (exp 0.1))}/> {[(exp 0.1)]} + <button value="asin of 0.1!" onclick={fn _ => alert (show (asin 0.1))}/> + {[(asin 0.1)]} + <button value="acos of 0.1!" onclick={fn _ => alert (show (acos 0.1))}/> + {[(acos 0.1)]} + <button value="atan of 0.1!" onclick={fn _ => alert (show (atan 0.1))}/> + {[(atan 0.1)]} + <button value="atan2 of 0.1 and -0.2!" onclick={fn _ => alert (show (atan2 0.1 -0.2))}/> + {[(atan2 0.1 -0.2)]} </body></xml> |