A Pen by Attractive Chaos on CodePen.
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
/* The MIT License | |
Copyright (c) 2019-2023 by Attractive Chaos <attractor@live.co.uk> | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to |
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
// see also: https://github.com/attractivechaos/plb2/blob/master/src/c/matmul.c | |
#include <stdio.h> | |
#include <stdlib.h> | |
double **mat_alloc(int n_row, int n_col) | |
{ | |
double **mat, *a; | |
int i; | |
mat = (double**)malloc(n_row * sizeof(void*)); |
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
/* The MIT License | |
Copyright (c) 2008, 2011 Attractive Chaos <attractor@live.co.uk> | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to |
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
#pragma once // or use the #ifndef guard | |
#include <stddef.h> // for offsetof() | |
typedef struct cl_head_s { | |
struct cl_head_s *prev, *next; | |
} cl_head_t; | |
static inline void cl_insert_after(cl_head_t *q, cl_head_t *p) | |
{ // insert _p_ after _q_; _q_ is in the list | |
p->prev = q, p->next = q->next, q->next = p, p->next->prev = p; |
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
#pragma once // or use the #ifndef guard | |
#include <stddef.h> // for offsetof() | |
typedef struct dl_head_s { // this struct can't be hidden | |
struct dl_head_s *p[2]; // p[0] points the previous record; p[1] points to the next | |
} dl_head_t; | |
// Given a pointer to a struct member, get the pointer to the struct | |
#define dl_container_of(ptr, type, member) ((type*)((char*)(ptr) - offsetof(type, member))) |
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
#!/usr/bin/env python | |
import random | |
import timeit | |
import string | |
import sys | |
import seqpy | |
global complement | |
complement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': '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
#include <stddef.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include "getopt.h" | |
char *optarg; | |
int optind=1, opterr=1, optopt, __optpos, optreset=0; | |
#define optpos __optpos |
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 <stdio.h> | |
#include <assert.h> | |
#include <stdlib.h> | |
#if HAVE_CILK | |
#include <cilk/cilk.h> | |
#include <cilk/cilk_api.h> | |
#endif | |
typedef struct { | |
int max_iter, w, h; |
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 <stdint.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#define rstype_t uint64_t // type of the array | |
#define rskey(x) (x) // specify how to get the integer from rstype_t | |
#define RS_MIN_SIZE 64 // for an array smaller than this, use insertion sort | |
typedef struct { |
NewerOlder