September 2018
Intermediate to advanced
606 pages
14h 32m
English
To demonstrate the detection and linking of math libraries, we wish to compile a C++ program that takes the dimension of a matrix as command-line input, generates a random square matrix A, a random vector b and solves the ensuing linear systems of equations: Ax = b. In addition, we will scale the random vector b by a random factor. The subroutines we need to use are DSCAL from BLAS, to perform the scaling and DGESV from LAPACK to find the solution of the linear system of equations. The listing for the example C++ code contains (linear-algebra.cpp):
#include "CxxBLAS.hpp"#include "CxxLAPACK.hpp"#include <iostream>#include <random>#include <vector>int main(int argc, char **argv) { if (argc != 2) { std::cout << "Usage: ./linear-algebra ...Read now
Unlock full access