// INVERSE
  // Inverse of a square Phasor matrix
  public PhasorMatrix inverse() {
    int n = this.nrow;
    if (n != this.ncol) throw new IllegalArgumentException("Matrix is not square");
    Phasor[] col = new Phasor[n];
    Phasor[] xvec = new Phasor[n];
    PhasorMatrix invmat = new PhasorMatrix(n, n);
    Phasor[][] invarray = invmat.getArrayReference();
    PhasorMatrix ludmat;

    ludmat = this.luDecomp();
    for (int j = 0; j < n; j++) {
      for (int i = 0; i < n; i++) col[i] = Phasor.zero();
      col[j] = Phasor.plusOne();
      xvec = ludmat.luBackSub(col);
      for (int i = 0; i < n; i++) invarray[i][j] = Phasor.copy(xvec[i]);
    }
    return invmat;
  }
  // Solves the set of n linear Phasor equations A.X=B
  // Phasor bvec is the vector B (input)
  // Phasor xvec is the vector X (output)
  public Phasor[] solveLinearSet(Phasor[] bvec) {
    PhasorMatrix ludmat;

    ludmat = this.luDecomp();
    return ludmat.luBackSub(bvec);
  }