Skip to content

Commit

Permalink
* added asin & acos
Browse files Browse the repository at this point in the history
* fixed typo in the tutorial
  • Loading branch information
vpisarev committed May 22, 2021
1 parent b917938 commit 8158c85
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions compiler/Parser.fx
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,15 @@ fun parse_simple_exp(ts: tklist_t, allow_mkrecord: bool): (tklist_t, exp_t)
| "__intrin_sin__" => IntrinMath(get_id("sin"))
| "__intrin_cos__" => IntrinMath(get_id("cos"))
| "__intrin_tan__" => IntrinMath(get_id("tan"))
| "__intrin_asin__" => IntrinMath(get_id("asin"))
| "__intrin_acos__" => IntrinMath(get_id("acos"))
| "__intrin_atan__" => IntrinMath(get_id("atan"))
| "__intrin_atan2__" => IntrinMath(get_id("atan2"))
| "__intrin_log__" => IntrinMath(get_id("log"))
| "__intrin_exp__" => IntrinMath(get_id("exp"))
| "__intrin_atanh__" => IntrinMath(get_id("atanh"))
| "__intrin_asinh__" => IntrinMath(get_id("asinh"))
| "__intrin_acosh__" => IntrinMath(get_id("acosh"))
| "__intrin_sinh__" => IntrinMath(get_id("sinh"))
| "__intrin_cosh__" => IntrinMath(get_id("cosh"))
| "__intrin_tanh__" => IntrinMath(get_id("tanh"))
Expand Down
1 change: 1 addition & 0 deletions doc/ficustut.md
Original file line number Diff line number Diff line change
Expand Up @@ -2314,6 +2314,7 @@ Ficus attempts to simplify the implementation of methods *3* and *4* by introduc
3. `A.wrap[i1, i2, ...]` is the array element access operation with wrapping. Each of `ij` is processed using the formula `ij mod Nj`, where `mod` is the *modulo* operation that gives unsigned division remainder. For example, in the case of 1D array `A.wrap[N1] ~ A[0], A.wrap[N1+1] ~ A[1], A.wrap[-1] ~ A[N1-1]`.
The border extrapolation operators have some limitations and special properties:
* They cannot be used with ranges; all indices must be scalar values.
* They can only be used with arrays which elements are scalar values (numbers, `bool`, `char`) or tuples of scalar values.
* They never throw an exception. `.clip` and `.wrap` will always return one of array elements, as long as the array is non-empty. If it's empty, zero element is returned (just like with .zero` operation).
Expand Down
2 changes: 1 addition & 1 deletion examples/fst.fx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ val a = [|for i <- 0:n {i+1}|]
for i <- 1:n {a[i] += a[i-1]}
println(f"triangular numbers: {a}")

@nothrow fun is_prime(n: int)
fun is_prime(n: int)
{
if n <= 1 {false} else if n % 2 == 0 {n == 2}
else {
Expand Down
8 changes: 8 additions & 0 deletions lib/Math.fx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ val DBL_EPSILON: double = @ccode {DBL_EPSILON}
@inline fun atan(x: double): double = __intrin_atan__(x)
@inline fun atan2(y: float, x: float): float = __intrin_atan2__(y, x)
@inline fun atan2(y: double, x: double): double = __intrin_atan2__(y, x)
@inline fun asin(x: float): float = __intrin_asin__(x)
@inline fun asin(x: double): double = __intrin_asin__(x)
@inline fun acos(x: float): float = __intrin_acos__(x)
@inline fun acos(x: double): double = __intrin_acos__(x)
@inline fun cos(x: float): float = __intrin_cos__(x)
@inline fun cos(x: double): double = __intrin_cos__(x)
@inline fun sin(x: float): float = __intrin_sin__(x)
Expand All @@ -47,6 +51,10 @@ val DBL_EPSILON: double = @ccode {DBL_EPSILON}

@inline fun atanh(x: float): float = __intrin_atanh__(x)
@inline fun atanh(x: double): double = __intrin_atanh__(x)
@inline fun asinh(x: float): float = __intrin_asinh__(x)
@inline fun asinh(x: double): double = __intrin_asinh__(x)
@inline fun acosh(x: float): float = __intrin_acosh__(x)
@inline fun acosh(x: double): double = __intrin_acosh__(x)
@inline fun cosh(x: float): float = __intrin_cosh__(x)
@inline fun cosh(x: double): double = __intrin_cosh__(x)
@inline fun sinh(x: float): float = __intrin_sinh__(x)
Expand Down

0 comments on commit 8158c85

Please sign in to comment.