DlangScience / scid

Scientific library for the D programming language
Boost Software License 1.0
90 stars 31 forks source link

Extend MatrixView API with overloaded operators #53

Open aleixgg opened 7 years ago

aleixgg commented 7 years ago

As it currently stands, the MatrixView struct in scid.matrix only provides the functionality to access elements with the opIndex and opIndexAssign overloaded operators.

It would be nice to have the arithmetic operators overloaded to provide elementwise operations. This would allow code like:

auto matrix_3 = 2 * matrix_1 - 1.5 * matrix_2^^2

Also I couldn't find any dot product for matrices. Following the nomenclature in std.numeric we could call this function dotProduct, so we could have code like:

auto Z = dotProduct(X, Y)

Is there any reason I overlooked why this has not been included? If it is just a lack of contributors, I'm already developing some of this stuff, and I will open a pull request so others can improve or point out possible errors in my code. When it is ready, it would be nice to merge it into the main repo.