Skip to content

Conversation

emmt
Copy link
Contributor

@emmt emmt commented Apr 13, 2023

Since Julia (ordinary) arrays have 1-based indices and are in column-major order, the linear index k and the Cartesian index (i,j) of an element in a m×n Julia array are related by: k = i + m*(j - 1). The examples of conversion between linear and Cartesian indices in the doc. use incorrect formulae although the results were correct in the specific element at (1,3). This can be easily checked for other indices than (1,3) with a simple 2×3 array (as in the examples) built by A = reshape(collect(1:6),2,3).

Since Julia (ordinary) arrays have 1-based indices and are in column-major order, the linear index `k` and the Cartesian index `(i,j)` of an element in a `m×n` Julia array are related by: `k = i + m*(j - 1)`. The examples of conversion between linear and Cartesian indices in the doc. use incorrect formulae although the results were correct in the specific element at `(1,3)`. This can be easily checked for other indices than `(1,3)` with a simple `2×3` array (as in the examples) built by `A = reshape(collect(1:6),2,3)`.
@timholy timholy merged commit b987396 into JuliaLang:master Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants