@@ -346,8 +346,8 @@ abstract type ColoringAlgorithm end
346346"""
347347 fast_matrix_colors(A)
348348
349- Query whether a matrix has a fast algorithm for getting the structural
350- colors of the matrix.
349+ Query whether a matrix has a fast algorithm for getting the structural
350+ colors of the matrix.
351351"""
352352fast_matrix_colors (A) = false
353353fast_matrix_colors (A:: AbstractArray ) = fast_matrix_colors (typeof (A))
@@ -356,8 +356,8 @@ fast_matrix_colors(A::Type{<:Union{Diagonal,Bidiagonal,Tridiagonal,SymTridiagona
356356"""
357357 matrix_colors(A::Union{Array,UpperTriangular,LowerTriangular})
358358
359- The color vector for dense matrix and triangular matrix is simply
360- `[1,2,3,...,size(A,2)]`
359+ The color vector for dense matrix and triangular matrix is simply
360+ `[1,2,3,...,size(A,2)]`
361361"""
362362function matrix_colors (A:: Union{Array,UpperTriangular,LowerTriangular} )
363363 eachindex (1 : size (A,2 )) # Vector size matches number of rows
@@ -379,12 +379,48 @@ function matrix_colors(A::Union{Tridiagonal,SymTridiagonal})
379379 _cycle (1 : 3 ,size (A,2 ))
380380end
381381
382+ """
383+ lu_instance(A) -> lu_factorization_instance
384+
385+ Return an instance of the LU factorization object with the correct type
386+ cheaply.
387+ """
388+ function lu_instance (A:: Matrix{T} ) where T
389+ noUnitT = typeof (zero (T))
390+ luT = LinearAlgebra. lutype (noUnitT)
391+ ipiv = Vector {LinearAlgebra.BlasInt} (undef, 0 )
392+ info = zero (LinearAlgebra. BlasInt)
393+ return LU {luT} (similar (A, 0 , 0 ), ipiv, info)
394+ end
395+
396+ """
397+ lu_instance(a::Number) -> a
398+
399+ Return the number.
400+ """
401+ lu_instance (a:: Number ) = a
402+
382403function __init__ ()
383404
405+ @require SuiteSparse= " 4607b0f0-06f3-5cda-b6b1-a6196a1729e9" begin
406+ lu_instance (jac_prototype:: SparseMatrixCSC ) = SuiteSparse. UMFPACK. UmfpackLU (Ptr {Cvoid} (), Ptr {Cvoid} (), 1 , 1 ,
407+ jac_prototype. colptr[1 : 1 ],
408+ jac_prototype. rowval[1 : 1 ],
409+ jac_prototype. nzval[1 : 1 ],
410+ 0 )
411+ end
412+
384413 @require StaticArrays= " 90137ffa-7385-5640-81b9-e52037218182" begin
385414 ismutable (:: Type{<:StaticArrays.StaticArray} ) = false
386415 can_setindex (:: Type{<:StaticArrays.StaticArray} ) = false
387416 ismutable (:: Type{<:StaticArrays.MArray} ) = true
417+ function lu_instance (_A:: StaticArrays.StaticMatrix{N,N} ) where {N}
418+ A = StaticArrays. SArray (_A)
419+ L = LowerTriangular (A)
420+ U = UpperTriangular (A)
421+ p = StaticArrays. SVector {N,Int} (1 : N)
422+ return StaticArrays. LU (L, U, p)
423+ end
388424 end
389425
390426 @require LabelledArrays= " 2ee39098-c373-598a-b85f-a56591580800" begin
0 commit comments