SinhCosh.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.util;

  18. /** Holder for both hyperbolic sine and hyperbolic cosine values.
  19.  * <p>
  20.  * This class is a simple container, it does not provide any computational method.
  21.  * </p>
  22.  * @see FastMath#sinhCosh(double)
  23.  * @since 2.0
  24.  */
  25. public class SinhCosh {

  26.     /** Value of the hyperbolic sine. */
  27.     private final double sinh;

  28.     /** Value of the hyperbolic cosine. */
  29.     private final double cosh;

  30.     /** Simple constructor.
  31.      * @param sinh value of the hyperbolic sine
  32.      * @param cosh value of the hyperbolic cosine
  33.      */
  34.     SinhCosh(final double sinh, final double cosh) {
  35.         this.sinh = sinh;
  36.         this.cosh = cosh;
  37.     }

  38.     /** Get the value of the hyperbolic sine.
  39.      * @return value of the hyperbolic sine
  40.      */
  41.     public double sinh() {
  42.         return sinh;
  43.     }

  44.     /** Get the value of the hyperbolic cosine.
  45.      * @return value of the hyperbolic cosine
  46.      */
  47.     public double cosh() {
  48.         return cosh;
  49.     }

  50.     /** Compute hyperbolic sine and hyperbolic cosine of angles sum.
  51.      * @param schAlpha \((\sinh \alpha, \cosh \alpha)\)
  52.      * @param schBeta \((\sinh \beta, \cosh \beta)\)
  53.      * @return \((\sinh \alpha+\beta, \cosh \alpha+\beta)\)
  54.      */
  55.     public static SinhCosh sum(final SinhCosh schAlpha, final SinhCosh schBeta) {
  56.         return new SinhCosh(MathArrays.linearCombination(schAlpha.sinh, schBeta.cosh,  schAlpha.cosh, schBeta.sinh),
  57.                             MathArrays.linearCombination(schAlpha.cosh, schBeta.cosh,  schAlpha.sinh, schBeta.sinh));
  58.     }

  59.     /** Compute hyperbolic sine and hyperbolic cosine of angles difference.
  60.      * @param schAlpha \((\sinh \alpha, \cosh \alpha)\)
  61.      * @param schBeta \((\sinh \beta, \cosh \beta)\)
  62.      * @return \((\sinh \alpha+\beta, \cosh \alpha-\beta)\)
  63.      */
  64.     public static SinhCosh difference(final SinhCosh schAlpha, final SinhCosh schBeta) {
  65.         return new SinhCosh(MathArrays.linearCombination(schAlpha.sinh, schBeta.cosh, schAlpha.cosh, -schBeta.sinh),
  66.                             MathArrays.linearCombination(schAlpha.cosh, schBeta.cosh, schAlpha.sinh, -schBeta.sinh));
  67.     }

  68. }