RWalib C Array Library User Guide > Hyperbolic Functions > alibTanh
  

alibTanh
Returns the hyperbolic tangent of each element in an array. The PV-WAVE API for this routine is the TANH Function.
Prototypes
void alibTanhf( wvlong n, float *p, float *r )
void alibTanhd( wvlong n, double *p, double *r )
void alibTanhc( wvlong n, COMPLEX *p, COMPLEX *r )
void alibTanhz( wvlong n, DCOMPLEX *p, DCOMPLEX *r )
Parameters
n — (Input) The number of elements in the source array.
*p — (Input) The n-element source array.
*r — (Input/Output) The n-element destination array. On return, array r contains the hyperbolic tangent of each element in array p. The operation can be done in-place, i.e., r can equal p.
Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
   /* make up some input data for the examples */
   float    f0[4]={1,2,3,4};
   /* make an output array */
   float    f[4];
   printf( "\n\n show 4-element vector f0" );
      alibinit( NULL, NULL, NULL, NULL );
      alibPrintArrayf( 1, 1, 1, 4, f0, NULL );
   printf( "\n\n show the hyperbolic tangent of each element in f0" );
      alibTanhf( 4, f0, f );
      alibPrintArrayf( 1, 1, 1, 4, f, NULL );
   printf( "\n\n repeat the operation in-place;  print result as a matrix" );
      alibTanhf( 4, f0, f0 );
      alibPrintArrayf( 1, 1, 2, 2, f0, NULL );
}
 
Output:
 
 show 4-element vector f0
 
   1.000e+00   2.000e+00   3.000e+00   4.000e+00
 
 show the hyperbolic tangent of each element in f0
 
   7.616e-01   9.640e-01   9.951e-01   9.993e-01
 
 repeat the operation in-place;  print result as a matrix
 
   7.616e-01   9.640e-01
   9.951e-01   9.993e-01
 

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