Skip to content

Instantly share code, notes, and snippets.

View MurageKibicho's full-sized avatar
🛼
Working from home

Murage Kibicho MurageKibicho

🛼
Working from home
  • Yale University
  • New Haven, Connnecticut
  • 00:23 (UTC -04:00)
View GitHub Profile
@MurageKibicho
MurageKibicho / Cmain.c
Created May 27, 2025 10:46
Calling Python Code inside a C code base
#include <stdio.h>
#include <stdlib.h>
#include <python3.8/Python.h>
//Run : gcc Cmain.c -I/usr/include/python3.8 -lpython3.8 -o Cmain.o && ./Cmain.o
//Full walkthrough : https://leetarxiv.substack.com/p/making-c-and-python-talk-to-each
int main()
{
printf("Python, you are inside me\n");
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define MAX_K 100
unsigned long long BinomialCoefficient(int n, int k)
{
if(k > n - k){k = n - k;}
unsigned long long result = 1;
for(int i = 0; i < k; ++i)
{
@MurageKibicho
MurageKibicho / WeakComposition.c
Created May 14, 2025 17:29
Enumerate Weak Integer Compositions
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define MAX_K 100
unsigned long long BinomialCoefficient(int n, int k)
{
if(k > n - k){k = n - k;}
unsigned long long result = 1;
for(int i = 0; i < k; ++i)
{
@MurageKibicho
MurageKibicho / Float2Rational.c
Created April 10, 2025 23:10
FloatToRational
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <gmp.h>
#define m32_ENABLE_ERRORS 1
#define m32_TRUE 1
#define m32_FALSE 0
#define PRINT_ERROR(msg) \
do { \
#include <stdio.h>
#include <stdlib.h>
void BinaryToSternBrocotFraction(int binaryLength, int *binary)
{
/*
Create the 2*2 identity matrix
|1 0| is the matrix {1, 0, 0, 1}
|0 1|
@MurageKibicho
MurageKibicho / Brocot-2.c
Created March 28, 2025 14:34
C program to convert a Binary Sequence to a fraction on the Stern Brocot tree
#include <stdio.h>
#include <stdlib.h>
void BinaryToSternBrocotFraction(int binaryLength, int * binary) {
/*
Create the 2*2 identity matrix
|1 0| is the matrix {1, 0, 0, 1}
|0 1|
@MurageKibicho
MurageKibicho / LeetArxiv.html
Created March 28, 2025 10:43
LeetArxiv Journal Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Asymptotically Fast Factorization</title>
<style>
body {
font-family: "Times New Roman", Times, serif;
max-width: 800px;
@MurageKibicho
MurageKibicho / GPT2-2.c
Created March 28, 2025 02:53
GPT2-C Part 2 31:23 minute mark before adding for loop
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <sys/mman.h>
#include <stdbool.h>
#include "cJSON.h"
#define VOCABULARY_SIZE 50257
@MurageKibicho
MurageKibicho / GPT2_1.c
Created March 27, 2025 19:29
Got to attention, just before creating function at 6.14.13
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <sys/mman.h>
#include <stdbool.h>
#include "cJSON.h"
#define VOCABULARY_SIZE 50257
@MurageKibicho
MurageKibicho / gpt.c
Created March 27, 2025 13:08
GPT in C before cahing safe tensors loading
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/mman.h>
#include "cJSON.h"
#define VOCABULARY_SIZE 50257
#define tf_d_vocab 50257
#define tf_d_seq 1024