From 5b48286996e36bec7324c497cee7d73b31bd3065 Mon Sep 17 00:00:00 2001 From: Andreas Scheidegger Date: Fri, 13 Nov 2015 19:51:32 +0100 Subject: [PATCH] correct sub2ind_loop() example (cherry picked from commit 627e68168b5cbba15f1c2305f01538353e43388c) ref #13978 --- doc/manual/metaprogramming.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/metaprogramming.rst b/doc/manual/metaprogramming.rst index 128f174c05001..0b193eb099d27 100644 --- a/doc/manual/metaprogramming.rst +++ b/doc/manual/metaprogramming.rst @@ -1036,7 +1036,7 @@ indices - in other words, to calculate the index ``i`` that can be used to index into an array ``A`` using ``A[i]``, instead of ``A[x,y,z,...]``. One possible implementation is the following:: - function sub2ind_loop(dims::NTuple{N}, I::Integer...) + function sub2ind_loop{N}(dims::NTuple{N}, I::Integer...) ind = I[N] - 1 for i = N-1:-1:1 ind = I[i]-1 + dims[i]*ind