當前位置: 首頁>>代碼示例>>Java>>正文


Java Complex.getReal方法代碼示例

本文整理匯總了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()));
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:18,代碼來源:SV.java

示例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;
    }
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:43,代碼來源:LaguerreSolver.java

示例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;
    }
}
 
開發者ID:Quanticol,項目名稱:CARMA,代碼行數:43,代碼來源:LaguerreSolver.java

示例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;
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:8,代碼來源:CalculatedValue.java

示例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();
}
 
開發者ID:eclipse,項目名稱:january,代碼行數:8,代碼來源:Operations.java

示例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()));
}
 
開發者ID:itesla,項目名稱:ipst,代碼行數:14,代碼來源:TransformerModel.java

示例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()));
}
 
開發者ID:itesla,項目名稱:ipst,代碼行數:14,代碼來源:TransformerModel.java

示例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();
}
 
開發者ID:eclipse,項目名稱:january,代碼行數:9,代碼來源:Operations.java

示例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);
}
 
開發者ID:langmo,項目名稱:youscope,代碼行數:59,代碼來源:DefaultObserver.java

示例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();
}
 
開發者ID:Sebubu,項目名稱:ComplexNeuralNet,代碼行數:6,代碼來源:Helper.java

示例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);
}
 
開發者ID:QwertygidQ,項目名稱:DeutschSim,代碼行數:14,代碼來源:Interpreter.java

示例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;
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:25,代碼來源:TransformUtils.java

示例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()};
}
 
開發者ID:interpss,項目名稱:DeepMachineLearning,代碼行數:12,代碼來源:AclfPyGateway.java


注:本文中的org.apache.commons.math3.complex.Complex.getReal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。