Write a function, that takes two sequences of equal length and takes
their dot product. In particular for two sequences A and B of length
n, it should return:
Sum_{i=0}^{n-1} A_{i} * B_{i}.
The function should require O(n) work and constant depth.
Note that in NESL, the sum operation is defined to have
constant depth (I'll motivate this in class).

In the following code replace "Fill in" with the appropriate
code.

The stock market problem is as follows: given the price of a stock
at each day for n days, determine the biggest profit you can make by
buying one day and selling on a later day. For example:

would return 5 since we can buy at 5 on day 5 and sell at 10 on day
11. This has a simple linear time serial solution. Write a NESL
program to solve the stock market problem with work complexity
O(n) and constant depth. Hint: you might try one of the scan
operations (the scan operations are defined to take constant depth).

Write a function that returns all the primes up to n by checking
for each integer i from 2 through n if it is a multiple
of some integer in the range [2...1+sqrt(i)].
The function isqrt takes the square root of an integer.

Hint: you can use the expression [2:n] to
generate a sequences of integers from 2 to n. The function mod(i,j) takes the modulus of i and j (ie. the remainder).

The sparse-matrix section
of the tutorial, showed how to represent sparse matrices as a nested
sequence and how to execute a sparse-matrix vector multiply.
Here you should write code that takes a sparse matrix (represented
in the same way) and extracts any column i.
For example, for a matrix:

Let's say we want to write our own version of the sum
operation, which sums the elements of a sequences.
Here is one way to write it:
Another way to write it would be to take the odd indexed elements
and the even indexed elements of a, sum them elementwise
and then recursively sum this new sequence. Write a my_sum
function that uses this other method.
You can assume the length of the input is a power of 2.

Hint: you might find the odd_elts and even_elts
functions useful.