1
1
module ArrayInterface
2
2
3
3
using LinearAlgebra
4
- using SparseArrays
5
- using SuiteSparse
6
4
7
5
@static if isdefined (Base, Symbol (" @assume_effects" ))
8
6
using Base: @assume_effects
@@ -121,8 +119,6 @@ Return the buffer data that `x` points to. Unlike `parent(x::AbstractArray)`, `b
121
119
may not return another array type.
122
120
"""
123
121
buffer (x) = parent (x)
124
- buffer (x:: SparseMatrixCSC ) = getfield (x, :nzval )
125
- buffer (x:: SparseVector ) = getfield (x, :nzval )
126
122
buffer (@nospecialize x:: Union{Base.Slice, Base.IdentityUnitRange} ) = getfield (x, :indices )
127
123
128
124
"""
@@ -308,7 +304,6 @@ Determine whether `findstructralnz` accepts the parameter `x`.
308
304
has_sparsestruct (x) = has_sparsestruct (typeof (x))
309
305
has_sparsestruct (:: Type ) = false
310
306
has_sparsestruct (:: Type{<:AbstractArray} ) = false
311
- has_sparsestruct (:: Type{<:SparseMatrixCSC} ) = true
312
307
has_sparsestruct (:: Type{<:Diagonal} ) = true
313
308
has_sparsestruct (:: Type{<:Bidiagonal} ) = true
314
309
has_sparsestruct (:: Type{<:Tridiagonal} ) = true
@@ -320,7 +315,6 @@ has_sparsestruct(::Type{<:SymTridiagonal}) = true
320
315
Determine whether a given abstract matrix is singular.
321
316
"""
322
317
issingular (A:: AbstractMatrix ) = issingular (Matrix (A))
323
- issingular (A:: AbstractSparseMatrix ) = ! issuccess (lu (A, check = false ))
324
318
issingular (A:: Matrix ) = ! issuccess (lu (A, check = false ))
325
319
issingular (A:: UniformScaling ) = A. λ == 0
326
320
issingular (A:: Diagonal ) = any (iszero, A. diag)
@@ -359,11 +353,6 @@ function findstructralnz(x::Union{Tridiagonal, SymTridiagonal})
359
353
(rowind, colind)
360
354
end
361
355
362
- function findstructralnz (x:: SparseMatrixCSC )
363
- rowind, colind, _ = findnz (x)
364
- (rowind, colind)
365
- end
366
-
367
356
abstract type ColoringAlgorithm end
368
357
369
358
"""
@@ -403,9 +392,6 @@ cheaply.
403
392
function bunchkaufman_instance (A:: Matrix{T} ) where T
404
393
return bunchkaufman (similar (A, 0 , 0 ), check = false )
405
394
end
406
- function bunchkaufman_instance (A:: SparseMatrixCSC )
407
- bunchkaufman (sparse (similar (A, 1 , 1 )), check = false )
408
- end
409
395
410
396
"""
411
397
bunchkaufman_instance(a::Number) -> a
@@ -429,14 +415,10 @@ cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorizati
429
415
Returns an instance of the Cholesky factorization object with the correct type
430
416
cheaply.
431
417
"""
432
- function cholesky_instance (A:: Matrix{T} , pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
418
+ function cholesky_instance (A:: Matrix{T} , pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
433
419
return cholesky (similar (A, 0 , 0 ), pivot, check = false )
434
420
end
435
421
436
- function cholesky_instance (A:: Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}} , pivot = DEFAULT_CHOLESKY_PIVOT)
437
- cholesky (sparse (similar (A, 1 , 1 )), check = false )
438
- end
439
-
440
422
"""
441
423
cholesky_instance(a::Number, pivot = LinearAlgebra.RowMaximum()) -> a
442
424
@@ -458,14 +440,10 @@ ldlt_instance(A) -> ldlt_factorization_instance
458
440
Returns an instance of the LDLT factorization object with the correct type
459
441
cheaply.
460
442
"""
461
- function ldlt_instance (A:: Matrix{T} ) where {T}
443
+ function ldlt_instance (A:: Matrix{T} ) where {T}
462
444
return ldlt_instance (SymTridiagonal (similar (A, 0 , 0 )))
463
445
end
464
446
465
- function ldlt_instance (A:: SparseMatrixCSC )
466
- ldlt (sparse (similar (A, 1 , 1 )), check= false )
467
- end
468
-
469
447
function ldlt_instance (A:: SymTridiagonal{T,V} ) where {T,V}
470
448
return LinearAlgebra. LDLt {T,SymTridiagonal{T,V}} (A)
471
449
end
@@ -498,9 +476,6 @@ function lu_instance(A::Matrix{T}) where {T}
498
476
info = zero (LinearAlgebra. BlasInt)
499
477
return LU {luT} (similar (A, 0 , 0 ), ipiv, info)
500
478
end
501
- function lu_instance (jac_prototype:: SparseMatrixCSC )
502
- SuiteSparse. UMFPACK. UmfpackLU (similar (jac_prototype, 1 , 1 ))
503
- end
504
479
505
480
function lu_instance (A:: Symmetric{T} ) where {T}
506
481
noUnitT = typeof (zero (T))
@@ -557,11 +532,6 @@ function qr_instance(A::Matrix{BigFloat},pivot = DEFAULT_CHOLESKY_PIVOT)
557
532
LinearAlgebra. QR (zeros (BigFloat,0 ,0 ),zeros (BigFloat,0 ))
558
533
end
559
534
560
- # Could be optimized but this should work for any real case.
561
- function qr_instance (jac_prototype:: SparseMatrixCSC , pivot = DEFAULT_CHOLESKY_PIVOT)
562
- qr (sparse (rand (1 ,1 )))
563
- end
564
-
565
535
"""
566
536
qr_instance(a::Number) -> a
567
537
0 commit comments