Ferrite-FEM / Ferrite-FEM/Tensors.jl

Implement the Cholesky decomposition

未关闭
#232 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Julia
星标
182
派生
40
PR 合并指标
30 天内没有已合并 PR

描述

Doing the Cholesky decomposition with `Tensors.jl` is significantly slower than using `StaticArrays.jl`, presumably because there is no specific code and everything is converted into a standard `Matrix`:

```julia-repl
julia> using Tensors, StaticArrays, LinearAlgebra, BenchmarkTools

julia> A = SymmetricTensor{2,2,Float64}((1.0, 2.0, 5.0))
2×2 SymmetricTensor{2, 2, Float64, 3}:
1.0 2.0
2.0 5.0

julia> B = SMatrix{2,2}(1.0, 2.0, 2.0, 5.0)
2×2 SMatrix{2, 2, Float64, 4} with indices SOneTo(2)×SOneTo(2):
1.0 2.0
2.0 5.0

julia> @benchmark cholesky($A)
BenchmarkTools.Trial: 10000 samples with 992 evaluations per sample.
Range (min … max): 38.306 ns … 3.228 μs ┊ GC (min … max): 0.00% … 98.18%
Time (median): 43.557 ns ┊ GC (median): 0.00%
Time (mean ± σ): 46.372 ns ± 71.473 ns ┊ GC (mean ± σ): 6.35% ± 4.48%

▇█▆▂▂
▁▅█▇▇▇▅▄▃▃▃▄▃▃▃▄▅█████▆▄▃▃▃▃▃▃▂▂▂▂▃▃▃▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▃
38.3 ns Histogram: frequency by time 55.4 ns <

Memory estimate: 112 bytes, allocs estimate: 2.

julia> @benchmark cholesky($B)
BenchmarkTools.Trial: 10000 samples with 1000 evaluations per sample.
Range (min … max): 1.708 ns … 13.750 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 1.792 ns ┊ GC (median): 0.00%
Time (mean ± σ): 1.864 ns ± 0.199 ns ┊ GC (mean ± σ): 0.00% ± 0.00%

▅ █ ▁ ▁ ▂ ▄ ▇ ▁
▅▁▁▁▁█▁▁▁▁▁█▁▁▁▁▁█▁▁▁▁▁█▁▁▁▁██▁▁▁▁█▁▁▁▁▁█▁▁▁▁▁█▁▁▁▁▁█▁▁▁▁█ █
1.71 ns Histogram: log(frequency) by time 2.12 ns <

Memory estimate: 0 bytes, allocs estimate: 0.
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。