diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 8b6919d8..26b012ec 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-18T07:46:16","documenter_version":"1.8.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.11.2","generation_timestamp":"2024-12-13T13:30:23","documenter_version":"1.8.0"}} \ No newline at end of file diff --git a/dev/conversions/index.html b/dev/conversions/index.html index e57551ca..f6e19131 100644 --- a/dev/conversions/index.html +++ b/dev/conversions/index.html @@ -1,9 +1,9 @@ -Julia's Extended Array Conversions Interface · ArrayInterface.jl

Julia's Extended Array Conversions Interface

The following ArrayInterface functions extend Julia's Array interface for how arrays can be converted to different forms.

Conversion Functions

ArrayInterface.promote_eltypeFunction
promote_eltype(::Type{<:AbstractArray{T,N}}, ::Type{T2})

Computes the type of the AbstractArray that results from the element type changing to promote_type(T,T2).

Note that no generic fallback is given.

source
ArrayInterface.restructureFunction
restructure(x,y)

Restructures the object y into a shape of x, keeping its values intact. For simple objects like an Array, this simply amounts to a reshape. However, for more complex objects such as an ArrayPartition, not all of the structural information is adequately contained in the type for standard tools to work. In these cases, restructure gives a way to convert for example an Array into a matching ArrayPartition.

source
ArrayInterface.safevecFunction
safevec(v)

It is a form of vec which is safe for all values in vector spaces, i.e., if it is already a vector, like an AbstractVector or Number, it will return said AbstractVector or Number.

source
ArrayInterface.has_trivial_array_constructorFunction
has_trivial_array_constructor(T::Type, args...) -> Bool

Returns true if an object of type T can be constructed using the collection of args

Note: This checks if a compatible convert methood exists between T and args

Examples:

julia> ca = ComponentVector((x = rand(3), y = rand(4),))
+Julia's Extended Array Conversions Interface · ArrayInterface.jl

Julia's Extended Array Conversions Interface

The following ArrayInterface functions extend Julia's Array interface for how arrays can be converted to different forms.

Conversion Functions

ArrayInterface.promote_eltypeFunction
promote_eltype(::Type{<:AbstractArray{T,N}}, ::Type{T2})

Computes the type of the AbstractArray that results from the element type changing to promote_type(T,T2).

Note that no generic fallback is given.

source
ArrayInterface.restructureFunction
restructure(x,y)

Restructures the object y into a shape of x, keeping its values intact. For simple objects like an Array, this simply amounts to a reshape. However, for more complex objects such as an ArrayPartition, not all of the structural information is adequately contained in the type for standard tools to work. In these cases, restructure gives a way to convert for example an Array into a matching ArrayPartition.

source
ArrayInterface.safevecFunction
safevec(v)

It is a form of vec which is safe for all values in vector spaces, i.e., if it is already a vector, like an AbstractVector or Number, it will return said AbstractVector or Number.

source
ArrayInterface.has_trivial_array_constructorFunction
has_trivial_array_constructor(T::Type, args...) -> Bool

Returns true if an object of type T can be constructed using the collection of args

Note: This checks if a compatible convert methood exists between T and args

Examples:

julia> ca = ComponentVector((x = rand(3), y = rand(4),))
 ComponentVector{Float64}(x = [0.6549137106381634, 0.37555505280294565, 0.8521039568665254], y = [0.40314196291239024, 0.35484725607638834, 0.6580528978034597, 0.10055508457632167])
 
 julia> ArrayInterface.has_trivial_array_constructor(typeof(ca), ones(6))
 true
 
 julia> ArrayInterface.has_trivial_array_constructor(typeof(cv), (x = rand(6),))
-false
source
+false
source
diff --git a/dev/index.html b/dev/index.html index 9753cead..0a57c7d7 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -ArrayInterface.jl: An Extended Array Interface for Julia Generic Programming · ArrayInterface.jl

ArrayInterface

Designs for new Base array interface primitives, used widely through scientific machine learning (SciML) and other organizations

Extensions

