List of usage examples for org.apache.commons.math3.complex Complex divide
public Complex divide(double divisor)
From source file:com.thalespf.dip.DeblurringTest.java
private static Complex divideDeconvolutionOp(Complex complexImg, Complex complexDeg) { return complexImg.divide(complexDeg); }
From source file:com.wwidesigner.geometry.calculation.Tube.java
/** * Calculate the transfer matrix of a cylinder. * @param waveNumber - 2*pi*f/c, in radians per metre * @param length - length of the cylinder, in metres. * @param radius - radius of the cylinder, in metres. * @param params - physical parameters/*from www . ja va2 s .c o m*/ * @return Transfer matrix */ public static TransferMatrix calcCylinderMatrix(double waveNumber, double length, double radius, PhysicalParameters params) { double Zc = params.calcZ0(radius); double epsilon = params.getAlphaConstant() / (radius * FastMath.sqrt(waveNumber)); Complex gammaL = new Complex(epsilon, 1.0 + epsilon).multiply(waveNumber * length); Complex coshL = gammaL.cosh(); Complex sinhL = gammaL.sinh(); TransferMatrix result = new TransferMatrix(coshL, sinhL.multiply(Zc), sinhL.divide(Zc), coshL); return result; }
From source file:edu.ucsf.valelab.saim.calculations.SaimCalc.java
/** * Calculates the transverse electric (TE) component, perpendicular to the * plane of incidence, of the Fresnel coefficient of reflection between the * sample interface and the virtual silicon oxidesilicon layer, * as described in:/*from w w w. j a v a2 s.c o m*/ * Paszek, M.J., C.C. DuFort, M.G. Rubashkin, M.W. Davidson, K.S. Thorn, J.T. * Liphardt, and V.M. Weaver. 2012. * Scanning angle interference microscopy reveals cell dynamics at the nanoscale. * Nat Meth. 9:825827. doi:10.1038/nmeth.2077. * * * 1/11/2016: Note that the above manuscript contains a mistake that is corrected * in a later publication: http://dx.doi.org/10.1016/B978-0-12-420138-5.00013-6 * That correction is now applied. * * * @param wavelength of the excitation light source in nm * @param angle with respect to the normal in radiance * @param dOx Thickness of the Silicon Oxide layer in nm * @param nSample Refractive index of the sample's buffer * @return FresnelCoefficient for these conditions */ public static Complex fresnelTE(final double wavelength, final double angle, final double dOx, final double nSample) { double nSi = RI.getRI(RI.Compound.SILICON, wavelength); double nOx = RI.getRI(RI.Compound.SILICONOXIDE, wavelength); double kOx = k(wavelength, nOx); double angleOx = snell2(angle, nSample, RI.getRI(RI.Compound.SILICONOXIDE, wavelength)); double cosOx = Math.cos(angleOx); double cosSi = Math.cos(snell2(angleOx, nOx, RI.getRI(RI.Compound.SILICON, wavelength))); double p0 = nSi * cosSi; double p1 = nOx * cosOx; double p2 = nSample * Math.cos(angle); double kOxdOxCosOx = kOx * dOx * cosOx; double cosOfkOxdOxCosOx = Math.cos(kOxdOxCosOx); double sinOfkOxdOxCosOx = Math.sin(kOxdOxCosOx); double m11TE = cosOfkOxdOxCosOx; Complex m12TE = Complex.I.multiply(-1 / p1 * sinOfkOxdOxCosOx); Complex m21TE = Complex.I.multiply(-p1 * sinOfkOxdOxCosOx); double m22TE = cosOfkOxdOxCosOx; Complex tmp1 = ((m12TE.multiply(p0)).add(m11TE)).multiply(p2); // this is the only line changed due to the error in the NM paper Complex tmp2 = tmp1.subtract(m21TE.add(m22TE * p0)); //Complex tmp2 = tmp1.add( m21TE.subtract(m22TE * p0) ); Complex tmp3 = tmp1.add(m21TE.add(m22TE * p0)); Complex rTE = tmp2.divide(tmp3); return rTE; }
From source file:com.wwidesigner.geometry.calculation.Tube.java
/** * Calculate the impedance of an open end of a real pipe, * assuming an infinite flange./*from w w w . j a v a2s. c o m*/ * From Jean Kergomard, Antoine Lefebvre, Gary Scavone, * "Matching of fundamental modes at a junction of a cylinder and a * truncated cone; application to the calculation of radiation impedances," * 2015. <hal-01134302>. https://hal.archives-ouvertes.fr/hal-01134302. * * @param freq - fundamental frequency of the waveform. * @param radius - radius of pipe, in metres. * @param params - physical parameters * @return impedance as seen by pipe. */ public static Complex calcZflanged_Kergomard(double freq, double radius, PhysicalParameters params) { double ka = params.calcWaveNumber(freq) * radius; double ka2 = ka * ka; Complex numerator = new Complex(0.3216 * ka2, (0.82159 - 0.0368 * ka2) * ka); Complex denominator = new Complex(1 + 0.3701 * ka2, (1.0 - 0.0368 * ka2) * ka); return numerator.divide(denominator).multiply(params.calcZ0(radius)); }
From source file:com.thalespf.dip.DeblurringTest.java
private static Complex deconvolutionByWiener(Complex imagem, Complex psf) { double K = Math.pow(1.07, 32) / 10000.0; double energyValue = Math.pow(psf.getReal(), 2) + Math.pow(psf.getImaginary(), 2); double wienerValue = energyValue / (energyValue + K); Complex divided = imagem.divide(psf); Complex c = divided.multiply(wienerValue); return c;/*from w w w .j a va 2s . com*/ }
From source file:eu.itesla_project.iidm.ddb.eurostag.model.TransformerModel.java
public StateVariable toSv2(StateVariable sv1) { Complex s1 = new Complex(-sv1.p, -sv1.q); // s1=p1+jq1 Complex u1 = ComplexUtils.polar2Complex(sv1.u, Math.toRadians(sv1.theta)); Complex v1 = u1.divide(SQUARE_3); // v1=u1/sqrt(3) Complex v1p = v1.multiply(ratio); // v1p=v1*rho Complex i1 = s1.divide(v1.multiply(3)).conjugate(); // i1=conj(s1/(3*v1)) Complex i1p = i1.divide(ratio); // i1p=i1/rho Complex i2 = i1p.subtract(y.multiply(v1p)).negate(); // i2=-(i1p-y*v1p) Complex v2 = v1p.subtract(z.multiply(i2)); // v2=v1p-z*i2 Complex s2 = v2.multiply(3).multiply(i2.conjugate()); // s2=3*v2*conj(i2) Complex u2 = v2.multiply(SQUARE_3);//from w ww . j ava2s . c om return new StateVariable(-s2.getReal(), -s2.getImaginary(), u2.abs(), Math.toDegrees(u2.getArgument())); }
From source file:eu.itesla_project.iidm.ddb.eurostag.model.TransformerModel.java
public StateVariable toSv1(StateVariable sv2) { Complex s2 = new Complex(-sv2.p, -sv2.q); // s2=p2+jq2 Complex u2 = ComplexUtils.polar2Complex(sv2.u, Math.toRadians(sv2.theta)); Complex v2 = u2.divide(SQUARE_3); // v2=u2/sqrt(3) Complex i2 = s2.divide(v2.multiply(3)).conjugate(); // i2=conj(s2/(3*v2)) Complex v1p = v2.add(z.multiply(i2)); // v1'=v2+z*i2 Complex i1p = i2.negate().add(y.multiply(v1p)); // i1'=-i2+v1'*y Complex i1 = i1p.multiply(ratio); // i1=i1p*ration Complex v1 = v1p.divide(ratio); // v1=v1p/ration Complex s1 = v1.multiply(3).multiply(i1.conjugate()); // s1=3*v1*conj(i1) Complex u1 = v1.multiply(SQUARE_3);// ww w. j a v a2 s . c o m return new StateVariable(-s1.getReal(), -s1.getImaginary(), u1.abs(), Math.toDegrees(u1.getArgument())); }
From source file:eu.itesla_project.iidm.network.util.SV.java
public SV otherSide(float r, float x, float g, float b, float ratio) { Complex z = new Complex(r, x); // z=r+jx Complex y = new Complex(g, b); // y=g+jb Complex s1 = new Complex(p, q); // s1=p1+jq1 Complex u1 = ComplexUtils.polar2Complex(u, Math.toRadians(a)); Complex v1 = u1.divide(Math.sqrt(3f)); // v1=u1/sqrt(3) Complex v1p = v1.multiply(ratio); // v1p=v1*rho Complex i1 = s1.divide(v1.multiply(3)).conjugate(); // i1=conj(s1/(3*v1)) Complex i1p = i1.divide(ratio); // i1p=i1/rho Complex i2 = i1p.subtract(y.multiply(v1p)); // i2=i1p-y*v1p Complex v2 = v1p.subtract(z.multiply(i2)); // v2=v1p-z*i2 Complex s2 = v2.multiply(3).multiply(i2.conjugate()); // s2=3*v2*conj(i2) Complex u2 = v2.multiply(Math.sqrt(3f)); return new SV((float) -s2.getReal(), (float) -s2.getImaginary(), (float) u2.abs(), (float) Math.toDegrees(u2.getArgument())); }
From source file:electrical_parameters.Rac_calculation.java
private Complex Bessel_1(Complex x) { Complex aux;//from w w w. j a v a 2 s .co m aux = x.divide((double) 2); aux = csub(aux, cpow(x.divide((double) 2), 3).multiply((double) 1 / 2)); aux = cadd(aux, cpow(x.divide((double) 2), 5).multiply((double) 1 / 12)); aux = csub(aux, cpow(x.divide((double) 2), 7).multiply((double) 1 / 144)); return aux; }
From source file:electrical_parameters.Rac_calculation.java
private Complex Bessel_0(Complex x) { Complex aux;//from w w w . j a v a 2 s .c om aux = csub(1, cpow(x.divide((double) 2), 2)); aux = cadd(aux, cpow(x.divide((double) 2), 4).multiply((double) 1 / 4)); aux = csub(aux, cpow(x.divide((double) 2), 6).multiply((double) 1 / 36)); return aux; }