@@ -346,8 +346,8 @@ abstract type ColoringAlgorithm end
346
346
"""
347
347
fast_matrix_colors(A)
348
348
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.
351
351
"""
352
352
fast_matrix_colors (A) = false
353
353
fast_matrix_colors (A:: AbstractArray ) = fast_matrix_colors (typeof (A))
@@ -356,8 +356,8 @@ fast_matrix_colors(A::Type{<:Union{Diagonal,Bidiagonal,Tridiagonal,SymTridiagona
356
356
"""
357
357
matrix_colors(A::Union{Array,UpperTriangular,LowerTriangular})
358
358
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)]`
361
361
"""
362
362
function matrix_colors (A:: Union{Array,UpperTriangular,LowerTriangular} )
363
363
eachindex (1 : size (A,2 )) # Vector size matches number of rows
@@ -379,12 +379,48 @@ function matrix_colors(A::Union{Tridiagonal,SymTridiagonal})
379
379
_cycle (1 : 3 ,size (A,2 ))
380
380
end
381
381
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
+
382
403
function __init__ ()
383
404
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
+
384
413
@require StaticArrays= " 90137ffa-7385-5640-81b9-e52037218182" begin
385
414
ismutable (:: Type{<:StaticArrays.StaticArray} ) = false
386
415
can_setindex (:: Type{<:StaticArrays.StaticArray} ) = false
387
416
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
388
424
end
389
425
390
426
@require LabelledArrays= " 2ee39098-c373-598a-b85f-a56591580800" begin
0 commit comments