Package org.jscience.mathematics.number

Examples of org.jscience.mathematics.number.Complex



        /* calculate the expoonent */
        Integer bi;
        Unit thisUnit;
        Complex thisComplex;
        if (bIsReal && bMagIsInteger){
            /* If this.cComplex.getImaginary==0 then it must remain zero, since
             exponent is whole nmber. Otherwise, we get small neg imaginary value
             which results in sqrt((-2)^2)=-2  which is technically correct but
             unexpected. */
            boolean zeroimag = false;
            if (this.cComplex.getImaginary()==0){
                zeroimag = true;
            }
            bi = (Integer)bo;
            thisUnit =  this.getUnit().pow(bi);
            thisComplex = this.cComplex.pow(bi.doubleValue());
            //thisComplex = Complex.valueOf(Math.pow(this.cComplex.getReal(),bi),0);
            if (zeroimag){
                thisComplex = Complex.valueOf(thisComplex.getReal(),0);
            }
            return ComplexAmount.valueOf(thisComplex, thisUnit);
        }
        else if (bIsReal && bInvIsInteger){
            /* If the inverse is an integer then we can take a root */
            thisUnit = this.getUnit().root(bInv);
            thisComplex = this.cComplex.pow(1/bInv.doubleValue());
            return ComplexAmount.valueOf(thisComplex,thisUnit);
        }
        else if (aIsUnitless){
            Logger.getLogger("com.CompPad").log(Level.FINE, bo + " " + this.cComplex);
            /* Must be complex or double */
            Complex a;
            Complex bb;
            a = this.cComplex;
            bb = b.cComplex;
            return ComplexAmount.valueOf(
                    a.pow(bb),
                    Unit.ONE);
View Full Code Here


        return A;
    }

    /* formulate matrix */
    private void doMatrix(){
        Complex x[][] = new Complex[m][n];
        /* This naively assumes that the first element is ComplexAmount, and has
         * the same units as all the other elements */
        this.unit = ((ComplexAmount)rows.get(0).get(0)).getUnit();
        for (int i=0; i<m; ++i){
            for (int j=0; j<n; ++j){
View Full Code Here

        System.out.print("Complex add: ");
        startTime();
        for (int i = 0; i < 10000; i++) {
            StackContext.enter();
            Complex x = Complex.valueOf(1.0, 2.0);
            for (int j = 0; j < results.length; j++) {
                results[j] = x.plus(x);
            }
            StackContext.exit();
        }
        endTime(10000 * results.length);

        System.out.print("Complex multiply: ");
        startTime();
        for (int i = 0; i < 10000; i++) {
            StackContext.enter();
            Complex x = Complex.valueOf(1.0, 2.0);
            for (int j = 0; j < results.length; j++) {
                results[j] = x.times(x);
            }
            StackContext.exit();
        }
        endTime(10000 * results.length);

        System.out.print("Amount<Mass> add: ");
        startTime();
        for (int i = 0; i < 10000; i++) {
            StackContext.enter();
            Amount<Mass> x = Amount.valueOf(1.0, SI.KILOGRAM);
            for (int j = 0; j < results.length; j++) {
                results[j] = x.plus(x);
            }
            StackContext.exit();
        }
        endTime(10000 * results.length);

        System.out.print("Amount<Mass> multiply: ");
        startTime();
        for (int i = 0; i < 10000; i++) {
            StackContext.enter();
            Amount<Mass> x = Amount.valueOf(1.0, SI.KILOGRAM);
            for (int j = 0; j < results.length; j++) {
                results[j] = x.times(x);
            }
            StackContext.exit();
        }
        endTime(10000 * results.length);

 
View Full Code Here

TOP

Related Classes of org.jscience.mathematics.number.Complex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.