Difference between revisions of "StepInterp"

Line 2: Line 2:
 
[[Category:Doc Status D]] <!-- For Lumina use, do not change -->
 
[[Category:Doc Status D]] <!-- For Lumina use, do not change -->
 
   
 
   
(stub)
+
= StepInterp( D,A,x,I ) =
  
= Declaration =
+
Returns the element or slice of array A corresponding to the smallest value in D that is greater than or equal to x. D and A must both be indexed by I, and D must be increasing along index I. If x is greater than all values of D, returns the element for which D has the largest value.
  
StepInterp( D,A,X,I)
+
If X is a single value, the result of Stepinterp() is an array indexed by all indexes of A except D’s index. If X is an array, the result of Stepinterp() is also indexed by the indexes of X.
  
= Notes =
+
StepInterp() is similar to [[Subscript]](u1, i, u2); however, [[Subscript]]() selects based on the index value being equal to x, while Stepinterp() selects based on the array value being greater than or equal to x.
  
StepInterp uses "right-lookup", finding a value u in D such that x<=u. In the interpolated graph, this makes the the step up takes place at the left edge of each interval.  Sometimes you might want a "left-lookup", finding a value u in D such that u<=x.  One implementation of this other variant is a [[User-Defined Functions|UDF]]:
+
Stepinterp() can be used to perform table lookup.
  
Function LStepInterp(D:ascending[I] ; R:Array[I] ; X ; I : Index )
+
= StepInterp( D,A,x,I, LeftLookup:True ) =
Definition:
+
 
    Var pos := StepInterp(D,@I,X,I);
+
When the optional parameter, LeftLookup, is specified as true, StepInterp returns the element or slice of A corresponding to the largest value in D that is less than or equal to x.
    R[@I= if X=D[@I=pos] then pos else max([1,pos-1]) ]
 
  
 
= See Also =
 
= See Also =
Line 21: Line 20:
 
* [[LinearInterp]]
 
* [[LinearInterp]]
 
* [[CubicInterp]]
 
* [[CubicInterp]]
 +
* [[Subscript]]

Revision as of 17:12, 26 October 2007


StepInterp( D,A,x,I )

Returns the element or slice of array A corresponding to the smallest value in D that is greater than or equal to x. D and A must both be indexed by I, and D must be increasing along index I. If x is greater than all values of D, returns the element for which D has the largest value.

If X is a single value, the result of Stepinterp() is an array indexed by all indexes of A except D’s index. If X is an array, the result of Stepinterp() is also indexed by the indexes of X.

StepInterp() is similar to Subscript(u1, i, u2); however, Subscript() selects based on the index value being equal to x, while Stepinterp() selects based on the array value being greater than or equal to x.

Stepinterp() can be used to perform table lookup.

StepInterp( D,A,x,I, LeftLookup:True )

When the optional parameter, LeftLookup, is specified as true, StepInterp returns the element or slice of A corresponding to the largest value in D that is less than or equal to x.

See Also

Comments


You are not allowed to post comments.