alibMod
Applies modulo operator to scalar or array arguments, element-wise. The PV-WAVE API for this routine is the
MOD.
Prototypes
void alibModb( wvlong m, wvlong n, UCHAR *p, UCHAR *q, UCHAR *r )
void alibMods( wvlong m, wvlong n, short *p, short *q, short *r )
void alibModi( wvlong m, wvlong n, int *p, int *q, int *r )
void alibModl( wvlong m, wvlong n, wvlong *p, wvlong *q, wvlong *r )
void alibModf( wvlong m, wvlong n, float *p, float *q, float *r )
void alibModd( 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 element-wise modulus 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 mod s2, element-wise" );
alibMods( 6, 0, s0, &s2, s );
alibPrintArrays( 1, 1, 1, 6, s, NULL );
printf( "\n\n show the result of s2 mod s0, element-wise" );
alibMods( 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 mod s1, element-wise" );
alibMods( 6, 6, s0, s1, s );
alibPrintArrays( 1, 1, 1, 6, s, NULL );
printf( "\n\n now do the same operation, but in-place in s1, \n" );
printf( " and show the result as a (2,3) matrix" );
alibMods( 6, 6, s0, s1, s1 );
alibPrintArrays( 1, 1, 2, 3, s1, NULL );
}
Output:
show 6-element vector s0 and scalar s2
2 3 4 5 6 7
5
show the result of s0 mod s2, element-wise
2 3 4 0 1 2
show the result of s2 mod s0, element-wise
1 2 1 0 5 5
show a second 6-element vector s1
7 2 6 3 5 3
show the result of s0 mod s1, element-wise
2 1 4 2 1 1
now do the same operation, but in-place in s1,
and show the result as a (2,3) matrix
2 1 4
2 1 1
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.