alibAtan2
Returns the inverse tangent for two arguments, element-wise. The PV-WAVE API for this routine is the
ATAN Function.
Prototypes
void alibAtan2f( wvlong m, wvlong n, float *p, float *q, float *r )
void alibAtan2d( wvlong m, wvlong n, double *p, double *q, double *r )
Parameters
m — (Input) The number of elements in the first array operand. A value of 0 indicates that the first operand is a scalar.
n — (Input) The number of elements in the second array operand. A value of 0 indicates that the second operand is a scalar. If both operands are arrays then n must equal m.
*p — (Input) The pointer to the first operand.
*q — (Input) The pointer to the second operand.
*r — (Input/Output) The destination array. On return, array r contains the inverse tangent of arguments p and q, element-wise. By convention, arguments p and q are associated with ordinates and abscissas, respectively. The operation can be done in-place, i.e., r can equal p or q.
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=1, f1[8]={-1,0,3,1,2,0,-3,-2}, f2[8]={-1,-2,-3,0,2,1,3,0};
/* make an output array */
float f[8];
printf( "\n\n show scalar f0 and (2,4) matrices f1 and f2" );
alibinit( NULL, NULL, NULL, NULL );
alibPrintArrayf( 1, 1, 1, 1, &f0, NULL );
alibPrintArrayf( 1, 1, 2, 4, f1, NULL );
alibPrintArrayf( 1, 1, 2, 4, f2, NULL );
printf( "\n\n show the inverse tangent for f0 and f1, element-wise" );
alibAtan2f( 0, 8, &f0, f1, f );
alibPrintArrayf( 1, 1, 2, 4, f, NULL );
printf( "\n\n show the inverse tangent for f1 and f0, element-wise" );
alibAtan2f( 8, 0, f1, &f0, f );
alibPrintArrayf( 1, 1, 2, 4, f, NULL );
printf( "\n\n show the inverse tangent for f1 and f2, element-wise" );
alibAtan2f( 8, 8, f1, f2, f );
alibPrintArrayf( 1, 1, 2, 4, f, NULL );
printf( "\n\n repeat the operation in-place" );
alibAtan2f( 8, 8, f1, f2, f2 );
alibPrintArrayf( 1, 1, 2, 4, f2, NULL );
}
Output:
show scalar f0 and (2,4) matrices f1 and f2
1.000e+00
-1.000e+00 0.000e+00 3.000e+00 1.000e+00
2.000e+00 0.000e+00 -3.000e+00 -2.000e+00
-1.000e+00 -2.000e+00 -3.000e+00 0.000e+00
2.000e+00 1.000e+00 3.000e+00 0.000e+00
show the inverse tangent for f0 and f1, element-wise
2.356e+00 1.571e+00 3.218e-01 7.854e-01
4.636e-01 1.571e+00 2.820e+00 2.678e+00
show the inverse tangent for f1 and f0, element-wise
-7.854e-01 0.000e+00 1.249e+00 7.854e-01
1.107e+00 0.000e+00 -1.249e+00 -1.107e+00
show the inverse tangent for f1 and f2, element-wise
-2.356e+00 3.142e+00 2.356e+00 1.571e+00
7.854e-01 0.000e+00 -7.854e-01 -1.571e+00
repeat the operation in-place
-2.356e+00 3.142e+00 2.356e+00 1.571e+00
7.854e-01 0.000e+00 -7.854e-01 -1.571e+00
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.