Course Home | Assignments | Computing Resources | Lab Hours/Tutoring | Questionnaire | Schedule | Submit

Saint Louis University

Computer Science 146
Object-Oriented Practicum

Michael Goldwasser

Fall 2012

Dept. of Math & Computer Science

Assignment 07

Matrix Proxy (and a flaw!)

Overview

Topic: Matrix Proxy (and a flaw!)
Due: 11:59pm Monday, 10 December 2012

Please make sure you adhere to the policies on academic integrity.


Introduction

In class, we introduced a new design for supporting matrix proxies, however there is also a subtle flaw in our design.

  1. One arises when evaluating an assignment statement

          B(range(3,6), range(4,8)) = P;
          

    After executing this command, if we look in the target region within B, the contents do not match the 3x4 pattern that P had represented.

  2. A related flaw arises when evaluating the subsequent assignment statement

          B = P;
          

    This statement crashes the program when executed. Presumably, it should have reconfigured B to be a 3x4 matrix with the specified contents.


Your Task

The goal is to modify the software suite in order to provide more reasonable semantics for the above scenarios. Of course, we want to also do our best to retain the desired efficiency of our matrix proxy framework when possible.

Both of the bugs involve subtleties of the assignment statement (operator=) in a case where the right-hand side and left-hand side are interdependent. When the left-hand and right-hand expressions for an assignment rely on completely independent forms of storage, the existing functionality works great. But if there is potential cross-contamination between the two expressions, you should take a safer (but more expensive) approach of explicitly creating a local copy of the right-hand expression before assigning those values to the left-hand side.

To aide you in fixing the bugs, we have already provided a new function, with signature

  const matrix_expression& underlyingStorage() const;
in all of the relevant classes. It returns a reference to the object that is responsible for the underlying storage of the data (in our current framework, this result is always a matrix instance). You can use it to detect the potential overlap using the syntax
  if (&underlyingStorage() == &other.underlyingStorage())


Files we are providing

If working on turing, change directories into a desired subdirectory of your home folder if desired, and to execute the following command verbatim

  cp -R /Public/goldwasser/146/asgn07 .
This will cause a new folder named asgn07 to appear in your working directory including all files that you need for this assignment. Alternatively, these files can be downloaded individual from this website. The matrix definition is essentially the same one we have been using for past assignments. However, we have written a new driver for this assignment to make it easier for you to test your code. That driver is named test and can be built with the make command.


Submitting your project

You are to submit an updated version of any files that you needed to modify (details on the submission process).


Michael Goldwasser
CSCI 146, Fall 2012
Last modified: Wednesday, 05 December 2012
Course Home | Assignments | Computing Resources | Lab Hours/Tutoring | Questionnaire | Schedule | Submit