Data Structures and Algorithms with Object-Oriented Design Patterns in C#
next up previous contents index

Dense Matrices

The simplest way to implement a matrix is to use a two-dimensional array as shown in Program gif. 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.

   program3143
Program: DenseMatrix fields, constructor, and properties.

The constructor takes two arguments, m and n, and constructs the corresponding tex2html_wrap_inline60321 matrix. Clearly, the running time of the constructor is O(mn). (Remember, C# initializes all the array elements to zero).


next up previous contents index

Bruno Copyright © 2001 by Bruno R. Preiss, P.Eng. All rights reserved.