I have a matrix called "sgrid" that is 6993 x 3.
Within this matrix, I need to search for rows that correspond to a certain criterion. I have a function that spits out a vector of row indices called "tidx". Here is tidx:
Unfortunately, tidx is not an integer. Most unfortunately, the matrix accepts it as a valid subscript vector, but returns the wrong rows. Behold:
To be precise, sgrid[tidx,.] returns rows 966, 1596 and 2226.
I have wasted innumerable hours because of the cognitive dissonance created by this. I could blame myself for not forcing tidx to be integer, but how much should I really blame myself?
1) Why should I care it's integer when it's right?
2) Why doesn't the matrix tell me that tidx is not integer and just refuse to take it as a subscript?
3) If the matrix has a good reason to take a noninteger subscript, why does it use "floor()" instead of "round()"?
4) How was I even supposed to know about all this?
I am not just upset. I really would like an answer to all four questions.
Within this matrix, I need to search for rows that correspond to a certain criterion. I have a function that spits out a vector of row indices called "tidx". Here is tidx:
Code:
: tidx 1 +--------+ 1 | 967 | 2 | 1597 | 3 | 2227 | +--------+
Code:
: sgrid[tidx,.] 1 2 3 +-------------------+ 1 | .01 0 .1 | 2 | .02 0 .1 | 3 | .03 0 .1 | +-------------------+ : sgrid[round(tidx),.] 1 2 3 +-------------------+ 1 | .01 1 0 | 2 | .02 1 0 | 3 | .03 1 0 | +-------------------+
I have wasted innumerable hours because of the cognitive dissonance created by this. I could blame myself for not forcing tidx to be integer, but how much should I really blame myself?
1) Why should I care it's integer when it's right?
2) Why doesn't the matrix tell me that tidx is not integer and just refuse to take it as a subscript?
3) If the matrix has a good reason to take a noninteger subscript, why does it use "floor()" instead of "round()"?
4) How was I even supposed to know about all this?
I am not just upset. I really would like an answer to all four questions.
Comment