コード例 #1
0
  public void testSineRoots() {
    {
      // Conjugate +- 1.0i root
      ComplexNumber[] roots =
          new ComplexNumber[] {new ComplexNumber(0.0, 1.0), new ComplexNumber(0.0, -1.0)};

      SolutionBasis basis = new SolutionBasis(roots);
      Set<EquationComponent> solutionComponents = basis.getSolutionComponents();

      EquationComponent component1 =
          new EquationComponent(
              Polynomial.getSingularPolynomial(),
              Exponential.getSingularExponential(),
              new SineAndCosine(
                  1.0, Polynomial.getSingularPolynomial(), Polynomial.getSingularPolynomial()));

      assertTrue(solutionComponents.contains(component1));
    }

    {
      // Double Conjugate +- 1.0i root
      ComplexNumber[] roots =
          new ComplexNumber[] {
            new ComplexNumber(0.0, 1.0),
            new ComplexNumber(0.0, -1.0),
            new ComplexNumber(0.0, 1.0),
            new ComplexNumber(0.0, -1.0)
          };

      SolutionBasis basis = new SolutionBasis(roots);
      Set<EquationComponent> solutionComponents = basis.getSolutionComponents();

      EquationComponent component1 =
          new EquationComponent(
              Polynomial.getSingularPolynomial(),
              Exponential.getSingularExponential(),
              new SineAndCosine(
                  1.0, Polynomial.getSingularPolynomial(), Polynomial.getSingularPolynomial()));

      EquationComponent component2 =
          new EquationComponent(
              new Polynomial(new Double[] {1.0, 0.0}),
              Exponential.getSingularExponential(),
              new SineAndCosine(
                  1.0, Polynomial.getSingularPolynomial(), Polynomial.getSingularPolynomial()));

      assertTrue(solutionComponents.contains(component1));
      assertTrue(solutionComponents.contains(component2));
    }
  }
コード例 #2
0
  @Test
  public void testSimpleRoots() {
    {
      ComplexNumber[] roots = new ComplexNumber[] {new ComplexNumber(0.0, 0.0)};

      SolutionBasis basis = new SolutionBasis(roots);
      Set<EquationComponent> solutionComponents = basis.getSolutionComponents();

      EquationComponent component =
          new EquationComponent(
              Polynomial.getSingularPolynomial(),
              Exponential.getSingularExponential(),
              SineAndCosine.getSingularSineAndCosine());

      boolean isInSet = solutionComponents.contains(component);

      assertTrue(isInSet);
    }

    {
      // Double 0.0 root
      ComplexNumber[] roots =
          new ComplexNumber[] {new ComplexNumber(0.0, 0.0), new ComplexNumber(0.0, 0.0)};

      SolutionBasis basis = new SolutionBasis(roots);
      Set<EquationComponent> solutionComponents = basis.getSolutionComponents();

      EquationComponent component1 =
          new EquationComponent(
              Polynomial.getSingularPolynomial(),
              Exponential.getSingularExponential(),
              SineAndCosine.getSingularSineAndCosine());

      EquationComponent component2 =
          new EquationComponent(
              new Polynomial(new Double[] {1.0, 0.0}),
              Exponential.getSingularExponential(),
              SineAndCosine.getSingularSineAndCosine());

      assertTrue(solutionComponents.contains(component1));
      assertTrue(solutionComponents.contains(component2));
    }

    {
      // Triple 0.0 root
      ComplexNumber[] roots =
          new ComplexNumber[] {
            new ComplexNumber(0.0, 0.0), new ComplexNumber(0.0, 0.0), new ComplexNumber(0.0, 0.0)
          };

      SolutionBasis basis = new SolutionBasis(roots);
      Set<EquationComponent> solutionComponents = basis.getSolutionComponents();

      EquationComponent component1 =
          new EquationComponent(
              Polynomial.getSingularPolynomial(),
              Exponential.getSingularExponential(),
              SineAndCosine.getSingularSineAndCosine());

      EquationComponent component2 =
          new EquationComponent(
              new Polynomial(new Double[] {1.0, 0.0}),
              Exponential.getSingularExponential(),
              SineAndCosine.getSingularSineAndCosine());

      EquationComponent component3 =
          new EquationComponent(
              new Polynomial(new Double[] {1.0, 0.0, 0.0}),
              Exponential.getSingularExponential(),
              SineAndCosine.getSingularSineAndCosine());

      assertTrue(solutionComponents.contains(component1));
      assertTrue(solutionComponents.contains(component2));
      assertTrue(solutionComponents.contains(component3));
    }
  }