algo.hpp 734 B

123456789101112131415161718192021222324
  1. #ifndef ALGO_HPP
  2. #define ALGO_HPP
  3. #include <cmath>
  4. #include <iostream>
  5. #include <string>
  6. using namespace std;
  7. /*! Thomas algorithm to solve AX=B where A is a tridiagonal matrix
  8. \param n size of the matrix A
  9. \param a (n-1) sub-diagonal coefficients of matrix A
  10. \param b n diagonal coefficients of matrix A
  11. \param c (n-1) sup-diagonal coefficients of matrix A (modified)
  12. \param d n coefficients of vector B (modified)
  13. \param x n coefficients vector to store the result (modified)
  14. */
  15. void Thomas(size_t n,double* a,double* b,double* c,double* d,double* x);
  16. double norm2(double* u,size_t n);
  17. double error2(double* u,double* v,size_t n);
  18. void clear(double* u,size_t n);
  19. void display(string name,double* u,size_t n);
  20. #endif