Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Array slicing
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Details== For "one-dimensional" (single-indexed) arrays{{snd}} vectors, sequences, strings etc.{{snd}} the most common slicing operation is extraction of zero or more consecutive elements. If we have a vector containing elements (2, 5, 7, 3, 8, 6, 4, 1), and want to create an array slice from the 3rd to the 6th elements, we get (7, 3, 8, 6). In [[programming language]]s that use a 0-based indexing scheme, the slice would be from index ''2'' to ''5''. Reducing the range of any index to a single value effectively removes the need for that index. This feature can be used, for example, to extract one-dimensional slices (vectors in 3D, including rows, columns, and tubes<ref name="Zhang Aeron pp. 1511β1526">{{cite journal | last1=Zhang | first1=Zemin | last2=Aeron | first2=Shuchin | title=Exact Tensor Completion Using t-SVD | journal=IEEE Transactions on Signal Processing | publisher=Institute of Electrical and Electronics Engineers (IEEE) | volume=65 | issue=6 | date=2017-03-15 | issn=1053-587X | doi=10.1109/tsp.2016.2639466 | pages=1511β1526| doi-access=free | arxiv=1502.04689 | bibcode=2017ITSP...65.1511Z }}</ref>) or two-dimensional slices (rectangular matrices) from a three-dimensional array. However, since the range can be specified at run-time, type-checked languages may require an explicit (compile-time) notation to actually eliminate the trivial indices. General array slicing can be implemented (whether or not built into the language) by referencing every array through a [[dope vector]] or ''descriptor''{{snd}} a record that contains the address of the first array element, and then the range of each index and the corresponding coefficient in the indexing formula. This technique also allows immediate array [[transpose|transposition]], index reversal, subsampling, etc. For languages like [[C (programming language)|C]], where the indices always start at zero, the dope vector of an array with ''d'' indices has at least 1 + 2''d'' parameters. For languages that allow arbitrary lower bounds for indices, like [[Pascal programming language|Pascal]], the dope vector needs 1 + 3''d'' entries. If the array abstraction does not support true negative indices (as the arrays of [[Ada (programming language)|Ada]] and [[Pascal (programming language)|Pascal]] do), then negative indices for the bounds of the slice for a given dimension are sometimes used to specify an offset from the end of the array in that dimension. In 1-based schemes, -1 generally indicates the second-to-last item, while in a 0-based system, it refers to the very last item.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)