package com.m3rcuriel.controve.control.statespace;

import com.m3rcuriel.controve.util.DoubleMatrix;

/**
 * General representation of a State Feedback Controller with L and K matrices.
 *
 * @author Lee Mracek
 */
public class StateFeedbackController {
  private final DoubleMatrix matrixL;
  private final DoubleMatrix matrixK;

  /**
   * Initializes a new StateFeedbackController wth the given control matrices.
   * @param numberOfStates the number of states in the state matrix
   * @param numberOfInputs the number of inputs in the input matrix
   * @param numberOfOutputs the number of outputs in the output matrix
   * @param matrixL the L matrix for the observer
   * @param matrixK the K matrix for the controller
   */
  public StateFeedbackController(int numberOfStates, int numberOfInputs, int numberOfOutputs,
      DoubleMatrix matrixL, DoubleMatrix matrixK) {
    if (matrixL.getWidth() != numberOfOutputs) {
      throw new IllegalArgumentException("The width of L must be the number of outputs");
    }
    if (matrixL.getHeight() != numberOfStates) {
      throw new IllegalArgumentException("The height of L must be the number of states");
    }
    if (matrixK.getWidth() != numberOfStates) {
      throw new IllegalArgumentException("The width of K must be the number of states");
    }
    if (matrixK.getHeight() != numberOfInputs) {
      throw new IllegalArgumentException("The height of K must be the number of inputs");
    }

    this.matrixL = matrixL;
    this.matrixK = matrixK;
  }

  /**
   * Returns the L matrix of the observer.
   *
   * @return the L matrix
   */
  public DoubleMatrix getMatrixL() {
    return matrixL;
  }

  /**
   * Returns the K matrix of the controller.
   *
   * @return the K matrix
   */
  public DoubleMatrix getMatrixK() {
    return matrixK;
  }
}

@@ -322,16 +322,77 @@
 matrixK;
+%0A  private final StateFeedbackPlantCoefficients coefficients;
 %0A%0A  /**%0A
@@ -779,16 +779,95 @@
 troller%0A
+   * @param coefficients the associated %7B@link StateFeedbackPlantCoefficients%7D%0A
    */%0A  
@@ -1006,16 +1006,61 @@
  matrixK
+, StateFeedbackPlantCoefficients coefficients
 ) %7B%0A    
@@ -1686,24 +1686,62 @@
  = matrixK;%0A
+    this.coefficients = coefficients;%0A
   %7D%0A%0A  /**%0A 
@@ -2002,24 +2002,24 @@
 MatrixK() %7B%0A
-
     return m
@@ -2029,11 +2029,273 @@
 ixK;%0A  %7D
+%0A%0A  /**%0A   * Retrieve the coefficients for the corresponding controller plant.%0A   *%0A   * @return the %7B@link StateFeedbackPlantCoefficients%7D associated with the controller%0A   */%0A  public StateFeedbackPlantCoefficients coefficients() %7B%0A    return coefficients;%0A  %7D
 %0A%7D%0A

Revert StateFeedbackController.java