1   /* Copyright 2002-2024 CS GROUP
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS 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    *   http://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.orekit.utils;
18  
19  import java.io.Serializable;
20  
21  /** Container for Love numbers.
22   * @author Luc Maisonobe
23   * @since 6.1
24   */
25  public class LoveNumbers implements Serializable {
26  
27      /** Serializable UID. */
28      private static final long serialVersionUID = 20131014L;
29  
30      /** Real part of the nominal Love numbers. */
31      private final double[][] real;
32  
33      /** Imaginary part of the nominal Love numbers. */
34      private final double[][] imaginary;
35  
36      /** Time-dependent part of the Love numbers. */
37      private final double[][] plus;
38  
39      /** Simple constructor.
40       * @param real real part of the nominal Love numbers
41       * @param imaginary imaginary part of the nominal Love numbers
42       * @param plus time-dependent part of the Love numbers
43       */
44      public LoveNumbers(final double[][] real, final double[][] imaginary, final double[][] plus) {
45          this.real      = copyIrregular(real);
46          this.imaginary = copyIrregular(imaginary);
47          this.plus      = copyIrregular(plus);
48      }
49  
50      /** Copy irregular-shape array.
51       * @param source source array
52       * @return copied array
53       */
54      private double[][] copyIrregular(final double[][] source) {
55          final double[][] copy = new double[source.length][];
56          for (int i = 0; i < source.length; ++i) {
57              copy[i] = source[i].clone();
58          }
59          return copy;
60      }
61  
62      /** Get the size of the arrays.
63       * @return size of the arrays (i.e. max degree for Love numbers + 1)
64       */
65      public int getSize() {
66          return real.length;
67      }
68  
69      /** Get the real part of a nominal Love numbers.
70       * @param n degree of the Love number (must be less than {@link #getSize()})
71       * @param m order of the Love number (must be less than {@code n})
72       * @return real part of k<sub>n,m</sub>
73       */
74      public final double getReal(final int n, final int m) {
75          return real[n][m];
76      }
77  
78      /** Get the imaginary part of a nominal Love numbers.
79       * @param n degree of the Love number (must be less than {@link #getSize()})
80       * @param m order of the Love number (must be less than {@code n})
81       * @return imaginary part of k<sub>n,m</sub>
82       */
83      public final double getImaginary(final int n, final int m) {
84          return imaginary[n][m];
85      }
86  
87      /** Get the real part of a nominal Love numbers.
88       * @param n degree of the Love number (must be less than {@link #getSize()})
89       * @param m order of the Love number (must be less than {@code n})
90       * @return k<sub>n,m</sub><sup>+</sup>
91       */
92      public final double getPlus(final int n, final int m) {
93          return plus[n][m];
94      }
95  
96  }
97