Example usage for org.apache.commons.math3.util FastMath asin

List of usage examples for org.apache.commons.math3.util FastMath asin

Introduction

In this page you can find the example usage for org.apache.commons.math3.util FastMath asin.

Prototype

public static double asin(double x) 

Source Link

Document

Compute the arc sine of a number.

Usage

From source file:gentracklets.conversions.java

public static double[] geo2radec(PVCoordinates obj, TopocentricFrame staF, Frame inertialFrame,
        AbsoluteDate epoch) {/*from w  ww  .ja  va2s. c  o  m*/

    Vector3D rho = new Vector3D(0, 0, 0);

    try {
        rho = obj.getPosition().subtract(staF.getPVCoordinates(epoch, inertialFrame).getPosition());
    } catch (OrekitException ex) {
        Logger.getLogger(conversions.class.getName()).log(Level.SEVERE, null, ex);
    }

    double rho_mag = rho.getNorm();
    double DEC = FastMath.asin(rho.getZ() / rho_mag);
    double cosRA = 0.0;
    double sinRA = 0.0;
    double RA = 0.0;

    Vector3D v_site = new Vector3D(0, 0, 0);
    try {
        v_site = staF.getPVCoordinates(epoch, inertialFrame).getVelocity();
    } catch (OrekitException ex) {
        Logger.getLogger(conversions.class.getName()).log(Level.SEVERE, null, ex);
    }

    Vector3D rhoDot = obj.getVelocity().subtract(v_site);

    if (FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2)) != 0) {
        cosRA = rho.getX() / FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2));
        sinRA = rho.getY() / FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2));
        RA = FastMath.atan2(sinRA, cosRA);
        if (RA <= 0) {
            RA = RA + 2 * FastMath.PI;
        }
    } else {
        sinRA = rhoDot.getY() / FastMath.sqrt(FastMath.pow(rhoDot.getX(), 2) + FastMath.pow(rhoDot.getY(), 2));
        cosRA = rhoDot.getX() / FastMath.sqrt(FastMath.pow(rhoDot.getX(), 2) + FastMath.pow(rhoDot.getY(), 2));
        RA = FastMath.atan2(sinRA, cosRA);
        if (RA <= 0) {
            RA = RA + 2 * FastMath.PI;
        }
    }

    double rhoDot_mag = rho.dotProduct(rhoDot) / rho_mag;
    double RAdot = (rhoDot.getX() * rho.getY() - rhoDot.getY() * rho.getX())
            / (-1 * FastMath.pow(rho.getY(), 2) - FastMath.pow(rho.getX(), 2));
    double DECdot = (rhoDot.getZ() - rhoDot_mag * FastMath.sin(DEC))
            / FastMath.sqrt(FastMath.pow(rho.getX(), 2) + FastMath.pow(rho.getY(), 2));

    double[] out = { RA, RAdot, DEC, DECdot, rho_mag, rhoDot_mag };

    return out;
}

From source file:cc.redberry.core.number.ComplexUtils.java

/**
 * Numeric arcsine form complex number./*ww w  . ja  v a2s .  com*/
 *
 * @param complex argument
 * @return arcsine
 */
public static Complex arcsin(Complex complex) {
    if (complex.isReal()) {
        double x = complex.getReal().doubleValue();
        if (x <= 1.0 && x >= -1)
            return new Complex(FastMath.asin(complex.getReal().doubleValue()));
    }
    return new Complex(new org.apache.commons.math3.complex.Complex(complex.getReal().doubleValue(),
            complex.getImaginary().doubleValue()).asin());
}

From source file:net.nicoulaj.benchmarks.math.DoubleAsin.java

@GenerateMicroBenchmark
public void commonsmath(BlackHole hole) {
    for (int i = 0; i < data.length - 1; i++)
        hole.consume(FastMath.asin(data[i]));
}

From source file:com.bc.jexp.impl.DefaultNamespace.java

