Questions tagged [array-indexing]

Use this tag for questions about how to construct and interpret indices for retrieval of or assignment to non-trivial subsets or reorderings of multidimensional arrays.

Arrays are usually indexed numerically along their different dimensions. However, some packages, like numpy and MATLAB, allow for more complex objects to be used to compute the numerical indices. Questions with this tag should refer to such non-trivial indices. Examples include boolean masks, lists of integers (which behave differently in different languages), and linear indices into a multidimensional array.

75 questions
1
vote
2 answers

C++ use class with conversion operator as index into array

#include #include template class sparse_set { static_assert(std::is_integral_v, ""); (1) static_assert(std::is_unsigned_v, ""); Value& operator[](Id id); void…
Symlink
  • 383
  • 2
  • 12
1
vote
1 answer

Angular Index of nested loop inside Template

I have a nested loop in a table, but i want to only show a limited amount of rows in the DOM and load more when a button is clicked. The Loop looks something like this:
Jeremias Nater
  • 650
  • 3
  • 18
1
vote
1 answer

PowerShell printing only first letter of a string

I have a PowerShell script that connects to a localhost API that returns a dictionary of "sessions" and whether they are active [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $response = Invoke-RestMethod…
user14958186
1
vote
3 answers

How do you get the index number of an array rather than the element?

I have written a basic program to find the largest number in an array and print it: #include int main(void) { int numbers[] = {3, 5, 12, 1, 4}; int largest; largest = numbers[0]; for (int i = 0; i < sizeof(numbers) /…
BlueKhakis
  • 293
  • 1
  • 8
1
vote
1 answer

Handling NaN / Inf in a numpy dnarray

Working on a 4D numpy array (array of arrays). Each nested array is of shape (1, 100, 4) trainset.shape (159984, 1, 100, 4) But then within the nested arrays, are found some nan values which I would like to handle. For example the first nested…
user12587364
1
vote
1 answer

Numpy ndArray: accessing input features of each class

For my current classification task, I am interesting in accessing the input features for the individual class such that each class is train on its input features only (weak classifier), later for ensemble of them. I am having a challenge accessing…
user12587364
1
vote
1 answer

Fast image processing with Look-up table

I have images from a video and a look-up table with indexes. The goal is to make a new image from each frame by using the indexes in the look-up table. My code work using my laptop, but bit slow. My aim is to make it to work in TX2. Below is my…
Drona
  • 107
  • 11
1
vote
1 answer
1
vote
2 answers

Why do arrays start on 0 instead of 1? (C, C++)

Not really a code problem but a doubt, why do arrays on C and C++ start on 0? Does it have anything to do with some internal process? int array[4]={1,2,3,4}; cout<
user11218276
1
vote
1 answer

Single dimensional numeric array converted to object array in PHP. How the value of object array can be accessed by its index

Here I have a single dimension numeric array $x = array(1,2,3,4); Below converted to an object array $x = (object) $x; I am not able to access values by its index echo $x->{'1'} //Tried but not working
Dharmendra Singh
  • 1,186
  • 12
  • 22
1
vote
1 answer

Find Index of first Matching Element $gte with $indexOfArray

MongoDB has $indexOfArray to let you find the element's array index, for example: $indexOfArray: ["$article.date", ISODate("2019-03-29")] Is it possible to use comparison operators with $indexOfArray together, like: $indexOfArray:…
nickmit
  • 53
  • 6
1
vote
1 answer

numpy indexing: shouldn't trailing Ellipsis be redundant?

While trying to properly understand numpy indexing rules I stumbled across the following. I used to think that a trailing Ellipsis in an index does nothing. Trivial isn't it? Except, it's not actually true: Python 3.5.2 (default, Nov 11 2016,…
Paul Panzer
  • 51,835
  • 3
  • 54
  • 99
0
votes
1 answer

Does array.map() starts iterating from the 1st element throughout the array?

Is n automatically set to represent array indexes starting from 0? What confuses me is that I usually set up for loops to define i as an index indicator. But here how does n do it without being set that way? x is an array function maps(x){ return…
Tamerlan
  • 3
  • 2
0
votes
0 answers

Python: how to save the array indexes at each iteration of the function in a loop

I am trying to save the indexes of list at each iteration of a function in a loop. Actually, I called a function within a loop and saved the function output values in a list. At each iteration, I selected some values from this list based on…
Waqar Ali
  • 1
  • 1
0
votes
0 answers

Addressing in RISC-V, indexing a byte of a string

if im writing a function that takes a string as an argument how would I traverse the string? I thought we have to multiply the index by 8 since RISC-V is byte addressible. ex slli x5, x5, 3 ;; x6 contains index i add a0, a0, x6 ;; a0 contains…
Rappterr
  • 1
  • 1