{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Recitation 1 Test (15 marks)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Make two 1D arrays 'u' and 'v' consisting of 3 uniform random numbers between 0 and 2 each. (**1 mark**)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compute the dot-product of 'u' and 'v'. (**1 mark**)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compute the lengths of vectors 'u' and 'v'. Vector lenghts are also called *magnitudes* or *norms*. (**1 mark**)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Find the angle between 'u' and 'v'. (**2 marks**)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compute the tensor-product of 'u' and 'v'. (**1 mark**)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Make a 2D array 'M' of size (2,3) containing uniform random numbers between 0 and 1. (**1 mark**)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Compute the matrix-vector product of 'M' and 'u'. (**1 mark**)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Make an array 'A' consisting of a (3,4) array, a (2,4) array and a (4,4) array. All 3 arrays should contain random integers less than 9. (**1 mark**)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Pad the three arrays in 'A' to make a tensor array 'B'. Padding should be at the top with constant value of -1. (**3 marks**)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Stack the arrays in 'A' vertically. (**1 mark**)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Stack the arrays in 'B' horizontally using only 1 line of code containing a for loop. (**2 marks**)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.9" } }, "nbformat": 4, "nbformat_minor": 2 }