Skip to content

Instantly share code, notes, and snippets.

View chutsu's full-sized avatar
:octocat:

Christopher Choi chutsu

:octocat:
View GitHub Profile
@chutsu
chutsu / test_chol.c
Last active March 16, 2023 12:38
Solving Ax = b using Cholesky Decomposition in C using LAPACK
/**
* Solving Ax = b using Cholesky Decomposition in C using LAPACK
* Compile with: gcc test_chol.c -lblas -llapack -llapacke -o test_chol
*/
#include <stdio.h>
#include <lapacke.h>
int main() {
// Define matrix A and vector b in A * x = b
// clang-format off
@chutsu
chutsu / Thinkpad T430 - Ubuntu 20.04.md
Created May 24, 2022 21:15
Thinkpad T430 - Ubuntu 20.04
xinput --set-prop "12" "libinput Accel Speed" -0.6

Configure Apple Magic Keyboard in Ubuntu

In-order to:

  • Enable function keys by default
  • Swap option (alt) with command key
  • Swap fn with left-ctrl key

on the Apple Magic Keyboard:

@chutsu
chutsu / README.md
Created April 24, 2022 10:39
Kensington Expert Mouse

Kensington Expert Mouse Button Mapping

Back               Forward
      [Track ball]
Left-click         Right-click

xinput set-button-map "Kensington Expert Wireless TB Mouse" 1 8 3 4 5 6 7 9
# Manual Fan Control
# Source: https://www.thinkwiki.org/wiki/How_to_control_fan_speed
echo level 7 | sudo tee /proc/acpi/ibm/fan
echo level auto | sudo tee /proc/acpi/ibm/fan
# Sleep
# For some reason since Ubuntu 20 closing lid does not sleep laptop
# only alternative I have found is to issue the following command
# Note: Tried `systemctl sleep` to no avail
systemctl hybrid-sleep
@chutsu
chutsu / Eigen Spline Derivative Example.md
Last active April 9, 2022 00:30
Eigen Spline Derivative Example

The following code snippet showcases how one would use Eigen's spline module to fit x^2 and find the first and second derivatives along the spline.

An important note is to remember to scale the derivatives with:

  • (x - x_min) / (x_max - x_min) (first derivative)
  • (x - x_min) / (x_max - x_min)^2 (second derivative).

Because when fitting a spline to x^2, the x values you feed into the spline fitter is actually normalized with (x - x_min) / (x_max - x_min). So using

@chutsu
chutsu / Eigen Spline Module 1D Example.md
Last active August 18, 2024 19:11
Eigen Spline Module 1D Example

Eigen has an unsupported spline module where you can fit a spline given some data. Once a spline is fitted you can use it as a function to obtain points inbetween. The following example fits 1D data but can be modified to fit N-dimensional data.

Usage

 git clone https://gist.github.com/chutsu/815c7c916c329eec85f34690a012f7cb spline_example
 g++ -I/usr/include/eigen3 spline_example.cpp -o spline_example

./spline_example