ArrayInterface.jl uses extension packages in order to add support for popular libraries to its interface functions. These packages are:

  • BandedMatrices.jl
  • BlockBandedMatrices.jl
  • GPUArrays.jl / CUDA.jl
  • OffsetArrays.jl
  • Tracker.jl

StaticArrayInterface.jl

If one is looking for an interface which includes functionality for statically-computed values, see StaticArrayInterface.jl. This was separated from ArrayInterface.jl because it includes a lot of functionality that does not give substantive improvements to the interface, and is likely to be deprecated in the near future as the compiler matures to automate a lot of its optimizations.

+ArrayInterface.jl: An Extended Array Interface for Julia Generic Programming · ArrayInterface.jl

ArrayInterface

Designs for new Base array interface primitives, used widely through scientific machine learning (SciML) and other organizations

Extensions

ArrayInterface.jl uses extension packages in order to add support for popular libraries to its interface functions. These packages are:

  • BandedMatrices.jl
  • BlockBandedMatrices.jl
  • GPUArrays.jl / CUDA.jl
  • OffsetArrays.jl
  • Tracker.jl

StaticArrayInterface.jl

If one is looking for an interface which includes functionality for statically-computed values, see StaticArrayInterface.jl. This was separated from ArrayInterface.jl because it includes a lot of functionality that does not give substantive improvements to the interface, and is likely to be deprecated in the near future as the compiler matures to automate a lot of its optimizations.

diff --git a/dev/indexing/index.html b/dev/indexing/index.html index 7ee7e982..204dfcbd 100644 --- a/dev/indexing/index.html +++ b/dev/indexing/index.html @@ -5,7 +5,7 @@ else @. y = f(args...) end -endsource
ArrayInterface.can_change_sizeFunction
can_change_size(::Type{T}) -> Bool

Returns true if the Base.size of T can change, in which case operations such as pop! and popfirst! are available for collections of type T.

source
ArrayInterface.can_setindexFunction
can_setindex(::Type{T}) -> Bool

Query whether a type can use setindex!.

source
ArrayInterface.fast_scalar_indexingFunction
fast_scalar_indexing(::Type{T}) -> Bool

Query whether an array type has fast scalar indexing.

source
ArrayInterface.ismutableFunction
ismutable(::Type{T}) -> Bool

Query whether instances of type T are mutable or not, see https://github.com/JuliaDiffEq/RecursiveArrayTools.jl/issues/19.

source
ArrayInterface.ndims_indexFunction
ndims_index(::Type{I}) -> Int

Returns the number of dimensions that an instance of I indexes into. If this method is not explicitly defined, then 1 is returned.

See also ndims_shape

Examples

julia> ArrayInterface.ndims_index(Int)
+end
source
ArrayInterface.can_change_sizeFunction
can_change_size(::Type{T}) -> Bool

Returns true if the Base.size of T can change, in which case operations such as pop! and popfirst! are available for collections of type T.

source
ArrayInterface.can_setindexFunction
can_setindex(::Type{T}) -> Bool

Query whether a type can use setindex!.

source
ArrayInterface.fast_scalar_indexingFunction
fast_scalar_indexing(::Type{T}) -> Bool

Query whether an array type has fast scalar indexing.

source
ArrayInterface.ismutableFunction
ismutable(::Type{T}) -> Bool

Query whether instances of type T are mutable or not, see https://github.com/JuliaDiffEq/RecursiveArrayTools.jl/issues/19.

source
ArrayInterface.ndims_indexFunction
ndims_index(::Type{I}) -> Int

Returns the number of dimensions that an instance of I indexes into. If this method is not explicitly defined, then 1 is returned.

See also ndims_shape

Examples

julia> ArrayInterface.ndims_index(Int)
 1
 
 julia> ArrayInterface.ndims_index(CartesianIndex(1, 2, 3))
@@ -13,7 +13,7 @@
 
 julia> ArrayInterface.ndims_index([CartesianIndex(1, 2), CartesianIndex(1, 3)])
 2
-
source
ArrayInterface.ndims_shapeFunction
ndims_shape(::Type{I}) -> Union{Int,Tuple{Vararg{Int}}}

