DoubleUserDefinedContinuousImplicitDynamicSystem.java

/*
 * Created on 2007/07/16
 * Copyright (C) 2007 Koga Laboratory. All rights reserved.
 *
 */
package org.mklab.tool.control.system.continuous;

import java.lang.reflect.InvocationTargetException;

import org.mklab.nfc.matrix.DoubleMatrix;
import org.mklab.nfc.ode.SolverStopException;


/**
 * ユーザ定義連続時間動的システムを表わすクラスです。
 * 
 * @author koga
 * @version $Revision: 1.14 $, 2007/07/16
 */
public class DoubleUserDefinedContinuousImplicitDynamicSystem extends DoubleUserDefinedContinuousDynamicSystem implements DoubleContinuousImplicitDynamicSystem {
  /**
   * 新しく生成された<code>UserDefinedDynamicSystem</code>オブジェクトを初期化します。
   * 
   * @param obj 呼び出し対象オブジェクト。nullの場合は静的メソッドを参照します
   */
  public DoubleUserDefinedContinuousImplicitDynamicSystem(Object obj) {
    super(obj);
  }

  /**
   * 新しく生成された<code>UserDefinedContinuousDynamicSystem</code>オブジェクトを初期化します。
   */
  public DoubleUserDefinedContinuousImplicitDynamicSystem() {
    this(null);
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public DoubleMatrix stateEquation(double t, DoubleMatrix x, DoubleMatrix dx, DoubleMatrix u) throws SolverStopException {
    try {
      return (DoubleMatrix)this.stateFunction.invoke(this.object, Double.valueOf(t), x, dx, u);
    } catch (IllegalArgumentException e) {
      throw new SolverStopException(e);
    } catch (IllegalAccessException e) {
      throw new SolverStopException(e);
    } catch (InvocationTargetException e) {
      throw new SolverStopException(e.getTargetException());
    } catch (Exception e) {
      throw new SolverStopException(e);
    }
  }

  /**
   * {@inheritDoc}
   */
  @Override
  final public DoubleMatrix differentialEquation(final double t, final DoubleMatrix x, DoubleMatrix dx, final DoubleMatrix inputOutput) throws SolverStopException {
    final DoubleMatrix u = inputOutput.getRowVectors(1, getInputSize());
    return stateEquation(t, x, dx, u);
  }
}