Class QrHelperFunctions_DDRM


  • public class QrHelperFunctions_DDRM
    extends java.lang.Object

    Contains different functions that are useful for computing the QR decomposition of a matrix.

    Two different families of functions are provided for help in computing reflectors. Internally both of these functions switch between normalization by division or multiplication. Multiplication is most often significantly faster than division (2 or 3 times) but produces less accurate results on very small numbers. It checks to see if round off error is significant and decides which one it should do.

    Tests were done using the stability benchmark in jmatbench and there doesn't seem to be any advantage to always dividing by the max instead of checking and deciding. The most noticeable difference between the two methods is with very small numbers.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double computeTauAndDivide​(int j, int numRows, double[] u, double max)
      Normalizes elements in 'u' by dividing by max and computes the norm2 of the normalized array u.
      static double computeTauAndDivide​(int j, int numRows, double[] u, int startU, double max)  
      static void divideElements​(int j, int numRows, double[] u, double u_0)  
      static void divideElements​(int j, int numRows, double[] u, int startU, double u_0)  
      static void divideElements_Bcol​(int j, int numRows, int numCols, double[] u, double[] b, int startB, double u_0)  
      static void divideElements_Brow​(int j, int numRows, double[] u, double[] b, int startB, double u_0)  
      static double findMax​(double[] u, int startU, int length)  
      static void rank1UpdateMultL​(org.ejml.data.DMatrixRMaj A, double[] u, double gamma, int colA0, int w0, int w1)
      Performs a rank-1 update operation on the submatrix specified by w with the multiply on the left.

      A = A(I - γ*u*uT)
      static void rank1UpdateMultR​(org.ejml.data.DMatrixRMaj A, double[] u, double gamma, int colA0, int w0, int w1, double[] _temp)
      Performs a rank-1 update operation on the submatrix specified by w with the multiply on the right.

      A = (I - γ*u*uT)*A
      static void rank1UpdateMultR​(org.ejml.data.DMatrixRMaj A, double[] u, int offsetU, double gamma, int colA0, int w0, int w1, double[] _temp)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • QrHelperFunctions_DDRM

        public QrHelperFunctions_DDRM()
    • Method Detail

      • findMax

        public static double findMax​(double[] u,
                                     int startU,
                                     int length)
      • divideElements

        public static void divideElements​(int j,
                                          int numRows,
                                          double[] u,
                                          double u_0)
      • divideElements

        public static void divideElements​(int j,
                                          int numRows,
                                          double[] u,
                                          int startU,
                                          double u_0)
      • divideElements_Brow

        public static void divideElements_Brow​(int j,
                                               int numRows,
                                               double[] u,
                                               double[] b,
                                               int startB,
                                               double u_0)
      • divideElements_Bcol

        public static void divideElements_Bcol​(int j,
                                               int numRows,
                                               int numCols,
                                               double[] u,
                                               double[] b,
                                               int startB,
                                               double u_0)
      • computeTauAndDivide

        public static double computeTauAndDivide​(int j,
                                                 int numRows,
                                                 double[] u,
                                                 int startU,
                                                 double max)
      • computeTauAndDivide

        public static double computeTauAndDivide​(int j,
                                                 int numRows,
                                                 double[] u,
                                                 double max)
        Normalizes elements in 'u' by dividing by max and computes the norm2 of the normalized array u. Adjust the sign of the returned value depending on the size of the first element in 'u'. Normalization is done to avoid overflow.
         for i=j:numRows
           u[i] = u[i] / max
           tau = tau + u[i]*u[i]
         end
         tau = sqrt(tau)
         if( u[j] < 0 )
            tau = -tau;
         
        Parameters:
        j - Element in 'u' that it starts at.
        numRows - Element in 'u' that it stops at.
        u - Array
        max - Max value in 'u' that is used to normalize it.
        Returns:
        norm2 of 'u'
      • rank1UpdateMultR

        public static void rank1UpdateMultR​(org.ejml.data.DMatrixRMaj A,
                                            double[] u,
                                            double gamma,
                                            int colA0,
                                            int w0,
                                            int w1,
                                            double[] _temp)

        Performs a rank-1 update operation on the submatrix specified by w with the multiply on the right.

        A = (I - γ*u*uT)*A

        The order that matrix multiplies are performed has been carefully selected to minimize the number of operations.

        Before this can become a truly generic operation the submatrix specification needs to be made more generic.

      • rank1UpdateMultR

        public static void rank1UpdateMultR​(org.ejml.data.DMatrixRMaj A,
                                            double[] u,
                                            int offsetU,
                                            double gamma,
                                            int colA0,
                                            int w0,
                                            int w1,
                                            double[] _temp)
      • rank1UpdateMultL

        public static void rank1UpdateMultL​(org.ejml.data.DMatrixRMaj A,
                                            double[] u,
                                            double gamma,
                                            int colA0,
                                            int w0,
                                            int w1)

        Performs a rank-1 update operation on the submatrix specified by w with the multiply on the left.

        A = A(I - γ*u*uT)

        The order that matrix multiplies are performed has been carefully selected to minimize the number of operations.

        Before this can become a truly generic operation the submatrix specification needs to be made more generic.