./
round2array.pro
topround2array
result = round2array(array, number [, FORCE=FORCE])
round a value to its nearest value in an array
not fully tested for nan values...
Return value
the index of the closest array element
Parameters
- array in required
SORTED!! array to round the number into (must be 1-d)
- number in required
the number(s) to round to the array
Keywords
- FORCE in optional
force the program to return an answer even if the input is not sorted
Examples
IDL> print, round2array(findgen(10), [3.4, 3.0, 6.7, 6.3])
3 3 7 6
Author information
- History:
Mon Sep 8 15:39:23 2008, Brian Larsen had a problem at the end point, fixed, probably lost some speed however Tue Aug 26 18:42:58 2008, Brian Larsen another x10 speed improvement suggested by Paolo Grigis http://groups.google.com/group/comp.lang.idl-pvwave/browse_frm/thread/5848f460a7aab59b/1aae381879eb7ef9#1aae381879eb7ef9 Mon Jan 7 10:46:02 2008, Brian Larsen totally rewritten using value_locate greatly simplified and sped up (factor of 11) Changed order of inputs to match that of value_locate (sorry) Tue Oct 16 14:51:20 2007, Brian Larsen written and tested
Statistics
| Lines: | 29 |
| McCabe complexity: |
File attributes
| Modifcation date: | Tue Sep 9 14:11:22 2008 |
| Lines: | 84 |
![[attach.png]](idldoc-resources/attach.png)