Returns the number of dimension that are represented in the shape of the returned array when indexing with an instance of I.

See also ndims_index

Examples

```julia julia> ArrayInterface.ndims_shape([CartesianIndex(1, 1), CartesianIndex(1, 2)]) 1

julia> ndims(CartesianIndices((2,2))[[CartesianIndex(1, 1), CartesianIndex(1, 2)]]) 1

source
ArrayInterface.defines_stridesFunction
defines_strides(::Type{T}) -> Bool

Is strides(::T) defined? It is assumed that types returning true also return a valid pointer on pointer(::T).

source
ArrayInterface.ensures_all_uniqueFunction
ensures_all_unique(T::Type) -> Bool

Returns true if all instances of type T are composed of a unique set of elements. This does not require that T subtypes AbstractSet or implements the AbstractSet interface.

Examples

julia> ArrayInterface.ensures_all_unique(BitSet())
+
source
ArrayInterface.ndims_shapeFunction
ndims_shape(::Type{I}) -> Union{Int,Tuple{Vararg{Int}}}

Returns the number of dimension that are represented in the shape of the returned array when indexing with an instance of I.

See also ndims_index

Examples

```julia julia> ArrayInterface.ndims_shape([CartesianIndex(1, 1), CartesianIndex(1, 2)]) 1

julia> ndims(CartesianIndices((2,2))[[CartesianIndex(1, 1), CartesianIndex(1, 2)]]) 1

source
ArrayInterface.defines_stridesFunction
defines_strides(::Type{T}) -> Bool

Is strides(::T) defined? It is assumed that types returning true also return a valid pointer on pointer(::T).

source
ArrayInterface.ensures_all_uniqueFunction
ensures_all_unique(T::Type) -> Bool

Returns true if all instances of type T are composed of a unique set of elements. This does not require that T subtypes AbstractSet or implements the AbstractSet interface.

Examples

julia> ArrayInterface.ensures_all_unique(BitSet())
 true
 
 julia> ArrayInterface.ensures_all_unique([])
@@ -23,20 +23,20 @@
 true
 
 julia> ArrayInterface.ensures_all_unique(LinRange(1, 1, 10))
-false
source
ArrayInterface.ensures_sortedFunction
ensures_sorted(T::Type) -> Bool

Returns true if all instances of T are sorted.

Examples

julia> ArrayInterface.ensures_sorted(BitSet())
+false
source
ArrayInterface.ensures_sortedFunction
ensures_sorted(T::Type) -> Bool

Returns true if all instances of T are sorted.

Examples

julia> ArrayInterface.ensures_sorted(BitSet())
 true
 
 julia> ArrayInterface.ensures_sorted([])
 false
 
 julia> ArrayInterface.ensures_sorted(1:10)
-true
source
ArrayInterface.indices_do_not_aliasFunction
indices_do_not_alias(::Type{T<:AbstractArray}) -> Bool

Is it safe to ivdep arrays of type T? That is, would it be safe to write to an array of type T in parallel? Examples where this is not true are BitArrays or view(rand(6), [1,2,3,1,2,3]). That is, it is not safe whenever different indices may alias the same memory.

source
ArrayInterface.instances_do_not_aliasFunction
instances_do_not_alias(::Type{T}) -> Bool

Is it safe to ivdep arrays containing elements of type T? That is, would it be safe to write to an array full of T in parallel? This is not true for mutable structs in general, where editing one index could edit other indices. That is, it is not safe when different instances may alias the same memory.

source
ArrayInterface.deviceFunction
device(::Type{T}) -> AbstractDevice

Indicates the most efficient way to access elements from the collection in low-level code. For GPUArrays, will return ArrayInterface.GPU(). For AbstractArray supporting a pointer method, returns ArrayInterface.CPUPointer(). For other AbstractArrays and Tuples, returns ArrayInterface.CPUIndex(). Otherwise, returns nothing.

source

Allowed Indexing Functions

