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.util;
18  
19  /** Holder for both hyperbolic sine and hyperbolic cosine values.
20   * <p>
21   * This class is a simple container, it does not provide any computational method.
22   * </p>
23   * @see FastMath#sinhCosh(double)
24   * @since 2.0
25   */
26  public class SinhCosh {
27  
28      /** Value of the hyperbolic sine. */
29      private final double sinh;
30  
31      /** Value of the hyperbolic cosine. */
32      private final double cosh;
33  
34      /** Simple constructor.
35       * @param sinh value of the hyperbolic sine
36       * @param cosh value of the hyperbolic cosine
37       */
38      SinhCosh(final double sinh, final double cosh) {
39          this.sinh = sinh;
40          this.cosh = cosh;
41      }
42  
43      /** Get the value of the hyperbolic sine.
44       * @return value of the hyperbolic sine
45       */
46      public double sinh() {
47          return sinh;
48      }
49  
50      /** Get the value of the hyperbolic cosine.
51       * @return value of the hyperbolic cosine
52       */
53      public double cosh() {
54          return cosh;
55      }
56  
57      /** Compute hyperbolic sine and hyperbolic cosine of angles sum.
58       * @param schAlpha \((\sinh \alpha, \cosh \alpha)\)
59       * @param schBeta \((\sinh \beta, \cosh \beta)\)
60       * @return \((\sinh \alpha+\beta, \cosh \alpha+\beta)\)
61       */
62      public static SinhCosh sum(final SinhCosh schAlpha, final SinhCosh schBeta) {
63          return new SinhCosh(MathArrays.linearCombination(schAlpha.sinh, schBeta.cosh,  schAlpha.cosh, schBeta.sinh),
64                              MathArrays.linearCombination(schAlpha.cosh, schBeta.cosh,  schAlpha.sinh, schBeta.sinh));
65      }
66  
67      /** Compute hyperbolic sine and hyperbolic cosine of angles difference.
68       * @param schAlpha \((\sinh \alpha, \cosh \alpha)\)
69       * @param schBeta \((\sinh \beta, \cosh \beta)\)
70       * @return \((\sinh \alpha+\beta, \cosh \alpha-\beta)\)
71       */
72      public static SinhCosh difference(final SinhCosh schAlpha, final SinhCosh schBeta) {
73          return new SinhCosh(MathArrays.linearCombination(schAlpha.sinh, schBeta.cosh, schAlpha.cosh, -schBeta.sinh),
74                              MathArrays.linearCombination(schAlpha.cosh, schBeta.cosh, schAlpha.sinh, -schBeta.sinh));
75      }
76  
77  }