LoveNumbers.java

  1. /* Copyright 2002-2020 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. import java.io.Serializable;

  19. /** Container for Love numbers.
  20.  * @author luc Luc Maisonobe
  21.  * @since 6.1
  22.  */
  23. public class LoveNumbers implements Serializable {

  24.     /** Serializable UID. */
  25.     private static final long serialVersionUID = 20131014L;

  26.     /** Real part of the nominal Love numbers. */
  27.     private final double[][] real;

  28.     /** Imaginary part of the nominal Love numbers. */
  29.     private final double[][] imaginary;

  30.     /** Time-dependent part of the Love numbers. */
  31.     private final double[][] plus;

  32.     /** Simple constructor.
  33.      * @param real real part of the nominal Love numbers
  34.      * @param imaginary imaginary part of the nominal Love numbers
  35.      * @param plus time-dependent part of the Love numbers
  36.      */
  37.     public LoveNumbers(final double[][] real, final double[][] imaginary, final double[][] plus) {
  38.         this.real      = copyIrregular(real);
  39.         this.imaginary = copyIrregular(imaginary);
  40.         this.plus      = copyIrregular(plus);
  41.     }

  42.     /** Copy irregular-shape array.
  43.      * @param source source array
  44.      * @return copied array
  45.      */
  46.     private double[][] copyIrregular(final double[][] source) {
  47.         final double[][] copy = new double[source.length][];
  48.         for (int i = 0; i < source.length; ++i) {
  49.             copy[i] = source[i].clone();
  50.         }
  51.         return copy;
  52.     }

  53.     /** Get the size of the arrays.
  54.      * @return size of the arrays (i.e. max degree for Love numbers + 1)
  55.      */
  56.     public int getSize() {
  57.         return real.length;
  58.     }

  59.     /** Get the real part of a nominal Love numbers.
  60.      * @param n degree of the Love number (must be less than {@link #getSize()})
  61.      * @param m order of the Love number (must be less than {@code n})
  62.      * @return real part of k<sub>n,m</sub>
  63.      */
  64.     public final double getReal(final int n, final int m) {
  65.         return real[n][m];
  66.     }

  67.     /** Get the imaginary part of a nominal Love numbers.
  68.      * @param n degree of the Love number (must be less than {@link #getSize()})
  69.      * @param m order of the Love number (must be less than {@code n})
  70.      * @return imaginary part of k<sub>n,m</sub>
  71.      */
  72.     public final double getImaginary(final int n, final int m) {
  73.         return imaginary[n][m];
  74.     }

  75.     /** Get the real part of a nominal Love numbers.
  76.      * @param n degree of the Love number (must be less than {@link #getSize()})
  77.      * @param m order of the Love number (must be less than {@code n})
  78.      * @return k<sub>n,m</sub><sup>+</sup>
  79.      */
  80.     public final double getPlus(final int n, final int m) {
  81.         return plus[n][m];
  82.     }

  83. }