January 2020
Intermediate to advanced
532 pages
13h 31m
English
The AbstractArray is the abstract type for all Julia array containers. Many Julia packages implement the array interface and are made to be subtypes of AbstractArray. It would be a shame if we go so far to make the sumprod function versatile enough, and yet we cannot support sparse matrices or other types of array-type containers. To make it more general, let's turn our function definition from Array to AbstractArray as follows:
sumprod_6(A::AbstractArray{S,N}, B::AbstractArray{T,N}) where {N, S <: Number, T <: Number} = sum(A .* B)
The signature is the same as the previous option, except that the function can be dispatched with any AbstractArray container types. Let's make sure that the function works as expected: ...
Read now
Unlock full access