Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.stsci.edu/~sontag/spicedocs/cspice/lstled_c.html
Дата изменения: Sat Dec 17 06:09:15 2005 Дата индексирования: Mon Apr 11 00:04:41 2016 Кодировка: Поисковые слова: mars polar lander |
Given a number x and an array of non-decreasing numbers, find the index of the largest array element less than or equal to x.
None.
VARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- x I Value to search against n I Number elements in array array I Array of possible lower bounds The function returns the index of the last element of array that is less than or equal to x.
x Double precision number. n Total number of elements in array. array Array of double precision numbers which forms a non-decreasing sequence. The elements of array need not be distinct.
The function returns the index of the highest-indexed element in the input array that is less than or equal to x. The routine assumes the array elements are sorted in non-decreasing order. Indices range from 0 to n-1. If all elements of the input array are greater than x, the function returns -1.
None.
Note: If you need to find the first element of the array that is greater than x, simply add 1 to the result returned by this function and check to see if the result is within the array bounds given by n.
1) Let array be assigned the following values: array[0] = -2.0; array[1] = -2.0; array[2] = 0.0; array[3] = 1.0; array[4] = 1.0; array[5] = 11.0; The table below demonstrates the behavior of lstled_c: Call Returned Value =========================== ============== lstled_c ( -3.0, 6, array ) -1 lstled_c ( -2.0, 6, array ) 1 lstled_c ( 0.0, 6, array ) 2 lstled_c ( 1.0, 6, array ) 4 lstled_c ( 11.1, 6, array ) 5
If the sequence of elements in array is not non-decreasing, the program will run to completion but the index found will not mean anything.
Error free. 1) In the case that n is input with value less than or equal to zero, the function returns -1. 2) If the input array is not sorted in increasing order, the output of this routine are undefined. No error is signaled.
None.
N.J. Bachman (JPL) W.L. Taber (JPL)
None.
-CSPICE Version 1.0.0, 09-JUL-2002 (NJB) (WLT)
last d.p. element less_than_or_equal_to