1
1
module ArrayInterface
2
2
3
+ const SLOWFALLBACKS = @load_preference (" slow_fallbacks" , true )
4
+
3
5
using LinearAlgebra
4
6
using SparseArrays
5
7
using SuiteSparse
@@ -282,7 +284,7 @@ function ismutable end
282
284
ismutable(::Type{T}) -> Bool
283
285
284
286
Query whether instances of type `T` are mutable or not, see
285
- https://github.com./JuliaDiffEq /RecursiveArrayTools.jl/issues/19.
287
+ https://github.com./SciML /RecursiveArrayTools.jl/issues/19.
286
288
"""
287
289
ismutable (x) = ismutable (typeof (x))
288
290
function ismutable (:: Type{T} ) where {T <: AbstractArray }
@@ -460,12 +462,15 @@ Returns the number.
460
462
"""
461
463
bunchkaufman_instance (a:: Number ) = a
462
464
463
- """
464
- bunchkaufman_instance(a::Any) -> cholesky(a, check=false)
465
+ @static if SLOWFALLBACKS
466
+ """
467
+ bunchkaufman_instance(a::Any) -> cholesky(a, check=false)
465
468
466
- Returns the number.
467
- """
468
- bunchkaufman_instance (a:: Any ) = bunchkaufman (a, check = false )
469
+ Slow fallback which gets the instance via factorization. Should get
470
+ specialized for new matrix types.
471
+ """
472
+ bunchkaufman_instance (a:: Any ) = bunchkaufman (a, check = false )
473
+ end
469
474
470
475
"""
471
476
cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance
@@ -487,13 +492,15 @@ Returns the number.
487
492
"""
488
493
cholesky_instance (a:: Number , pivot = LinearAlgebra. RowMaximum ()) = a
489
494
490
- """
491
- cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
495
+ @static if SLOWFALLBACKS
496
+ """
497
+ cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
492
498
493
- Slow fallback which gets the instance via factorization. Should get
494
- specialized for new matrix types.
495
- """
496
- cholesky_instance (a:: Any , pivot = LinearAlgebra. RowMaximum ()) = cholesky (a, pivot, check = false )
499
+ Slow fallback which gets the instance via factorization. Should get
500
+ specialized for new matrix types.
501
+ """
502
+ cholesky_instance (a:: Any , pivot = LinearAlgebra. RowMaximum ()) = cholesky (a, pivot, check = false )
503
+ end
497
504
498
505
"""
499
506
ldlt_instance(A) -> ldlt_factorization_instance
@@ -515,13 +522,15 @@ Returns the number.
515
522
"""
516
523
ldlt_instance (a:: Number ) = a
517
524
518
- """
519
- ldlt_instance(a::Any) -> ldlt(a, check=false)
525
+ @static if SLOWFALLBACKS
526
+ """
527
+ ldlt_instance(a::Any) -> ldlt(a, check=false)
520
528
521
- Slow fallback which gets the instance via factorization. Should get
522
- specialized for new matrix types.
523
- """
524
- ldlt_instance (a:: Any ) = ldlt (a)
529
+ Slow fallback which gets the instance via factorization. Should get
530
+ specialized for new matrix types.
531
+ """
532
+ ldlt_instance (a:: Any ) = ldlt (a)
533
+ end
525
534
526
535
"""
527
536
lu_instance(A) -> lu_factorization_instance
@@ -558,13 +567,15 @@ Returns the number.
558
567
"""
559
568
lu_instance (a:: Number ) = a
560
569
561
- """
562
- lu_instance(a::Any) -> lu(a, check=false)
570
+ @static if SLOWFALLBACKS
571
+ """
572
+ lu_instance(a::Any) -> lu(a, check=false)
563
573
564
- Slow fallback which gets the instance via factorization. Should get
565
- specialized for new matrix types.
566
- """
567
- lu_instance (a:: Any ) = lu (a, check = false )
574
+ Slow fallback which gets the instance via factorization. Should get
575
+ specialized for new matrix types.
576
+ """
577
+ lu_instance (a:: Any ) = lu (a, check = false )
578
+ end
568
579
569
580
"""
570
581
qr_instance(A) -> qr_factorization_instance
@@ -588,13 +599,15 @@ Returns the number.
588
599
"""
589
600
qr_instance (a:: Number ) = a
590
601
591
- """
592
- qr_instance(a::Any) -> qr(a)
602
+ @static if SLOWFALLBACKS
603
+ """
604
+ qr_instance(a::Any) -> qr(a)
593
605
594
- Slow fallback which gets the instance via factorization. Should get
595
- specialized for new matrix types.
596
- """
597
- qr_instance (a:: Any ) = qr (a)# check = false)
606
+ Slow fallback which gets the instance via factorization. Should get
607
+ specialized for new matrix types.
608
+ """
609
+ qr_instance (a:: Any ) = qr (a)# check = false)
610
+ end
598
611
599
612
"""
600
613
svd_instance(A) -> qr_factorization_instance
@@ -613,13 +626,15 @@ Returns the number.
613
626
"""
614
627
svd_instance (a:: Number ) = a
615
628
616
- """
617
- svd_instance(a::Any) -> svd(a)
629
+ @static if SLOWFALLBACKS
630
+ """
631
+ svd_instance(a::Any) -> svd(a)
618
632
619
- Slow fallback which gets the instance via factorization. Should get
620
- specialized for new matrix types.
621
- """
622
- svd_instance (a:: Any ) = svd (a) # check = false)
633
+ Slow fallback which gets the instance via factorization. Should get
634
+ specialized for new matrix types.
635
+ """
636
+ svd_instance (a:: Any ) = svd (a) # check = false)
637
+ end
623
638
624
639
"""
625
640
safevec(v)
@@ -1034,3 +1049,4 @@ import Requires
1034
1049
end
1035
1050
1036
1051
end # module
1052
+
0 commit comments