BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
op_MatrixMinus.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_MATRIXMINUS_HPP
13#define BELFEM_OP_MATRIXMINUS_HPP
14
15#include "cl_Matrix.hpp"
16
17namespace belfem
18{
19//------------------------------------------------------------------------------
20
21 template< typename T >
22 inline auto
23 operator-( const Matrix<T> & aA,
24 const Matrix<T> & aB )
25 -> decltype( aA.matrix_data() - aB.matrix_data() )
26 {
27 BELFEM_ASSERT( aA.n_rows() == aB.n_rows(),
28 "Number of rows of matrices does not match ( %lu and %lu ).",
29 ( long unsigned int ) aA.n_rows(),
30 ( long unsigned int ) aB.n_rows() );
31
32 BELFEM_ASSERT( aA.n_cols() == aB.n_cols(),
33 "Number of colums of matrices does not match ( %lu and %lu ).",
34 ( long unsigned int ) aA.n_cols(),
35 ( long unsigned int ) aB.n_cols() );
36
37 return aA.matrix_data() - aB.matrix_data();
38 }
39
40// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
41
42 template< typename A, typename B >
43 inline auto
45 const B & aB )
46 -> decltype( aA.matrix_data() - aB )
47 {
48
49 return aA.matrix_data() - aB ;
50 }
51
52// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
53
54 template< typename A, typename B >
55 inline auto
56 operator-( const A & aA,
57 const Matrix< B > & aB )
58 -> decltype( aA - aB.matrix_data() )
59 {
60
61 return aA - aB.matrix_data() ;
62 }
63
64//------------------------------------------------------------------------------
65}
66
67#endif //BELFEM_OP_MATRIXMINUS_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
Dense column-major matrix.
Definition cl_BZ_Matrix.hpp:28
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_MatrixMinus.hpp:23