diff --git a/README.md b/README.md new file mode 100644 index 0000000..a13492e --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# Squiggle.c + + + +## Why C? + +- Because it is fast +- Because it can be made faster if need be, e.g., with a multi-threading library like OpenMP +- Because if you can implement something in C, you can implement it anywhere else +- Because it will last long +- Because the language is honest +- Because I enjoy it + +## To do list + +- [ ] Have some more complicated & realistic example +- [ ] Add summarization functions, like mean, std, 90% ci (or all c.i.?) +- [ ] Add README + - Schema: a function which takes a sample and manipulates it, + - and at the end, an array of samples. + - Explain boxes + - Explain individual examples + - Explain nested functions +- [ ] Publish online + +## Done + +- [x] Add example for only one sample +- [x] Add example for many samples +- ~~[ ] Add a custom preprocessor to allow simple nested functions that don't rely on local scope?~~ +- [x] Use gcc extension to define functions nested inside main. +- [x] Chain various mixture functions +- [x] Add beta distribution + - See for a faster method. +- ~~[-] Use OpenMP for acceleration~~ +- [x] Add function to get sample when given a cdf +- [x] Don't have a single header file. +- [x] Structure project a bit better diff --git a/examples/04_sample_from_cdf_simple/example b/examples/04_sample_from_cdf_simple/example index 37f99c9..d280840 100755 Binary files a/examples/04_sample_from_cdf_simple/example and b/examples/04_sample_from_cdf_simple/example differ diff --git a/examples/04_sample_from_cdf_simple/example.c b/examples/04_sample_from_cdf_simple/example.c index 2b13061..77eee02 100644 --- a/examples/04_sample_from_cdf_simple/example.c +++ b/examples/04_sample_from_cdf_simple/example.c @@ -5,7 +5,7 @@ #include #include -#define NUM_SAMPLES 1000000 +#define NUM_SAMPLES 10000 // Example cdf float cdf_uniform_0_1(float x) diff --git a/examples/05_sample_from_cdf_beta/example b/examples/05_sample_from_cdf_beta/example index 1ad5fec..481e2d0 100755 Binary files a/examples/05_sample_from_cdf_beta/example and b/examples/05_sample_from_cdf_beta/example differ diff --git a/examples/05_sample_from_cdf_beta/example.c b/examples/05_sample_from_cdf_beta/example.c index 7c8c0bf..03198a5 100644 --- a/examples/05_sample_from_cdf_beta/example.c +++ b/examples/05_sample_from_cdf_beta/example.c @@ -5,7 +5,7 @@ #include #include -#define NUM_SAMPLES 1000000 +#define NUM_SAMPLES 10000 #define STOP_BETA 1.0e-8 #define TINY_BETA 1.0e-30 diff --git a/examples/05_sample_from_cdf_beta/makefile b/examples/05_sample_from_cdf_beta/makefile index 69adb6d..24c2c1c 100644 --- a/examples/05_sample_from_cdf_beta/makefile +++ b/examples/05_sample_from_cdf_beta/makefile @@ -5,7 +5,7 @@ # make run # Compiler -CC=gcc # required for nested functions +# CC=gcc # required for nested functions # CC=tcc # <= faster compilation # Main file diff --git a/squiggle.c b/squiggle.c index 560cd53..c68a14a 100644 --- a/squiggle.c +++ b/squiggle.c @@ -5,6 +5,7 @@ #include #include #include + #define EXIT_ON_ERROR 0 #define MAX_ERROR_LENGTH 500 #define PROCESS_ERROR(...) \ diff --git a/to-do.md b/to-do.md deleted file mode 100644 index 2eb1eb1..0000000 --- a/to-do.md +++ /dev/null @@ -1,16 +0,0 @@ - -- [x] Add example for only one sample -- [x] Add example for many samples -- ~~[ ] Add a custom preprocessor to allow simple nested functions that don't rely on local scope?~~ -- [x] Use gcc extension to define functions nested inside main. -- [x] Chain various mixture functions -- [ ] Have some more complicated & realistic example -- [ ] Add summarization functions, like mean, std, 90% ci (or all c.i.?) -- [x] Add beta distribution - - See for a faster method. -- [ ] Use OpenMP for acceleration -- [x] Add function to get sample when given a cdf -- [ ] Don't have a single header file. -- [ ] Structure project a bit better -- [ ] Add README -- [ ] Publish