0

根据我的问题,我想跟进并从 spqr 过程的输出以(内存)有效的方式计算 Q 矩阵。到目前为止,似乎只实现了 matrix() 。但是,我只需要稀疏格式的 Q 矩阵,没有足够的内存稍后将其转换为稀疏矩阵:

using LinearAlgebra, SparseArrays
N  = 500
ns = 3
d = 0.0001
A = sprand(N,N-ns,d)
H = A*A'
println("eigen")
@time eigen(Matrix(H))
println("qr")
@time F = qr(H)
println("Matrix(F.Q)")
@time Q = Matrix(F.Q)
println("sparse(Q)")
@time sparse(Q)
println("sparse(F.Q)")
@time sparse(F.Q)

输出:

eigen
  0.046383 seconds (22 allocations: 7.810 MiB)
qr
  0.000479 seconds (649 allocations: 125.533 KiB)
Matrix(F.Q)
  0.000454 seconds (508 allocations: 1.931 MiB)
sparse(Q)
  0.000371 seconds (9 allocations: 12.406 KiB)
sparse(F.Q)
  1.355230 seconds (1.50 M allocations: 1.982 GiB, 33.47% gc time)

不幸的是,我在标准库中找不到执行 Matrix(FQ) 的例程,否则我可以自己用稀疏的方式替换它。

最好的,

五。

4

1 回答 1

0

一般来说,Q不会稀疏,所以我认为我们和 SuiteSparse 都不提供这样的功能。您也许可以根据Q结构中的稀疏反射器编写一个。

于 2020-07-24T12:58:39.050 回答