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