These are generic functions for forced "allowed indexing". For example, with CUDA.jl's CuArrays a mode can be enabled such that allowscalar(false) forces errors to be thrown if a GPU array is scalar indexed. Instead of using the CUDA-specific CUDA.@allowscalar on an operation, these functions allow for a general generic "allowed indexing" for all array types.

ArrayInterface.allowed_getindexFunction
allowed_getindex(x,i...)

A scalar getindex which is always allowed.

source
ArrayInterface.allowed_setindex!Function
allowed_setindex!(x,v,i...)

A scalar setindex! which is always allowed.

source

Indexing Type Buffers

The following indexing types allow for generically controlling bounds checking and index translations.

ArrayInterface.ArrayIndexType
ArrayIndex{N}

Subtypes of ArrayIndex represent series of transformations for a provided index to some buffer which is typically accomplished with square brackets (e.g., buffer[index[inds...]]). The only behavior that is required of a subtype of ArrayIndex is the ability to transform individual index elements (i.e. not collections). This does not guarantee bounds checking or the ability to iterate (although additional functionality may be provided for specific types).

source
ArrayInterface.GetIndexType
GetIndex(buffer) = GetIndex{true}(buffer)
+true
source
ArrayInterface.indices_do_not_aliasFunction
indices_do_not_alias(::Type{T<:AbstractArray}) -> Bool

Is it safe to ivdep arrays of type T? That is, would it be safe to write to an array of type T in parallel? Examples where this is not true are BitArrays or view(rand(6), [1,2,3,1,2,3]). That is, it is not safe whenever different indices may alias the same memory.

source
ArrayInterface.instances_do_not_aliasFunction
instances_do_not_alias(::Type{T}) -> Bool

Is it safe to ivdep arrays containing elements of type T? That is, would it be safe to write to an array full of T in parallel? This is not true for mutable structs in general, where editing one index could edit other indices. That is, it is not safe when different instances may alias the same memory.

source
ArrayInterface.deviceFunction
device(::Type{T}) -> AbstractDevice

Indicates the most efficient way to access elements from the collection in low-level code. For GPUArrays, will return ArrayInterface.GPU(). For AbstractArray supporting a pointer method, returns ArrayInterface.CPUPointer(). For other AbstractArrays and Tuples, returns ArrayInterface.CPUIndex(). Otherwise, returns nothing.

source

Allowed Indexing Functions

These are generic functions for forced "allowed indexing". For example, with CUDA.jl's CuArrays a mode can be enabled such that allowscalar(false) forces errors to be thrown if a GPU array is scalar indexed. Instead of using the CUDA-specific CUDA.@allowscalar on an operation, these functions allow for a general generic "allowed indexing" for all array types.

ArrayInterface.allowed_getindexFunction
allowed_getindex(x,i...)

A scalar getindex which is always allowed.

source
ArrayInterface.allowed_setindex!Function
allowed_setindex!(x,v,i...)

A scalar setindex! which is always allowed.

source

Indexing Type Buffers

The following indexing types allow for generically controlling bounds checking and index translations.

ArrayInterface.ArrayIndexType
ArrayIndex{N}

Subtypes of ArrayIndex represent series of transformations for a provided index to some buffer which is typically accomplished with square brackets (e.g., buffer[index[inds...]]). The only behavior that is required of a subtype of ArrayIndex is the ability to transform individual index elements (i.e. not collections). This does not guarantee bounds checking or the ability to iterate (although additional functionality may be provided for specific types).

source
ArrayInterface.GetIndexType
GetIndex(buffer) = GetIndex{true}(buffer)
 GetIndex{check}(buffer) -> g

Wraps an indexable buffer in a function type that is indexed when called, so that g(inds..) is equivalent to buffer[inds...]. If check is false, then all indexing arguments are considered in-bounds. The default value for check is true, requiring bounds checking for each index.

See also SetIndex!

Warning

Passing false as check may result in incorrect results/crashes/corruption for out-of-bounds indices, similar to inappropriate use of @inbounds. The user is responsible for ensuring this is correctly used.

Examples

