code: @Nonnull
    @ReturnsMutableCopy
    public Matrix solve (@Nonnull final Matrix aMatrix)
    {
      if (aMatrix.getRowDimension () != m_nRows)
        throw new IllegalArgumentException ("Matrix row dimensions must agree.");
      if (!isNonsingular ())
        throw new IllegalStateException ("Matrix is singular.");
  
      // Copy right hand side with pivoting
      final int nCols = aMatrix.getColumnDimension ();
      final Matrix aNewMatrix = aMatrix.getMatrix (m_aPivot, 0, nCols - 1);
      final double [] [] aNewArray = aNewMatrix.internalGetArray ();
  
      // Solve L*Y = B(piv,:)
      for (int k = 0; k < m_nCols; k++)
      {
        final double [] aNewk = aNewArray[k];
        for (int i = k + 1; i < m_nCols; i++)
        {
          final double [] aLUi = m_aLU[i];
          final double [] aNewi = aNewArray[i];
          for (int j = 0; j < nCols; j++)
            aNewi[j] -= aNewk[j] * aLUi[k];
        }
      }
      // Solve U*X = Y;
      for (int k = m_nCols - 1; k >= 0; k--)
      {
        final double [] aLUk = m_aLU[k];
        final double [] aNewk = aNewArray[k];
        for (int j = 0; j < nCols; j++)
          aNewk[j] /= aLUk[k];
        for (int i = 0; i < k; i++)
        {
          final double [] aLUi = m_aLU[i];
          final double [] aNewi = aNewArray[i];
          for (int j = 0; j < nCols; j++)
            aNewi[j] -= aNewk[j] * aLUi[k];
        }
      }
      return aNewMatrix;
    }
docs: Solve A*X = B
  
  @param aMatrix
  A Matrix with as many rows as A and any number of columns.
  @return X so that L*U*X = B(piv,:)
  @exception IllegalArgumentException
  Matrix row dimensions must agree.
  @exception RuntimeException
  Matrix is singular.