Files
seer/tests/helloarray/helloarray.cpp
T

88 lines
1.3 KiB
C++
Raw Normal View History

2021-09-05 11:58:58 -05:00
#include <string.h>
#include <stdio.h>
#include <malloc.h>
2022-03-19 15:46:34 -05:00
#include <math.h>
#include <iostream>
2021-09-05 11:58:58 -05:00
2022-05-15 13:32:00 -05:00
float* function1() {
float* float_array = (float*)malloc(256);
for (int i=0; i<64; i++) {
float_array[i] = (float)i * 1.13;
}
return float_array;
}
2021-09-05 11:58:58 -05:00
int main (void) {
2022-08-05 08:58:34 -05:00
//
//
//
float local_array[] = {1.0, 2.0, 3.0};
2022-03-19 15:46:34 -05:00
//
//
//
2021-09-05 11:58:58 -05:00
char* array = (char*)malloc(256);
for (int i=0; i<256; i++) {
array[i] = i;
}
2022-03-19 15:46:34 -05:00
//
//
//
2021-09-05 11:58:58 -05:00
int* int_array = (int*)malloc(256);
for (int i=0; i<64; i++) {
2022-03-19 15:46:34 -05:00
int_array[i] = i*0;
2021-09-05 11:58:58 -05:00
}
2022-03-19 15:46:34 -05:00
//
//
//
2022-03-14 18:28:46 -05:00
float* float_array = (float*)malloc(256);
for (int i=0; i<64; i++) {
float_array[i] = (float)i * 1.13;
}
2022-03-19 15:46:34 -05:00
//
//
//
int table_size = 512;
double two_pi = (3.14159 * 2);
float phaseIncrement = two_pi/table_size;
float currentPhase = 0.0;
float* sine_array = (float*)malloc(table_size*sizeof(float));
for (int i = 0; i < 512; i ++){
sine_array[i] = sin(currentPhase);
currentPhase += phaseIncrement;
}
2022-05-15 13:32:00 -05:00
//
//
//
float* x = function1();
2022-03-19 15:46:34 -05:00
//
//
//
2021-09-05 11:58:58 -05:00
printf("Hello array!\n");
free(array);
free(int_array);
2022-03-14 18:28:46 -05:00
free(float_array);
2022-03-19 15:46:34 -05:00
free(sine_array);
2022-05-15 13:32:00 -05:00
free(x);
2021-09-05 11:58:58 -05:00
return 0;
}