7.7.3. IDX of Integers
(lsh/libidx/idx-int.lsh)


Basic operations on vectors, matrices, and tensors of integers.

7.7.3.0. (idx-i1addc m1 c m2)
(lsh/libidx/idx-int.lsh)


Add constant to idx1 of int.

7.7.3.1. (idx-i2addc m1 c m2)
(lsh/libidx/idx-int.lsh)


Add constant to idx2 of int.

7.7.3.2. (idx-i1concat int-vec1 int-vec2 ...)
(lsh/libidx/idx-int.lsh)


Concatenate the int-vectors in argument list and return new big vector.

7.7.3.3. (random-permute perm-vector)
(lsh/libidx/idx-int.lsh)


randomly permute the elements of the given permutation-vector (an integer vector)

7.7.3.4. (multinomial-sample probabilities)
(lsh/libidx/idx-int.lsh)


Given a vector of probabilities of length N summing to one for events 0 to N-1, return an integer i associated to these events with probability probabilities [i]. The algorithm samples a uniform number between 0 and 1 and loops through the probabilities vector, so its running time is O(N).

N.B.: if the sum S of the elements is 1, then the value N-1 will be sampled more frequently with extra probability 1 - S. if the sum S of the elements is 1, then only the first M elements will be sampled, with M being such that it is the largest integer such that the sum of the probabilities from 0 to M-1 is above 1.



7.7.3.5. (fast-multinomial-sample cumulative-probabilities)
(lsh/libidx/idx-int.lsh)


Given a vector of cumulative-probabilities of length N, monotonically increasing between 0 and 1, return an integer between 0 and N-1 sampled from the corresponding distribution. The algorithm samples a uniform number between 0 and 1 and does a binary search in the cumulative probabilities, so its running time O(log(N)) whereas the running time of (multinomial-sample probabilities ) is O(N). For this call to be really fast, the computation of cumulative-probabilities from probabilities must be done ahead of time (because it takes O(N) time). It can be done with (distribution2cumulative probabilities cumulative-probabilities ).

See: (multinomial-sample probabilities )
See: (distribution2cumulative probabilities cumulative-probabilities )



7.7.3.6. (distribution2cumulative probabilities cumulative-probabilities)
(lsh/libidx/idx-int.lsh)


Fill cumulative-probabilities by putting at the i-th position the sum the numbers in probabilities from the beginning to the (i-1)-th position. Therefore, cp[0]=0 and cp[N-1] may be 1. This is P(value < i).

7.7.3.7. (element-in-set int-element int-set)
(lsh/libidx/idx-int.lsh)


Return true iff int-element is in the int-set vector.

7.7.3.8. (idx-i1max m)
(lsh/libidx/idx-int.lsh)


returns largest element in m

7.7.3.9. (idx-i1min m)
(lsh/libidx/idx-int.lsh)


same as idx-m1min for vectors of integers

7.7.3.10. (idx-i1fill-with-index m)
(lsh/libidx/idx-int.lsh)


fill the elements of idx1 m with their index.

7.7.3.11. (idx-i1fill m c)
(lsh/libidx/idx-int.lsh)


((-idx1- (-int-)) m):
((-int-) c):
CREATED: P.Haffner, April 97
DESCRIPTION: Fills 1D int matrix with constant <c>


7.7.3.12. (idx-i2fill m c)
(lsh/libidx/idx-int.lsh)


((-idx2- (-int-)) m)):
((-int-) c):
CREATED: P.Haffner, April 97
DESCRIPTION: Fills 2D int matrix with constant <c>