Data Structures and Algorithms with Object-Oriented Design Patterns in Ruby
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 attribute readers, numberOfRows and numberOfColumns.

   program3145
Program: Matrix class.

Program gif also defines several abstract methods: +, *, and transpose.


next up previous index

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