API reference

VectorInterface.MinimalMVecType
const MinimalMVec = MinimalVec{true}
MinimalMVec(v::AbstractVector)

Type alias for MinimalVec{true}, representing a vector wrapper that implements the minimal interface of VectorInterface.jl, including in-place operations (!-methods).

See also MinimalVec and MinimalSVec.

source
VectorInterface.MinimalSVecType
const MinimalSVec = MinimalVec{false}
MinimalSVec(v::AbstractVector)

Type alias for MinimalVec{false}, representing a vector wrapper that implements the minimal interface of VectorInterface.jl, excluding in-place operations (!-methods).

See also MinimalVec and MinimalMVec.

source
VectorInterface.MinimalVecType
MinimalVec{M,V<:AbstractVector}
MinimalVec{M}(vec::V) where {M,V<:AbstractVector}

Wraps a vector of type V<:AbstractVector in such a way that the wrapper only supports the minimal interface put forward by VectorInterface.jl. The type parameter M can take the values true or false and determines whether the vector behaves as a mutable vector that supports in-place operations (M == true) or whether it behaves as an immutable or static vector (M == false).

This wrapper can be used to test whether an algorithm is implemented using only the minimal interface of VectorInterface.jl, without relying on other methods that would for example be available for AbstractVector or AbstractArray.

To unwrap the contents of a v::MinimalVec instance, the field access v.vec can be used.

See also MinimalMVec and MinimalSVec for convenience constructors.

source
VectorInterface.OneType
struct One end

Singleton type for representing a hard-coded constant 1 in vector addition / linear combinations.

source
VectorInterface.ZeroType
struct Zero end

Singleton type for representing a hard-coded constant 0 in vector addition / linear combinations.

    Now I am become Zero, the destroyer of NaN. - Vishnu
source
VectorInterface.add!!Method
add!!(y, x, [α::Number = 1, β::Number = 1])

Add y and x, or more generally construct the linear combination y * β + x * α, thereby trying to store the result in y. A new object will be created when this fails due to immutability, incompatible scalar types or incommensurate sizes.

Note

New types should only implement the four-argument version. When desired, the two- and three-argument version can be distinguished by specializing on α and β being of type One.

See also: add and add!

source
VectorInterface.add!Method
add!(y, x, [α::Number = One(), β::Number = One()])

Add y and x, or more generally construct the linear combination y * β + x * α, storing the result in y. This will error in case of incompatible scalar types or incommensurate sizes.

Note

New types should only implement the four-argument version. When desired, the two- and three-argument version can be distinguished by specializing on α and β being of type One.

See also: add and add!!

source
VectorInterface.addMethod
add(y, x, [α::Number = 1, β::Number = 1])

Add y and x, or more generally construct the linear combination y * β + x * α.

Note

New types should only implement the four-argument version. When desired, the two- and three-argument version can be distinguished by specializing on α and β being of type One.

See also: add! and add!!

source
VectorInterface.scalartypeFunction
scalartype(x)

Returns the type of scalar over which the vector-like object x behaves as a vector, e.g. the type of scalars with which x could be scaled in-place. This function should also work in the type domain, i.e. if x is a vector like object, then also scalartype(typeof(x)) should work.

Note

New types should only implement the method with the argument in the type domain.

source
VectorInterface.scale!Function
scale!(x, α::Number) -> x
scale!(y, x, α::Number) -> y

Rescale x with the scalar coefficient α, thereby overwrite and thus recylcing the contents of x (in the first form) or y (in the second form). This is only possible if x, respectively y is mutable, and if the scalar types involed are compatible and can be promoted and converted.

Also see: scale and scale!!

source
VectorInterface.scale!!Function
scale!!(x, α::Number)
scale!!(y, x, α::Number)

Rescale x with the scalar coefficient α, thereby trying to overwrite and thus recylce the contents of x (in the first form) or y (in the second form). A new object will be created when this fails due to immutability, incompatible scalar types or incommensurate sizes.

Also see: scale and scale!

source
VectorInterface.zerovectorFunction
zerovector(x, [S::Type{<:Number} = scalartype(x)])

Returns a zero vector in the vector space of x. Optionally, a modified scalar type S for the resulting zero vector can be specified.

Note

New types should only implement the two-argument version, if applicable.

Also see: zerovector!, zerovector!!

source
VectorInterface.zerovector!!Function
zerovector!!(x, [S::Type{<:Number} = scalartype(x)])

Construct a zero vector in the vector space of x, thereby trying to overwrite and thus recycle x when possible. Optionally, a modified scalar type S for the resulting zero vector can be specified.

Note

New types should only implement the one-argument version. The two-argument version amounts to S == scalartype(x) ? zerovector!!(x) : zerovector(x, S)

Also see: zerovector, zerovector!

source