From aab124332dffb7c4229fb5e235b6b2db604dc6a5 Mon Sep 17 00:00:00 2001 From: Andreas Noack Date: Wed, 16 Dec 2015 11:49:53 -0500 Subject: [PATCH] Rename rank one up- and downdate functions for Cholesky to rank(up/down)date Add NEWS.md entry --- NEWS.md | 2 ++ base/linalg/cholesky.jl | 16 ++++++++-------- doc/stdlib/linalg.rst | 8 ++++---- test/linalg/cholesky.jl | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/NEWS.md b/NEWS.md index 244d8c3c4f3e1b..ecf86aed55a0e4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -70,6 +70,8 @@ Library improvements appropriate. The `sparsevec` function returns a one-dimensional sparse vector instead of a one-column sparse matrix. ([#13440]) + * Rank one update and downdate function for dense Choleksy factorizations ([#14243],[#14424]) + * New `foreach` function for calling a function on every element of a collection when the results are not needed. diff --git a/base/linalg/cholesky.jl b/base/linalg/cholesky.jl index 91623ffc4bbff5..0167c897b6228b 100644 --- a/base/linalg/cholesky.jl +++ b/base/linalg/cholesky.jl @@ -267,11 +267,11 @@ chkfullrank(C::CholeskyPivoted) = C.rank < size(C.factors, 1) && throw(RankDefic rank(C::CholeskyPivoted) = C.rank """ - update!(C::Cholesky, v::StridedVector) -> CC::Cholesky + rankupdate!(C::Cholesky, v::StridedVector) -> CC::Cholesky Update a Cholesky factorization `C` with the vector `v`. If `A = C[:U]'C[:U]` then `CC = cholfact(C[:U]'C[:U] + v*v')` but the computation of `CC` only uses `O(n^2)` operations. The input factorization `C` is updated in place such that on exit `C == CC`. The vector `v` is destroyed during the computation. """ -function update!(C::Cholesky, v::StridedVector) +function rankupdate!(C::Cholesky, v::StridedVector) A = C.factors n = length(v) if size(C, 1) != n @@ -310,11 +310,11 @@ function update!(C::Cholesky, v::StridedVector) end """ - downdate!(C::Cholesky, v::StridedVector) -> CC::Cholesky + rankdowndate!(C::Cholesky, v::StridedVector) -> CC::Cholesky Downdate a Cholesky factorization `C` with the vector `v`. If `A = C[:U]'C[:U]` then `CC = cholfact(C[:U]'C[:U] - v*v')` but the computation of `CC` only uses `O(n^2)` operations. The input factorization `C` is updated in place such that on exit `C == CC`. The vector `v` is destroyed during the computation. """ -function downdate!(C::Cholesky, v::StridedVector) +function rankdowndate!(C::Cholesky, v::StridedVector) A = C.factors n = length(v) if size(C, 1) != n @@ -360,15 +360,15 @@ function downdate!(C::Cholesky, v::StridedVector) end """ - update(C::Cholesky, v::StridedVector) -> CC::Cholesky + rankupdate(C::Cholesky, v::StridedVector) -> CC::Cholesky Update a Cholesky factorization `C` with the vector `v`. If `A = C[:U]'C[:U]` then `CC = cholfact(C[:U]'C[:U] + v*v')` but the computation of `CC` only uses `O(n^2)` operations. """ -update(C::Cholesky, v::StridedVector) = update!(copy(C), copy(v)) +rankupdate(C::Cholesky, v::StridedVector) = rankupdate!(copy(C), copy(v)) """ - downdate(C::Cholesky, v::StridedVector) -> CC::Cholesky + rankdowndate(C::Cholesky, v::StridedVector) -> CC::Cholesky Downdate a Cholesky factorization `C` with the vector `v`. If `A = C[:U]'C[:U]` then `CC = cholfact(C[:U]'C[:U] - v*v')` but the computation of `CC` only uses `O(n^2)` operations. """ -downdate(C::Cholesky, v::StridedVector) = downdate!(copy(C), copy(v)) +rankdowndate(C::Cholesky, v::StridedVector) = rankdowndate!(copy(C), copy(v)) diff --git a/doc/stdlib/linalg.rst b/doc/stdlib/linalg.rst index 8223d2a3ed0bd2..dab4b9f607fc0a 100644 --- a/doc/stdlib/linalg.rst +++ b/doc/stdlib/linalg.rst @@ -161,25 +161,25 @@ Linear algebra functions in Julia are largely implemented by calling functions f .. currentmodule:: Base.LinAlg -.. function:: update(C::Cholesky, v::StridedVector) -> CC::Cholesky +.. function:: rankupdate(C::Cholesky, v::StridedVector) -> CC::Cholesky .. Docstring generated from Julia source Update a Cholesky factorization ``C`` with the vector ``v``\ . If ``A = C[:U]'C[:U]`` then ``CC = cholfact(C[:U]'C[:U] + v*v')`` but the computation of ``CC`` only uses ``O(n^2)`` operations. -.. function:: downdate(C::Cholesky, v::StridedVector) -> CC::Cholesky +.. function:: rankdowndate(C::Cholesky, v::StridedVector) -> CC::Cholesky .. Docstring generated from Julia source Downdate a Cholesky factorization ``C`` with the vector ``v``\ . If ``A = C[:U]'C[:U]`` then ``CC = cholfact(C[:U]'C[:U] - v*v')`` but the computation of ``CC`` only uses ``O(n^2)`` operations. -.. function:: update!(C::Cholesky, v::StridedVector) -> CC::Cholesky +.. function:: rankupdate!(C::Cholesky, v::StridedVector) -> CC::Cholesky .. Docstring generated from Julia source Update a Cholesky factorization ``C`` with the vector ``v``\ . If ``A = C[:U]'C[:U]`` then ``CC = cholfact(C[:U]'C[:U] + v*v')`` but the computation of ``CC`` only uses ``O(n^2)`` operations. The input factorization ``C`` is updated in place such that on exit ``C == CC``\ . The vector ``v`` is destroyed during the computation. -.. function:: downdate!(C::Cholesky, v::StridedVector) -> CC::Cholesky +.. function:: rankdowndate!(C::Cholesky, v::StridedVector) -> CC::Cholesky .. Docstring generated from Julia source diff --git a/test/linalg/cholesky.jl b/test/linalg/cholesky.jl index 8596b0f3c54e2c..f42cfbe98fb07c 100644 --- a/test/linalg/cholesky.jl +++ b/test/linalg/cholesky.jl @@ -152,7 +152,7 @@ let A = complex(randn(10,5), randn(10, 5)), v = complex(randn(5), randn(5)) for uplo in (:U, :L) AcA = A'A F = cholfact(AcA, uplo) - @test LinAlg.update(F, v)[uplo] ≈ cholfact(AcA + v*v')[uplo] - @test LinAlg.downdate(F, v)[uplo] ≈ cholfact(AcA - v*v')[uplo] + @test LinAlg.rankupdate(F, v)[uplo] ≈ cholfact(AcA + v*v')[uplo] + @test LinAlg.rankdowndate(F, v)[uplo] ≈ cholfact(AcA - v*v')[uplo] end end