UNB/ CS/ David Bremner/ teaching/ old/ cs4735/ milestones/ CS4735 Assignment 1

Overview

The goals of this assignment are are to review the basics of matrix and vector arithmetic, and to learn the basics of JavaScript.

Before you start.

  1. See the assignment notes for the required repository structure. You may also want to refer to the lab guide.

  2. Since you'll need to know a little git to hand in this assignment, you may want to work through Lab 1 in advance.

  3. This assignment must be your own individual work. It may surprise you to learn that profs are quite good at finding the same code on the internet you found. The consequences are not fun.

Software Environment

This assignment will be be done using standard JavaScript in a browser. No extra frameworks or libraries are permitted.

Tests

You should write unit tests for each function and method. Be sure to think about what the corner and error cases are. A substantial part of the marks for this assignment will be for the quality of your tests. Your tests should focus on the algorithmic aspects (i.e. do the matrices to be multiplied have the appropriate dimension), rather than JavaScript specific issues like "did the user actually pass us an array of numbers". Make sure you document what you are not testing for.

Vector functions

For the first part of the assignment, represent (arbitrary dimensional) vectors as JavaScript arrays. You are to write functions

The latter should throw an exception in cases when cross product is not defined. For simplicity, you can assume cross product is only defined in 3 dimensions.

Matrix methods

Write a matrix class. Note that JavaScript classes are based on prototypes, which is quite different than e.g. Java or Python. Your class should support the following methods

All of your methods should do appropriate error checking and throw exceptions cases on bad input (and document what kinds of checks are not done).

Deliverables

Your assignment directory in coursegit should include

vector.js vector functions as above
vector-test.js tests for vector functions
matrix.js matrix objects as above
matrix-test.js tests for matrix objects

Evaluation