Jet  v1.3.3
blas.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_BLAS_H_
8 #define INCLUDE_JET_BLAS_H_
9 
10 #include <jet/vector4.h>
11 #include <jet/matrix4x4.h>
12 
13 namespace jet {
14 
26 template <typename S, typename V, typename M>
27 struct Blas {
28  typedef S ScalarType;
29  typedef V VectorType;
30  typedef M MatrixType;
31 
33  static void set(ScalarType s, VectorType* result);
34 
36  static void set(const VectorType& v, VectorType* result);
37 
39  static void set(ScalarType s, MatrixType* result);
40 
42  static void set(const MatrixType& m, MatrixType* result);
43 
45  static ScalarType dot(const VectorType& a, const VectorType& b);
46 
49  static void axpy(
50  ScalarType a,
51  const VectorType& x,
52  const VectorType& y,
53  VectorType* result);
54 
56  static void mvm(
57  const MatrixType& m,
58  const VectorType& v,
59  VectorType* result);
60 
62  static void residual(
63  const MatrixType& a,
64  const VectorType& x,
65  const VectorType& b,
66  VectorType* result);
67 
69  static ScalarType l2Norm(const VectorType& v);
70 
72  static ScalarType lInfNorm(const VectorType& v);
73 };
74 
75 } // namespace jet
76 
77 #include "detail/blas-inl.h"
78 
79 #endif // INCLUDE_JET_BLAS_H_
jet::Blas::set
static void set(ScalarType s, VectorType *result)
Sets entire element of given vector result with scalar s.
jet::Blas::residual
static void residual(const MatrixType &a, const VectorType &x, const VectorType &b, VectorType *result)
Computes residual vector (b - ax).
jet::Blas::set
static void set(const MatrixType &m, MatrixType *result)
Copies entire element of given matrix result with other matrix v.
jet::Blas
Generic BLAS operator wrapper class.
Definition: blas.h:27
jet::Blas::VectorType
V VectorType
Definition: blas.h:29
jet::Blas::mvm
static void mvm(const MatrixType &m, const VectorType &v, VectorType *result)
Performs matrix-vector multiplication.
jet::Blas::ScalarType
S ScalarType
Definition: blas.h:28
jet
Definition: advection_solver2.h:18
jet::Blas::l2Norm
static ScalarType l2Norm(const VectorType &v)
Returns L2-norm of the given vector v.
jet::Blas::MatrixType
M MatrixType
Definition: blas.h:30
matrix4x4.h
jet::Blas::dot
static ScalarType dot(const VectorType &a, const VectorType &b)
Performs dot product with vector a and b.
vector4.h
jet::Blas::set
static void set(const VectorType &v, VectorType *result)
Copies entire element of given vector result with other vector v.
jet::Blas::set
static void set(ScalarType s, MatrixType *result)
Sets entire element of given matrix result with scalar s.
jet::Blas::axpy
static void axpy(ScalarType a, const VectorType &x, const VectorType &y, VectorType *result)
jet::Blas::lInfNorm
static ScalarType lInfNorm(const VectorType &v)
Returns Linf-norm of the given vector v.