1/27/2017 planets (1)

CIS 211 Project 3: OOP Due 11:00 P.M. January 27, 2017

Reading: M&R 10.1 10.4

Our goal this week is to gain some experience writing class definitions for some simple objects. The classes are part of a solar system simulation. This week we’ll define the objects used in the simulation. Next week we’ll implement the simulation itself, and later in the term we’ll add visualization.

Part 1: Vectors (50 points)

Define a class named Vector. Instances of this class will be Euclidan vectors (https://en.wikipedia.org/wiki/Euclidean_vector (https://en.wikipedia.org/wiki/Euclidean_vector)).

An instance of this class will have three attributes, representing , , and coordinates in space. When a Vector object is created the constructor should be passed three numbers to use as the initial values of the coordinates.

Your class should also have:

accessor functions named x, y, and z, which return the current value of the specified coordinate

a __repr__ function that displays a Vector as a tuple of 3 numbers; use “%.3g” in the format statement so coordinates are shown with 3

significant digits

methods that implement ==, +, ‐, and * operations (see below)

a method named norm that computes the length, or magnitude, of the vector, defined by the equation

a method named clear that sets all coordinates to 0

To see if two vectors are equal, simply see if their , , and components are the same. This will almost certainly fail (due to roundoff errors) when the coordinates are of the size used in the solar system simulation, but it will help test the other operations, and we’ll use small numbers in these tests.

To add or subtract two vectors, make a new vector that has the sum or difference of the components of two existing vectors.

The method that implemements multiplication should implement scalar multiplication: the second operand should be an integer or a float, and the result is a new vector where all components are multiplied by the scalar.

# Monthly Archives: January 2017

# January 28, 2017

#
January 25, 2017

MIPS | CMPUT 229 (Winter 2017) – Homewor

CMPUT 229 (Winter 2017) – Homework #1 Instructor: Karim Ali

Question 1: (5 points)

Consider that a processor architecture ToyProc, which was initially designed as big- endian, is changed to use little-endian byte ordering. Assuming the subset of the MIPS ISA that you are familiar with, and assuming a memory with a word-level interface, give examples of instructions whose operations will be affected by such a change in endianness.

Question 2: (5 points)

Write the C code that best corresponds to the following MIPS assembly code. Assume that registers $s1, $s2, and $s3 store the values of 32-bit integers x, y, and z.

L1: beq $s1, $zero, L2

addu $s1, $s1, $s2

addu $s1, $s1, $s3

L2:

Question 3: (15 points)

For this question, assume that:

• p, q, i, j are 32-bit integers whose values are stored in $s0, $s1, $s2, and $s3, respectively.

• A and B are arrays of integers.

• r is a pointer declared as int *r.

• r, the base address of array A, and the base address of array B are all in the stack frame of the current function, as shown below

For each of the C statements below, give the translation into MIPS. Do not use pseudo- instructions in your code. Clearly label which MIPS instructions are for which statement.

a. (5 points) q = *r

b. (5 points) B[i] = A[j]

c. (5 points) p = q + A[B[j]] Question 4: (15 points)

Write the assembly code to implement the following C function:

int selector(int array[], int i) {

return array[array[i]];

}

#
January 20, 2017

Processing | Excel | Matlab | EXAM – ECE 102

EXAM – ECE 102

Instructor: Peter Jamieson

Directions:

– This is a take home exam. The work must be your own. Any common code will result in the exam being forwarded to administration for academic integrity violation. Do not show, give, or tell anyone else how you are solving the problems.

– Submit your zipped file.

– Please read all instructions carefully!

Details:

– The total for the exam is 100 marks.

– Submit your zip file with the exact details below

ZIP File:

Your zip file for answering the questions should have where XYOURUSERNAMEX is equal to your Miami username. Any additional changes I need to make will result in point deductions from the respective question:

– XYOURUSERNAMEX.xls or a link to a google spreadsheet for question 1

– XYOURUSERNAMEX/XYOURUSERNAMEX.pde a directory and in that directory a processing file for question 2

– MATLAB/ XYOURUSERNAMEX.m a directory called MATLAB with a matlab script for question 3

– ETHICS/ XYOURUSERNAMEX.doc or .txt a directory called ETHICS with a document describing your ethical thoughts

#
January 12, 2017

MIPS | Algorithm | Minecraft-Texturen

作业 Minecraft-Texturen

在本次作业中,您将开发一个 MIPS 汇编程序,包含降低分辨率和降低数字图像 的色彩深度。

程序框架见 vorgabe.s 图像见 Ha01 文件夹

作业 1: Load and save images (7 分)

提示

1. An image can be stored in the memory as an array by continuously storing the individual lines with image points one behind the other.

2. At the beginning of the image there is also a header, which contains the width, height and color depth, which is the number of colors.

要求

1.Your program should be able to read and write image files in the PGM format (binary, P5). a) 提示:To read and write files, QtSPIM, similar, or other operating system, provides different syscalls. You must calculate the value of the number from a string of digits.

To do this You need an ASCII table.

2.Implement a routine load_img that loads an image and processes the header

#
January 10, 2017

Processing | COMP115 – Introduction to Computer Programming

Department of Computing

COMP115 – Introduction to Computer Programming Assignment 2

ASSESSMENT DETAILS

Due: 23:45, 17th January, 2017

Worth: 20% (marked out of 100)

Updated: 9th January, 12:45pm. Update 1: added values for S1 and S2 under subtask 1.1. Update 2: corrected weight of assignment (20)

INSTRUCTIONS

In this assignment, you will write a simple particles simulation. A particle is represented by a circle, filled with a random colour and size. Each particle moves at a velocity and bounces when hits with the edges of the simulation screen. The simulator must be able to run on the graphic screen of different size.

NATURE OF THE TASK

The assignment is an individual task.

MATERIALS REQUIRED / SUGGESTED RESOURCES