Examples of Complex

@author Edward A. Lee, Jeff Tsay, Steve Neuendorffer, Adam Cataldo @version $Id: Complex.java,v 1.91 2007/12/06 21:57:08 cxh Exp $ @since Ptolemy II 0.2 @Pt.ProposedRating Yellow (eal) @Pt.AcceptedRating Red (cxh)
  • r.data.RComplex.Complex

  • Examples of jscicalc.complex.Complex

         * @param x The value (right of symbol)
         * @return The result of the operation
         */
        public OObject function( OObject x ){
      if( x instanceof Complex ){
          Complex c = (Complex)x;
          if( scale != 1 && StrictMath.abs( c.imaginary() ) > 1e-6 )
        throw new RuntimeException( "Error" );
          return c.atan().scale( iscale );
      } else {
          return x.atan( angleType );
      }
        }
    View Full Code Here

    Examples of jscicalc.complex.Complex

         * @param x The value (right of symbol)
         * @return The result of the operation
         */
        public OObject function( OObject x ){
      if( x instanceof Complex ){
          Complex c = (Complex)x;
          if( scale != 1 && StrictMath.abs( c.imaginary() ) > 1e-6 )
        throw new RuntimeException( "Error" );
          if( scale != 1 && StrictMath.abs( c.real() ) > 1 )
        throw new RuntimeException( "Error" );
          return c.asin().scale( iscale );
      } else {
          return x.asin( angleType );
      }
        }
    View Full Code Here

    Examples of kompleksnaStevila.Complex

        Complex c1;

        @Test(expected = IllegalArgumentException.class)
        public void testNumberFormatException() {
            c1 = new Complex("hg");
            c1.add(new Complex(3, 4));
            System.out.println(c1);
        }
    View Full Code Here

    Examples of model.Complex

        for (int times = 0; times < amountPossible; times++) {
          Complex[] complex = new Complex[4096];
          for (int i = 0; i < 4096; i++) {
            // Put the time domain data into a complex number with imaginary
            // part as 0:
            complex[i] = new Complex(audio[(times * 4096) + i], 0);
          }
          // Perform FFT analysis on the chunk:
          results[times] = FFT.fft(complex);
        }
        determineKeyPoints(results, songId, isMatching);
    View Full Code Here

    Examples of org.apache.commons.math.complex.Complex

        /**
         * Test of solver for the quintic function using solveAll().
         */
        public void testQuinticFunction2() throws MathException {
            double initial = 0.0, tolerance;
            Complex expected, result[];

            // p(x) = x^5 + 4x^3 + x^2 + 4 = (x+1)(x^2-x+1)(x^2+4)
            double coefficients[] = { 4.0, 0.0, 1.0, 4.0, 0.0, 1.0 };
            LaguerreSolver solver = new LaguerreSolver();
            result = solver.solveAll(coefficients, initial);

            expected = new Complex(0.0, -2.0);
            tolerance = Math.max(solver.getAbsoluteAccuracy(),
                        Math.abs(expected.abs() * solver.getRelativeAccuracy()));
            TestUtils.assertContains(result, expected, tolerance);

            expected = new Complex(0.0, 2.0);
            tolerance = Math.max(solver.getAbsoluteAccuracy(),
                        Math.abs(expected.abs() * solver.getRelativeAccuracy()));
            TestUtils.assertContains(result, expected, tolerance);

            expected = new Complex(0.5, 0.5 * Math.sqrt(3.0));
            tolerance = Math.max(solver.getAbsoluteAccuracy(),
                        Math.abs(expected.abs() * solver.getRelativeAccuracy()));
            TestUtils.assertContains(result, expected, tolerance);

            expected = new Complex(-1.0, 0.0);
            tolerance = Math.max(solver.getAbsoluteAccuracy(),
                        Math.abs(expected.abs() * solver.getRelativeAccuracy()));
            TestUtils.assertContains(result, expected, tolerance);

            expected = new Complex(0.5, -0.5 * Math.sqrt(3.0));
            tolerance = Math.max(solver.getAbsoluteAccuracy(),
                        Math.abs(expected.abs() * solver.getRelativeAccuracy()));
            TestUtils.assertContains(result, expected, tolerance);
        }
    View Full Code Here

    Examples of org.apache.commons.math3.complex.Complex

         * @param yi imaginary part of the second number
         * @return result of the complex division
         */
        private Complex cdiv(final double xr, final double xi,
                             final double yr, final double yi) {
            return new Complex(xr, xi).divide(new Complex(yr, yi));
        }
    View Full Code Here

    Examples of org.apache.commons.math3.complex.Complex

                    // Last vector component imaginary so matrix is triangular
                    if (FastMath.abs(matrixT[idx][idx - 1]) > FastMath.abs(matrixT[idx - 1][idx])) {
                        matrixT[idx - 1][idx - 1] = q / matrixT[idx][idx - 1];
                        matrixT[idx - 1][idx]     = -(matrixT[idx][idx] - p) / matrixT[idx][idx - 1];
                    } else {
                        final Complex result = cdiv(0.0, -matrixT[idx - 1][idx],
                                                    matrixT[idx - 1][idx - 1] - p, q);
                        matrixT[idx - 1][idx - 1] = result.getReal();
                        matrixT[idx - 1][idx]     = result.getImaginary();
                    }

                    matrixT[idx][idx - 1] = 0.0;
                    matrixT[idx][idx]     = 1.0;

                    for (int i = idx - 2; i >= 0; i--) {
                        double ra = 0.0;
                        double sa = 0.0;
                        for (int j = l; j <= idx; j++) {
                            ra += matrixT[i][j] * matrixT[j][idx - 1];
                            sa += matrixT[i][j] * matrixT[j][idx];
                        }
                        double w = matrixT[i][i] - p;

                        if (Precision.compareTo(imagEigenvalues[i], 0.0, EPSILON) < 0) {
                            z = w;
                            r = ra;
                            s = sa;
                        } else {
                            l = i;
                            if (Precision.equals(imagEigenvalues[i], 0.0)) {
                                final Complex c = cdiv(-ra, -sa, w, q);
                                matrixT[i][idx - 1] = c.getReal();
                                matrixT[i][idx] = c.getImaginary();
                            } else {
                                // Solve complex equations
                                double x = matrixT[i][i + 1];
                                double y = matrixT[i + 1][i];
                                double vr = (realEigenvalues[i] - p) * (realEigenvalues[i] - p) +
                                            imagEigenvalues[i] * imagEigenvalues[i] - q * q;
                                final double vi = (realEigenvalues[i] - p) * 2.0 * q;
                                if (Precision.equals(vr, 0.0) && Precision.equals(vi, 0.0)) {
                                    vr = Precision.EPSILON * norm *
                                         (FastMath.abs(w) + FastMath.abs(q) + FastMath.abs(x) +
                                          FastMath.abs(y) + FastMath.abs(z));
                                }
                                final Complex c     = cdiv(x * r - z * ra + q * sa,
                                                           x * s - z * sa - q * ra, vr, vi);
                                matrixT[i][idx - 1] = c.getReal();
                                matrixT[i][idx]     = c.getImaginary();

                                if (FastMath.abs(x) > (FastMath.abs(z) + FastMath.abs(q))) {
                                    matrixT[i + 1][idx - 1] = (-ra - w * matrixT[i][idx - 1] +
                                                               q * matrixT[i][idx]) / x;
                                    matrixT[i + 1][idx]     = (-sa - w * matrixT[i][idx] -
                                                               q * matrixT[i][idx - 1]) / x;
                                } else {
                                    final Complex c2        = cdiv(-r - y * matrixT[i][idx - 1],
                                                                   -s - y * matrixT[i][idx], z, q);
                                    matrixT[i + 1][idx - 1] = c2.getReal();
                                    matrixT[i + 1][idx]     = c2.getImaginary();
                                }
                            }

                            // Overflow control
                            double t = FastMath.max(FastMath.abs(matrixT[i][idx - 1]),
    View Full Code Here

    Examples of org.apache.commons.math3.complex.Complex

         * 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++) {
    View Full Code Here

    Examples of org.apache.commons.math3.complex.Complex

                  new PolynomialFunction(coefficients),
                  Double.NEGATIVE_INFINITY,
                  Double.POSITIVE_INFINITY,
                  initial);
            return complexSolver.solveAll(ComplexUtils.convertToComplex(coefficients),
                                          new Complex(initial, 0d));
        }
    View Full Code Here

    Examples of org.apache.hadoop.hive.serde2.proto.test.Complexpb.Complex

          // real object
          List<Integer> c2 = Arrays.asList(new Integer[] {1, 2, 3});
          List<String> c3 = Arrays.asList(new String[] {"one", "two"});
          List<IntString> c4 = new ArrayList<IntString>();
          Complex c = new Complex(1, "test", c2, c3, c4);

          assertEquals(1, soi.getStructFieldData(c, fields.get(0)));
          assertEquals("test", soi.getStructFieldData(c, fields.get(1)));
          assertEquals(c2, soi.getStructFieldData(c, fields.get(2)));
          assertEquals(c3, soi.getStructFieldData(c, fields.get(3)));
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. 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.