Math 420 Homework 5
Q1: Cleaning up memory usage:
i. Create a “destructor” function for your Homework 4 dmatrix that frees
allocated array memory and sets the data pointer in the dmatrix to NULL.
ii. Review your Homework 4 dmatrix code and driver routines. Find and
eliminate all instances of memory leakage [ i.e. make sure your destructor is
called before a dmatrix goes out of scope ]. Document all instances where you
had to add or change code . It is sufficient to include your new codes in your
report and annotate the changes by hand .
Q2: Using BLAS and LAPACK:
a) Replace your self-written matrix operations in Homework 4 with functions that
call
BLAS and LAPACK to perform the following tasks.
i. matrix A times matrix B
ii. matrix A plus matrix B
iii. scalar c times matrix A
iv. matrix A left divides matrix B
HINTS:
1. Your matrix_multiply routine must call dgemm.
2. You are also likely to use daxpy and dgesv
3. You will need to pay attention to the calling convention when invoking a
Fortran subroutine from C.
4. Q2 part iv is not optional.
5. Modify your dmatrix struct and set/get functions to use a contiguous column
major storage format.
b) Use matrices A and B from Homework 4 Q6 and compute the
following using your
new BLAS/LAPACK based operators :
i. Compute C =AB
ii. Compute D=A+C
iii. Compute E=1.2*D
iv. Compute F=A\D
Prev | Next |