Or using the generalized indexing accessors,
function offdiag2(A::AbstractMatrix)
[A[ι] for ι in CartesianIndices(A) if ι[1] ≠ ι[2]]
end
which should work for indexes other than 1-based.
Or using the generalized indexing accessors,
function offdiag2(A::AbstractMatrix)
[A[ι] for ι in CartesianIndices(A) if ι[1] ≠ ι[2]]
end
which should work for indexes other than 1-based.