Loading...
Searching...
No Matches
BLAS.hpp
Go to the documentation of this file.
1// This code is based on Jet framework.
2// Copyright (c) 2018 Doyub Kim
3// CubbyFlow is voxel-based fluid simulation engine for computer games.
4// Copyright (c) 2020 CubbyFlow Team
5// Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6// AI Part: Dongheon Cho, Minseo Kim
7// We are making my contributions/submissions to this project solely in our
8// personal capacity and are not conveying any rights to any intellectual
9// property of any third parties.
10
11#ifndef CUBBYFLOW_BLAS_HPP
12#define CUBBYFLOW_BLAS_HPP
13
14namespace CubbyFlow
15{
27template <typename S, typename V, typename M>
28struct BLAS
29{
30 using ScalarType = S;
31 using VectorType = V;
32 using MatrixType = M;
33
35 static void Set(ScalarType s, VectorType* result);
36
38 static void Set(const VectorType& v, VectorType* result);
39
41 static void Set(ScalarType s, MatrixType* result);
42
44 static void Set(const MatrixType& m, MatrixType* result);
45
47 [[nodiscard]] static ScalarType Dot(const VectorType& a,
48 const VectorType& b);
49
52 static void AXPlusY(ScalarType a, const VectorType& x, const VectorType& y,
54
56 static void MVM(const MatrixType& m, const VectorType& v,
58
60 static void Residual(const MatrixType& a, const VectorType& x,
61 const VectorType& b, VectorType* result);
62
64 [[nodiscard]] static ScalarType L2Norm(const VectorType& v);
65
67 [[nodiscard]] static ScalarType LInfNorm(const VectorType& v);
68};
69} // namespace CubbyFlow
70
72
73#endif
Definition Matrix.hpp:30
Definition pybind11Utils.hpp:21
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
Generic BLAS operator wrapper class.
Definition BLAS.hpp:29
static ScalarType L2Norm(const VectorType &v)
Returns L2-norm of the given vector v.
Definition BLAS-Impl.hpp:80
static void Set(ScalarType s, VectorType *result)
Sets entire element of given vector result with scalar s.
Definition BLAS-Impl.hpp:19
M MatrixType
Definition BLAS.hpp:32
static void Residual(const MatrixType &a, const VectorType &x, const VectorType &b, VectorType *result)
Computes residual vector (b - ax).
Definition BLAS-Impl.hpp:71
V VectorType
Definition BLAS.hpp:31
static void MVM(const MatrixType &m, const VectorType &v, VectorType *result)
Performs matrix-vector multiplication.
Definition BLAS-Impl.hpp:63
static void AXPlusY(ScalarType a, const VectorType &x, const VectorType &y, VectorType *result)
Definition BLAS-Impl.hpp:54
static ScalarType LInfNorm(const VectorType &v)
Returns L-inf-norm of the given vector v.
Definition BLAS-Impl.hpp:86
S ScalarType
Definition BLAS.hpp:30
static ScalarType Dot(const VectorType &a, const VectorType &b)
Performs dot product with vector a and b.
Definition BLAS-Impl.hpp:47