View Javadoc
1   /*
2    * Licensed to the Hipparchus project under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The Hipparchus project licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.hipparchus.special.elliptic.jacobi;
18  
19  import org.hipparchus.complex.Complex;
20  import org.hipparchus.special.elliptic.legendre.LegendreEllipticIntegral;
21  import org.hipparchus.util.MathUtils;
22  
23  /** Algorithm for computing the principal Jacobi functions for parameter m in [0; 1].
24   * @since 2.0
25   */
26  class BoundedParameter extends JacobiElliptic {
27  
28      /** Jacobi θ functions. */
29      private final JacobiTheta jacobiTheta;
30  
31      /** Value of Jacobi θ functions at origin. */
32      private final Theta t0;
33  
34      /** Scaling factor. */
35      private final double scaling;
36  
37      /** Simple constructor.
38       * @param m parameter of the Jacobi elliptic function
39       */
40      BoundedParameter(final double m) {
41  
42          super(m);
43  
44          // compute nome
45          final double q = LegendreEllipticIntegral.nome(m);
46  
47          // prepare underlying Jacobi θ functions
48          this.jacobiTheta = new JacobiTheta(q);
49          this.t0          = jacobiTheta.values(Complex.ZERO);
50          this.scaling     = MathUtils.SEMI_PI / LegendreEllipticIntegral.bigK(m);
51  
52      }
53  
54      /** {@inheritDoc}
55       * <p>
56       * The algorithm for evaluating the functions is based on {@link JacobiTheta
57       * Jacobi theta functions}.
58       * </p>
59       */
60      @Override
61      public CopolarN valuesN(double u) {
62  
63          // evaluate Jacobi θ functions at argument
64          final Theta tZ = jacobiTheta.values(new Complex(u * scaling));
65  
66          // convert to Jacobi elliptic functions
67          final double sn = t0.theta3().multiply(tZ.theta1()).divide(t0.theta2().multiply(tZ.theta4())).getRealPart();
68          final double cn = t0.theta4().multiply(tZ.theta2()).divide(t0.theta2().multiply(tZ.theta4())).getRealPart();
69          final double dn = t0.theta4().multiply(tZ.theta3()).divide(t0.theta3().multiply(tZ.theta4())).getRealPart();
70  
71          return new CopolarN(sn, cn, dn);
72  
73      }
74  
75  }