w10-task1-external-solver
External library: armadillo and eigen
Objective
The objective is to use an external library to solve the sytem. In order to keep our library as much as possible independent of external libraries, we will implement a new solver that includes everything needed for this external library. This means that the external library should only appear in this specific solver.
Groups: 1,3,5,...: you will use the armadillo library. Groups: 2,4,6,...: you will use the eigen library.
Tasks
-
Check the documentation for your respective libraries. You can search for
armadillo c++ library
oreigen c++ library
to find their respective documentation. -
Once you have found the documentation, explore it and answer the following questions.
-
What could these two libraries be used for?
-
How can you install/download these two libraries to your local machine?
-
Is it possible to use these two libraries to define Matrices and Vectors in our tehpc library. If so, could you give an example (syntax) of how will you initialize a matrix of type
double
and size4x4
. -
Is it possible to use these two libraries to solve a system of linear equations. If so, give an example (syntax) of how will you solve the system
A*x = b
. -
Suppose we were to use one of these two libraries in our
tehpc
library, what functionalities/classes do you think could be replaced or enhanced?
-
-
Check
tehpc/CMakeLists.txt
andtehpc/src/CMakeLists.txt
for parts related to the external library. Check specifically for thetarget_link_libraries(...)
command. -
Consider the
tehpc/src/[your-ext-library]_solver.[c/h]pp
files, and make sure that it is included in compilation. -
Compile code with the option for your external library
ON
(see ccmake). -
Complete the
solve(...)
function in[your-ext-library]_solver.cpp
to solve the system using the solver of the external library. -
Modify the
tehpc/tests/NLsolver_test.cpp
, write the equivalenttehpc/tests/NLsolver_test_nr.sh
script for your solver, and add the appropriate line intehpc/tests/CMakeLists.txt
such that you can run the test for your library and that it is included in the commandmake test
. -
Correct all compilation errors.
-
If the code compiles without errors, run the test
NLsolver_test
for your solver, and make sure that it passes (also run all tests withmake test
). -
Modify the
hancock.inp
file intehpc/examples/
such that the basic example will use your solver (you might also need to changetehpc/src/nonlinear_solver.cpp
). Compile the code and run the example. Check terminal output to verify that the correct solver was used. -
Plot the result and verify if it is still the same as before.
-
run valgrind to check for memory leakage:
valgrind --leak-check=full ./basic_example
. Correct memory leakage if you encounter problems. -
Make sure that your code is well structured and commented.