List of usage examples for org.apache.commons.math3.complex Complex ONE
Complex ONE
To view the source code for org.apache.commons.math3.complex Complex ONE.
Click Source Link
From source file:com.wwidesigner.math.StateVector.java
/** * @return a state vector representing an ideal open end. *//*from w w w . j a v a2 s . c om*/ public static StateVector OpenEnd() { // At an open end, pressure is zero. return new StateVector(Complex.ZERO, Complex.ONE); }
From source file:com.wwidesigner.math.StateVector.java
/** * @return a state vector representing an ideal closed end. *//* w ww .j a va 2s .co m*/ public static StateVector ClosedEnd() { // At a closed end, acoustic flow is zero. return new StateVector(Complex.ONE, Complex.ZERO); }
From source file:net.sf.dsp4j.octave_3_2_4.m.polynomial.Poly.java
public static Complex[] poly(Complex[] x) { Complex[] y;//from ww w. jav a2 s . c om if (x.length == 0) { return new Complex[] { Complex.ONE }; } y = new Complex[x.length + 1]; Arrays.fill(y, Complex.ZERO); y[0] = Complex.ONE; for (int j = 1; j < y.length; j++) { for (int i = j; i >= 1; i--) { y[i] = y[i].subtract(x[j - 1].multiply(y[i - 1])); } } return y; }
From source file:com.wwidesigner.math.TransferMatrix.java
/** * Simple 2x2 complex matrix. Here e.g. PU represents the component of the * output pressure that depends on the input volume flow, etc. * The default matrix is the identity matrix. *//*from www . ja va 2 s . c o m*/ public TransferMatrix() { mPP = Complex.ONE; mPU = Complex.ZERO; mUP = Complex.ZERO; mUU = Complex.ONE; }
From source file:com.wwidesigner.geometry.calculation.FluteMouthpieceCalculator.java
@Override protected TransferMatrix calcTransferMatrix(Mouthpiece mouthpiece, double waveNumber, PhysicalParameters parameters) { if (mouthpiece.isPressureNode()) { // Resort to default if this is not a flow-node mouthpiece. return super.calcTransferMatrix(mouthpiece, waveNumber, parameters); }/*from ww w. java 2s .com*/ double freq = parameters.calcFrequency(waveNumber); Complex Zwindow = calcZ(mouthpiece, freq, parameters); return new TransferMatrix(Complex.ONE, Zwindow, Complex.ZERO, Complex.ONE); }
From source file:com.wwidesigner.geometry.calculation.SimpleFippleMouthpieceCalculator.java
@Override protected TransferMatrix calcTransferMatrix(Mouthpiece mouthpiece, double waveNumber, PhysicalParameters parameters) { if (mouthpiece.isPressureNode()) { // Resort to default if this is not a flow-node mouthpiece. return super.calcTransferMatrix(mouthpiece, waveNumber, parameters); }/*from w w w . j av a 2 s .c o m*/ double freq = parameters.calcFrequency(waveNumber); Complex Zwindow = calcZ(mouthpiece, freq, parameters); /* List<BoreSection> headspace = mouthpiece.getHeadspace(); if (headspace.size() > 0) { StateVector windowState = new StateVector(Zwindow, Complex.ONE); StateVector headspaceState = calcHeadspace_compliance(headspace, waveNumber, parameters); // Assume the bore sees the window impedance in parallel with // the headspace impedance. windowState = windowState.parallel(headspaceState); Zwindow = windowState.getImpedance(); } */ return new TransferMatrix(Complex.ONE, Zwindow, Complex.ZERO, Complex.ONE); }
From source file:com.wwidesigner.math.TransferMatrix.java
public static TransferMatrix makeIdentity() { return new TransferMatrix(Complex.ONE, Complex.ZERO, Complex.ZERO, Complex.ONE); }
From source file:com.wwidesigner.geometry.calculation.DefaultHoleCalculator.java
public TransferMatrix calcTransferMatrix_2010(Hole hole, boolean isOpen, double waveNumber, PhysicalParameters parameters) { double radius = mFudgeFactor * hole.getDiameter() / 2; double boreRadius = hole.getBoreDiameter() / 2; Complex Zs = null;/*from w w w. j a v a 2 s . c o m*/ Complex Za = null; // double Z0 = parameters.calcZ0(boreRadius); double Z0h = parameters.calcZ0(radius); double delta = radius / boreRadius; double tm = (radius * delta / 8.) * (1. + 0.207 * delta * delta * delta); double te = hole.getHeight() + tm; double ta = 0.; // Complex Gamma = Complex.I.multiply(wave_number); if (isOpen) // open { double kb = waveNumber * radius; double ka = waveNumber * boreRadius; double xhi = 0.25 * kb * kb; ta = (-0.35 + 0.06 * Math.tanh(2.7 * hole.getHeight() / radius)) * radius * delta * delta * delta * delta; Complex Zr = Complex.I.multiply(waveNumber * 0.61 * radius).add(xhi); Complex Zo = (Zr.multiply(Math.cos(waveNumber * te)).add(Complex.I.multiply(Math.sin(waveNumber * te)))) .divide(Complex.I.multiply(Zr).multiply(Math.sin(waveNumber * te)) .add(Math.cos(waveNumber * te))); double ti = radius * (0.822 - 0.10 * delta - 1.57 * delta * delta + 2.14 * delta * delta * delta - 1.6 * delta * delta * delta * delta + 0.50 * delta * delta * delta * delta * delta) * (1. + (1. - 4.56 * delta + 6.55 * delta * delta) * (0.17 * ka + 0.92 * ka * ka + 0.16 * ka * ka * ka - 0.29 * ka * ka * ka * ka)); Zs = Complex.I.multiply(waveNumber * ti).add(Zo).multiply(Z0h); } else { ta = (-0.12 - 0.17 * Math.tanh(2.4 * hole.getHeight() / radius)) * radius * delta * delta * delta * delta; Zs = Complex.valueOf(0, -Z0h / Math.tan(waveNumber * te)); } Za = Complex.I.multiply(Z0h * waveNumber * ta); Complex Za_Zs = Za.divide(Zs); TransferMatrix result = new TransferMatrix(Za_Zs.divide(2.).add(1.), Za.multiply(Za_Zs.divide(4.).add(1.)), Complex.ONE.divide(Zs), Za_Zs.divide(2.0).add(1.)); assert result.determinant() == Complex.ONE; return result; }
From source file:net.sf.dsp4j.octave.packages.signal_1_0_11.Bilinear.java
public Bilinear(Complex[] sZero, Complex[] sPole, double sGain, double T) { Complex _2 = new Complex(2); if (sZero.length > sPole.length || sPole.length == 0) { // error("bilinear: must have at least as many poles as zeros in s-plane"); }// w w w.j a v a 2s. c o m Complex[] bz = new Complex[sZero.length]; for (int i = 0; i < sZero.length; i++) { bz[i] = _2.subtract(sZero[i].multiply(T)).divide(T); } Complex[] bp = new Complex[sPole.length]; for (int i = 0; i < sPole.length; i++) { bp[i] = _2.subtract(sPole[i].multiply(T)).divide(T); } zGain = new Complex(sGain, 0).multiply(prod(bz).divide(prod(bp))).getReal(); zPole = new Complex[sPole.length]; for (int i = 0; i < sPole.length; i++) { zPole[i] = _2.add(sPole[i].multiply(T)).divide(_2.subtract(sPole[i].multiply(T))); } zZero = new Complex[sPole.length]; if (sZero.length == 0) { Arrays.fill(zZero, Complex.ONE.negate()); } else { } for (int i = 0; i < sZero.length; i++) { zZero[i] = _2.add(sZero[i].multiply(T)).divide(_2.subtract(sZero[i].multiply(T))); } if (sZero.length < zZero.length) { Arrays.fill(zZero, sZero.length, zZero.length, Complex.ONE.negate()); } }
From source file:com.wwidesigner.geometry.calculation.SimpleFippleMouthpieceCalculator.java
public Complex calcZ_old(Mouthpiece mouthpiece, double freq, PhysicalParameters physicalParams) { // Assume the open window acts as a flanged tube with an effective radius // that corresponds to the window area. double effRadius = FastMath.sqrt( mouthpiece.getFipple().getWindowLength() * mouthpiece.getFipple().getWindowWidth() / FastMath.PI); double waveNumber = physicalParams.calcWaveNumber(freq); StateVector sv = new StateVector(Tube.calcZflanged(freq, effRadius, physicalParams), Complex.ONE); TransferMatrix tm = Tube.calcCylinderMatrix(waveNumber, mouthpiece.getFipple().getWindowHeight(), effRadius, physicalParams);//from w w w .j a v a 2 s. c om sv = tm.multiply(sv); return sv.getImpedance(); }