Due: September 18, 2008
CS 257 (Luke Olson): Homework #3
Problem 1
[Puzzled] You are profiling a loop in your numerical code at work with the following snippet:
Listing 1: First
1
function
t = test1 ( n )
2
3
tic
;
4
5
x(1) = 150;
6
for
i=2:n
7
x(i) = .99
*
x(i1);
8
end
9
10
t =
toc
;
However, it is noticed that this piece is very slow as
n
increases. Offer a fix (
hint: one line
) that speeds
up your code.
Hand in the solution, a comparative timing showing the speedup, and a short explanation
.
Problem 2
[Storage] While profiling another portion of code (
matvec.m
) you implement two versions of a matrix
vector multiply (
see review lecture slides 5a
). Why is one method faster? Is this Matlab dependent?
Hand
in a timing result and a short explanation
.
Page 1 of 3
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Due: September 18, 2008
CS 257 (Luke Olson): Homework #3
Problem 3
[Naive Gaussian Elimination] Implement the following algorithm for (naive) Gaussian elimination. You can
use the template
GE
naive.m
. Hand in just your implementation.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '08
 Olson
 Linear Algebra, Big O notation, Naïve Gauss, Luke Olson

Click to edit the document details