julia> ArrayInterface.GetIndex(1:10)(3)
 3
 
 julia> ArrayInterface.GetIndex{false}(1:10)(11)  # shouldn't be in-bounds
 11
-
source
ArrayInterface.SetIndex!Type
SetIndex!(buffer) = SetIndex!{true}(buffer)
+
source
ArrayInterface.SetIndex!Type
SetIndex!(buffer) = SetIndex!{true}(buffer)
 SetIndex!{check}(buffer) -> g

Wraps an indexable buffer in a function type that sets a value at an index when called, so that g(val, inds..) is equivalent to setindex!(buffer, val, inds...). If check is false, then all indexing arguments are considered in-bounds. The default value for check is true, requiring bounds checking for each index.

See also GetIndex

Warning

Passing false as check may result in incorrect results/crashes/corruption for out-of-bounds indices, similar to inappropriate use of @inbounds. The user is responsible for ensuring this is correctly used.

Examples


 julia> x = [1, 2, 3, 4];
 
@@ -44,4 +44,4 @@
 
 julia> x[2]
 10
-
source
+source diff --git a/dev/linearalgebra/index.html b/dev/linearalgebra/index.html index 707ceedd..63999f3d 100644 --- a/dev/linearalgebra/index.html +++ b/dev/linearalgebra/index.html @@ -1,2 +1,2 @@ -Julia's Extended Linear Algebra Interface · ArrayInterface.jl

Julia's Extended Linear Algebra Interface

The following ArrayInterface functions extend Julia's Base LinearAlgebra interface to improve the ability to do generic linear algebra.

Generic Matrix Constructors

These functions allow for the construction of matrices from array information in a generic way. It handles cases like how if x is a vector on the GPU, its associated matrix type should also be GPU-based, and thus appropriately placed with zeros/undef values.

ArrayInterface.zeromatrixFunction
zeromatrix(u::AbstractVector)

Creates the zero'd matrix version of u. Note that this is unique because similar(u,length(u),length(u)) returns a mutable type, so it is not type-matching, while fill(zero(eltype(u)),length(u),length(u)) doesn't match the array type, i.e., you'll get a CPU array from a GPU array. The generic fallback is u .* u' .* false, which works on a surprising number of types, but can be broken with weird (recursive) broadcast overloads. For higher-order tensors, this returns the matrix linear operator type which acts on the vec of the array.

source
ArrayInterface.undefmatrixFunction
undefmatrix(u::AbstractVector)

Creates the matrix version of u with possibly undefined values. Note that this is unique because similar(u,length(u),length(u)) returns a mutable type, so it is not type-matching, while fill(zero(eltype(u)),length(u),length(u)) doesn't match the array type, i.e., you'll get a CPU array from a GPU array. The generic fallback is u .* u', which works on a surprising number of types, but can be broken with weird (recursive) broadcast overloads. For higher-order tensors, this returns the matrix linear operator type which acts on the vec of the array.

source

Generic Matrix Functions

These query allow for easily learning properties of a general matrix.

Factorization Instance Functions

These functions allow for generating the instance of a factorization's result without running the full factorization. This thus allows for building types to hold the factorization without having to perform expensive extra computations.

ArrayInterface.bunchkaufman_instanceFunction

bunchkaufmaninstance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufmanfactorization_instance

Returns an instance of the Bunch-Kaufman factorization object with the correct type cheaply.

source

bunchkaufman_instance(a::Number) -> a

Returns the number.

source

bunchkaufman_instance(a::Any) -> cholesky(a, check=false)

Returns the number.

source
ArrayInterface.cholesky_instanceFunction

choleskyinstance(A, pivot = LinearAlgebra.RowMaximum()) -> choleskyfactorization_instance

Returns an instance of the Cholesky factorization object with the correct type cheaply.

source

cholesky_instance(a::Number, pivot = LinearAlgebra.RowMaximum()) -> a

Returns the number.

source

cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)

Slow fallback which gets the instance via factorization. Should get specialized for new matrix types.

source
ArrayInterface.ldlt_instanceFunction

ldltinstance(A) -> ldltfactorization_instance

