
Hi  Is there a modulus operator on a matrix? More specifically, I'm creating a matrix:
var matrixA = new DenseMatrix(new[,] { { 5.0, 8.0 }, { 17.0, 3.0 } });
and I would like to perform the following operation:
var matrixB = matrixA % 26;
or something to that effect. The application is for encryption (Hill Cipher).
Thanks,
Mike



Hi Mike,
There isn't. I'll add it to the to do list.
In the meantime, you could use an extenstion method such as:
public static Matrix Mod(this DenseMatrix matrix, int mod)
{
var result = (DenseMatrix)matrix.Clone();
Parallel.For(0, result.Data.Length, index => result.Data[index] %= mod);
return result;
}
Then the usage would be:
var matrixB = matrixA.Mod(26);



This discussion has been copied to a work item. Click
here to go to the work item and continue the discussion.

