Does this lose the benefit of QR decomposition?

My understanding is that one can do fast multiplies by the Q matrix of the QR decomposition because it is represented as a sequence of Householder reflections. I want to compute

    deltai = 3:size(T, 1)
    δ = Q[:, deltai] * fp[deltai]

(not self-containted; fp is one dimensional) where Q is the result of a call to qr().Q. I’m concerned that, since I subset Q explicitly this loses the benefit.

Should I be concerned? If so, what can I do about it?

I don’t think (Q*fp)[deltai] yields the same result.

I guess I could force the first 2 values of fp to 0; then I think Q*fp does give the result I want.

I think padding the first two entries to be zero would be the most efficient option here: otherwise it has to form Q, which requires applying the reflectors of Q to an identity matrix:

3 Likes

Thank you. After overcoming the fact that my code became so optimized it wouldn’t run at all, I got it to work. The difference was very large, ~8x faster based on the means, considering that is only one part of the calculations. Memory use shows similar improvements.

Before

   julia> @benchmark RBSilly.fit(yx, 2)
    BenchmarkTools.Trial:
      memory estimate:  3.17 MiB
      allocs estimate:  602
      --------------
      minimum time:     71.913 μs (0.00% GC)
      median time:      168.027 μs (0.00% GC)
      mean time:        241.267 μs (41.50% GC)
      maximum time:     2.101 ms (89.42% GC)
      --------------
      samples:          10000
      evals/sample:     1

After

    julia> @benchmark RBSilly.fit(yx, 2)
    BenchmarkTools.Trial:
      memory estimate:  59.86 KiB
      allocs estimate:  190
      --------------
      minimum time:     23.335 μs (0.00% GC)
      median time:      24.966 μs (0.00% GC)
      mean time:        29.430 μs (11.89% GC)
      maximum time:     3.025 ms (94.90% GC)
      --------------
      samples:          10000
      evals/sample:     1
4 Likes