=========================== Some BLAS Level 1 functions [TOC] =========================== BLAS Level 1 functions operate on vectors. In practical cases these vectors are often rows or columns of a matrix. Hence, it is important to recall that in memory the vector elements are separated from each other by a constant increment that can be larger than one. Skeleton for the exercises ========================== You can use the following skeleton to solve the exercises below step by step: :import: session03/blas1_example.c ---- SHELL (path=session03) --------------------------- gcc -Wall -std=c99 -o blas1_example blas1_example.c ./blas1_example ------------------------------------------------------- Exercise: One-Norm of a vector dnrm1 ====================================== Write a function dnrm1 that computes and returns ---- LATEX ------------------------------------------------- \alpha = \| x \|_1 = \left\| \left(\begin{array}{c} x_1 \\ \vdots \\ x_n \end{array}\right) \right\|_1 = |x_1| + \dots + |x_n| ------------------------------------------------------------ Adjust the previous test program such that it computes the one-norm - of the second row (i.e. row with index one), - the third column (i.e. column with index two), - the diagonal. Exercise: Swap vectors dswap ============================== Write a function dswap that swaps (i.e. exchanges) the elements of two vectors. Extend the test program, such that it - swaps the second and third row, - swaps the second and third column. Exercise: Adding a scaled vector daxpy ======================================== The so called axpy-operation (alpha x plus y) computes ---- LATEX ------------------------------------------------- y \leftarrow \alpha x + y ------------------------------------------------------------ Implement a function daxpy for this operation. Test it by - adding 3 times the second column to the third column, - subtracting 2.5 times the second row from the 4th row. :navigate: up -> doc:index next -> doc:session03/page02