RWalib C Array Library User Guide > Type Conversion > alibImaginary
  

alibImaginary
Returns imaginary part of each element in a complex array (for the real part see alibFloat or alibDouble). The PV-WAVE API for this routine is the IMAGINARY Function.
Prototypes
void alibImaginaryc( wvlong n, COMPLEX *p, float *r )
void alibImaginaryz( wvlong n, DCOMPLEX *p, double *r )
Parameters
n — (Input) The number of elements in the source array.
*p — (Input) The n-element source array.
*r — (Input/Output) The n-element destination array. On return, array r is the imaginary part of array p, i.e., r[j] = p[j].i.
Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
    COMPLEX  c[9] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
    float *f;
    f = (float*)malloc(9*sizeof(float));
    alibinit( NULL, NULL, NULL, NULL );
    printf( "\n\n print the input array" );
    alibPrintArrayc( 1, 1, 3, 3, c, NULL );
    printf( "\n\n compute and print the result array" );
    alibImaginaryc( 9, c, f );
    alibPrintArrayf( 1, 1, 3, 3, f, NULL );
}
 
Output:
 
 print the input array
 
(    0.0e+00    1.0e+00 ) (    2.0e+00    3.0e+00 ) (    4.0e+00    5.0e+00 ) 
(    6.0e+00    7.0e+00 ) (    8.0e+00    9.0e+00 ) (    1.0e+01    1.1e+01 ) 
(    1.2e+01    1.3e+01 ) (    1.4e+01    1.5e+01 ) (    1.6e+01    1.7e+01 ) 
 
 compute and print the result array
 
    1.00e+00    3.00e+00    5.00e+00
    7.00e+00    9.00e+00    1.10e+01
    1.30e+01    1.50e+01    1.70e+01

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