FieldBoundedParameter.java

  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. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.special.elliptic.legendre.LegendreEllipticIntegral;

  20. /** Algorithm for computing the principal Jacobi functions for parameter m in [0; 1].
  21.  * @param <T> the type of the field elements
  22.  * @since 2.0
  23.  */
  24. class FieldBoundedParameter<T extends CalculusFieldElement<T>> extends FieldJacobiElliptic<T> {

  25.     /** Jacobi θ functions. */
  26.     private final FieldJacobiTheta<T> jacobiTheta;

  27.     /** Value of Jacobi θ functions at origin. */
  28.     private final FieldTheta<T> t0;

  29.     /** Scaling factor. */
  30.     private final T scaling;

  31.     /** Simple constructor.
  32.      * @param m parameter of the Jacobi elliptic function
  33.      */
  34.     FieldBoundedParameter(final T m) {

  35.         super(m);

  36.         // compute nome
  37.         final T q   = LegendreEllipticIntegral.nome(m);

  38.         // prepare underlying Jacobi θ functions
  39.         this.jacobiTheta = new FieldJacobiTheta<>(q);
  40.         this.t0          = jacobiTheta.values(m.getField().getZero());
  41.         this.scaling     = LegendreEllipticIntegral.bigK(m).reciprocal().multiply(m.getPi().multiply(0.5));

  42.     }

  43.     /** {@inheritDoc}
  44.      * <p>
  45.      * The algorithm for evaluating the functions is based on {@link FieldJacobiTheta
  46.      * Jacobi theta functions}.
  47.      * </p>
  48.      */
  49.     @Override
  50.     public FieldCopolarN<T> valuesN(T u) {

  51.         // evaluate Jacobi θ functions at argument
  52.         final FieldTheta<T> tZ = jacobiTheta.values(u.multiply(scaling));

  53.         // convert to Jacobi elliptic functions
  54.         final T sn = t0.theta3().multiply(tZ.theta1()).divide(t0.theta2().multiply(tZ.theta4()));
  55.         final T cn = t0.theta4().multiply(tZ.theta2()).divide(t0.theta2().multiply(tZ.theta4()));
  56.         final T dn = t0.theta4().multiply(tZ.theta3()).divide(t0.theta3().multiply(tZ.theta4()));

  57.         return new FieldCopolarN<>(sn, cn, dn);

  58.     }

  59. }