w07-g04-matrix-uint-inherited
Base Matrix UInt Class
Objective
The overall objective of this assignment is to implement an abstract matrix class BaseMatrixUInt
, and make the current matrix class MatrixUInt
inheritated from the parent class BaseMatrixUInt
. The nodal array class NodalArrayUInt
will be another child class of BaseMatrixUInt
. This abstract matrix class makes it possible to extend the project with more matrices without the need of modifying other classes.
Here, you need to implement an abstract class BaseMatrixUInt
in tehpc/src/base_matrix.hpp
. Then you need to modify the matrix class MatrixUInt
in tehpc/src/matrix
(both .hpp
and .cpp
) into a child class of BaseMatrixUInt
. Move as much functionality as possible while keeping the BaseMatrixUInt
class general enough to allow also the NodalArrayUInt
to inherit from it.
Implementation
-
load appropriate modules by performing the following command in your terminal:
source tehpc/tools/tehpc_load_modules.sh
. -
If
base_matrix.hpp
is not already included at the appropriate place intehpc/src/CMakeLists.txt
, add it. This makes sure that it is compiled. -
Add
tehpc_add_test(matrix_uint_test)
in thetehpc/tests/CMakeLists.txt
to include the test in the compilation. -
Compile your code, use the following steps:
a. go into
tehpc/build/
b. type:
cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DTEHPC_TESTS:STRING=ON ..
or useccmake ..
to configure (you only have to do this the very first time).c. type:
make
(do this whenever you want to recompile). -
Implement the base matrix class
BaseMatrixUInt
intehpc/src/base_matrix.hpp
and modify the matrixMatrixUInt
into a child class ofBaseMatrixUInt
. Correct all compilation errors.a. compare
MatrixUInt
andNodalArrayUInt
, move the shared part into theBaseMatrixUInt
, including the #include directive, members and member functions. Consider using pure virtual methods where appropriate.b. make
MatrixUInt
inheritated fromBaseMatrixUInt
. The use ofvirtual function
could help. Pay attention to the constructor and destructor.c. read
tehpc/tests/matrix_uint_test.cpp
, especially the function that has a pointer to the abstract class as one of its arguments, and compare the way of creating an object to last week.d. If you have enough time, repeat the procees of making
MatrixUInt
inheritating fromBaseMatrixUInt
by applying it also onNodalArrayUInt
. -
If the code compiles without errors, run the test
matrix_uint_test
:a. go into
tehpc/build/tests/
b. type:
./matrix_uint_test
-
Make sure that the tests run without error and return success.
-
run valgrind to check for memory leakage:
valgrind --leak-check=full ./matrix_uint_test
. Correct memory leakage if you encounter this problem. -
Make sure that your code is well structured and commented.
-
Generate the
doxygen
software catalogue for the entire project:a. go into
tehpc/build/
b. type:
ccmake .
and switch on the option forTEHPC_DOC
, and configure withc
and generate withg
c. type:
make
d. download the generated catalogue files in
tehpc/build/docs/doxygen
to your local computer and view it.e. IMPORTANT: you can use the same approach for your project (i.e. stage II) for that, you need to copy the Doxygen part of
tehpc/CMakeLists.txt
toyour-project/CMakeLists.txt
, and copy thetehpc/docs/CMakeLists.txt
andtehpc/docs/Doxyfile.in
to the equivalent directories of your project.