Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions eo-runtime/src/main/eo/ms/acos.eo
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
+alias ms.abs
+alias ms.pi
+alias ms.real
+architect yegor256@gmail.com
+home https://github.com/objectionary/eo
+package ms
+rt jvm org.eolang:eo-runtime:0.0.0
+rt node eo2js-runtime:0.0.0
+version 0.0.0
+spdx SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
+spdx SPDX-License-Identifier: MIT

# Calculates arc cosine of a `num` as `org.eolang.number`.
[num] > acos ?
Comment thread
coderabbitai[bot] marked this conversation as resolved.
# Tests that arccosine of -1 equals pi.
[] +> tests-arccos-negative-one-test
eq. +> @
acos -1.0
pi

# Tests that arccosine of 0 equals pi/2.
[] +> tests-arccos-zero-test
eq. +> @
acos 0
div.
pi
2

# Tests that arccosine of 1 equals zero.
[] +> tests-arccos-one-test
eq. +> @
acos 1.0
0

# Tests acos calculation for a positive value inside [-1,1].
[] +> tests-arccos-positive-calculated-test
lt. +> @
abs
real
minus.
acos 0.6
0.927295
0.000001

# Tests acos calculation for a negative value inside [-1,1].
[] +> tests-arccos-negative-calculated-test
lt. +> @
abs
real
minus.
acos -0.6
2.214297
0.000001

# Tests that acos returns NaN for a positive value outside [-1,1].
[] +> tests-arccos-nan-positive-value-test
is-nan. +> @
acos 2.0

# Tests that acos returns NaN for a negative value outside [-1,1].
[] +> tests-arccos-nan-negative-value-test
is-nan. +> @
acos -2.0

# Tests that arccosine of NaN is NaN.
[] +> tests-arccos-nan-input
is-nan. +> @
acos nan

# Tests that arccosine of positive-infinity is NaN.
[] +> tests-arccos-positive-infinity
is-nan. +> @
acos positive-infinity

# Tests that arccosine of negative-infinity is NaN.
[] +> tests-arccos-negative-infinity
is-nan. +> @
acos negative-infinity
64 changes: 0 additions & 64 deletions eo-runtime/src/main/eo/ms/real.eo
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
+alias ms.abs
+alias ms.e
+alias ms.pi
+alias ms.pow
+architect yegor256@gmail.com
+home https://github.com/objectionary/eo
Expand Down Expand Up @@ -30,13 +29,6 @@
# https://github.com/objectionary/eo/issues/4751
[] > ln ?

# Calculates arc cosine of a `num` as `org.eolang.number`.
# @todo #4751:15min Move `acos` to a separate object with it's tests.
# It's atom, don't forget change `EOreal$EOacos`.
# For more information check this ticket:
# https://github.com/objectionary/eo/issues/4751
[] > acos ?

# Tests mathematical operation functionality.
[] +> tests-positive-float-to-the-pow-of-positive-infinity-is-positive-infinity
eq. +> @
Expand Down Expand Up @@ -210,59 +202,3 @@
ln.
real 20
2.995732273553991

# Tests that arccosine of -1 equals pi.
[] +> tests-arccos-negative-one-test
eq. +> @
acos.
real -1.0
pi

# Tests that arccosine of 0 equals pi/2.
[] +> tests-arccos-zero-test
eq. +> @
acos.
real 0
div.
pi
2

# Tests that arccosine of 1 equals zero.
[] +> tests-arccos-one-test
eq. +> @
acos.
real 1.0
0

# Tests mathematical operation functionality.
[] +> tests-arccos-positive-calculated-test
lt. +> @
abs
real
minus.
acos.
real 0.6
0.927295
0.000001

# Tests mathematical operation functionality.
[] +> tests-arccos-negative-calculated-test
lt. +> @
abs
real
minus.
acos.
real -0.6
2.214297
0.000001

# Tests mathematical operation functionality.
[] +> tests-arccos-nan-positive-value-test
is-nan. +> @
acos.
real 2.0

# Tests mathematical operation functionality.
[] +> tests-arccos-nan-negative-value-test
is-nan. +> @
(real -2.0).acos
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,33 @@
*/
package org.eolang.EOms; // NOPMD

import org.eolang.AtVoid;
import org.eolang.Atom;
import org.eolang.Dataized;
import org.eolang.PhDefault;
import org.eolang.Phi;
import org.eolang.XmirObject;
Comment thread
eshabakhov marked this conversation as resolved.

/**
* Real.acos.
* Acos.
*
* @since 0.40
* @checkstyle TypeNameCheck (100 lines)
*/
@XmirObject(oname = "real.acos")
@SuppressWarnings("PMD.AvoidDollarSigns")
public final class EOreal$EOacos extends PhDefault implements Atom {
@XmirObject(oname = "acos")
public final class EOacos extends PhDefault implements Atom {
/**
* Ctor.
*/
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public EOacos() {
this.add("num", new AtVoid("num"));
}

@Override
public Phi lambda() {
return new ToPhi(
Math.acos(new Dataized(this.take(Phi.RHO)).asNumber())
Math.acos(new Dataized(this.take("num")).asNumber())
);
}
}
Loading