RWalib C Array Library User Guide > Type Conversion > alibComplex
  

alibComplex
Makes a complex array from two real arrays or from a real array and scalar. The PV-WAVE API's for this routine are the COMPLEX Function and DCOMPLEX Function.
Prototypes
void alibComplexf( wvlong m, wvlong n, float *p, float *q, COMPLEX *r )
void alibComplexd( wvlong m, wvlong n, double *p, double *q, DCOMPLEX *r )
Parameters
m — (Input) If m=0 the real part of the result array is constant, otherwise m is the number of elements in the array for the real part.
n — (Input) If n=0 the imaginary part of the result array is constant, otherwise n is the number of elements in the array for the imaginary part. If m and n are both nonzero, they must be equal.
*p — (Input) Pointer to the scalar or the m-element array defining the real part of the result array.
*q — (Input) Pointer to the scalar or the n-element array defining the imaginary part of the result array.
*r — (Input/Output) On return, r[i] = cmplxflt( p[i], q[i] ), where if either p or q is a scalar then that same scalar is used for all i.
Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
    float  f = -1;
    float  f0[9] = {0,1,2,3,4,5,6,7,8};
    float  f1[9] = {9,10,11,12,13,14,15,16,17};
    COMPLEX  *c;
    c = (COMPLEX*)malloc(9*sizeof(COMPLEX));
    alibinit( NULL, NULL, NULL, NULL );
    printf( "\n\n input scalar and array and print result" );
    alibComplexf( 0, 9, &f, f0, c );
    alibPrintArrayc( 1, 1, 3, 3, c, NULL );
    printf( "\n\n input array and scalar and print result" );
    alibComplexf( 9, 0, f0, &f, c );
    alibPrintArrayc( 1, 1, 3, 3, c, NULL );
    printf( "\n\n input array and array and print result" );
    alibComplexf( 9, 9, f0, f1, c );
    alibPrintArrayc( 1, 1, 3, 3, c, NULL );
}
 
Output:
 
 input scalar and array and print result
 
(   -1.0e+00    0.0e+00 ) (   -1.0e+00    1.0e+00 ) (   -1.0e+00    2.0e+00 ) 
(   -1.0e+00    3.0e+00 ) (   -1.0e+00    4.0e+00 ) (   -1.0e+00    5.0e+00 ) 
(   -1.0e+00    6.0e+00 ) (   -1.0e+00    7.0e+00 ) (   -1.0e+00    8.0e+00 ) 
 
 input array and scalar and print result
 
(    0.0e+00   -1.0e+00 ) (    1.0e+00   -1.0e+00 ) (    2.0e+00   -1.0e+00 ) 
(    3.0e+00   -1.0e+00 ) (    4.0e+00   -1.0e+00 ) (    5.0e+00   -1.0e+00 ) 
(    6.0e+00   -1.0e+00 ) (    7.0e+00   -1.0e+00 ) (    8.0e+00   -1.0e+00 ) 
 
 input array and array and print result
 
(    0.0e+00    9.0e+00 ) (    1.0e+00    1.0e+01 ) (    2.0e+00    1.1e+01 ) 
(    3.0e+00    1.2e+01 ) (    4.0e+00    1.3e+01 ) (    5.0e+00    1.4e+01 ) 
(    6.0e+00    1.5e+01 ) (    7.0e+00    1.6e+01 ) (    8.0e+00    1.7e+01 ) 

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