public DenseMatrix getQ ( ) { int m = qr . nrows ( ) ; int n = qr . ncols ( ) ; DenseMatrix Q = Matrix . zeros ( m , n ) ; for ( int k = n - 1 ; k >= 0 ; k -- ) { Q . set ( k , k , 1.0 ) ; for ( int j = k ; j < n ; j ++ ) { if ( qr . get ( k , k ) != 0 ) { double s = 0.0 ; for ( int i = k ; i < m ; i ++ ) { s += qr . get ( i , k ) * Q . get ( i , j ) ; } s = - s / qr . get ( k , k ) ; for ( int i = k ; i < m ; i ++ ) { Q . add ( i , j , s * qr . get ( i , k ) ) ; } } } } return Q ; }
Returns the orthogonal factor .