List of usage examples for org.apache.commons.math3.util FastMath sinh
public static double sinh(double x)
From source file:net.sf.dsp4j.octave.packages.signal_1_0_11.Cheby1.java
private Cheby1(int n, double Rp, double[] W, boolean digital, boolean stop) { super(W, digital, stop); if (Rp < 0) { throw new IllegalArgumentException("cheby1: passband ripple must be positive decibels"); }/* w w w. j a v a2 s. c o m*/ this.Rp = Rp; //## Generate splane poles and zeros for the chebyshev type 1 filter final double C = 1; //# default cutoff frequency final double epsilon = FastMath.sqrt(FastMath.pow(10, (Rp / 10)) - 1); final double v0 = FastMath.asinh(1 / epsilon) / n; pole = new Complex[n]; for (int i = 0; i < n; i++) { final Complex p = new Complex(0, FastMath.PI * (2.0 * i - n + 1.0) / (2.0 * n)).exp(); //TODO richtig ??? pole[i] = new Complex(-FastMath.sinh(v0) * p.getReal()) .add(IMAG_ONE.multiply(FastMath.cosh(v0)).multiply(p.getImaginary())); } zero = new Complex[0]; //## compensate for amplitude at s=0 Complex gainC = OctaveBuildIn.prod(OctaveBuildIn.neg(pole)); //## if n is even, the ripple starts low, but if n is odd the ripple //## starts high. We must adjust the s=0 amplitude to compensate. if (n % 2 == 0) { gainC = gainC.divide(FastMath.pow(10, Rp / 20)); } gain = gainC.getReal(); }
From source file:net.sf.dsp4j.octave.packages.signal_1_0_11.Cheby2.java
private Cheby2(int n, double Rs, double[] W, boolean digital, boolean stop) { super(W, digital, stop); if (Rs < 0) { throw new IllegalArgumentException("cheby2: stopband attenuation must be positive decibels"); }// w w w .j a va 2 s. com this.Rs = Rs; //## Generate splane poles and zeros for the chebyshev type 2 filter //## From: Stearns, SD; David, RA; (1988). Signal Processing Algorithms. //## New Jersey: Prentice-Hall. int C = 1; //# default cutoff frequency final double lambda = FastMath.pow(10, Rs / 20); final double phi = FastMath.log(lambda + FastMath.sqrt(FastMath.pow(lambda, 2) - 1)) / n; final double[] theta = new double[n]; final double[] alpha = new double[n]; final double[] beta = new double[n]; for (int i = 0; i < n; i++) { theta[i] = FastMath.PI * (i + 0.5) / n; alpha[i] = -FastMath.sinh(phi) * FastMath.sin(theta[i]); beta[i] = FastMath.cosh(phi) * FastMath.cos(theta[i]); } final Complex IMAG_ONE = new Complex(0.0, 1); if (n % 2 != 0) { //## drop theta==pi/2 since it results in a zero at infinity zero = new Complex[n - 1]; for (int i = 0; i < n / 2; i++) { zero[i] = IMAG_ONE.multiply(C / FastMath.cos(theta[i])); } for (int i = n / 2 + 1; i < n; i++) { zero[i - 1] = IMAG_ONE.multiply(C / FastMath.cos(theta[i])); } } else { zero = new Complex[n]; for (int i = 0; i < n; i++) { zero[i] = IMAG_ONE.multiply(C / FastMath.cos(theta[i])); } } pole = new Complex[n]; for (int i = 0; i < n; i++) { pole[i] = new Complex(C / (FastMath.pow(alpha[i], 2) + FastMath.pow(beta[i], 2))) .multiply(new Complex(alpha[i], -beta[i])); } /* ## Compensate for amplitude at s=0 ## Because of the vagaries of floating point computations, the ## prod(pole)/prod(zero) sometimes comes out as negative and ## with a small imaginary component even though analytically ## the gain will always be positive, hence the abs(real(...)) */ gain = FastMath.abs(OctaveBuildIn.prod(pole).divide(OctaveBuildIn.prod(zero)).getReal()); }
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;// www .j a v a 2 s.c om 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:de.tuberlin.uebb.jbop.example.DSCompilerOnlyCompose.java
@Override public void cosh(final double[] operand, final double[] result) { // create the function value and derivatives final double[] function = new double[1 + order]; function[0] = FastMath.cosh(operand[0]); if (order > 0) { function[1] = FastMath.sinh(operand[0]); for (int i = 2; i <= order; ++i) { function[i] = function[i - 2]; }/*from ww w .j a v a2 s. c o m*/ } // apply function composition compose(operand, function, result); }
From source file:de.tuberlin.uebb.jbop.example.DSCompilerOnlyCompose.java
@Override public void sinh(final double[] operand, final double[] result) { // create the function value and derivatives final double[] function = new double[1 + order]; function[0] = FastMath.sinh(operand[0]); if (order > 0) { function[1] = FastMath.cosh(operand[0]); for (int i = 2; i <= order; ++i) { function[i] = function[i - 2]; }// w w w. j av a 2 s .c o m } // apply function composition compose(operand, function, result); }
From source file:de.tuberlin.uebb.jbop.example.DSCompiler.java
@Override @Optimizable// www .j av a2 s . com @StrictLoops public void cosh(final double[] operand, final double[] result) { // create the function value and derivatives final double[] function = new double[1 + order]; function[0] = FastMath.cosh(operand[0]); if (order > 0) { function[1] = FastMath.sinh(operand[0]); for (int i = 2; i <= order; ++i) { function[i] = function[i - 2]; } } // apply function composition compose(operand, function, result); }
From source file:de.tuberlin.uebb.jbop.example.DSCompiler.java
@Override @Optimizable//from ww w.j a v a 2s. co m @StrictLoops public void sinh(final double[] operand, final double[] result) { // create the function value and derivatives final double[] function = new double[1 + order]; function[0] = FastMath.sinh(operand[0]); if (order > 0) { function[1] = FastMath.cosh(operand[0]); for (int i = 2; i <= order; ++i) { function[i] = function[i - 2]; } } // apply function composition compose(operand, function, result); }
From source file:gamlss.distributions.JSUo.java
/** Computes the quantile (inverse cumulative probability) * function of this distribution./*from www .j a v a 2 s.c om*/ * @param p - value of cumulative probability * @param mu - value of mu distribution parameters * @param sigma - value of sigma distribution parameters * @param nu - value of nu distribution parameters * @param tau - value of tau distribution parameters * @param lowerTail - logical; if TRUE (default), probabilities * are P[X <= x] otherwise, P[X > x] * @param isLog - logical; if TRUE, probabilities p are given as log(p). * @return value of quantile function */ public final double qJSUo(final double p, final double mu, final double sigma, final double nu, final double tau, final boolean lowerTail, final boolean isLog) { // { if (any(sigma <= 0))stop(paste("sigma must be positive",)) if (sigma < 0) { System.err.println("sigma must be positive"); return -1.0; } //if (any(tau < 0)) stop(paste("tau must be positive", "\n", "")) if (tau < 0) { System.err.println("nu must be positive"); return -1.0; } double out = p; //if (log.p==TRUE) p <- exp(p) else p <- p if (isLog) { out = FastMath.exp(out); } //if (any(p <= 0)|any(p >= 1)) //stop(paste("p must be between 0 and 1", "\n", "")) if (out <= 0 || out >= 1) { System.err.println("p must be between 0 and 1"); } //if (lower.tail==TRUE) p <- p else p <- 1-p if (!lowerTail) { out = 1 - out; } //r <- qNO(p,0,1) //z <- sinh((r-nu)/tau) final double z = FastMath.sinh((noDist.inverseCumulativeProbability(out) - nu) / tau); //q <- mu+sigma*z out = mu + sigma * z; return out; }
From source file:org.apache.sysml.runtime.codegen.LibSpoofPrimitives.java
public static void vectSinhAdd(double[] a, double[] c, int ai, int ci, int len) { for (int j = ai; j < ai + len; j++, ci++) c[ci] += FastMath.sinh(a[j]); }
From source file:org.apache.sysml.runtime.codegen.LibSpoofPrimitives.java
public static void vectSinhAdd(double[] a, double[] c, int[] aix, int ai, int ci, int alen, int len) { for (int j = ai; j < ai + alen; j++) c[ci + aix[j]] += FastMath.sinh(a[j]); }