PandA-2024.02
generate.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <sys/types.h>
5 #include <sys/stat.h>
6 #include <fcntl.h>
7 #include <unistd.h>
8 #include <assert.h>
9 #include <math.h>
10 
11 #include "fft.h"
12 
13 int main(int argc, char **argv)
14 {
15  struct bench_args_t data;
16  int i, n, fd;
17  double typed;
18  struct prng_rand_t state;
19 
20  // Fill data structure
21  prng_srand(1, &state);
22  for(i=0; i<FFT_SIZE; i++){
23  data.real[i] = ((double)prng_rand(&state))/((double)PRNG_RAND_MAX);
24  data.img[i] = ((double)prng_rand(&state))/((double)PRNG_RAND_MAX);
25  }
26 
27  //Pre-calc twiddles
28  for(n=0; n<(FFT_SIZE>>1); n++){
29  typed = (double)(twoPI*n/FFT_SIZE);
30  data.real_twid[n] = cos(typed);
31  data.img_twid[n] = (-1.0)*sin(typed);
32  }
33 
34  // Open and write
35  fd = open("input.data", O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
36  assert( fd>0 && "Couldn't open input data file" );
37  data_to_input(fd, (void *)(&data));
38 
39  return 0;
40 }
double real[FFT_SIZE]
Definition: fft.h:15
static uint64_t prng_rand(struct prng_rand_t *state)
Definition: support.h:85
double img[FFT_SIZE]
Definition: fft.h:16
#define FFT_SIZE
Definition: fft.h:5
void data_to_input(int fd, void *vdata)
Definition: local_support.c:34
double real_twid[FFT_SIZE/2]
Definition: fft.h:17
double img_twid[FFT_SIZE/2]
Definition: fft.h:18
uint_fast16_t i
Definition: support.h:78
int main(int argc, char **argv)
Definition: generate.c:12
static void prng_srand(uint64_t seed, struct prng_rand_t *state)
Definition: support.h:106
#define twoPI
Definition: fft.h:6
#define PRNG_RAND_MAX
Definition: support.h:82

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13