I’m following the MIT class “Introduction to Computational Thinking”, and have some trouble with the recent homework. (The class is amazing by the way. Any applied math course should be taught in this way IMO.)
A structure is defined as follows.
struct RankOneMatrix{T} <: AbstractMatrix{T}
v::AbstractVector{T}
w::AbstractVector{T}
end
If we immediately construct an object using this type, we will get errors.
We need to extend Base.size()
and Base.getindex()
first. Then the object of this type can be constructed.
Is this the canonical way to inherit an abstract type like AbstractMatrix
?
Or there is a better way to do the same thing?