Skip to content

LinearML

LinearML banner

A learning project where I try to build a ML library from scratch in C.

Building LinearML

LinearML uses BuildMe as it's build system. It's a build system that I made. It is still WIP.

Install the BuildMe with the command

pip3 install buildme

Clone the repo

git clone --depth=1 -b master https://github.com/Adwaith-Rajesh/LinearML.git

Compile the liblinearml.so

cd ./LinearML
chmod +x buildme
./buildme all --gslpath=/path/to/your/gsl/installation

This will create a build folder where the shared object will be present in the build/lib folder

Testing the install

Let's create a simple Array and print it to check whether everything works

touch test_lm.c
// test_lm.c

#define INCLUDE_ARRAY_STATS
#include "ds/array.h"

int main(void) {
    Array *arr = arr_create(3);

    ARR_AT(arr, 0) = 1;
    ARR_AT(arr, 1) = 4;
    ARR_AT(arr, 2) = 5;

    arr_print(arr);
    arr_free(arr);

    return 0;
}

Compile

gcc -o test_lm test_lm.c -I./include -L./build/lib -llinearml -lm -lgsl -lgslcblas

Run

$ LD_LIBRARY_PATH=./build/lib ./test_lm
[ 1.00 4.00 5.00 ]