This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // end range is the first number that shouldn't be included (to be in line with problem formulation) | |
| constexpr int projecteuler1(int endRange) { | |
| return (3*((endRange-1)/3)*((endRange-1)/3+1) | |
| + 5*((endRange-1)/5)*((endRange-1)/5+1) | |
| - 15*((endRange-1)/15)*((endRange-1)/15+1))/2; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct A { | |
| uint8_t data[80]; | |
| }; | |
| struct B { | |
| uint8_t data[80]; | |
| }; | |
| struct C { | |
| uint8_t data[160]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .L2: | |
| subq $144, %rsp | |
| .cfi_def_cfa_offset 320 | |
| movq %r12, %rsi | |
| movq %rbx, %rcx | |
| movq %rsp, %rdi | |
| rep movsq | |
| movl (%rsi), %eax | |
| movl %eax, (%rdi) | |
| call _Z8consumer7payloadILi33EE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| addq $-128, %rsp | |
| .cfi_def_cfa_offset 288 | |
| movq 128(%rsp), %rax | |
| movq %rax, (%rsp) | |
| movq 136(%rsp), %rax | |
| movq %rax, 8(%rsp) | |
| movq 144(%rsp), %rax | |
| movq %rax, 16(%rsp) | |
| movq 152(%rsp), %rax | |
| movq %rax, 24(%rsp) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| double carrier_phase[2]; | |
| double carrier_strength = fourier1p(dbuffer, (float) length * carrier / (float)rate, length, &carrier_phase[0], &carrier_phase[1]); | |
| if(carrier_strength < threshold) continue; | |
| double delta_re = carrier_phase[0] * old_carrier_phase[0] + carrier_phase[1]*old_carrier_phase[1]; | |
| double delta_im = -carrier_phase[1]*old_carrier_phase[0] + carrier_phase[0] * old_carrier_phase[1]; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| double fourier1p(double x_in[], double n, int length, double* phase_r, double* phase_i) { | |
| double x_complex[2] = { 0, 0 }; | |
| int i; | |
| for(i = 0; i < length; i++) { | |
| x_complex[0] += x_in[i] * cos(M_PI * 2 * i * n / (double) length); | |
| x_complex[1] += x_in[i] * sin(M_PI * 2 * i * n / (double) length); | |
| } | |
| double norm = sqrt(x_complex[0]*x_complex[0] + x_complex[1]*x_complex[1]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if(sum < threshold) { | |
| if(signal_length) { | |
| if(signal_length > 10) { | |
| if(bit != 0) printf("(?)"); | |
| bit = 0; | |
| signal_length = 0; | |
| } else { | |
| bit_data = 2 * bit_data + (signal_length < 6); | |
| if(++bit == 8) { | |
| printf("%c", bit_data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if(sum > threshold) { | |
| /* Signal is present in data block */ | |
| } else { | |
| /* Signal isn't present */ | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| double sum = 0; | |
| for(harmonic = 1; 2*harmonic < length / frq; harmonic++) { | |
| sum += fourier1(data, frq * harmonic, length); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| double fourier1(double x_in[], double n, int length) { | |
| double x_complex[2] = { 0, 0 }; | |
| int i; | |
| for(i = 0; i < length; i++) { | |
| x_complex[0] += x_in[i] * cos(M_PI * 2 * i * n / (double) length); | |
| x_complex[1] += x_in[i] * sin(M_PI * 2 * i * n / (double) length); | |
| } | |
| return sqrt(x_complex[0]*x_complex[0] + x_complex[1]*x_complex[1]) / (double) length; | |
| } |
NewerOlder