/** * Returns the {@link #norm()} value of this vector. * * @return <code>this.norm().doubleValue()</code>. */ public double normValue() { double normSquared = 0; for (int i = _dimension; --i >= 0;) { double values = _values[i]; normSquared += values * values; } return MathLib.sqrt(normSquared); }
/** * Returns the magnitude of this complex number, also referred to * as the "modulus" or "length". * * @return the magnitude of this complex number. */ public double magnitude() { return MathLib.sqrt(_real * _real + _imaginary * _imaginary); }
/** * Returns the positive square root of this number. * * @return <code>sqrt(this)</code>. */ public Float64 sqrt() { Float64 r = FACTORY.object(); r._value = MathLib.sqrt(this._value); return r; }
/** * Returns the arc sine of the specified value, * in the range of -<i>pi</i>/2 through <i>pi</i>/2. * * @param x the value whose arc sine is to be returned. * @return the arc sine in radians for the specified value. **/ public static double asin(double x) { if (x < -1.0 || x > 1.0) return MathLib.NaN; if (x == -1.0) return -HALF_PI; if (x == 1.0) return HALF_PI; return MathLib.atan(x / MathLib.sqrt(1.0 - x * x)); } /**/
/** * Returns the arc sine of the specified value, * in the range of -<i>pi</i>/2 through <i>pi</i>/2. * * @param x the value whose arc sine is to be returned. * @return the arc sine in radians for the specified value. **/ public static double asin(double x) { if (x < -1.0 || x > 1.0) return MathLib.NaN; if (x == -1.0) return -HALF_PI; if (x == 1.0) return HALF_PI; return MathLib.atan(x / MathLib.sqrt(1.0 - x * x)); }
/** * Returns the arc sine of the specified value, * in the range of -<i>pi</i>/2 through <i>pi</i>/2. * * @param x the value whose arc sine is to be returned. * @return the arc sine in radians for the specified value. **/ public static double asin(double x) { if (x < -1.0 || x > 1.0) return MathLib.NaN; if (x == -1.0) return -HALF_PI; if (x == 1.0) return HALF_PI; return MathLib.atan(x / MathLib.sqrt(1.0 - x * x)); }
/** * Returns the arc sine of the specified value, * in the range of -<i>pi</i>/2 through <i>pi</i>/2. * * @param x the value whose arc sine is to be returned. * @return the arc sine in radians for the specified value. **/ public static double asin(double x) { if (x < -1.0 || x > 1.0) return MathLib.NaN; if (x == -1.0) return -HALF_PI; if (x == 1.0) return HALF_PI; return MathLib.atan(x / MathLib.sqrt(1.0 - x * x)); }
/** * Returns the square root of this measure. * * @return <code>sqrt(this)</code> * */ public Amount<? extends Quantity> sqrt() { Amount<Q> m = Amount.newInstance(_unit.root(2)); if (this._isExact) { double sqrtDouble = MathLib.sqrt(_exactValue); long sqrtLong = (long) sqrtDouble; if (sqrtLong * sqrtLong == _exactValue) return m.setExact(sqrtLong); } double min = MathLib.sqrt(_minimum); double max = MathLib.sqrt(_maximum); m._isExact = false; m._minimum = (min < 0) ? min * INCREMENT : min * DECREMENT; m._maximum = (max < 0) ? max * DECREMENT : max * INCREMENT; return m; }
/** * Returns the root mean square value of the given inputs over the given * range. * * @param lowerFreqHz * >= 1 * @param upperFreqHz * < {@link #getUpperMeasurableFrequency()} * @param fftd * powers * * @return the rms value */ public double rms(int lowerFreqHz, int upperFreqHz, double... fftd) { assert fftd != null && fftd.length > 0; assert lowerFreqHz >= 1 && lowerFreqHz < upperFreqHz && upperFreqHz < getUpperMeasurableFrequency(); int divisor = fftd.length; double sum = 0; for (int i = lowerFreqHz; i <= upperFreqHz; i++) { sum += MathLib.pow(fftd[i], 2); } return MathLib.sqrt(new BigDecimal(sum).divide(new BigDecimal(divisor), 10, RoundingMode.HALF_UP).doubleValue()); }
/** * Returns one of the two square root of this complex number. * * @return <code>sqrt(this)</code>. */ public Complex sqrt() { Complex c = FACTORY.object(); double m = MathLib.sqrt(this.magnitude()); double a = this.argument() / 2.0; c._real = m * MathLib.cos(a); c._imaginary = m * MathLib.sin(a); return c; }