0

I'm new to Math.Net. Let's say I have a multi-dimensional matrix as:

double [,,] matA = new double [2,3,3];

for(k = 0; k < 2; k++)
{
   for(i = 0; i < 3; i++)
   {
      for(j = 0 ;j < 3; j++)
      {
        matA[k,i,j] = ... // assign some value
      }
   }
}

I want to find the transpose of "matA[0,All,All]" and "matA[1,All,All]" where the "All" pseudo-syntax is from Mathematica which is useful, however, I don't know how to extract the [0,All,All] or [1,All,All] matrices in Math.Net.

I appreciate any help and advice about how to extract a specific part of the multi-dimensional matrix in Math.Net.

I have copied the matrix defined above as "matA" into "matAnew" as follows:

Matrix<double> matAnew = DenseMatrix.OfArray(matA);

matAnew.SubMatrix(?,?,?,?)

I have an intuition that the SubMatrix method in Math.Net can be used for it but I'm not sure how could it be done.

LW001
  • 2,452
  • 6
  • 27
  • 36
hasahmet
  • 1
  • 2
  • `double[2,3,3]` is a regular .net multidimensional array, not a math.net matrix. If you want to extract a submatrix/array, just write three loops to copy elements one by one. I cannot see anything suggesting that Math.Net Matrix handles more than 2 dimensions. – JonasH Aug 14 '23 at 13:38

1 Answers1

0

Just a Suggesting answer, it is bit confusing

The SubMatrix method is used to extract a submatrix from matAnew. The method takes four arguments: rowStart, rowCount, columnStart, and columnCount.

The rowStart specifies the starting row index for the submatrix.

The rowCount specifies the number of rows in the submatrix.

The columnStart specifies the starting column index for the submatrix.

The columnCount specifies the number of columns in the submatrix.

matAnew.SubMatrix(matAnew.RowStart, matAnew.RowCount, matAnew.ColumnStart, matAnew.ColumnCount);
Matrix<double> matAnew = DenseMatrix.OfArray(matA);

// Extract specific submatrices
Matrix<double> subMatrix0 = matAnew.SubMatrix(0, 1, 0, matAnew.ColumnCount);
Matrix<double> subMatrix1 = matAnew.SubMatrix(1, 1, 0, matAnew.ColumnCount);