Skip to content

Commit 117a188

Browse files
Merge pull request #399 from JuliaArrays/linearalgebra_instance
complete the linear algebra instance functions for the main factorizations
2 parents 9ec85d5 + 537c93c commit 117a188

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ArrayInterface"
22
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
3-
version = "7.2.1"
3+
version = "7.3.0"
44

55
[deps]
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

docs/src/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ArrayInterface.jl uses extension packages in order to add support for popular li
1717

1818
## StaticArrayInterface.jl
1919

20-
If one is looking for an interface which includes functionality for statically-computed values, see
20+
If one is looking for an interface which includes functionality for statically-computed values, see
2121
[StaticArrayInterface.jl](https://github.com/JuliaArrays/StaticArrayInterface.jl).
2222
This was separated from ArrayInterface.jl because it includes a lot of functionality that does not give substantive improvements
2323
to the interface, and is likely to be deprecated in the near future as the compiler matures to automate a lot of its optimizations.
@@ -44,7 +44,6 @@ ArrayInterface.isstructured
4444
ArrayInterface.has_sparsestruct
4545
ArrayInterface.ndims_index
4646
ArrayInterface.ndims_shape
47-
4847
```
4948

5049
### Functions
@@ -57,6 +56,8 @@ ArrayInterface.buffer
5756
ArrayInterface.findstructralnz
5857
ArrayInterface.flatten_tuples
5958
ArrayInterface.lu_instance
59+
ArrayInterface.qr_instance
60+
ArrayInterface.svd_instance
6061
ArrayInterface.map_tuple_type
6162
ArrayInterface.matrix_colors
6263
ArrayInterface.issingular
@@ -74,4 +75,4 @@ ArrayInterface.undefmatrix
7475
ArrayInterface.ArrayIndex
7576
ArrayInterface.GetIndex
7677
ArrayInterface.SetIndex!
77-
```
78+
```

src/ArrayInterface.jl

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,59 @@ Returns the number.
482482
"""
483483
lu_instance(a::Any) = lu(a, check = false)
484484

485+
"""
486+
qr_instance(A) -> qr_factorization_instance
487+
488+
Returns an instance of the QR factorization object with the correct type
489+
cheaply.
490+
"""
491+
function qr_instance(A::Matrix{T}) where {T}
492+
LinearAlgebra.QRCompactWYQ(zeros(T,0,0),zeros(T,0,0))
493+
end
494+
495+
# Could be optimized but this should work for any real case.
496+
function qr_instance(jac_prototype::SparseMatrixCSC)
497+
qr(sparse(rand(1,1)), check = false)
498+
end
499+
500+
"""
501+
qr_instance(a::Number) -> a
502+
503+
Returns the number.
504+
"""
505+
qr_instance(a::Number) = a
506+
507+
"""
508+
qr_instance(a::Any) -> qr(a, check=false)
509+
510+
Returns the number.
511+
"""
512+
qr_instance(a::Any) = qr(a, check = false)
513+
514+
"""
515+
svd_instance(A) -> qr_factorization_instance
516+
517+
Returns an instance of the SVD factorization object with the correct type
518+
cheaply.
519+
"""
520+
function svd_instance(A::Matrix{T}) where {T}
521+
LinearAlgebra.SVD(zeros(T,0,0),zeros(T,0),zeros(T,0,0))
522+
end
523+
524+
"""
525+
svd_instance(a::Number) -> a
526+
527+
Returns the number.
528+
"""
529+
svd_instance(a::Number) = a
530+
531+
"""
532+
svd_instance(a::Any) -> qr(a, check=false)
533+
534+
Returns the number.
535+
"""
536+
svd_instance(a::Any) = svd(a, check = false)
537+
485538
"""
486539
safevec(v)
487540

0 commit comments

Comments
 (0)