AnyIntervalDerivativeMatrix.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.IntervalNumericalMatrix;
import org.mklab.cga.interval.scalar.IntervalNumericalScalar;
import org.mklab.nfc.matrix.NumericalMatrix;
import org.mklab.nfc.scalar.NumericalScalar;

/**
 * @param <IS> 区間スカラーの型
 * @param <IM> 区間行列の型
 * @param <S> スカラーの型
 * @param <M> の型
 * @author koga
 * @version $Revision$, 2021/09/14
 */
public class AnyIntervalDerivativeMatrix<IS extends IntervalNumericalScalar<IS,IM,S,M>,  IM extends IntervalNumericalMatrix<IS,IM,S,M>, S extends NumericalScalar<S,M>, M extends NumericalMatrix<S,M> > extends AbstractIntervalDerivativeMatrix<AnyIntervalDerivativeNumber<IS,IM,S,M>, AnyIntervalDerivativeMatrix<IS,IM,S,M>, IS, IM, S, M> {

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

  /**
   * Creates {@link AnyIntervalDerivativeMatrix}.
   * @param elements elements
   */
  public AnyIntervalDerivativeMatrix(AnyIntervalDerivativeNumber<IS, IM, S, M>[] elements) {
    super(elements);
  }

  /**
   * Creates {@link AnyIntervalDerivativeMatrix}.
   * @param elements elements
   */
  public AnyIntervalDerivativeMatrix(AnyIntervalDerivativeNumber<IS, IM, S, M>[][] elements) {
    super(elements);
  }

  /**
   * Creates {@link AnyIntervalDerivativeMatrix}.
   * @param rowSize row size
   * @param columnSize column size
   * @param elements elements
   */
  public AnyIntervalDerivativeMatrix(int rowSize, int columnSize, AnyIntervalDerivativeNumber<IS, IM, S, M>[][] elements) {
    super(rowSize, columnSize, elements);
  }

  /**
   * {@inheritDoc}
   */
  public AnyIntervalDerivativeMatrix<IS, IM, S, M> create(IM matrix) {
    AnyIntervalDerivativeNumber<IS, IM, S, M>[][] elements = getElement(1, 1).createArray(matrix.getRowSize(), matrix.getColumnSize());
    for (int i = 0; i < matrix.getRowSize(); i++) {
      for (int j = 0; j < matrix.getColumnSize(); j++) {
        elements[i][j] = getElement(1,1).create(matrix.getElement(i+1,j+1));
      }
    }
    return new AnyIntervalDerivativeMatrix<>(elements);
  }

  /**
   * {@inheritDoc}
   */
  public AnyIntervalDerivativeMatrix<IS, IM, S, M> create(IM x, IM dx) {
    AnyIntervalDerivativeNumber<IS, IM, S, M>[][] elements = getElement(1, 1).createArray(x.getRowSize(), x.getColumnSize());
    for (int i = 0; i < x.getRowSize(); i++) {
      for (int j = 0; j < x.getColumnSize(); j++) {
        elements[i][j] = getElement(1,1).create(x.getElement(i+1,j+1), dx.getElement(i+1,j+1));
      }
    }
    return new AnyIntervalDerivativeMatrix<>(elements);
  }


}