Skip to content

Instantly share code, notes, and snippets.

View samkhn's full-sized avatar

Samiur Khan samkhn

View GitHub Profile
@samkhn
samkhn / .bashrc
Last active December 31, 2023 01:33
dotfiles
# Prompt customization
# PROMPT_COMMAND='echo'
PS1='\w $ '
export PS1
export EDITOR="vim"
alias e="vim"
alias vi="vim"
session_name="main"
@samkhn
samkhn / fast-matrix-transpose.cc
Last active February 26, 2023 02:06
Fast matrix transpose with `follow-the-cycle`.
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
// num_columns refers to the number of columns in the original matrix, not the
// desired column count post transpose.
void Transpose(int* begin, int* end, const std::size_t num_columns) {
const int64_t size = (end-begin-1); // num_elements-1
const int64_t num_rows = (end-begin)/num_columns;
// Demo of a FSM using function pointers.
#include <stdio.h>
enum return_codes { ok, fail, repeat };
int entry_state() { return ok; }
int foo_state() { return ok; }
int bar_state() { return ok; }
int end_state() { return ok; }
int unknown_state() { return ok; }
// Sparse Matrices
#include <stdio.h>
#include <stdlib.h>
void PrintMatrix(int** twoDimensionalArray, unsigned numRows, unsigned numColumns);
// COO: coordinate format. We store tuples of (row, column, value).
// Ex:
// For matrix M = {