diff --git a/src/Factorizations/mplu!.jl b/src/Factorizations/mplu!.jl index d613fb12..ba71a004 100644 --- a/src/Factorizations/mplu!.jl +++ b/src/Factorizations/mplu!.jl @@ -38,3 +38,19 @@ function mplu!(MPA::Union{MPArray,MPEArray}) end return MPF end + + +""" +mplu(A::Array{Float64,2}; TL=Float32, onthefly=false) + +Combines the constructor of the multiprecision array with the +factorization. +""" +function mplu(A::Array{TH,2}; TL=Float32, onthefly=nothing) where TH <: Real +(TH == Float32) && (TL = Float16) +((onthefly == nothing ) && (TL == Float16)) && (onthefly=true) +((onthefly == nothing ) && (TL == Float32)) && (onthefly=false) +MPA=MPArray(A; TL=TL, onthefly=onthefly) +MPF=mplu!(MPA) +return MPF +end diff --git a/src/MultiPrecisionArrays.jl b/src/MultiPrecisionArrays.jl index 0576a0bc..2b8a0fd3 100644 --- a/src/MultiPrecisionArrays.jl +++ b/src/MultiPrecisionArrays.jl @@ -84,6 +84,7 @@ export hlu # them to nonlinear solvers and eigen solvers. # export mplu! +export mplu export mphlu! export mpglu! export mpqr! diff --git a/test/DetailsTest/.mplu_test.jl.swp b/test/DetailsTest/.mplu_test.jl.swp new file mode 100644 index 00000000..ef4d25fb Binary files /dev/null and b/test/DetailsTest/.mplu_test.jl.swp differ diff --git a/test/DetailsTest/mplu_test.jl b/test/DetailsTest/mplu_test.jl new file mode 100644 index 00000000..571e9ed7 --- /dev/null +++ b/test/DetailsTest/mplu_test.jl @@ -0,0 +1,27 @@ +""" +mplu_test() + +Make sure that mplu and mplu! do what they are supposed to do +""" +function mplu_test() +AD=rand(10,10); MPD=MPArray(AD); MPF1=mplu!(MPD); MPF2=mplu(AD); +eq64=test_eq(MPF1,MPF2) +ADx=rand(10,10); MPDx=MPArray(ADx; TL=Float16); +MPF1x=mplu!(MPDx); MPF2x=mplu(ADx; TL=Float16); +eq64x=test_eq(MPF1x,MPF2x) +AS=Float32.(AD); MPS=MPArray(AS); MSF1=mplu!(MPS); MSF2=mplu(AS) +eq32=test_eq(MSF1,MSF2) +mpluok = (eq64 && eq64x && eq32) +mpluok || println("mplu failure") +return mpluok +end + + +function test_eq(MF1,MF2) +eqok=true +for nf in fieldnames(MPLFact) +gx=getfield(MF1,nf); hx =getfield(MF2,nf) +eqok= ((gx==hx) && eqok) +end +return eqok +end diff --git a/test/runtests.jl b/test/runtests.jl index 40608321..0a62fd22 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,6 +10,7 @@ include("NLTest/nltest.jl") include("DetailsTest/precision_test.jl") include("DetailsTest/hlu_test.jl") include("DetailsTest/slashtest.jl") +include("DetailsTest/mplu_test.jl") include("GM-IRTest/mpgmtest.jl") include("GM-IRTest/hvse.jl") @@ -29,6 +30,7 @@ end @test precision_test() @test hlu_test() @test slashtest() + @test mplu_test() end @testset "GM-IR" begin