DoubleComplexIntervalDerivativeMatrix.java

/**
 * Copyright (C) 2021 MKLab.org (Koga Laboratory)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.mklab.cga.derivative;

import org.mklab.cga.interval.matrix.DoubleComplexIntervalMatrix;
import org.mklab.cga.interval.matrix.DoubleIntervalMatrix;
import org.mklab.cga.interval.scalar.DoubleComplexIntervalNumber;
import org.mklab.cga.interval.scalar.DoubleIntervalNumber;
import org.mklab.nfc.matrix.DoubleComplexMatrix;
import org.mklab.nfc.matrix.DoubleMatrix;
import org.mklab.nfc.scalar.DoubleComplexNumber;
import org.mklab.nfc.scalar.DoubleNumber;

/**
 * @author koga
 * @version $Revision$, 2021/09/10
 */
public class DoubleComplexIntervalDerivativeMatrix extends AbstractIntervalDerivativeComplexMatrix<DoubleIntervalDerivativeNumber,DoubleIntervalDerivativeMatrix,DoubleComplexIntervalDerivativeNumber,DoubleComplexIntervalDerivativeMatrix,DoubleIntervalNumber,DoubleIntervalMatrix,DoubleComplexIntervalNumber,DoubleComplexIntervalMatrix,DoubleNumber,DoubleMatrix,DoubleComplexNumber,DoubleComplexMatrix> {

  /** */
  private static final long serialVersionUID = 1L;

  /**
   * Creates {@link DoubleComplexIntervalDerivativeMatrix}.
   * @param elements elements
   */
  public DoubleComplexIntervalDerivativeMatrix(DoubleComplexIntervalDerivativeNumber[][] elements) {
    super(elements);
  }

  /**
   * Creates {@link DoubleComplexIntervalDerivativeMatrix}.
   * @param elements elements
   */
  public DoubleComplexIntervalDerivativeMatrix(DoubleComplexIntervalDerivativeNumber[] elements) {
    super(elements);
  }

  /**
   * Creates {@link DoubleComplexIntervalDerivativeMatrix}.
   * @param rowSize row size
   * @param columnSize column size
   * @param elements elements
   */
  public DoubleComplexIntervalDerivativeMatrix(int rowSize, int columnSize, DoubleComplexIntervalDerivativeNumber[][] elements) {
    super(rowSize, columnSize, elements);
  }

  /**
   * Creates {@link DoubleComplexIntervalDerivativeMatrix}.
   * @param matrix matrix
   */
  public DoubleComplexIntervalDerivativeMatrix(DoubleComplexIntervalMatrix matrix) {
    this(createDerivativeElements(matrix));
  }

  /**
   * Creates {@link DoubleComplexIntervalDerivativeMatrix}.
   * @param x x
   * @param dx dx
   */
  public DoubleComplexIntervalDerivativeMatrix(DoubleComplexIntervalMatrix x, DoubleComplexIntervalMatrix dx) {
    this(createDerivativeElements(x, dx));
  }

  
  /**
   * {@inheritDoc}
   */
  public DoubleComplexIntervalDerivativeMatrix create(DoubleComplexIntervalMatrix matrix) {
    return new DoubleComplexIntervalDerivativeMatrix(matrix);
  }

  /**
   * {@inheritDoc}
   */
  public DoubleComplexIntervalDerivativeMatrix create(DoubleComplexIntervalMatrix x, DoubleComplexIntervalMatrix dx) {
    return new DoubleComplexIntervalDerivativeMatrix(x, dx);
  }
  
  /**
   * Creates interval derivative elements.
   * 
   * @param matrix matrix
   * @return interval derivative elements
   */
  private static DoubleComplexIntervalDerivativeNumber[][] createDerivativeElements(DoubleComplexIntervalMatrix matrix) {
    int rowSize = matrix.getRowSize();
    int columnSize = matrix.getColumnSize();
    
    DoubleComplexIntervalDerivativeNumber[][] elements = new DoubleComplexIntervalDerivativeNumber[rowSize][columnSize];
    for (int i = 0; i < rowSize; i++) {
      for (int j = 0; j < columnSize; j++) {
        elements[i][j] = new DoubleComplexIntervalDerivativeNumber(matrix.getElement(i+1, j+1));
      }
    }
    return elements;
  }

  /**
   * Creates interval derivative elements.
   * 
   * @param x x
   * @param dx dx
   * @return interval derivative elements
   */
  private static DoubleComplexIntervalDerivativeNumber[][] createDerivativeElements(DoubleComplexIntervalMatrix x, DoubleComplexIntervalMatrix dx) {
    int rowSize = x.getRowSize();
    int columnSize = x.getColumnSize();
    DoubleComplexIntervalDerivativeNumber[][] elements = new DoubleComplexIntervalDerivativeNumber[rowSize][columnSize];
    for (int i = 0; i < rowSize; i++) {
      for (int j = 0; j < columnSize; j++) {
        elements[i][j] = new DoubleComplexIntervalDerivativeNumber(x.getElement(i+1, j+1), dx.getElement(i+1, j+1));
      }
    }
    return elements;
  }
}