ZeroOrderHoldSystem.java

/*
 * $Id$
 *
 * Copyright (C) 2004-2005 Koga Laboratory. All rights reserved.
 */

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

import org.mklab.nfc.matrix.ComplexNumericalMatrix;
import org.mklab.nfc.matrix.RealNumericalMatrix;
import org.mklab.nfc.scalar.ComplexNumericalScalar;
import org.mklab.nfc.scalar.RealNumericalScalar;


/**
 * ゼロ次ホールドシステムを表すクラスです。
 * 
 * @author koga
 * @version $Revision$
 * @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 class ZeroOrderHoldSystem<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 HoldSystem<RS,RM,CS,CM> {
  
  /**
   * Creates {@link ZeroOrderHoldSystem}.
   * @param sunit unit of scalar
   */
  public ZeroOrderHoldSystem(RS sunit) {
    super(sunit);
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public RM outputEquation( final RS t, final RM u) {
    if (isAtSamplingPoint()) {
      setState(u);
    }

    return getState();
  }

  /**
   * @see org.mklab.tool.control.system.SystemOperator#initialize()
   */
  @Override
  public void initialize() {
    final int size = getInputSize();

    if (size < 0) {
      return;
    }

    setState(this.sunit.createZeroGrid(size, 1));
  }
}