# Implementation of householder/reflection matrices with efficient multiplication?

Is there a standard implementation of reflector/householder matrices and their efficient multiplication with vectors (e.g. O(n) cost)?

I don’t think this would be hard to implement for my specific purposes, but for that same reason I’m suspecting it exists somewhere already. But I haven’t been able to find it anywhere.

Thanks!

I think you want `LinearAlgebra.reflectorApply!`. Unfortunately no documentation…

``````help?> LinearAlgebra.reflectorApply!
No documentation found.

LinearAlgebra.reflectorApply! is a Function.

# 1 method for generic function "reflectorApply!":
[1] reflectorApply!(x::AbstractVector, τ::Number, A::AbstractMatrix) in LinearAlgebra at /Users/sheehanolver/Projects/julia-1.7/usr/share/julia/stdlib/v1.7/LinearAlgebra/src/generic.jl:1518
``````

Thanks! I’ll take a look at the implementation to see if it’s doing what I need

But I was more wondering if there was some generic type that used this functionality through an implementation of the array interface. Then I could just plug in its representation where I need it. I guess this doesn’t exist?

Even more “low level” is the LAPACK interface with `LinearAlgebra.LAPACK.larfg!` and `LinearAlgebra.LAPACK.larf!`, and my knowledge ends about here; cf. ?larf

(Also, let’s appreciate the name )

Not for a single reflection. There is `LinearAlgebra.QRPackedQ` which is the LAPack format for a sequence of Householder reflections. (Also `LinearAlgebra.QRCompactWYQ` for the blocked storage )

There’s not much need for a library routine for a single reflector, since applying a single (unit-normalized) reflector `v` to a vector `x` is such a simple operation:

``````x .- v .* (2(v'x))
``````
1 Like