Created
          October 29, 2017 14:41 
        
      - 
      
- 
        Save denius/ffa555b7e2f0c01c876e88d82f9fa0ee to your computer and use it in GitHub Desktop. 
    Application of Householder reflector from right
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # apply reflector from right | |
| # derived from base/linalg/generic.jl | |
| @inline function reflectorApplyRight!(x::AbstractVector, τ::Number, A::AbstractMatrix) | |
| m, n = size(A) | |
| if length(x) != n | |
| throw(DimensionMismatch("reflector has length $(length(x)), which must match the first dimension of matrix A, $n")) | |
| end | |
| @inbounds begin | |
| for i = 1:m | |
| # note: ommited x[1] == 1 | |
| # dot | |
| Aiv = A[i, 1] | |
| for j = 2:n | |
| Aiv += A[i, j]*x[j] | |
| end | |
| Aiv = τ*Aiv | |
| # ger | |
| A[i, 1] -= Aiv | |
| for j = 2:n | |
| A[i, j] -= Aiv*x[j]' | |
| end | |
| end | |
| end | |
| return A | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment