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
| using SymPy | |
| # Keep only terms of a given orders in a polynomial expression | |
| function truncate_upto(ex::Sym, x::Sym, order::Int) | |
| if ex.func.__name__ != "Add" | |
| error("The main expression should be an addition") | |
| end | |
| return ex.func(ex.args[findall(y->degree(y,x) ≤ order,ex.args)]...) | |
| end |
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
| # textConnection creates a connection from a string | |
| a<-read.table(textConnection(system2("ls",stdout=T))) |
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
| # to_a transform each key=>value of the hash as [key,value]. | |
| # to_h reverts back [key,value] as key=>value. | |
| hash=hash.to_a.map{|a,b| [a.to_sym,b]}.to_h |
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
| char commit[256]; // to store the commit hash | |
| char call_git[512]; // to store the command to be executed | |
| sprintf(call_git,"git log -1 --pretty=format:'%%H' %s",__FILE__); | |
| FILE *fp = popen(call_git, "r"); | |
| fscanf(fp, "%s", commit) | |
| pclose(fp); |
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
| /* Assert is a nice way to avoid bugs | |
| * but sometimes one needs to differentiate the reason for calling assert. | |
| * This macro seems to do the job (using the stringification). | |
| */ | |
| #define assert_initialize(EX,MSG,CODE) if(!(EX)) {fprintf(stderr,"%s:%i Initialization error (" #EX "): " MSG "\nAborting :-(\n",__FILE__,__LINE__);exit(CODE);}; |
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
| #include <math.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <gsl/gsl_math.h> | |
| #include <gsl/gsl_errno.h> | |
| #include <gsl/gsl_sf_result.h> // for avoiding underflows and overflows | |
| #include <gsl/gsl_sf_erf.h> | |
| #include <gsl/gsl_rng.h> | |
| #include <gsl/gsl_randist.h> |