Skip to content

Commit

Permalink
Documentation Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Dendukuri committed Jul 8, 2024
1 parent 1d165a8 commit 23b358e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
6 changes: 5 additions & 1 deletion benchmark/benchmark_tridiagonal_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const bool MAKE_DIAGONALLY_DOMINANT = true;
const unsigned RANDOM_NUMBER_SEED = 1;

/// @brief This function benchmarks the lapacke tridiagonal matrix solver for single precision
/// @param state Benchmarking argument
static void BM_LAPACKE_SINGLE_PRECISISON(benchmark::State& state)
{
std::vector<float> x(SYSTEM_SIZE);
Expand Down Expand Up @@ -46,6 +47,7 @@ static void BM_LAPACKE_SINGLE_PRECISISON(benchmark::State& state)
}

/// @brief This function benchmarks the lapacke tridiagonal matrix solver for double precision
/// @param state Benchmarking argument
static void BM_LAPACKE_DOUBLE_PRECISISON(benchmark::State& state)
{
std::vector<double> x(SYSTEM_SIZE);
Expand Down Expand Up @@ -75,6 +77,7 @@ static void BM_LAPACKE_DOUBLE_PRECISISON(benchmark::State& state)
}

/// @brief This function benchmarks the tuvx tridiagonal matrix solver for single precision
/// @param state Benchmarking argument
static void BM_TUVX_DOUBLE_PRECISISON(benchmark::State& state)
{
std::vector<double> x(SYSTEM_SIZE);
Expand All @@ -93,6 +96,7 @@ static void BM_TUVX_DOUBLE_PRECISISON(benchmark::State& state)
}

/// @brief This function benchmarks the tuvx tridiagonal matrix solver for double precision
/// @param state Benchmarking argument
static void BM_TUVX_SINGLE_PRECISISON(benchmark::State& state)
{
std::vector<float> x(SYSTEM_SIZE);
Expand All @@ -118,5 +122,5 @@ BENCHMARK(BM_LAPACKE_SINGLE_PRECISISON);
BENCHMARK(BM_TUVX_DOUBLE_PRECISISON);
BENCHMARK(BM_TUVX_SINGLE_PRECISISON);

/// @brief run all benchmarks
/// @brief Run all benchmarks
BENCHMARK_MAIN();
29 changes: 13 additions & 16 deletions include/tuvx/linear_algebra/linear_algebra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,42 @@ namespace tuvx
std::vector<T> upper_diagonal_; // upper diagonal
std::vector<T> lower_diagonal_; // lower diagonal
std::vector<T> main_diagonal_; // main diagonal
/// @fn tridiagonal matrix structure constructor
/// @brief initializes the three internal vectors based on
/// @brief Initializes the three internal vectors based on
/// size. Main diagonal will be of size $n$, while the upper/lower
/// diagonals will be of size $n-1#
/// diagonals will be of size $n-1$
/// @param size Size of the matrix to be initialized
TridiagonalMatrix(std::size_t size);
};

/// @brief Fill a std::vector with random values
/// @brief Fills a std::vector with random values
/// @param x Vector to allocate and fill
/// @param seed for random number generation
/// @param seed Seed for random number generation
template<typename T>
void FillRandom(std::vector<T> &x, const unsigned &seed);

/// @brief Fills a matrix with uniformly distributed random values.
/// @param A Tridiagonal matrix to allocate and fill
/// @param seed For random number generation
/// @param seed Seed for random number generation
/// @param make_diagonally_dominant Make the tridiagonal matrix diagonally dominant (diagonal value is greater than sum of
/// the corrosponding row)
/// the corrosponding row values)
template<typename T>
void FillRandom(TridiagonalMatrix<T> &A, const unsigned &seed, const bool &make_diagonally_dominant = false);

/// @fn print vector function
/// @brief displays the data stored inside a std::vector
/// @brief Displays the data stored inside a std::vector
/// @param x Vector to print
template<typename T>
void Print(const std::vector<T> &x);

/// @fn print matrix function
/// @brief displays the data stored inside a tridiagonal matrix.
/// @brief Displays the data stored inside a tridiagonal matrix.
/// For now, this function simply calls printvec() on the three diagonals.
/// @param A tridiagonal matrix to print
/// @param A Tridiagonal matrix to print
template<typename T>
void Print(const TridiagonalMatrix<T> &A);

/// @fn Tridiagonal Linear System Solver
/// @brief Thomas' algorithm for solving tridiagonal linear system (A x = b).
/// store solution in b.
/// @param A tridiagonal coeffcient matrix
/// @param b right hand side vector of the tridiagonal system.
/// @param A Tridiagonal coeffcient matrix
/// @param b Right hand side vector of the tridiagonal system.
template<typename T>
void Solve(TridiagonalMatrix<T> &A, std::vector<T> &b);

Expand All @@ -66,7 +63,7 @@ namespace tuvx
template<typename T>
std::vector<T> Dot(const TridiagonalMatrix<T> &A, const std::vector<T> &b);

/// @brief Computes the LP error norm between two vectors. Used for computing
/// @brief Computes the relative error between two vectors. Used for computing
/// approximation errors.
/// @param x True solution
/// @param x_approx Approximated solution
Expand Down
1 change: 1 addition & 0 deletions test/unit/linear_algebra/test_error_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const unsigned RANDOM_NUMBER_SEED = 1;

/// @brief Test the correctness of the error function used for
/// testing the Linear approximation solvers with double precision data types.
/// @param ErrorFunctionTest Name of the test suite
TEST(ErrorFunctionTest, DoublePrecision)
{
// same vector should return 0 error
Expand Down

0 comments on commit 23b358e

Please sign in to comment.