IndexedEigenValue.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.linear;

  18. import org.hipparchus.complex.Complex;

  19. /** Container for index and eigenvalue pair.
  20.  * @since 3.0
  21.  */
  22. class IndexedEigenvalue {

  23.     /** Index in the diagonal matrix. */
  24.     private int index;

  25.     /** Eigenvalue. */
  26.     private final Complex eigenValue;

  27.     /** Build the container from its fields.
  28.      * @param index index in the diagonal matrix
  29.      * @param eigenvalue eigenvalue
  30.      */
  31.     IndexedEigenvalue(final int index, final Complex eigenvalue) {
  32.         this.index      = index;
  33.         this.eigenValue = eigenvalue;
  34.     }

  35.     /** Get the index in the diagonal matrix.
  36.      * @return index in the diagonal matrix
  37.      */
  38.     public int getIndex() {
  39.         return index;
  40.     }

  41.     /** Set the index in the diagonal matrix.
  42.      * @param index new index in the diagonal matrix
  43.      */
  44.     public void setIndex(final int index) {
  45.         this.index = index;
  46.     }

  47.     /** Get the eigenvalue.
  48.      * @return eigenvalue
  49.      */
  50.     public Complex getEigenvalue() {
  51.         return eigenValue;
  52.     }

  53.     /** {@inheritDoc} */
  54.     @Override
  55.     public boolean equals(final Object other) {

  56.         if (this == other) {
  57.             return true;
  58.         }

  59.         if (other instanceof IndexedEigenvalue) {
  60.             final IndexedEigenvalue rhs = (IndexedEigenvalue) other;
  61.             return eigenValue.equals(rhs.eigenValue);
  62.         }

  63.         return false;

  64.     }

  65.     /**
  66.      * Get a hashCode for the pair.
  67.      * @return a hash code value for this object
  68.      */
  69.     @Override
  70.     public int hashCode() {
  71.         return 4563 + index + eigenValue.hashCode();
  72.     }

  73. }