RWalib C Array Library User Guide > Type Conversion > alibFloat
  

alibFloat
Converts an array to type float. This returns the real part of complex input. The PV-WAVE API for this routine is the FLOAT Function.
Prototypes
void alibFloatb( wvlong n, UCHAR *p, float *r )
void alibFloats( wvlong n, short *p, float *r )
void alibFloati( wvlong n, int *p, float *r )
void alibFloatl( wvlong n, wvlong *p, float *r )
void alibFloatf( wvlong n, float *p, float *r )
void alibFloatd( wvlong n, double *p, float *r )
void alibFloatc( wvlong n, COMPLEX *p, float *r )
void alibFloatz( wvlong n, DCOMPLEX *p, float *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, r is the array obtained from array p by converting each of its elements to type float. If array p is complex then array r is the real part of p.
Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
   UCHAR    b0[9] = {0,1,2,3,4,5,6,7,8};
   DCOMPLEX z0[9] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
   float *b;
   float *z;
   b = (float*)malloc(9*sizeof(float));
   z = (float*)malloc(9*sizeof(float));
   alibinit( NULL, NULL, NULL, NULL );
   printf( "\n\n print the input arrays" );
   alibPrintArrayb( 1, 1, 3, 3, b0, NULL );
   alibPrintArrayz( 1, 1, 3, 3, z0, NULL );
   alibFloatb( 9, b0, b );
   alibFloatz( 9, z0, z );
   printf( "\n\n print the result arrays" );
   alibPrintArrayf( 1, 1, 3, 3, b, NULL );
   alibPrintArrayf( 1, 1, 3, 3, z, NULL );
}
 
Output:
 
 print the input arrays
 
   0   1   2
   3   4   5
   6   7   8
 
(    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 ) 
 
 print the result arrays
 
    0.00e+00    1.00e+00    2.00e+00
    3.00e+00    4.00e+00    5.00e+00
    6.00e+00    7.00e+00    8.00e+00
 
    0.00e+00    2.00e+00    4.00e+00
    6.00e+00    8.00e+00    1.00e+01
    1.20e+01    1.40e+01    1.60e+01

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