Skip to content

Commit

Permalink
compat changes for Julia v1.8 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarrasch committed Dec 14, 2021
1 parent b6175fb commit 7e739b6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NiceNumbers"
uuid = "fd372b59-0929-42ec-9982-92b7b2350263"
authors = ["Felix Kastner <kastner.felix@gmail.com>"]
version = "0.2.2"
version = "0.2.3"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
20 changes: 14 additions & 6 deletions src/NiceLinAlg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ using LinearAlgebra: Hermitian, Symmetric, UpperTriangular, LowerTriangular
using LinearAlgebra: _chol!, Cholesky, checkpositivedefinite
import LinearAlgebra: cholesky!


function cholesky!(A::Union{Hermitian{NiceNumber,S}, Symmetric{NiceNumber,S}} where S, ::Val{false}=Val(false); check::Bool = true)
C, info = _chol!(A.data, A.uplo == 'U' ? UpperTriangular : LowerTriangular)
check && checkpositivedefinite(info)
return Cholesky(C.data, A.uplo, info)
end
@static if VERSION < v"1.8.0-DEV.1139"
function cholesky!(A::Union{Hermitian{NiceNumber}, Symmetric{NiceNumber}}, ::Val{false}=Val(false); check::Bool = true)
C, info = _chol!(A.data, A.uplo == 'U' ? UpperTriangular : LowerTriangular)
check && checkpositivedefinite(info)
return Cholesky(C.data, A.uplo, info)
end
else
using LinearAlgebra: NoPivot
function cholesky!(A::Union{Hermitian{NiceNumber}, Symmetric{NiceNumber}}, ::NoPivot=NoPivot(); check::Bool = true)
C, info = _chol!(A.data, A.uplo == 'U' ? UpperTriangular : LowerTriangular)
check && checkpositivedefinite(info)
return Cholesky(C.data, A.uplo, info)
end
end
11 changes: 9 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
using NiceNumbers
using Test, LinearAlgebra

@static if VERSION < v"1.7"
nopivot = Val(false)
pivot = Val(true)
else
nopivot = NoPivot()
pivot = RowMaximum()
end

@testset "NiceNumbers" begin
@testset "Constructors" begin
Expand Down Expand Up @@ -136,12 +143,12 @@ using Test, LinearAlgebra
@testset "LU" begin
@nice L = [1 0 0;im 1 0; 1/2 -3im 1]
@nice U = [1 1 1;0 1 1; 0 0 1]
LUL, LUU = lu(L*U, Val(false))
LUL, LUU = lu(L*U, nopivot)
@test LUL == L
@test LUU == U

@nice A = [2 2 0;2 2 1; 2 3 5]
L, U, p = lu(A, Val(true))
L, U, p = lu(A, pivot)
@test L == @nice [1 0 0;1 1 0;1 0 1]
@test U == @nice [2 2 0;0 1 5;0 0 1]
@test p == [1,3,2]
Expand Down

2 comments on commit 7e739b6

@fkastner
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/50571

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.3 -m "<description of version>" 7e739b656351117573fc9466b14b2cfecce1c1c0
git push origin v0.2.3

Please sign in to comment.