nomemory / andreinc-site

My personal blog
10 stars 4 forks source link

2021/01/20/writing-your-own-linear-algebra-matrix-library-in-c #11

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Writing your own linear algebra matrix library in C | andreinc

A step-by-step guide on how to implement a matrix library in pure C.

https://www.andreinc.net/2021/01/20/writing-your-own-linear-algebra-matrix-library-in-c

YoelMonsalve commented 2 years ago

Hi Andrei, I located a tiny bug in the method nml_mat_sub. In

nml_mat *nml_mat_sub(nml_mat *m1, nml_mat *m2) {
  nml_mat *r = nml_mat_cp(m2);
  if (!nml_mat_sub_r(r, m2)) {
    nml_mat_free(r);
    return NULL;
  }
  return r;
}

Where it says

  nml_mat *r = nml_mat_cp(m2);

it should be

  nml_mat *r = nml_mat_cp(m1);

otherwise, it would be substracting the matrix m2 from itself.

By the way, I have worked hard on preparing a contribution to your library. Can I have an email to send it? The mine is yymonsalve@gmail.com if you don't want to be spamned. Yoel.-