本文整理匯總了Java中org.apache.commons.math3.complex.Complex.getReal方法的典型用法代碼示例。如果您正苦於以下問題:Java Complex.getReal方法的具體用法?Java Complex.getReal怎麽用?Java Complex.getReal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.math3.complex.Complex
的用法示例。
在下文中一共展示了Complex.getReal方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNetOutput
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
@Override
public double[] getNetOutput() {
int i = 3;
double[] output = new double[2 * i];
Complex power = getAclfNet().getBranch("Bus5->Bus6(1)").powerFrom2To();
output[0] = power.getReal();
output[1] = power.getImaginary();
power = getAclfNet().getBranch("Bus4->Bus7(1)").powerFrom2To();
output[2] = power.getReal();
output[3] = power.getImaginary();
power = getAclfNet().getBranch("Bus4->Bus9(1)").powerFrom2To();
output[4] = power.getReal();
output[5] = power.getImaginary();
return output;
}
開發者ID:interpss,項目名稱:DeepMachineLearning,代碼行數:17,代碼來源:InterfacePowerRandomChangeTrainCaseBuilder.java
示例2: otherSide
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
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()));
}
示例3: laguerre
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
/**
* Find a real root in the given interval.
*
* Despite the bracketing condition, the root returned by
* {@link LaguerreSolver.ComplexSolver#solve(Complex[],Complex)} may
* not be a real zero inside {@code [min, max]}.
* For example, <code> p(x) = x<sup>3</sup> + 1, </code>
* with {@code min = -2}, {@code max = 2}, {@code initial = 0}.
* When it occurs, this code calls
* {@link LaguerreSolver.ComplexSolver#solveAll(Complex[],Complex)}
* in order to obtain all roots and picks up one real root.
*
* @param lo Lower bound of the search interval.
* @param hi Higher bound of the search interval.
* @param fLo Function value at the lower bound of the search interval.
* @param fHi Function value at the higher bound of the search interval.
* @return the point at which the function value is zero.
* @deprecated This method should not be part of the public API: It will
* be made private in version 4.0.
*/
@Deprecated
public double laguerre(double lo, double hi,
double fLo, double fHi) {
final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());
final Complex initial = new Complex(0.5 * (lo + hi), 0);
final Complex z = complexSolver.solve(c, initial);
if (complexSolver.isRoot(lo, hi, z)) {
return z.getReal();
} else {
double r = Double.NaN;
// Solve all roots and select the one we are seeking.
Complex[] root = complexSolver.solveAll(c, initial);
for (int i = 0; i < root.length; i++) {
if (complexSolver.isRoot(lo, hi, root[i])) {
r = root[i].getReal();
break;
}
}
return r;
}
}
示例4: laguerre
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
/**
* Find a real root in the given interval.
*
* Despite the bracketing condition, the root returned by
* {@link LaguerreSolver.ComplexSolver#solve(Complex[],Complex)} may
* not be a real zero inside {@code [min, max]}.
* For example, <code>p(x) = x<sup>3</sup> + 1,</code>
* with {@code min = -2}, {@code max = 2}, {@code initial = 0}.
* When it occurs, this code calls
* {@link LaguerreSolver.ComplexSolver#solveAll(Complex[],Complex)}
* in order to obtain all roots and picks up one real root.
*
* @param lo Lower bound of the search interval.
* @param hi Higher bound of the search interval.
* @param fLo Function value at the lower bound of the search interval.
* @param fHi Function value at the higher bound of the search interval.
* @return the point at which the function value is zero.
* @deprecated This method should not be part of the public API: It will
* be made private in version 4.0.
*/
@Deprecated
public double laguerre(double lo, double hi,
double fLo, double fHi) {
final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());
final Complex initial = new Complex(0.5 * (lo + hi), 0);
final Complex z = complexSolver.solve(c, initial);
if (complexSolver.isRoot(lo, hi, z)) {
return z.getReal();
} else {
double r = Double.NaN;
// Solve all roots and select the one we are seeking.
Complex[] root = complexSolver.solveAll(c, initial);
for (int i = 0; i < root.length; i++) {
if (complexSolver.isRoot(lo, hi, root[i])) {
r = root[i].getReal();
break;
}
}
return r;
}
}
示例5: setComplexValue
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
public ValueType setComplexValue(Complex c)
{
real = c.getReal();
imaginary = c.getImaginary();
valueType = (imaginary != 0.0) ? ValueType.COMPLEX : ValueType.REAL;
return valueType;
}
示例6: complexOperate
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
@Override
public void complexOperate(double[] out, double ra, double ia, double rb, double ib) {
Complex c = new Complex(ra, ia);
c = ib == 0 ? c.pow(rb) : c.pow(new Complex(rb, ib));
out[0] = c.getReal();
out[1] = c.getImaginary();
}
示例7: toSv2
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
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);
return new StateVariable(-s2.getReal(), -s2.getImaginary(), u2.abs(), Math.toDegrees(u2.getArgument()));
}
示例8: toSv1
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
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);
return new StateVariable(-s1.getReal(), -s1.getImaginary(), u1.abs(), Math.toDegrees(u1.getArgument()));
}
示例9: UseIfEqualTo
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
/**
* @param z
* given value as Complex
*/
public UseIfEqualTo(Complex z) {
super(z.getReal());
di = z.getImaginary();
}
示例10: runObserver
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
@Override
public DropletObserverResult runObserver(ExecutionInformation executionInformation, MeasurementContext measurementContext,
double dropletOffset, int microfluidicChipID) throws ResourceException, RemoteException
{
assertInitialized();
ObserverState state = loadState(measurementContext, microfluidicChipID);
int l = state.getNextDropletID(executionInformation);
double[] x = state.getEstimatedOffsets();
double c0 = state.getObserverMean();
double c1 = state.getObserverIndividual();
int N = state.getNumDroplets(); // number of droplets
double pi = Math.PI;
double y = x[l]; // estimated offset for current droplet
double h = dropletOffset; // observed offset
// Transform states by discrete Fourier transform (DFT).
Complex[] z = new Complex[N];
for(int i=0; i<N; i++)
{
z[i] = new Complex(0);
for(int k=0; k<N; k++)
{
z[i] = z[i].add(ComplexUtils.polar2Complex(1.0/N, -2.0*pi*k/N*i).multiply(x[k]));
}
}
// Update step
// Formula in Matlab: zp = z + ct/N .* exp(-2*pi*j * K.' * l/N) * (h-y);
for(int i=0; i<N; i++)
{
double c;
if(i == 0)
c=c0;
else
c=c1;
z[i] = z[i].add(ComplexUtils.polar2Complex(c/N, -2.0*pi*i/N*l).multiply(h-y));
}
// Transform states back by inverse discrete Fourier transformation (IDFT).
for(int i=0; i<N; i++)
{
Complex xi = new Complex(0);
for(int k=0; k<N; k++)
{
xi = xi.add(ComplexUtils.polar2Complex(1.0, 2.0*pi*k/N*i).multiply(z[k]));
}
x[i] = xi.getReal();
}
// Save result
state.setEstimatedOffsets(x);
saveState(state, measurementContext, microfluidicChipID);
sendMessage("Observed droplet offset of " + Integer.toString((int)dropletOffset) + "um, estimated before "+Integer.toString((int)y) + "um. Changed mean droplet offset estimate to "+Integer.toString((int)z[0].getReal())+"um.");
return new DropletObserverResult(l, x);
}
示例11: transform
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
public static double transform(Complex c){
//c = c.log();
//return (c.getImaginary()/(Math.PI/2)) *max_value;
return c.getReal();
}
示例12: interpret
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
public Complex interpret() {
Complex value = sum();
if (current.type != Token.Type.END)
throw new RuntimeException("Given expression has an invalid syntax");
double real = value.getReal(), imag = value.getImaginary();
real = Tools.round(real);
imag = Tools.round(imag);
return new Complex(real, imag);
}
示例13: createRealImaginaryArray
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
/**
* Builds a new two dimensional array of {@code double} filled with the real
* and imaginary parts of the specified {@link Complex} numbers. In the
* returned array {@code dataRI}, the data is laid out as follows
* <ul>
* <li>{@code dataRI[0][i] = dataC[i].getReal()},</li>
* <li>{@code dataRI[1][i] = dataC[i].getImaginary()}.</li>
* </ul>
*
* @param dataC the array of {@link Complex} data to be transformed
* @return a two dimensional array filled with the real and imaginary parts
* of the specified complex input
*/
public static double[][] createRealImaginaryArray(final Complex[] dataC) {
final double[][] dataRI = new double[2][dataC.length];
final double[] dataR = dataRI[0];
final double[] dataI = dataRI[1];
for (int i = 0; i < dataC.length; i++) {
final Complex c = dataC[i];
dataR[i] = c.getReal();
dataI[i] = c.getImaginary();
}
return dataRI;
}
示例14: getMismatch
import org.apache.commons.math3.complex.Complex; //導入方法依賴的package包/類
/**
* compute and return the mismatch based on the network solution
* for bus voltage
*
* @param netVolt network bus voltage solution
* @return mismatch info string
*/
public double[] getMismatch(double[] netVolt) {
Complex maxMis= this.trainCaseBuilder.calMismatch(netVolt).maxMis;
return new double[] {maxMis.getReal(),maxMis.getImaginary()};
}