Question
vector functions - error fix
- May 11, 2010
- 3 replies
- 3157 views
While perusing Richard's recent post "Hexagonal Packing(4).mcd," which contained Stuart's vector support functions, I saw one vector function - locate (x,v) - that I was about to write for myself. Loosely described, the function determines the effective index of an arbitrary value x within a given vector v. As the test value x is swept thru the various vector values, the returned index should step in unity increments. The actual behavior for one simple test is in the attachment, and does not show the expected behavior.
A second function, IndexOfNearest, behaves as expected, but is not what I was looking for.
I created the locate2 function for my own needs, but it may be useful for others wanting a similar function. This new fct. distinguishes among test values equal to vector values, test values which fall between vector values, and test values outside the range of the vector. It is straightforward to collapse the result into integer index ony functions.
I haven't as yet found any errors in the new routine, but test volunteers are encouraged to find bugs.
Lou
A second function, IndexOfNearest, behaves as expected, but is not what I was looking for.
I created the locate2 function for my own needs, but it may be useful for others wanting a similar function. This new fct. distinguishes among test values equal to vector values, test values which fall between vector values, and test values outside the range of the vector. It is straightforward to collapse the result into integer index ony functions.
I haven't as yet found any errors in the new routine, but test volunteers are encouraged to find bugs.
Lou

