This file contains 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
fib(n) = | |
if n <= 1 | |
then n // TODO: is "then" keyword required? not strictly but improves readability? | |
else | |
left = fib(n-2) | |
right = fib(n-1) | |
left + right | |
fib_iter(n) = | |
iter(a, b, n) = |
This file contains 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 kepler_elements { | |
double semi_latus_rectum; | |
double eccentricity; | |
double mean_motion; | |
double inclination; | |
double longitude_of_ascending_node; | |
double argument_of_periapsis; | |
double periapsis_time; | |
}; |
This file contains 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
#define ZEROF(x) ((x)*(x) < 1.0e-15) | |
#define EQF(a, b) ((ZEROF(a) && ZEROF(b)) || ZEROF(((a)-(b))*((a)-(b))/((a)*(a) + ((b)*(b))))) | |
#define LTF(a, b) ((a) < (b) || EQF((a), (b))) | |
#define ASSERT(cond, msg, ...) { numtest_assert(cond, test_ctx, __FILE__, __LINE__, __FUNCTION__, msg, ##__VA_ARGS__); } | |
#define ASSERT_EQF(a, b, msg, ...) ASSERT(EQF((a), (b)), msg, ##__VA_ARGS__) | |
#define ASSERT_LTF(a, b, msg, ...) ASSERT(LTF((a), (b)), msg, ##__VA_ARGS__) | |
#define ASSERT_RANGEF(x, min, max, msg, ...) ASSERT(LTF((min), (x)) && LTF((x), (max)), msg, ##__VA_ARGS__) | |
struct numtest_ctx; |
This file contains 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 <stdbool.h> | |
#include <float.h> | |
#include <math.h> | |
double dot(const double *a, const double *b) { | |
return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; | |
} | |
double mag(const double *a) { | |
return sqrt(dot(a, a)); |
This file contains 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
r(p,e,f) = p/(1.0 + e * cos(f)) | |
orbit_x(p,e,i,an,argp,f) = \ | |
r(p,e,f) * (\ | |
cos(f) * ((cos(argp) * cos(an)) - (sin(argp) * sin(an) * cos(i))) + \ | |
sin(f) * (-(cos(argp) * sin(an) * cos(i)) - (sin(argp) * cos(an)))) | |
orbit_y(p,e,i,an,argp,f) = \ | |
r(p,e,f) * (\ | |
cos(f) * ((sin(argp) * cos(an) * cos(i)) + (cos(argp) * sin(an))) + \ | |
sin(f) * ((cos(argp) * cos(an) * cos(i)) - (sin(argp) * sin(an)))) |
This file contains 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
% vim:nolist lbr tw=78 expandtab autoindent nocindent | |
\documentclass[a4paper]{article} | |
\usepackage[utf8]{inputenc} | |
\usepackage[landscape,top=1cm,bottom=1cm,left=1cm,right=1cm]{geometry} | |
%\usepackage{amsmath} | |
\pagestyle{empty} | |
\setcounter{secnumdepth}{0} |
This file contains 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> | |
void hsv2rgb(float h, float s, float v, float *rgb) { | |
float c = v * s; | |
float hh = h * 6.0; | |
float x = c * (1.0 - fabsf(fmodf(hh, 2) - 1.)); | |
float m = v - c; | |
int i = (int)hh % 6; | |
rgb[(1 + 2*i)%3] = x + m; |
This file contains 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
call pathogen#runtime_append_all_bundles() | |
call pathogen#helptags() | |
set nocompatible | |
colorscheme desert | |
tab all | |
set mouse=a |
This file contains 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
.code64 | |
.section .text | |
.global thread_context_switch | |
# from thread: rdi = interrupt_stack_frame*, rsi = registers_t* | |
# to thread: rdx = const interrupt_stack_frame*, rcx = const registers_t* | |
thread_context_switch: | |
# store general purpose registers to *rdi | |
mov %r15, 0(%rdi) | |
mov %r14, 8(%rdi) | |
mov %r13, 16(%rdi) |
This file contains 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
noremap <silent> <leader>qw :botright cwindow<cr> | |
noremap <silent> <leader>qo :botright copen<cr> | |
noremap <silent> <leader>qc :cclose<cr> | |
noremap <silent> <leader>qq :cc!<cr> | |
noremap <silent> <leader>qn :cnext<cr> | |
noremap <silent> <leader>qp :cprev<cr> | |
noremap <silent> <leader>lw :botright lwindow<cr> | |
noremap <silent> <leader>lo :botright lopen<cr> | |
noremap <silent> <leader>lc :lclose<cr> |
OlderNewer