RWalib C Array Library User Guide > Relational Operations > alibThreshold
  

alibThreshold
Thresholds an array.
Prototype
void alibThresholdl( wvlong n, wvlong p, wvlong q, wvlong *i )
Parameters
n — (Input) The number of elements in the array to be thresholded.
p — (Input) The lower threshold.
q — (Input) The upper threshold.
*i — (Input/Output) The array to be thresholded. On return, elements less than p have been set to p and elements greater than q have been set to q.
Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
   /* make up some data for the example */
   wvlong b[128];
   alibinit( NULL, NULL, NULL, NULL );
   alibIndexl( 128, -32, 1, b );
   printf( "\n\n show (16,8) array b" );
      alibPrintArrayl( 1, 1, 16, 8, b, "%8lld" );
   printf( "\n\n threshold b into the range [0,63]" );
      alibThresholdl( 128, 0, 63, b );
      alibPrintArrayl( 1, 1, 16, 8, b, "%8lld" );
}
 
Output:
 
 show (16,8) array b
 
     -32     -31     -30     -29     -28     -27     -26     -25
     -24     -23     -22     -21     -20     -19     -18     -17
     -16     -15     -14     -13     -12     -11     -10      -9
      -8      -7      -6      -5      -4      -3      -2      -1
       0       1       2       3       4       5       6       7
       8       9      10      11      12      13      14      15
      16      17      18      19      20      21      22      23
      24      25      26      27      28      29      30      31
      32      33      34      35      36      37      38      39
      40      41      42      43      44      45      46      47
      48      49      50      51      52      53      54      55
      56      57      58      59      60      61      62      63
      64      65      66      67      68      69      70      71
      72      73      74      75      76      77      78      79
      80      81      82      83      84      85      86      87
      88      89      90      91      92      93      94      95
 
 threshold b into the range [0,63]
 
       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0
       0       0       0       0       0       0       0       0
       0       1       2       3       4       5       6       7
       8       9      10      11      12      13      14      15
      16      17      18      19      20      21      22      23
      24      25      26      27      28      29      30      31
      32      33      34      35      36      37      38      39
      40      41      42      43      44      45      46      47
      48      49      50      51      52      53      54      55
      56      57      58      59      60      61      62      63
      63      63      63      63      63      63      63      63
      63      63      63      63      63      63      63      63
      63      63      63      63      63      63      63      63
      63      63      63      63      63      63      63      63

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.