@@ -40,22 +40,8 @@ julia> ArrayInterface.map_tuple_type(sqrt, Tuple{1,4,16})
40
40
```
41
41
"""
42
42
function map_tuple_type end
43
- if VERSION >= v " 1.8"
44
- @inline function map_tuple_type (f, @nospecialize (T:: Type ))
45
- ntuple (i -> f (fieldtype (T, i)), Val {fieldcount(T)} ())
46
- end
47
- else
48
- function map_tuple_type (f:: F , :: Type{T} ) where {F, T <: Tuple }
49
- if @generated
50
- t = Expr (:tuple )
51
- for i in 1 : fieldcount (T)
52
- push! (t. args, :(f ($ (fieldtype (T, i)))))
53
- end
54
- Expr (:block , Expr (:meta , :inline ), t)
55
- else
56
- Tuple (f (fieldtype (T, i)) for i in 1 : fieldcount (T))
57
- end
58
- end
43
+ @inline function map_tuple_type (f, @nospecialize (T:: Type ))
44
+ ntuple (i -> f (fieldtype (T, i)), Val {fieldcount(T)} ())
59
45
end
60
46
61
47
"""
@@ -78,50 +64,22 @@ julia> ArrayInterface.flatten_tuples((1, (2, (3,))))
78
64
```
79
65
"""
80
66
function flatten_tuples end
81
- if VERSION >= v " 1.8"
82
- function flatten_tuples (t:: Tuple )
83
- fields = _new_field_positions (t)
84
- ntuple (Val {nfields(fields)} ()) do k
85
- i, j = getfield (fields, k)
86
- i = length (t) - i
87
- @inbounds j === 0 ? getfield (t, i) : getfield (getfield (t, i), j)
88
- end
89
- end
90
- _new_field_positions (:: Tuple{} ) = ()
91
- @nospecialize
92
- function _new_field_positions (x:: Tuple )
93
- (_fl1 (x, x[1 ])... , _new_field_positions (Base. tail (x))... )
94
- end
95
- _fl1 (x:: Tuple , x1:: Tuple ) = ntuple (Base. Fix1 (tuple, length (x) - 1 ), Val (length (x1)))
96
- _fl1 (x:: Tuple , x1) = ((length (x) - 1 , 0 ),)
97
- @specialize
98
- else
99
- @inline function flatten_tuples (t:: Tuple )
100
- if @generated
101
- texpr = Expr (:tuple )
102
- for i in 1 : fieldcount (t)
103
- p = fieldtype (t, i)
104
- if p <: Tuple
105
- for j in 1 : fieldcount (p)
106
- push! (texpr. args, :(@inbounds (getfield (getfield (t, $ i), $ j))))
107
- end
108
- else
109
- push! (texpr. args, :(@inbounds (getfield (t, $ i))))
110
- end
111
- end
112
- Expr (:block , Expr (:meta , :inline ), texpr)
113
- else
114
- _flatten (t)
115
- end
116
- end
117
- _flatten (:: Tuple{} ) = ()
118
- @inline function _flatten (t:: Tuple{Any, Vararg{Any}} )
119
- (getfield (t, 1 ), _flatten (Base. tail (t))... )
120
- end
121
- @inline function _flatten (t:: Tuple{Tuple, Vararg{Any}} )
122
- (getfield (t, 1 )... , _flatten (Base. tail (t))... )
67
+ function flatten_tuples (t:: Tuple )
68
+ fields = _new_field_positions (t)
69
+ ntuple (Val {nfields(fields)} ()) do k
70
+ i, j = getfield (fields, k)
71
+ i = length (t) - i
72
+ @inbounds j === 0 ? getfield (t, i) : getfield (getfield (t, i), j)
123
73
end
124
74
end
75
+ _new_field_positions (:: Tuple{} ) = ()
76
+ @nospecialize
77
+ function _new_field_positions (x:: Tuple )
78
+ (_fl1 (x, x[1 ])... , _new_field_positions (Base. tail (x))... )
79
+ end
80
+ _fl1 (x:: Tuple , x1:: Tuple ) = ntuple (Base. Fix1 (tuple, length (x) - 1 ), Val (length (x1)))
81
+ _fl1 (x:: Tuple , x1) = ((length (x) - 1 , 0 ),)
82
+ @specialize
125
83
126
84
"""
127
85
parent_type(::Type{T}) -> Type
@@ -299,11 +257,7 @@ ismutable(::Type{BigFloat}) = false
299
257
ismutable (:: Type{BigInt} ) = false
300
258
function ismutable (:: Type{T} ) where {T}
301
259
if parent_type (T) <: T
302
- @static if VERSION ≥ v " 1.7.0-DEV.1208"
303
- return Base. ismutabletype (T)
304
- else
305
- return T. mutable
306
- end
260
+ return Base. ismutabletype (T)
307
261
else
308
262
return ismutable (parent_type (T))
309
263
end
@@ -440,32 +394,17 @@ matrix_colors(A::Bidiagonal) = _cycle(1:2, Base.size(A, 2))
440
394
matrix_colors (A:: Union{Tridiagonal, SymTridiagonal} ) = _cycle (1 : 3 , Base. size (A, 2 ))
441
395
_cycle (repetend, len) = repeat (repetend, div (len, length (repetend)) + 1 )[1 : len]
442
396
443
- @static if VERSION > v " 1.9-"
444
- """
445
- bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance
397
+ """
398
+ bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance
446
399
447
- Returns an instance of the Bunch-Kaufman factorization object with the correct type
448
- cheaply.
449
- """
450
- function bunchkaufman_instance (A:: Matrix{T} ) where T
451
- return bunchkaufman (similar (A, 0 , 0 ), check = false )
452
- end
453
- function bunchkaufman_instance (A:: SparseMatrixCSC )
454
- bunchkaufman (sparse (similar (A, 1 , 1 )), check = false )
455
- end
456
- else
457
- """
458
- bunchkaufman_instance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufman_factorization_instance
459
-
460
- Returns an instance of the Bunch-Kaufman factorization object with the correct type
461
- cheaply.
462
- """
463
- function bunchkaufman_instance (A:: Matrix{T} ) where T
464
- return bunchkaufman (similar (A, 0 , 0 ))
465
- end
466
- function bunchkaufman_instance (A:: SparseMatrixCSC )
467
- bunchkaufman (sparse (similar (A, 1 , 1 )))
468
- end
400
+ Returns an instance of the Bunch-Kaufman factorization object with the correct type
401
+ cheaply.
402
+ """
403
+ function bunchkaufman_instance (A:: Matrix{T} ) where T
404
+ return bunchkaufman (similar (A, 0 , 0 ), check = false )
405
+ end
406
+ function bunchkaufman_instance (A:: SparseMatrixCSC )
407
+ bunchkaufman (sparse (similar (A, 1 , 1 )), check = false )
469
408
end
470
409
471
410
"""
@@ -482,32 +421,16 @@ Returns the number.
482
421
"""
483
422
bunchkaufman_instance (a:: Any ) = bunchkaufman (a, check = false )
484
423
485
- @static if VERSION < v " 1.8beta"
486
- const DEFAULT_CHOLESKY_PIVOT = Val (false )
487
- else
488
- const DEFAULT_CHOLESKY_PIVOT = LinearAlgebra. NoPivot ()
489
- end
424
+ const DEFAULT_CHOLESKY_PIVOT = Val (false )
490
425
491
- @static if VERSION > v " 1.9-"
492
- """
493
- cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance
426
+ """
427
+ cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance
494
428
495
- Returns an instance of the Cholesky factorization object with the correct type
496
- cheaply.
497
- """
498
- function cholesky_instance (A:: Matrix{T} , pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
499
- return cholesky (similar (A, 0 , 0 ), pivot, check = false )
500
- end
501
- else
502
- """
503
- cholesky_instance(A, pivot = LinearAlgebra.RowMaximum()) -> cholesky_factorization_instance
504
-
505
- Returns an instance of the Cholesky factorization object with the correct type
506
- cheaply.
507
- """
508
- function cholesky_instance (A:: Matrix{T} , pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
509
- return cholesky (similar (A, 0 , 0 ), pivot)
510
- end
429
+ Returns an instance of the Cholesky factorization object with the correct type
430
+ cheaply.
431
+ """
432
+ function cholesky_instance (A:: Matrix{T} , pivot = DEFAULT_CHOLESKY_PIVOT) where {T}
433
+ return cholesky (similar (A, 0 , 0 ), pivot, check = false )
511
434
end
512
435
513
436
function cholesky_instance (A:: Union{SparseMatrixCSC,Symmetric{<:Number,<:SparseMatrixCSC}} , pivot = DEFAULT_CHOLESKY_PIVOT)
@@ -521,23 +444,13 @@ Returns the number.
521
444
"""
522
445
cholesky_instance (a:: Number , pivot = DEFAULT_CHOLESKY_PIVOT) = a
523
446
524
- @static if VERSION > v " 1.9-"
525
- """
526
- cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
527
-
528
- Slow fallback which gets the instance via factorization. Should get
529
- specialized for new matrix types.
530
- """
531
- cholesky_instance (a:: Any , pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky (a, pivot, check = false )
532
- else
533
- """
534
- cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
535
-
536
- Slow fallback which gets the instance via factorization. Should get
537
- specialized for new matrix types.
538
- """
539
- cholesky_instance (a:: Any , pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky (a, pivot)
540
- end
447
+ """
448
+ cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)
449
+
450
+ Slow fallback which gets the instance via factorization. Should get
451
+ specialized for new matrix types.
452
+ """
453
+ cholesky_instance (a:: Any , pivot = DEFAULT_CHOLESKY_PIVOT) = cholesky (a, pivot, check = false )
541
454
542
455
"""
543
456
ldlt_instance(A) -> ldlt_factorization_instance
@@ -586,18 +499,14 @@ function lu_instance(A::Matrix{T}) where {T}
586
499
return LU {luT} (similar (A, 0 , 0 ), ipiv, info)
587
500
end
588
501
function lu_instance (jac_prototype:: SparseMatrixCSC )
589
- @static if VERSION < v " 1.9.0-DEV.1622"
590
- SuiteSparse. UMFPACK. UmfpackLU (Ptr {Cvoid} (),
591
- Ptr {Cvoid} (),
592
- 1 ,
593
- 1 ,
594
- jac_prototype. colptr[1 : 1 ],
595
- jac_prototype. rowval[1 : 1 ],
596
- jac_prototype. nzval[1 : 1 ],
597
- 0 )
598
- else
599
- SuiteSparse. UMFPACK. UmfpackLU (similar (jac_prototype, 1 , 1 ))
600
- end
502
+ SuiteSparse. UMFPACK. UmfpackLU (Ptr {Cvoid} (),
503
+ Ptr {Cvoid} (),
504
+ 1 ,
505
+ 1 ,
506
+ jac_prototype. colptr[1 : 1 ],
507
+ jac_prototype. rowval[1 : 1 ],
508
+ jac_prototype. nzval[1 : 1 ],
509
+ 0 )
601
510
end
602
511
603
512
function lu_instance (A:: Symmetric{T} ) where {T}
@@ -629,23 +538,13 @@ Returns the number.
629
538
"""
630
539
lu_instance (a:: Number ) = a
631
540
632
- @static if VERSION > v " 1.9-"
633
- """
634
- lu_instance(a::Any) -> lu(a, check=false)
635
-
636
- Slow fallback which gets the instance via factorization. Should get
637
- specialized for new matrix types.
638
- """
639
- lu_instance (a:: Any ) = lu (a, check = false )
640
- else
641
- """
541
+ """
642
542
lu_instance(a::Any) -> lu(a, check=false)
643
543
644
- Slow fallback which gets the instance via factorization. Should get
645
- specialized for new matrix types.
646
- """
647
- lu_instance (a:: Any ) = lu (a)
648
- end
544
+ Slow fallback which gets the instance via factorization. Should get
545
+ specialized for new matrix types.
546
+ """
547
+ lu_instance (a:: Any ) = lu (a, check = false )
649
548
650
549
"""
651
550
qr_instance(A, pivot = NoPivot()) -> qr_factorization_instance
0 commit comments