Returns an instance of the LDLT factorization object with the correct type cheaply.

source

ldlt_instance(a::Number) -> a

Returns the number.

source

ldlt_instance(a::Any) -> ldlt(a, check=false)

Slow fallback which gets the instance via factorization. Should get specialized for new matrix types.

source
ArrayInterface.lu_instanceFunction

luinstance(A) -> lufactorization_instance

Returns an instance of the LU factorization object with the correct type cheaply.

source

lu_instance(a::Number) -> a

Returns the number.

source
lu_instance(a::Any) -> lu(a, check=false)

Slow fallback which gets the instance via factorization. Should get specialized for new matrix types.

source
ArrayInterface.qr_instanceFunction

qrinstance(A, pivot = NoPivot()) -> qrfactorization_instance

Returns an instance of the QR factorization object with the correct type cheaply.

source

qr_instance(a::Number) -> a

Returns the number.

source
qr_instance(a::Any) -> qr(a)

Slow fallback which gets the instance via factorization. Should get specialized for new matrix types.

source
ArrayInterface.svd_instanceFunction

svdinstance(A) -> qrfactorization_instance

Returns an instance of the SVD factorization object with the correct type cheaply.

source

svd_instance(a::Number) -> a

Returns the number.

source
svd_instance(a::Any) -> svd(a)

Slow fallback which gets the instance via factorization. Should get specialized for new matrix types.

source

Addtional Linear Algebra Interface Tools

If dealing with general linear algebra, consider:

  • LinearSolve.jl: An extended linear solving library with support for generic arrays.
+Julia's Extended Linear Algebra Interface · ArrayInterface.jl

Julia's Extended Linear Algebra Interface

The following ArrayInterface functions extend Julia's Base LinearAlgebra interface to improve the ability to do generic linear algebra.

Generic Matrix Constructors

These functions allow for the construction of matrices from array information in a generic way. It handles cases like how if x is a vector on the GPU, its associated matrix type should also be GPU-based, and thus appropriately placed with zeros/undef values.

ArrayInterface.zeromatrixFunction
zeromatrix(u::AbstractVector)

Creates the zero'd matrix version of u. Note that this is unique because similar(u,length(u),length(u)) returns a mutable type, so it is not type-matching, while fill(zero(eltype(u)),length(u),length(u)) doesn't match the array type, i.e., you'll get a CPU array from a GPU array. The generic fallback is u .* u' .* false, which works on a surprising number of types, but can be broken with weird (recursive) broadcast overloads. For higher-order tensors, this returns the matrix linear operator type which acts on the vec of the array.

source
ArrayInterface.undefmatrixFunction
undefmatrix(u::AbstractVector)

Creates the matrix version of u with possibly undefined values. Note that this is unique because similar(u,length(u),length(u)) returns a mutable type, so it is not type-matching, while fill(zero(eltype(u)),length(u),length(u)) doesn't match the array type, i.e., you'll get a CPU array from a GPU array. The generic fallback is u .* u', which works on a surprising number of types, but can be broken with weird (recursive) broadcast overloads. For higher-order tensors, this returns the matrix linear operator type which acts on the vec of the array.

source

Generic Matrix Functions

These query allow for easily learning properties of a general matrix.

Factorization Instance Functions

These functions allow for generating the instance of a factorization's result without running the full factorization. This thus allows for building types to hold the factorization without having to perform expensive extra computations.

ArrayInterface.bunchkaufman_instanceFunction

bunchkaufmaninstance(A, pivot = LinearAlgebra.RowMaximum()) -> bunchkaufmanfactorization_instance

Returns an instance of the Bunch-Kaufman factorization object with the correct type cheaply.

source

bunchkaufman_instance(a::Number) -> a

Returns the number.

source

bunchkaufman_instance(a::Any) -> cholesky(a, check=false)

Returns the number.

source
ArrayInterface.cholesky_instanceFunction

choleskyinstance(A, pivot = LinearAlgebra.RowMaximum()) -> choleskyfactorization_instance

