BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
op_MatrixTimes.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_OP_MATRIXTIMES_HPP
13#define BELFEM_OP_MATRIXTIMES_HPP
14
15#include "cl_Vector.hpp"
16#include "cl_Matrix.hpp"
17
18namespace belfem
19{
20//------------------------------------------------------------------------------
21
22 template< typename T >
23 inline auto
24 operator*( const Matrix <T> & aA,
25 const Matrix <T> & aB )
26 -> decltype( aA.matrix_data() * aB.matrix_data())
27 {
28 BELFEM_ASSERT( aA.n_cols() == aB.n_rows(),
29 "Number of cols of matrix A must be equal to rows of B ( is %lu and %lu ).",
30 ( long unsigned int ) aA.n_cols(),
31 ( long unsigned int ) aB.n_rows());
32
33
34 return aA.matrix_data() * aB.matrix_data();
35 }
36
37// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38
39 template< typename T >
40 inline auto
41 operator*( const Matrix <T> & aA,
42 const Vector <T> & aB )
43 -> decltype( aA.matrix_data() * aB.vector_data())
44 {
45 BELFEM_ASSERT( aA.n_cols() == aB.length(),
46 "Number of cols of matrix A must be equal to rows of B ( is %lu and %lu ).",
47 ( long unsigned int ) aA.n_cols(),
48 ( long unsigned int ) aB.length());
49
50 return aA.matrix_data() * aB.vector_data();
51 }
52
53// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
54
55 template< typename A, typename B >
56 inline auto
57 operator*( const Matrix <A> & aA,
58 const B & aB )
59 -> decltype( aA.matrix_data() * aB )
60 {
61
62 return aA.matrix_data() * aB;
63 }
64
65// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
66
67 template< typename A, typename B >
68 inline auto
69 operator*( const A & aA,
70 const Matrix <B> & aB )
71 -> decltype( aA * aB.matrix_data())
72 {
73
74 return aA * aB.matrix_data();
75 }
76
77//------------------------------------------------------------------------------
78
79}
80#endif //BELFEM_OP_MATRIXTIMES_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
USER GUIDES:
Definition cl_Capacitor.cpp:16
auto operator*(const Matrix< T > &aA, const Matrix< T > &aB) -> decltype(aA.matrix_data() *aB.matrix_data())
Definition op_MatrixTimes.hpp:24