BLAS.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: BLAS.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Generic BLAS operator wrapper class.
6 > Created Time: 2017/08/13
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_BLAS_H
10 #define CUBBYFLOW_BLAS_H
11 
12 namespace CubbyFlow
13 {
25  template <typename S, typename V, typename M>
26  struct BLAS
27  {
28  using ScalarType = S;
29  using VectorType = V;
30  using MatrixType = M;
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 
48  static void AXPlusY(ScalarType a, const VectorType& x, const VectorType& y, VectorType* result);
49 
51  static void MVM(const MatrixType& m, const VectorType& v, VectorType* result);
52 
54  static void Residual(const MatrixType& a, const VectorType& x, const VectorType& b, VectorType* result);
55 
57  static ScalarType L2Norm(const VectorType& v);
58 
60  static ScalarType LInfNorm(const VectorType& v);
61  };
62 }
63 
64 #include <Core/Math/BLAS-Impl.h>
65 
66 #endif
static ScalarType L2Norm(const VectorType &v)
Returns L2-norm of the given vector v.
Definition: BLAS-Impl.h:66
static void Residual(const MatrixType &a, const VectorType &x, const VectorType &b, VectorType *result)
Computes residual vector (b - ax).
Definition: BLAS-Impl.h:60
Generic BLAS operator wrapper class.
Definition: BLAS.h:26
static ScalarType LInfNorm(const VectorType &v)
Returns L-inf-norm of the given vector v.
Definition: BLAS-Impl.h:72
Definition: pybind11Utils.h:24
static void MVM(const MatrixType &m, const VectorType &v, VectorType *result)
Performs matrix-vector multiplication.
Definition: BLAS-Impl.h:54
static void Set(ScalarType s, VectorType *result)
Sets entire element of given vector result with scalar s.
Definition: BLAS-Impl.h:18
M MatrixType
Definition: BLAS.h:30
V VectorType
Definition: BLAS.h:29
S ScalarType
Definition: BLAS.h:28
static void AXPlusY(ScalarType a, const VectorType &x, const VectorType &y, VectorType *result)
Performs ax + y operation where a is a matrix and x and y are vectors.
Definition: BLAS-Impl.h:48
static ScalarType Dot(const VectorType &a, const VectorType &b)
Performs dot product with vector a and b.
Definition: BLAS-Impl.h:42