From 9d6f59a795fd95190ffcf7040b922d9e7c8e9019 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Fri, 5 Jan 2018 23:04:53 +0100 Subject: [PATCH] MatrixStorage: more reasonable GetHashCode #534 --- src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs index 25297625..3195759e 100644 --- a/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs +++ b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs @@ -190,8 +190,13 @@ namespace MathNet.Numerics.LinearAlgebra.Storage { for (var i = 0; i < hashNum; i++) { - var col = i%ColumnCount; - var row = (i - col)%RowCount; +#if PORTABLE || NETSTANDARD + int col = i%ColumnCount; + int row = i/ColumnCount; +#else + int col; + int row = Math.DivRem(i, ColumnCount, out col); +#endif hash = hash*31 + At(row, col).GetHashCode(); } }