CodePlexProject Hosting for Open Source Software

1

Resolved

In RectangularMatrixAlgorithms.cs (Meta.Numerics.Matrices) MatrixAlgorithms class.

I think that the formula for these 3 methods is wrong,

**Am I saying something silly or there is a bug?**

I think that the formula for these 3 methods is wrong,

```
public static int GetIndex (int nRows, int nCols, int r, int c) {
return (nRows * c + r);
}
public static void SetEntry (double[] store, int nRows, int nCols, int r, int c, double value) {
store[nRows * c + r] = value;
}
public static double GetEntry (double[] store, int nRows, int nCols, int r, int c) {
return (store[nRows * c + r]);
}
```

since that the RectangularMatrix constructor initializes the "store" array as a sequence of rows.
```
/// <summary>
/// Initializes a rectangular matrix from the given 2D array.
/// </summary>
/// <param name="source">The source 2D array.</param>
public RectangularMatrix (double[,] source) {
if (source == null) throw new ArgumentNullException("source");
rows = source.GetLength(0);
cols = source.GetLength(1);
store = MatrixAlgorithms.AllocateStorage(rows, cols);
offset = 0;
rowStride = 1;
colStride = rows;
for (int r = 0; r < rows; r++) {
for (int c = 0; c < cols; c++) {
store[MatrixAlgorithms.GetIndex(rows, cols, r, c)] = source[r, c];
}
}
}
```

No files are attached

## comments

ichbin wrote Jul 8, 2016 at 8:50 PM