mat: use lapack64.Potri in Cholesky.InverseTo

Also,
 - make tricky shadowing conversion from a SymDense to a TriDense more
 explicit in Cholesky.ToSym,
 - add a benchmark for InverseTo:

name                        old time/op  new time/op  delta
CholeskyInverseTo/n=10-4    10.8µs ± 2%   3.2µs ± 1%  -70.16%  (p=0.008 n=5+5)
CholeskyInverseTo/n=100-4   1.07ms ± 2%  0.51ms ± 2%  -52.06%  (p=0.008 n=5+5)
CholeskyInverseTo/n=1000-4   713ms ± 1%   315ms ± 1%  -55.83%  (p=0.008 n=5+5)
This commit is contained in:
Vladimir Chalupecky
2019-01-04 14:33:43 +01:00
committed by Vladimír Chalupecký
parent ce5163176b
commit 9d4132a30c
2 changed files with 64 additions and 15 deletions

View File

@@ -616,3 +616,31 @@ func BenchmarkCholeskyToSym(b *testing.B) {
})
}
}
func BenchmarkCholeskyInverseTo(b *testing.B) {
for _, n := range []int{10, 100, 1000} {
b.Run("n="+strconv.Itoa(n), func(b *testing.B) {
rnd := rand.New(rand.NewSource(1))
data := make([]float64, n*n)
for i := range data {
data[i] = rnd.NormFloat64()
}
var a SymDense
a.SymOuterK(1, NewDense(n, n, data))
var chol Cholesky
ok := chol.Factorize(&a)
if !ok {
panic("not positive definite")
}
dst := NewSymDense(n, nil)
b.ResetTimer()
for i := 0; i < b.N; i++ {
chol.InverseTo(dst)
}
})
}
}