Vector Optimized Library of Kernels  3.0.0
Architecture-tuned implementations of math kernels

Overview

Computes the hyperbolic tangent of each element of the aVector:

c[i] = tanh(a[i])

Dispatcher Prototype

void volk_32f_tanh_32f(float* cVector, const float* aVector, unsigned int num_points)

Inputs

  • aVector: The buffer of points.
  • num_points: The number of values in input buffer.

Outputs

  • cVector: The output buffer.

Example

int N = 10;
unsigned int alignment = volk_get_alignment();
float* in = (float*)volk_malloc(sizeof(float)*N, alignment);
float* out = (float*)volk_malloc(sizeof(float)*N, alignment);
for(unsigned int ii = 0; ii < N; ++ii){
// the approximate artanh(x) for x<1
float x = (float)ii / (float)N;
in[ii] = 0.5 * std::log((1.f+x)/(1.f-x));
}
volk_32f_tanh_32f(out, in, N);
for(unsigned int ii = 0; ii < N; ++ii){
printf("out(%i) = %f\n", ii, out[ii]);
}
volk_free(out);
size_t volk_get_alignment(void)
Get the machine alignment in bytes.
Definition: volk.tmpl.c:90
__VOLK_DECL_BEGIN VOLK_API void * volk_malloc(size_t size, size_t alignment)
Allocate size bytes of data aligned to alignment.
Definition: volk_malloc.c:38
VOLK_API void volk_free(void *aptr)
Free's memory allocated by volk_malloc.
Definition: volk_malloc.c:80