CS2322

Laboratory Problem 28

Matrices as Vectors of Vectors

An m x n matrix can also be represented as a vector of length m in which the element with index i is a vector of length n containing the elements in row i of the matrix. Thus the matrix

2 1 -3

4 -2 -1

is represented as the vector

(vector (vector 2 1 -3) (vector 4 -2 -1))

For this representation of matrices, define the procedures num-rows, num-cols, matrix-ref, matrix-set! and matrix-generator.

Lab 28 Scheme Code