Returns an instance of the Cholesky factorization object with the correct type cheaply.

source

cholesky_instance(a::Number, pivot = LinearAlgebra.RowMaximum()) -> a

Returns the number.

source

cholesky_instance(a::Any, pivot = LinearAlgebra.RowMaximum()) -> cholesky(a, check=false)

Slow fallback which gets the instance via factorization. Should get specialized for new matrix types.

source
ArrayInterface.ldlt_instanceFunction

ldltinstance(A) -> ldltfactorization_instance

Returns an instance of the LDLT factorization object with the correct type cheaply.

source

ldlt_instance(a::Number) -> a

Returns the number.

source

ldlt_instance(a::Any) -> ldlt(a, check=false)

Slow fallback which gets the instance via factorization. Should get specialized for new matrix types.

source
ArrayInterface.lu_instanceFunction

luinstance(A) -> lufactorization_instance

Returns an instance of the LU factorization object with the correct type cheaply.

source

lu_instance(a::Number) -> a

Returns the number.

source
lu_instance(a::Any) -> lu(a, check=false)

Slow fallback which gets the instance via factorization. Should get specialized for new matrix types.

source
ArrayInterface.qr_instanceFunction

qrinstance(A, pivot = NoPivot()) -> qrfactorization_instance

Returns an instance of the QR factorization object with the correct type cheaply.

source

qr_instance(a::Number) -> a

Returns the number.

source
qr_instance(a::Any) -> qr(a)

Slow fallback which gets the instance via factorization. Should get specialized for new matrix types.

source
ArrayInterface.svd_instanceFunction

svdinstance(A) -> qrfactorization_instance

Returns an instance of the SVD factorization object with the correct type cheaply.

source

svd_instance(a::Number) -> a

Returns the number.

source
svd_instance(a::Any) -> svd(a)

Slow fallback which gets the instance via factorization. Should get specialized for new matrix types.

source

Addtional Linear Algebra Interface Tools

If dealing with general linear algebra, consider:

  • LinearSolve.jl: An extended linear solving library with support for generic arrays.
diff --git a/dev/sparsearrays/index.html b/dev/sparsearrays/index.html index 389f74f9..69e0b31c 100644 --- a/dev/sparsearrays/index.html +++ b/dev/sparsearrays/index.html @@ -1,2 +1,2 @@ -Julia's Extended Sparse Array Interface · ArrayInterface.jl

Julia's Extended Sparse Array Interface

The following ArrayInterface functions extend Julia's Base LinearAlgebra interface to improve the ability to do sparse linear algebra.

Sparse Indexing

These routines allow for improving sparse iteration and indexing.

ArrayInterface.findstructralnzFunction
findstructralnz(x::AbstractArray)

Return: (I,J) #indexable objects Find sparsity pattern of special matrices, the same as the first two elements of findnz(::SparseMatrixCSC).

source

Matrix Coloring

Many routines require calculating the coloring of a matrix, such as for sparse differentation. The matrix_colors function is the high level function which returns a color vector Vector{Int} with the column colors. This function is overloaded for many special matrix types with analytical solutions for the matrix colors.

ArrayInterface.matrix_colorsFunction
matrix_colors(A::Union{Array,UpperTriangular,LowerTriangular})

The color vector for dense matrix and triangular matrix is simply [1,2,3,..., Base.size(A,2)].

source

General Matrix Colors

For the general dispatch of matrix_colors, see SparseDiffTools.jl for a full graph-based coloring algorithm which extends ArrayInterface.

Addtional Sparse Array Interface Tools

If dealing with general sparse arrays, consider:

  • SparseDiffTools.jl: A general set of tools for extending calculus libraries for sparse optimizations.
  • LinearSolve.jl: An extended linear solving library with support for generic sparse arrays.
+Julia's Extended Sparse Array Interface · ArrayInterface.jl

Julia's Extended Sparse Array Interface

The following ArrayInterface functions extend Julia's Base LinearAlgebra interface to improve the ability to do sparse linear algebra.

Sparse Indexing

These routines allow for improving sparse iteration and indexing.

