You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
:func:`getindex(A, I...) <getindex>` defined in terms of scalar :func:`getindex` :ref:`Multidimensional and nonscalar indexing <man-array-indexing>`
161
161
:func:`setindex!(A, I...) <setindex!>` defined in terms of scalar :func:`setindex!` :ref:`Multidimensional and nonscalar indexed assignment <man-array-indexing>`
@@ -226,15 +226,11 @@ As a more complicated example, let's define our own toy N-dimensional sparse-lik
Notice that this is a ``LinearSlow`` array, so we must manually define :func:`getindex` and :func:`setindex!` for each dimensionality we'd like to support. Unlike the ``SquaresVector``, we are able to define :func:`setindex!`, and so we can mutate the array:
229
+
# Define scalar indexing and indexed assignment
230
+
Base.getindex{T,N}(A::SparseArray{T,N}, I::Vararg{Int,N}) = get(A.data, I, zero(T))
Notice that this is a ``LinearSlow`` array, so we must manually define :func:`getindex` and :func:`setindex!` at the dimensionality of the array. Unlike the ``SquaresVector``, we are able to define :func:`setindex!`, and so we can mutate the array:
0 commit comments