MCPcopy Create free account
hub / github.com/LancePutnam/Gamma / main

Function main

examples/function/analysis.cpp:17–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15using namespace gam::gen;
16
17int main(){
18
19 const unsigned size = 32;
20 float table[size];
21 //unsigned indices[size];
22
23 for(unsigned i=0; i<size; ++i){
24 float phs = float(i)/size;
25 table[i] = scl::abs(cos(2 * 2*M_PI*phs) * exp(-phs));
26 }
27
28 // print out function
29 for(unsigned i=0; i<size; i++){
30 printf("[%4d]\t% 7.4f ", i, table[i]);
31 printPlot(table[i]);
32 printf("\n");
33 }
34
35
36 unsigned featureI;
37 float featureF;
38
39 printf("\n");
40
41 featureF = arr::dot(table, table, size);
42 printf("Dot Product: %f\n", featureF);
43
44 unsigned min, max;
45 arr::extrema(table, size, min, max);
46 printf("Extrema: [%f, %f]\n", table[min], table[max]);
47
48 float slope, inter;
49 arr::lineFit(table, size, slope, inter);
50 printf("Linear fit: inter = %f, slope = %f\n", inter, slope);
51
52 featureI = arr::indexOfMax(table, size);
53 printf("Max: [%2d] %f\n", featureI, table[featureI]);
54
55 unsigned peaks[size>>1];
56 featureI = arr::maxima(peaks, table, size);
57 printf("Maxima (%d):\n", featureI);
58 for(unsigned long i=0; i<featureI; i++) printf("\t[%2d] %f\n", peaks[i], table[peaks[i]]);
59
60 featureF = arr::mean(table, size);
61 printf("Mean: %f\n", featureF);
62
63 featureF = arr::meanNorm(table, size);
64 printf("Mean Norm: %f\n", featureF);
65
66 featureF = arr::meanWeightedIndex(table, size);
67 printf("Mean Weight Index: %f\n", featureF);
68
69 featureF = arr::rms(table, size);
70 printf("RMS: %f\n", featureF);
71
72 featureF = arr::sum(table, size);
73 printf("Sum: %f\n", featureF);
74

Callers

nothing calls this directly

Calls 15

absFunction · 0.85
printPlotFunction · 0.85
dotFunction · 0.85
extremaFunction · 0.85
lineFitFunction · 0.85
indexOfMaxFunction · 0.85
maximaFunction · 0.85
meanNormFunction · 0.85
meanWeightedIndexFunction · 0.85
rmsFunction · 0.85
varianceFunction · 0.85
zeroCountFunction · 0.85

Tested by

no test coverage detected