Data Structures and Algorithms with Object-Oriented Design Patterns in Python
next up previous index

Matrices

Two-dimensional arrays of floating-point numbers arise in many different scientific computations. Such arrays are usually called matrices . Mathematicians have studied the properties of matrices for many years and have developed an extensive repertoire of operations on matrices. In this section we consider two-dimensional matrices and examine the implementation of simple, matrix multiplication.

The dimensions of a two-dimensional matrix are referred to as the rows and the columns of the matrix. Program gif defines a Matrix class which provides two properties, numberOfRows and numberOfColumns.

   program3190
Program: Matrix class.

The Matrix class has two plain integer instance attributes, _numberOfRows and _numberOfColumns, which record the dimensions of the matrix.


next up previous index

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