BELFEM 0.9.4
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
fn_is_finite.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 */
16#ifndef BELFEM_FN_IS_FINITE_HPP
17#define BELFEM_FN_IS_FINITE_HPP
18
19#include <cmath>
20#include "typedefs.hpp"
21#include "cl_Matrix.hpp"
22#include "cl_Vector.hpp"
23
24namespace belfem
25{
26//------------------------------------------------------------------------------
27
35 template< typename T >
36 bool
37 is_finite( const Matrix< T > & aA )
38 {
39 const size_t tNumRows = aA.n_rows();
40 const size_t tNumCols = aA.n_cols();
41 for( size_t j = 0; j < tNumCols; ++j )
42 {
43 for( size_t i = 0; i < tNumRows; ++i )
44 {
45 if( ! std::isfinite( aA( i, j ) ) )
46 {
47 return false;
48 }
49 }
50 }
51 return true;
52 }
53
54// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
55
56 template< typename T >
57 bool
58 is_finite( const Vector< T > & aA )
59 {
60 const size_t tN = aA.length();
61 for( size_t k = 0; k < tN; ++k )
62 {
63 if( ! std::isfinite( aA( k ) ) )
64 {
65 return false;
66 }
67 }
68 return true;
69 }
70
71//------------------------------------------------------------------------------
72}
73#endif //BELFEM_FN_IS_FINITE_HPP
Dense column-major matrix.
Definition cl_BZ_Matrix.hpp:28
size_t n_rows() const
Definition cl_AR_Matrix.hpp:187
size_t n_cols() const
Definition cl_AR_Matrix.hpp:195
Column vector.
Definition cl_BZ_Vector.hpp:42
size_t length() const
get the length of the vector
Definition cl_AR_Vector.hpp:333
USER GUIDES:
Definition cl_Capacitor.cpp:16
bool is_finite(const Matrix< T > &aA)
true if every entry of aA is finite ( no NaN, no infinity ).
Definition fn_is_finite.hpp:37