=========================== Some BLAS Level 1 Functions [TOC] =========================== We will implement the following BLAS Level 1 operations: - Function `dcopy` Copying vectors denoted mathematically as $x \to y$. - Function `daxpy` Scaled vector update denoted mathematically as $\alpha x + y \to y$. Hence, `axpy` for alpha x plus y. - Function `ddot` Computing the dot product of two vector, i.e. $x^T \cdot y$. - Function `dscal` - If $\alpha \neq 0$ it computed the scaled vector $x \leftarrow \alpha x$. - If $\alpha = 0$ it overwrites $x$ with zeros, i.e. $x \leftarrow \mathcal{0}$. Note that these cases need to be handled separately because in the case $\alpha=0$ vector $x$ is allowed to contain *Not-a-Number (NaN)* values. If a matrix has NaN entries and $\alpha \neq 0$ the result of scal is allowed to be undefined. Exercise: BLAS Level 1 ====================== - The signature of function `dcopy` is given: - Add the implementation - Fix the function call to match the operation indicated by the preceding printf statement - How function `daxpy` is supposed to be used is given in `main`: - Derive a proper declaration for the function and - implement the function. - For function `ddot` we give fewer hints. Specify a signature that indicates: - The function expects two vectors of same length. - The vectors are not modified by the function. - The function returns the result. Then implement the function and use it in `main`. - For function `dscal` we provide a skeleton: - In case $\alpha=1$ the function makes a _quick return_. - Implement the cases for - $\alpha \neq 1$ and \alpha \neq 0$ - $\alpha \neq 1$ and \alpha = 0$ Note that `main` contains a test where NaNs are inserted through function `nan` (declared in `math.h`). :import: session10/matvec_02_ex.c