• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

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:

C++:
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:

C++:
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