code: public static double qualityTriangular(ZMatrixRMaj T)
      {
          int N = Math.min(T.numRows,T.numCols);
  
          double max = elementDiagMaxMagnitude2(T);
  
          if( max == 0.0 )
              return 0.0;
  
          max = Math.sqrt(max);
          int rowStride = T.getRowStride();
  
          double qualityR = 1.0;
          double qualityI = 0.0;
  
          for( int i = 0; i < N; i++ ) {
              int index = i*rowStride + i*2;
  
              double real = T.data[index]/max;
              double imaginary = T.data[index]/max;
  
              double r = qualityR*real - qualityI*imaginary;
              double img = qualityR*imaginary + real*qualityI;
  
              qualityR = r;
              qualityI = img;
          }
  
          return Math.sqrt(qualityR*qualityR + qualityI*qualityI);
      }
docs: Computes the quality of a triangular matrix, where the quality of a matrix
  is defined in {@link LinearSolverDense#quality()}.  In
  this situation the quality is the magnitude of the product of
  each diagonal element divided by the magnitude of the largest diagonal element.
  If all diagonal elements are zero then zero is returned.
  
  @return the quality of the system.