Hi all, would anyone be interested in having matrix/vector support (or expose) element wise mathematical operations when using them in F#? Something like the below:

> open MathNet.Numerics.LinearAlgebra;;

> let m = matrix [[1.0; 2.0; 3.0]; [0.5; 1.1; 2.1]];;

val m : Matrix = DenseMatrix 2x3-Double

1 2 3

0.5 1.1 2.1

log m;;

val it : Matrix =

DenseMatrix 2x3-Double

0 0.693147 1.09861

-0.693147 0.0953102 0.741937

```
{ColumnCount = 3;
Item = ?;
RowCount = 2;
Storage = MathNet.Numerics.LinearAlgebra.Storage.DenseColumnMajorMatrixStorage`1[System.Double];
Values = [|0.0; -0.6931471806; 0.6931471806; 0.0953101798; 1.098612289;
0.7419373447|];}
```

exp m;;

val it : Matrix =

DenseMatrix 2x3-Double

2.71828 7.38906 20.0855

1.64872 3.00417 8.16617

```
{ColumnCount = 3;
Item = ?;
RowCount = 2;
Storage = MathNet.Numerics.LinearAlgebra.Storage.DenseColumnMajorMatrixStorage`1[System.Double];
Values = [|2.718281828; 1.648721271; 7.389056099; 3.004166024;
20.08553692; 8.166169913|];}
```

m .^ 2.0;;

val it : Matrix =

DenseMatrix 2x3-Double

1 4 9

0.25 1.21 4.41

```
{ColumnCount = 3;
Item = ?;
RowCount = 2;
Storage = MathNet.Numerics.LinearAlgebra.Storage.DenseColumnMajorMatrixStorage`1[System.Double];
Values = [|1.0; 0.25; 4.0; 1.21; 9.0; 4.41|];}
```

The last one is mimicking the octave element wise exponent operator.

All it takes to have these in F# is for the point-wise operations to be exposed as a static member function with a specific name, e.g. Log() for ‘log’, Exp() for ‘exp’ in the Matrix and Vector types. Implementation wise, PointwiseLog() and PointwiseExp() are already there but they are not yet exposed (please correct me if I am wrong). I have added some code to implement all the operators under “Math Operators” in this post: https://blogs.msdn.microsoft.com/dsyme/2008/09/01/the-f-operators-and-basic-functions/ plus exposing the existing PointwiseLog() and PointwiseExp() functions in Matrix.Operators.cs and Vector.Operators.cs.

If any one is interested in having these, I would gladly send a pull request. Or if this is actually not a very good idea for whatever reasons, please kindly share.

Thanks for reading!

Cheers,

Albert