Data Structures and Algorithms
with Object-Oriented Design Patterns in C#![]() ![]() ![]() ![]() ![]() |
The simplest way to implement a matrix is to use a two-dimensional
array as shown in Program .
In this case, we use three fields.
The first two fields, numberOfRows and numberOfColumns
record the dimensions of the matrix.
The third field, array,
is a C# two-dimensional array of doubles.
Program: DenseMatrix fields, constructor, and properties.
The constructor takes two arguments, m and n,
and constructs the corresponding matrix.
Clearly, the running time of the constructor is O(mn).
(Remember, C# initializes all the array elements to zero).