alibDiv
Divides scalar or array arguments, element-wise. The PV-WAVE API for this routine is the
Division Operator /.
Prototypes
void alibDivb( wvlong m, wvlong n, UCHAR *p, UCHAR *q, UCHAR *r )
void alibDivs( wvlong m, wvlong n, short *p, short *q, short *r )
void alibDivi( wvlong m, wvlong n, int *p, int *q, int *r )
void alibDivl( wvlong m, wvlong n, wvlong *p, wvlong *q, wvlong *r )
void alibDivf( wvlong m, wvlong n, float *p, float *q, float *r )
void alibDivd( wvlong m, wvlong n, double *p, double *q, double *r )
void alibDivc( wvlong m, wvlong n, COMPLEX *p, COMPLEX *q, COMPLEX *r )
void alibDivz( wvlong m, wvlong n, DCOMPLEX *p, DCOMPLEX *q, DCOMPLEX *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 element-wise quotient of the two operands. 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 */
short s0[6]={2,3,4,5,6,7}, s1[6]={7,2,6,3,5,3}, s2=5;
/* make an output array */
short s[6];
printf( "\n\n show 6-element vector s0 and scalar s2" );
alibinit( NULL, NULL, NULL, NULL );
alibPrintArrays( 1, 1, 1, 6, s0, NULL );
alibPrintArrays( 1, 1, 1, 1, &s2, NULL );
printf( "\n\n show the result of s0 / s2, element-wise" );
alibDivs( 6, 0, s0, &s2, s );
alibPrintArrays( 1, 1, 1, 6, s, NULL );
printf( "\n\n show the result of s2 / s0, element-wise" );
alibDivs( 0, 6, &s2, s0, s );
alibPrintArrays( 1, 1, 1, 6, s, NULL );
printf( "\n\n show a second 6-element vector s1" );
alibPrintArrays( 1, 1, 1, 6, s1, NULL );
printf( "\n\n show the result of s0 / s1, element-wise" );
alibDivs( 6, 6, s0, s1, s );
alibPrintArrays( 1, 1, 1, 6, s, NULL );
printf( "\n\n now do the same operation, but in-place in s0, \n" );
printf( " and show the result as a (2,3) matrix" );
alibDivs( 6, 6, s0, s1, s0 );
alibPrintArrays( 1, 1, 2, 3, s0, NULL );
}
Output:
show 6-element vector s0 and scalar s2
2 3 4 5 6 7
5
show the result of s0 / s2, element-wise
0 0 0 1 1 1
show the result of s2 / s0, element-wise
2 1 1 1 0 0
show a second 6-element vector s1
7 2 6 3 5 3
show the result of s0 / s1, element-wise
0 1 0 1 1 2
now do the same operation, but in-place in s0,
and show the result as a (2,3) matrix
0 1 0
1 1 2
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.