Skip to content
Snippets Groups Projects
Commit be110934 authored by Recolic's avatar Recolic 🏡
Browse files

add plain c

parent 34a950aa
No related branches found
No related tags found
No related merge requests found
#include <iostream>
#include <array>
#include <cassert>
#include <stdio.h>
#include <assert.h>
constexpr auto sample_per_u = 10;
constexpr auto iteration_count = 200;
constexpr auto sample_range_begin = 1.000;
constexpr auto sample_range_end = 4.000;
constexpr auto delta_u = 0.001;
#define sample_per_u 10
#define iteration_count 200
#define sample_range_begin 1.000
#define sample_range_end 4.000
#define delta_u 0.001
auto sample_after_iteration(double u) {
void sample_after_iteration(double u, double *output_samples_arr) {
// Firstly, let's do some iterations.
double x_curr = 0.01;
for(int i = 0; i < iteration_count; ++i) {
......@@ -16,19 +15,18 @@ auto sample_after_iteration(double u) {
x_curr = u * x_curr * (1 - x_curr);
}
// And then, take some samples.
std::array<double, sample_per_u> samples;
for(int i = 0; i < sample_per_u; ++i) {
samples[i] = x_curr;
output_samples_arr[i] = x_curr;
x_curr = u * x_curr * (1 - x_curr);
}
return samples;
}
void print_points() {
for(auto curr_u = sample_range_begin; curr_u <= sample_range_end; curr_u += delta_u) {
auto samples = sample_after_iteration(curr_u);
for(auto &&sample : samples) {
std::cout << curr_u << ' ' << sample << std::endl;
double samples_arr[sample_per_u];
for(double curr_u = sample_range_begin; curr_u <= sample_range_end; curr_u += delta_u) {
sample_after_iteration(curr_u, samples_arr);
for(int i = 0; i < sample_per_u; ++i) {
printf("%f %f\n", curr_u, samples_arr[i]);
}
}
}
......
g++ generate-points.cc -O3 -o generate-points && ./generate-points | tee points.log && python draw.py
gcc generate-points.c -O3 -o generate-points && ./generate-points | tee points.log && python draw.py
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment