BaseSampledDataStaticSystem.java

/*
 * $Id: BaseSampledDataStaticSystem.java,v 1.6 2008/07/16 03:51:36 koga Exp $
 *
 * Copyright (C) 2004-2005 Koga Laboratory. All rights reserved.
 */

package org.mklab.tool.control.system.sampled;

import org.mklab.nfc.matrix.ComplexNumericalMatrix;
import org.mklab.nfc.matrix.RealNumericalMatrix;
import org.mklab.nfc.ode.SolverStopException;
import org.mklab.nfc.scalar.ComplexNumericalScalar;
import org.mklab.nfc.scalar.RealNumericalScalar;
import org.mklab.tool.control.system.SystemOperator;


/**
 * サンプル値静的システムを表わすクラスです。
 * 
 * @author koga
 * @version $Revision: 1.6 $
* @param <RS> type of real scalar
 * @param <RM> type of real matrix
 * @param <CS> type of complex scalar
 * @param <CM> type of complex matrix
  */
public abstract class BaseSampledDataStaticSystem<RS extends RealNumericalScalar<RS,RM,CS,CM>, RM extends RealNumericalMatrix<RS,RM,CS,CM>, CS extends ComplexNumericalScalar<RS,RM,CS,CM>, CM extends ComplexNumericalMatrix<RS,RM,CS,CM>> extends SystemOperator<RS,RM,CS,CM> implements SampledDataStaticSystem<RS,RM,CS,CM> {

  /** サンプリング点ならばtrue */
  private boolean atSamplingPoint;

  /**
   * 新しく生成された<code>AbstractSampledDataStaticSystem</code>オブジェクトを初期化します。
   * 
   * @param inputSize 入力の数
   * @param outputSize 出力の数
   * @param sunit unit of scalar
   */
  public BaseSampledDataStaticSystem(final int inputSize, final int outputSize, RS sunit) {
    super(sunit);
    setInputSize(inputSize);
    setOutputSize(outputSize);
    setDynamic(false);
    if (inputSize == 0) {
      setForcedSystem(false);
    }
  }

  /**
   * @see org.mklab.tool.control.system.SystemOperator#initialize()
   */
  @Override
  public void initialize() {
    this.atSamplingPoint = false;
  }

  /**
   * {@inheritDoc}
   */
  public RM outputEquation( final RS t) throws SolverStopException {
    throw new SolverStopException(Messages.getString("BaseSampledDataStaticSystem.0")); //$NON-NLS-1$
  }

  /**
   * {@inheritDoc}
   */
  public RM outputEquation( final RS t,  final RM input) throws SolverStopException {
    throw new SolverStopException(Messages.getString("BaseSampledDataStaticSystem.1")); //$NON-NLS-1$
  }

  /**
   * @see org.mklab.nfc.ode.Sampling#isAtSamplingPoint()
   */
  public boolean isAtSamplingPoint() {
    return this.atSamplingPoint;
  }

  /**
   * @see org.mklab.nfc.ode.Sampling#setAtSamplingPoint(boolean)
   */
  public void setAtSamplingPoint(final boolean samplingPoint) {
    this.atSamplingPoint = samplingPoint;
  }

  /**
   * @see org.mklab.tool.control.system.SystemOperator#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (!super.equals(o)) {
      return false;
    }
    if (o == null) {
      return false;
    }
    if (o.getClass() != getClass()) {
      return false;
    }
    BaseSampledDataStaticSystem<RS,RM,CS,CM> castedObj = (BaseSampledDataStaticSystem<RS,RM,CS,CM>)o;
    return ((this.atSamplingPoint == castedObj.atSamplingPoint));
  }

  /**
   * @see org.mklab.tool.control.system.SystemOperator#hashCode()
   */
  @Override
  public int hashCode() {
    int hashCode = super.hashCode();
    hashCode = 31 * hashCode + (this.atSamplingPoint ? 1231 : 1237);
    return hashCode;
  }
}