Questions tagged [indices]

Use this tag for questions about specifying or selecting the correct information from a structure using indices.

For any set of records, indices are identifiers of which specify information of the address of each record.

Check the Wikipedia page for arrays to know more.

882 questions
6
votes
1 answer

Hard time understanding indices with glDrawElements

I'm trying to draw a terrain with GL_TRIANGLE_STRIP and glDrawElements but I'm having a really hard time understanding the indices thing behind glDrawElements... Here's what I have so far: void Terrain::GenerateVertexBufferObjects(float ox, float…
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
6
votes
3 answers

Sum matrix elements group by indices in Python

I have two matrix (same row and column): one with float values, which are grouped by indices in the other matrix. As a result, I want a dictionary or a list with the sums of the elements for each index. Indices always start at 0. A =…
Mortafix
  • 95
  • 9
6
votes
2 answers

Extract columns from data table by numeric indices stored in a vector

I want to extract the 4th, 5th, and 6th column from a data table named dt the following method works: dt[, c(4,5,6)] but the following doesn't: a = c(4,5,6) dt[, a] In fact, the second method gives me a reult of: 4 5 6 Can someone…
Amazonian
  • 391
  • 2
  • 8
  • 22
6
votes
5 answers

Selecting multiple dataframe columns by position in pandas

I have a (large) dataframe. How can I select specific columns by position? e.g. columns 1..3, 5, 6 Rather than just drop column4, I am trying to do it in this way because there are a ton of rows in my dataset and I want to select by position: …
aiden rosenblatt
  • 403
  • 2
  • 5
  • 9
6
votes
2 answers

Why are Postgres lookups on jsonb columns so slow?

I have a table targeting that has a column marital_status of type text[] and another column data of type jsonb. The content of these two columns is the same, just in a different format (it's just for demonstration purposes). Example data: id | …
satoshi
  • 3,963
  • 6
  • 46
  • 57
6
votes
2 answers

TypeError: list indices must be integers, not list. How to fix?

There's the code with the TypeError in it. "list indices must be integers, not list", though they are integers. I'd appreciate you helping me figure out what's wrong. What I need is to get matrix 7x5 from source 7x5 tab with different values. The…
Larleyt
  • 83
  • 1
  • 1
  • 5
6
votes
1 answer

OpenMesh Random Access

I thought OpenMesh would support random access to faces edges vertices. All I can find are iterators and circulators: for( auto v : mesh->vertices() ) mesh->point(v).data(); How can I do something like this: mesh->vertices(42);
6
votes
1 answer

Assigning identical array indices at once in Python/Numpy

I want to find a fast way (without for loop) in Python to assign reoccuring indices of an array. This is the desired result using a for loop: import numpy as np a=np.arange(9, dtype=np.float64).reshape((3,3)) # The array indices: [2,3,4] are…
Paul
  • 85
  • 5
6
votes
3 answers

Get indices for all elements in an array in numpy

I'm trying to get a list of the indices for all the elements in an array so for an array of 1000 x 1000 I end up with [(0,0), (0,1),...,(999,999)]. I made a function to do this which is below: def indices(alist): results = [] ele =…
Jason White
  • 666
  • 4
  • 10
  • 23
6
votes
5 answers

Python: split list of integers based on step between them

I have the following problem. Having a list of integers, I want to split it, into a list of lists, whenever the step between two elements of the original input list is not 1. For example: input = [0, 1, 3, 5, 6, 7], output = [[0, 1], [3], [5, 6,…
matetam
  • 75
  • 1
  • 7
5
votes
8 answers

Python: Delete all list indices meeting a certain condition

to get right down to it, I'm trying to iterate through a list of coordinate pairs in python and delete all cases where one of the coordinates is negative. For example: in the array: map = [[-1, 2], [5, -3], [2, 3], [1, -1], [7, 1]] I want to…
Will
  • 53
  • 1
  • 3
5
votes
1 answer

How to find the index of the first row of a matrix that satisfies two conditions in APL Language?

One more question to learn how to use APL Language. Suppose you have an array, as an example: c1 c2 c3 c4 c5 c6 3 123 0 4 5 6 3 134 0 2 3 4 3 231 180 1 2 5 4 121 0 3 2 4 4 124 120 4 6 3 4 222 222 5 3 5 So, how to find out which…
5
votes
2 answers

How to use Hibernate @Index annotation properly?

i have a java class used as an entity that has 2 classes that inherit from it. this class has some indices but these indices didn't appear in the database. this is my java super class code import java.io.Serializable; import java.util.List; import…
user597987
5
votes
3 answers

Model binding to a list with Non-Sequential Indices possible in MVC 3?

I'm following the info on http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx from Phil Haack He talks about Non-Sequential indices:
Kevin
  • 125
  • 1
  • 10
5
votes
3 answers

Access elements of a Matrix by a list of indices in Python to apply a max(val, 0.5) to each value without a for loop

I know how to access elements in a vector by indices doing: test = numpy.array([1,2,3,4,5,6]) indices = list([1,3,5]) print(test[indices]) which gives the correct answer : [2 4 6] But I am trying to do the same thing using a 2D matrix, something…
Zhell
  • 95
  • 1
  • 1
  • 6