I’m trying to subtype AbstractMatrix
for a matrix which has infinite rows. What should axes
, size
and length
return? Floating-point Inf
is probably out, because the indices must be integers. I could report it as typemin(Int):typemax(Int)
(it’s infinite in both positive and negative directions), but then the length will always overflow; I could report the length as typemax(Int)
on top of that, but at that point my “too many special cases” alarm starts going off. Would it cause problems, though? Or do you think this is too far out of AbstractMatrix
territory in the first place?
Welcome! The only advantage to subtyping AbstractMatrix
is that it allows your object to use code that uses the ::AbstractMatrix
type in its signature. I think you’ll find that the number of functions that are written to accept ::AbstractMatrix
objects and would still work with your infinite matrix to be fairly small. Small enough, in fact, that it’s probably significantly easier to just not implement size
/axes
/etc and simply subtype <: Any
instead.
4 Likes
Checkout InfiniteArrays.jl
5 Likes