Matrix dimensions

Joined
2/21/10
Messages
50
Points
18
Hello!

I wonder how can I get the matrix dimensions double[n,m]. So im interested in getting n provided that m is unknown. Im using C#. Thanks
 
Hi again. For example you have the following matrix:

Code:
double[,] matrix = new double[n , m];

and you want to get the dimensions n and m respectively. So you get those numbers in the following way: You invoke the GetLength method and pass the zero-based argument (0 or 1) to get the dimensions of rows and columns respectively. Here's the example:

Code:
int rows = matrix.GetLength(0);
int columns = matrix.GetLength(1);

David, by the way, when I provided the matrix multiplication algorithm I actually had stated this method in that algorithm. As I guess in addition problem which you said you had the same.
 
Back
Top Bottom