private void registerDefaultFunctions() {
    registerFunction(new AbstractFunction.D("sin", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return FastMath.sin(args[0].evalD(env));
        }/*w  ww.jav  a2  s .  c  om*/
    });
    registerFunction(new AbstractFunction.D("cos", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return FastMath.cos(args[0].evalD(env));
        }
    });
    registerFunction(new AbstractFunction.D("tan", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return FastMath.tan(args[0].evalD(env));
        }
    });
    registerFunction(new AbstractFunction.D("asin", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return FastMath.asin(args[0].evalD(env));
        }
    });
    registerFunction(new AbstractFunction.D("acos", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return FastMath.acos(args[0].evalD(env));
        }
    });
    registerFunction(new AbstractFunction.D("atan", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return FastMath.atan(args[0].evalD(env));
        }
    });
    registerFunction(new AbstractFunction.D("atan2", 2) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return Math.atan2(args[0].evalD(env), args[1].evalD(env));
        }
    });
    registerFunction(new AbstractFunction.D("log", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return Math.log(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("log10", 1) {
        public double evalD(EvalEnv env, Term[] args) throws EvalException {
            return Math.log10(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("exp", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return FastMath.exp(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("exp10", 1) {

        public double evalD(EvalEnv env, Term[] args) throws EvalException {
            return FastMath.pow(10.0, args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("sqr", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            double v = args[0].evalD(env);
            return v * v;
        }
    });

    registerFunction(new AbstractFunction.D("sqrt", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return Math.sqrt(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("pow", 2) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return FastMath.pow(args[0].evalD(env), args[1].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.I("min", 2) {

        public int evalI(final EvalEnv env, final Term[] args) {
            return Math.min(args[0].evalI(env), args[1].evalI(env));
        }
    });

    registerFunction(new AbstractFunction.D("min", 2) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return Math.min(args[0].evalD(env), args[1].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.I("max", 2) {

        public int evalI(final EvalEnv env, final Term[] args) {
            return Math.max(args[0].evalI(env), args[1].evalI(env));
        }
    });

    registerFunction(new AbstractFunction.D("max", 2) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return Math.max(args[0].evalD(env), args[1].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("floor", 1) {
        public double evalD(EvalEnv env, Term[] args) throws EvalException {
            return Math.floor(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("round", 1) {
        public double evalD(EvalEnv env, Term[] args) throws EvalException {
            return Math.round(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("ceil", 1) {
        public double evalD(EvalEnv env, Term[] args) throws EvalException {
            return Math.ceil(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("rint", 1) {
        public double evalD(EvalEnv env, Term[] args) throws EvalException {
            return Math.rint(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.I("sign", 1) {

        public int evalI(final EvalEnv env, final Term[] args) {
            return ExtMath.sign(args[0].evalI(env));
        }
    });

    registerFunction(new AbstractFunction.D("sign", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return ExtMath.sign(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.I("abs", 1) {

        public int evalI(final EvalEnv env, final Term[] args) {
            return Math.abs(args[0].evalI(env));
        }
    });

    registerFunction(new AbstractFunction.D("abs", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return Math.abs(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("deg", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return Math.toDegrees(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("rad", 1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            return Math.toRadians(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("ampl", 2) {

        public double evalD(final EvalEnv env, final Term[] args) {
            final double a = args[0].evalD(env);
            final double b = args[1].evalD(env);
            return Math.sqrt(a * a + b * b);
        }
    });

    registerFunction(new AbstractFunction.D("phase", 2) {

        public double evalD(final EvalEnv env, final Term[] args) {
            final double a = args[0].evalD(env);
            final double b = args[1].evalD(env);
            return Math.atan2(b, a);
        }
    });

    registerFunction(new AbstractFunction.B("feq", 2) {
        public boolean evalB(EvalEnv env, Term[] args) throws EvalException {
            final double x1 = args[0].evalD(env);
            final double x2 = args[1].evalD(env);
            return ExtMath.feq(x1, x2, EPS);
        }
    });

    registerFunction(new AbstractFunction.B("feq", 3) {
        public boolean evalB(EvalEnv env, Term[] args) throws EvalException {
            final double x1 = args[0].evalD(env);
            final double x2 = args[1].evalD(env);
            final double eps = args[2].evalD(env);
            return ExtMath.feq(x1, x2, eps);
        }
    });

    registerFunction(new AbstractFunction.B("fneq", 2) {
        public boolean evalB(EvalEnv env, Term[] args) throws EvalException {
            final double x1 = args[0].evalD(env);
            final double x2 = args[1].evalD(env);
            return ExtMath.fneq(x1, x2, EPS);
        }
    });

    registerFunction(new AbstractFunction.B("fneq", 3) {
        public boolean evalB(EvalEnv env, Term[] args) throws EvalException {
            final double x1 = args[0].evalD(env);
            final double x2 = args[1].evalD(env);
            final double eps = args[2].evalD(env);
            return ExtMath.fneq(x1, x2, eps);
        }
    });

    registerFunction(new AbstractFunction.B("inf", 1) {
        public boolean evalB(EvalEnv env, Term[] args) throws EvalException {
            return Double.isInfinite(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.B("nan", 1) {
        public boolean evalB(EvalEnv env, Term[] args) throws EvalException {
            return Double.isNaN(args[0].evalD(env));
        }
    });

    registerFunction(new AbstractFunction.D("distance", -1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            double sqrSum = 0.0;
            final int n = args.length / 2;
            for (int i = 0; i < n; i++) {
                final double v = args[i + n].evalD(env) - args[i].evalD(env);
                sqrSum += v * v;
            }
            return Math.sqrt(sqrSum);
        }
    });

    registerFunction(new AbstractFunction.D("distance_deriv", -1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            double sqrSum = 0.0;
            final int n = args.length / 2;
            for (int i = 0; i < n - 1; i++) {
                final double v1 = args[i + 1].evalD(env) - args[i].evalD(env);
                final double v2 = args[i + n + 1].evalD(env) - args[i + n].evalD(env);
                sqrSum += (v1 - v2) * (v1 - v2);
            }
            return Math.sqrt(sqrSum);
        }
    });

    registerFunction(new AbstractFunction.D("distance_integ", -1) {

        public double evalD(final EvalEnv env, final Term[] args) {
            double sqrSum = 0.0;
            double v1Sum = 0.0;
            double v2Sum = 0.0;
            final int n = args.length / 2;
            for (int i = 0; i < n; i++) {
                v1Sum += args[i].evalD(env);
                v2Sum += args[i + n].evalD(env);
                sqrSum += (v2Sum - v1Sum) * (v2Sum - v1Sum);
            }
            return Math.sqrt(sqrSum);
        }
    });

    registerFunction(new AbstractFunction.B("inrange", -1) {

        public boolean evalB(final EvalEnv env, final Term[] args) {
            final int n1 = args.length / 3;
            final int n2 = n1 + args.length / 3;
            for (int i = 0; i < n1; i++) {
                final double v = args[i].evalD(env);
                final double v1 = args[i + n1].evalD(env);
                final double v2 = args[i + n2].evalD(env);
                if (v < v1 || v > v2) {
                    return false;
                }
            }
            return true;
        }
    });

    registerFunction(new AbstractFunction.B("inrange_deriv", -1) {

        public boolean evalB(final EvalEnv env, final Term[] args) {
            final int n1 = args.length / 3;
            final int n2 = 2 * n1;
            for (int i = 0; i < n1 - 1; i++) {
                final double v = args[i + 1].evalD(env) - args[i].evalD(env);
                final double v1 = args[i + n1 + 1].evalD(env) - args[i + n1].evalD(env);
                final double v2 = args[i + n2 + 1].evalD(env) - args[i + n2].evalD(env);
                if (v < v1 || v > v2) {
                    return false;
                }
            }
            return true;
        }
    });

    registerFunction(new AbstractFunction.B("inrange_integ", -1) {

        public boolean evalB(final EvalEnv env, final Term[] args) {
            final int n1 = args.length / 3;
            final int n2 = 2 * n1;
            double vSum = 0.0;
            double v1Sum = 0.0;
            double v2Sum = 0.0;
            for (int i = 0; i < n1; i++) {
                vSum += args[i].evalD(env);
                v1Sum += args[i + n1].evalD(env);
                v2Sum += args[i + n2].evalD(env);
                if (vSum < v1Sum || vSum > v2Sum) {
                    return false;
                }
            }
            return true;
        }
    });

}

From source file:lambertmrev.Lambert.java

public double x2tof2(double x, int N, double m_lambda) {
    double a = 1.0 / (1.0 - x * x);
    double tof;/*from ww  w .ja v  a 2  s . co  m*/
    if (a > 0) //ellipse
    {
        double alfa = 2.0 * FastMath.acos(x);
        double beta = 2.0 * FastMath.asin(FastMath.sqrt(m_lambda * m_lambda / a));
        if (m_lambda < 0.0)
            beta = -beta;
        tof = ((a * FastMath.sqrt(a)
                * ((alfa - FastMath.sin(alfa)) - (beta - FastMath.sin(beta)) + 2.0 * FastMath.PI * N)) / 2.0);
    } else {
        double alfa = 2.0 * FastMath.acosh(x);
        double beta = 2.0 * FastMath.asinh(FastMath.sqrt(-m_lambda * m_lambda / a));
        if (m_lambda < 0.0)
            beta = -beta;
        tof = (-a * FastMath.sqrt(-a) * ((beta - FastMath.sinh(beta)) - (alfa - FastMath.sinh(alfa))) / 2.0);
    }
    return tof;
}

From source file:com.ibm.bi.dml.runtime.functionobjects.Builtin.java

public double execute(double in) throws DMLRuntimeException {
    switch (bFunc) {
    case SIN:// ww w.  j av  a 2  s . c  o  m
        return FASTMATH ? FastMath.sin(in) : Math.sin(in);
    case COS:
        return FASTMATH ? FastMath.cos(in) : Math.cos(in);
    case TAN:
        return FASTMATH ? FastMath.tan(in) : Math.tan(in);
    case ASIN:
        return FASTMATH ? FastMath.asin(in) : Math.asin(in);
    case ACOS:
        return FASTMATH ? FastMath.acos(in) : Math.acos(in);
    case ATAN:
        return Math.atan(in); //faster in Math
    case CEIL:
        return FASTMATH ? FastMath.ceil(in) : Math.ceil(in);
    case FLOOR:
        return FASTMATH ? FastMath.floor(in) : Math.floor(in);
    case LOG:
        //if ( in <= 0 )
        //   throw new DMLRuntimeException("Builtin.execute(): logarithm can only be computed for non-negative numbers (input = " + in + ").");
        // for negative numbers, Math.log will return NaN
        return FASTMATH ? FastMath.log(in) : Math.log(in);
    case LOG_NZ:
        return (in == 0) ? 0 : FASTMATH ? FastMath.log(in) : Math.log(in);

    case ABS:
        return Math.abs(in); //no need for FastMath

    case SQRT:
        //if ( in < 0 )
        //   throw new DMLRuntimeException("Builtin.execute(): squareroot can only be computed for non-negative numbers (input = " + in + ").");
        return Math.sqrt(in); //faster in Math

    case PLOGP:
        if (in == 0.0)
            return 0.0;
        else if (in < 0)
            return Double.NaN;
        else
            return (in * (FASTMATH ? FastMath.log(in) : Math.log(in)));

    case EXP:
        return FASTMATH ? FastMath.exp(in) : Math.exp(in);

    case ROUND:
        return Math.round(in); //no need for FastMath

    case SPROP:
        //sample proportion: P*(1-P)
        return in * (1 - in);

    case SIGMOID:
        //sigmoid: 1/(1+exp(-x))
        return FASTMATH ? 1 / (1 + FastMath.exp(-in)) : 1 / (1 + Math.exp(-in));

    case SELP:
        //select positive: x*(x>0)
        return (in > 0) ? in : 0;

    default:
        throw new DMLRuntimeException("Builtin.execute(): Unknown operation: " + bFunc);
    }
}

From source file:fr.cs.examples.bodies.Phasing.java

/** Guess an initial orbit from theoretical model.
 * @param date orbit date/* w ww .  j av  a 2  s  .c o  m*/
 * @param frame frame to use for defining orbit
 * @param nbOrbits number of orbits in the phasing cycle
 * @param nbDays number of days in the phasing cycle
 * @param latitude reference latitude for Sun synchronous orbit
 * @param ascending if true, crossing latitude is from South to North
 * @param mst desired mean solar time at reference latitude crossing
 * @return an initial guess of Earth phased, Sun synchronous orbit
 * @exception OrekitException if mean solar time cannot be computed
 */
private CircularOrbit guessOrbit(AbsoluteDate date, Frame frame, int nbOrbits, int nbDays, double latitude,
        boolean ascending, double mst) throws OrekitException {

    double mu = gravityField.getMu();
    NormalizedSphericalHarmonicsProvider.NormalizedSphericalHarmonics harmonics = gravityField.onDate(date);

    // initial semi major axis guess based on Keplerian period
    double period0 = (nbDays * Constants.JULIAN_DAY) / nbOrbits;
    double n0 = 2 * FastMath.PI / period0;
    double a0 = FastMath.cbrt(mu / (n0 * n0));

    // initial inclination guess based on ascending node drift due to J2
    double[][] unnormalization = GravityFieldFactory.getUnnormalizationFactors(3, 0);
    double j2 = -unnormalization[2][0] * harmonics.getNormalizedCnm(2, 0);
    double j3 = -unnormalization[3][0] * harmonics.getNormalizedCnm(3, 0);
    double raanRate = 2 * FastMath.PI / Constants.JULIAN_YEAR;
    double ae = gravityField.getAe();
    double i0 = FastMath.acos(-raanRate * a0 * a0 / (1.5 * ae * ae * j2 * n0));

    // initial eccentricity guess based on J2 and J3
    double ex0 = 0;
    double ey0 = -j3 * ae * FastMath.sin(i0) / (2 * a0 * j2);

    // initial ascending node guess based on mean solar time
    double alpha0 = FastMath.asin(FastMath.sin(latitude) / FastMath.sin(i0));
    if (!ascending) {
        alpha0 = FastMath.PI - alpha0;
    }
    double h = meanSolarTime(
            new CircularOrbit(a0, ex0, ey0, i0, 0.0, alpha0, PositionAngle.TRUE, frame, date, mu));
    double raan0 = FastMath.PI * (mst - h) / 12.0;

    return new CircularOrbit(a0, ex0, ey0, i0, raan0, alpha0, PositionAngle.TRUE, frame, date, mu);

}

From source file:de.tuberlin.uebb.jbop.example.DSCompilerOnlyCompose.java

@Override
public void asin(final double[] operand, final double[] result) {

    // create the function value and derivatives
    final double[] function = new double[1 + order];
    final double x = operand[0];
    function[0] = FastMath.asin(x);
    if (order > 0) {
        // the nth order derivative of asin has the form:
        // dn(asin(x)/dxn = P_n(x) / [1 - x^2]^((2n-1)/2)
        // where P_n(x) is a degree n-1 polynomial with same parity as n-1
        // P_1(x) = 1, P_2(x) = x, P_3(x) = 2x^2 + 1 ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (1-x^2) P_(n-1)'(x) + (2n-3) x P_(n-1)(x)
        // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
        final double[] p = new double[order];
        p[0] = 1;//from  ww w  .  j  a v  a 2s.  c o m
        final double x2 = x * x;
        final double f = 1.0 / (1 - x2);
        double coeff = FastMath.sqrt(f);
        function[1] = coeff * p[0];
        for (int n = 2; n <= order; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n - 1] = (n - 1) * p[n - 2];
            for (int k = n - 1; k >= 0; k -= 2) {
                v = (v * x2) + p[k];
                if (k > 2) {
                    p[k - 2] = ((k - 1) * p[k - 1]) + (((2 * n) - k) * p[k - 3]);
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 0) {
                v *= x;
            }

            coeff *= f;
            function[n] = coeff * v;

        }
    }

    // apply function composition
    compose(operand, function, result);

}

From source file:de.tuberlin.uebb.jbop.example.DSCompiler.java

@Override
@Optimizable/* w  w  w .jav a 2 s. com*/
@StrictLoops
public void asin(final double[] operand, final double[] result) {

    // create the function value and derivatives
    final double[] function = new double[1 + order];
    final double x = operand[0];
    function[0] = FastMath.asin(x);
    if (order > 0) {
        // the nth order derivative of asin has the form:
        // dn(asin(x)/dxn = P_n(x) / [1 - x^2]^((2n-1)/2)
        // where P_n(x) is a degree n-1 polynomial with same parity as n-1
        // P_1(x) = 1, P_2(x) = x, P_3(x) = 2x^2 + 1 ...
        // the general recurrence relation for P_n is:
        // P_n(x) = (1-x^2) P_(n-1)'(x) + (2n-3) x P_(n-1)(x)
        // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array
        final double[] p = new double[order];
        p[0] = 1;
        final double x2 = x * x;
        final double f = 1.0 / (1 - x2);
        double coeff = FastMath.sqrt(f);
        function[1] = coeff * p[0];
        for (int n = 2; n <= order; ++n) {

            // update and evaluate polynomial P_n(x)
            double v = 0;
            p[n - 1] = (n - 1) * p[n - 2];
            for (int k = n - 1; k >= 0; k -= 2) {
                v = (v * x2) + p[k];
                if (k > 2) {
                    p[k - 2] = ((k - 1) * p[k - 1]) + (((2 * n) - k) * p[k - 3]);
                } else if (k == 2) {
                    p[0] = p[1];
                }
            }
            if ((n & 0x1) == 0) {
                v *= x;
            }

            coeff *= f;
            function[n] = coeff * v;

        }
    }

    // apply function composition
    compose(operand, function, result);

}

From source file:org.apache.sysml.runtime.codegen.LibSpoofPrimitives.java

public static void vectAsinAdd(double[] a, double[] c, int ai, int ci, int len) {
    for (int j = ai; j < ai + len; j++, ci++)
        c[ci] += FastMath.asin(a[j]);
}