ArrayInterface.findstructralnzFunction
findstructralnz(x::AbstractArray)

Return: (I,J) #indexable objects Find sparsity pattern of special matrices, the same as the first two elements of findnz(::SparseMatrixCSC).

source

Matrix Coloring

Many routines require calculating the coloring of a matrix, such as for sparse differentation. The matrix_colors function is the high level function which returns a color vector Vector{Int} with the column colors. This function is overloaded for many special matrix types with analytical solutions for the matrix colors.

ArrayInterface.matrix_colorsFunction
matrix_colors(A::Union{Array,UpperTriangular,LowerTriangular})

The color vector for dense matrix and triangular matrix is simply [1,2,3,..., Base.size(A,2)].

source

General Matrix Colors

For the general dispatch of matrix_colors, see SparseDiffTools.jl for a full graph-based coloring algorithm which extends ArrayInterface.

Addtional Sparse Array Interface Tools

If dealing with general sparse arrays, consider:

  • SparseDiffTools.jl: A general set of tools for extending calculus libraries for sparse optimizations.
  • LinearSolve.jl: An extended linear solving library with support for generic sparse arrays.
diff --git a/dev/tuples/index.html b/dev/tuples/index.html index 909bf5f3..28ccae60 100644 --- a/dev/tuples/index.html +++ b/dev/tuples/index.html @@ -7,6 +7,6 @@ julia> ArrayInterface.flatten_tuples((1, (2, (3,)))) (1, 2, (3,)) -source
ArrayInterface.map_tuple_typeFunction
ArrayInterface.map_tuple_type(f, T::Type{<:Tuple})

Returns tuple where each field corresponds to the field type of T modified by the function f.

Examples

julia> ArrayInterface.map_tuple_type(sqrt, Tuple{1,4,16})
+
source
ArrayInterface.map_tuple_typeFunction
ArrayInterface.map_tuple_type(f, T::Type{<:Tuple})

Returns tuple where each field corresponds to the field type of T modified by the function f.

Examples

julia> ArrayInterface.map_tuple_type(sqrt, Tuple{1,4,16})
 (1.0, 2.0, 4.0)
-
source
+source diff --git a/dev/wrapping/index.html b/dev/wrapping/index.html index 617c37a9..45bbadf1 100644 --- a/dev/wrapping/index.html +++ b/dev/wrapping/index.html @@ -1,2 +1,2 @@ -Julia's Array Wrapping Interface · ArrayInterface.jl

Julia's Array Wrapping Interface

The following functions make it easier to handle array wrappers, such as Adjoint, which can obscure an underlying array's properties under a layer of indirection.

ArrayInterface.is_forwarding_wrapperFunction
is_forwarding_wrapper(::Type{T}) -> Bool

Returns true if the type T wraps another data type and does not alter any of its standard interface. For example, if T were an array then its size, indices, and elements would all be equivalent to its wrapped data.

source
ArrayInterface.bufferFunction
buffer(x)

Return the buffer data that x points to. Unlike parent(x::AbstractArray), buffer(x) may not return another array type.

source

Additional Array Wrapping Libraries

If dealing with array wrappers, additionally consider:

  • Adapt.jl: conversions for handling device (GPU) wrappers.
+Julia's Array Wrapping Interface · ArrayInterface.jl

Julia's Array Wrapping Interface

The following functions make it easier to handle array wrappers, such as Adjoint, which can obscure an underlying array's properties under a layer of indirection.

ArrayInterface.is_forwarding_wrapperFunction
is_forwarding_wrapper(::Type{T}) -> Bool

Returns true if the type T wraps another data type and does not alter any of its standard interface. For example, if T were an array then its size, indices, and elements would all be equivalent to its wrapped data.

source
ArrayInterface.bufferFunction
buffer(x)

Return the buffer data that x points to. Unlike parent(x::AbstractArray), buffer(x) may not return another array type.

source

Additional Array Wrapping Libraries

If dealing with array wrappers, additionally consider:

  • Adapt.jl: conversions for handling device (GPU) wrappers.