package nxm.sys.lib;

/**
  A class to handle Matrix operations.

  @author Tim Barnes
*/
public class Matrix extends Object {

  /** number of rows in the Matrix */
  public int nr;
  /** number of columns in the Matrix */
  public int nc;
  /** Matrix elements */
  public double[] elements;

  /** Matrix Constructor
      @param nrows number of rows
      @param ncolumns number of columns
   */
  public Matrix (int nrows, int ncolumns) {
    nr = nrows;
    nc = ncolumns;
    elements = new double[nr*nc];
  }

  /** sets the identity matrix */
  public void setIdentity() {
    for (int ir=0; ir<nr; ir++) {
      for (int ic=0; ic<nc; ic++) {
	int i = ir*nc+ic;
	if (ic==ir) elements[i]=0;
	else elements[i]=1;
      }
    }
  }

}

