ocaml.org icon indicating copy to clipboard operation
ocaml.org copied to clipboard

Cookbook recipe for matrix addition and multiplication

Open RCHG opened this issue 1 year ago • 1 comments

Hello!

I have prepared a recipe for the matrix addition and multiplication. In this case using the Array module of the standard library and implemented using integer elements for the arrays.

Note that it relies on vector addition and dot product of vectors to define the matrix operations in a kind of functional style (rather than using loops). Also in the process the recipe defines additional useful functions:

  • Transpose of a matrix
  • Vector addition
  • Vector dot product

It can be useful for those cases where Owl library can't be used, otherwise these operations of the matrices are defined in (a more performant way) in Owl.

This example use integer vector and matrix, but I am happy to implement for floats if preferred.

Thanks and kind regards, Ramiro.

RCHG avatar Aug 27 '24 16:08 RCHG