Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-232

Would like to have RealMatrix.getFrobeniusNorm()

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.0
    • None
    • None
    • Any

    Description

      I have been converting over some of my code that used Jama to use commons-math. One thing I would like to have is Matrix.normF() which returns the Frobenius norm (ie the square root of the sum of squares of all the elements).

      I have gotten around this by implementing this as a utility method, like so:

      /**

      • Return the square root of the sum of squares of all elements in
      • the matrix. In Jama, it is Matrix.normF().
      • @param matrix a RealMatrix.
      • @return the Frobenius norm.
        */
        public static double getFrobeniusNorm(RealMatrix matrix) {
        double frobeniusNorm = 0.0D;
        for (int row = 0; row < matrix.getRowDimension(); row++)
        Unknown macro: { for (int col = 0; col < matrix.getColumnDimension(); col++) { frobeniusNorm += Math.pow(matrix.getEntry(row, col), 2); } }

        return Math.sqrt(frobeniusNorm);
        }

      It would be nice if RealMatrix mandated a method getFrobeniusNorm() like getNorm(), that way this method is available from within a RealMatrix.

      Attachments

        Activity

          People

            luc Luc Maisonobe
            sujitpal Sujit Pal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: