Skip to content

Commit 7b1e843

Browse files
committed
Update headers for compatibility with kokkos metaphysicl
1 parent 6bd3df0 commit 7b1e843

File tree

6 files changed

+48
-40
lines changed

6 files changed

+48
-40
lines changed

include/numerics/dense_matrix.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ class DenseMatrix : public DenseMatrixBase<T>
324324
* This is the natural matrix norm that is compatible to the l1-norm
325325
* for vectors, i.e. \f$ |Mv|_1 \leq |M|_1 |v|_1 \f$.
326326
*/
327-
auto l1_norm () const -> decltype(std::abs(T(0)));
327+
auto l1_norm () const;
328328

329329
/**
330330
* \returns The linfty-norm of the matrix, that is, the max row sum:
@@ -334,7 +334,7 @@ class DenseMatrix : public DenseMatrixBase<T>
334334
* This is the natural matrix norm that is compatible to the
335335
* linfty-norm of vectors, i.e. \f$ |Mv|_\infty \leq |M|_\infty |v|_\infty \f$.
336336
*/
337-
auto linfty_norm () const -> decltype(std::abs(T(0)));
337+
auto linfty_norm () const;
338338

339339
/**
340340
* Left multiplies by the transpose of the matrix \p A.
@@ -1122,23 +1122,24 @@ auto DenseMatrix<T>::max () const -> decltype(libmesh_real(T(0)))
11221122

11231123
template<typename T>
11241124
inline
1125-
auto DenseMatrix<T>::l1_norm () const -> decltype(std::abs(T(0)))
1125+
auto DenseMatrix<T>::l1_norm () const
11261126
{
11271127
libmesh_assert (this->_m);
11281128
libmesh_assert (this->_n);
11291129

1130-
auto columnsum = std::abs(T(0));
1130+
using std::abs;
1131+
auto columnsum = abs(T(0));
11311132
for (unsigned int i=0; i!=this->_m; i++)
11321133
{
1133-
columnsum += std::abs((*this)(i,0));
1134+
columnsum += abs((*this)(i,0));
11341135
}
11351136
auto my_max = columnsum;
11361137
for (unsigned int j=1; j!=this->_n; j++)
11371138
{
11381139
columnsum = 0.;
11391140
for (unsigned int i=0; i!=this->_m; i++)
11401141
{
1141-
columnsum += std::abs((*this)(i,j));
1142+
columnsum += abs((*this)(i,j));
11421143
}
11431144
my_max = (my_max > columnsum? my_max : columnsum);
11441145
}
@@ -1149,23 +1150,24 @@ auto DenseMatrix<T>::l1_norm () const -> decltype(std::abs(T(0)))
11491150

11501151
template<typename T>
11511152
inline
1152-
auto DenseMatrix<T>::linfty_norm () const -> decltype(std::abs(T(0)))
1153+
auto DenseMatrix<T>::linfty_norm () const
11531154
{
11541155
libmesh_assert (this->_m);
11551156
libmesh_assert (this->_n);
1157+
using std::abs;
11561158

1157-
auto rowsum = std::abs(T(0));
1159+
auto rowsum = abs(T(0));
11581160
for (unsigned int j=0; j!=this->_n; j++)
11591161
{
1160-
rowsum += std::abs((*this)(0,j));
1162+
rowsum += abs((*this)(0,j));
11611163
}
11621164
auto my_max = rowsum;
11631165
for (unsigned int i=1; i!=this->_m; i++)
11641166
{
11651167
rowsum = 0.;
11661168
for (unsigned int j=0; j!=this->_n; j++)
11671169
{
1168-
rowsum += std::abs((*this)(i,j));
1170+
rowsum += abs((*this)(i,j));
11691171
}
11701172
my_max = (my_max > rowsum? my_max : rowsum);
11711173
}

include/numerics/dense_matrix_impl.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,8 @@ void DenseMatrix<T>::_lu_back_substitute (const DenseVector<T> & b,
630630
template<typename T>
631631
void DenseMatrix<T>::_lu_decompose ()
632632
{
633+
using std::abs;
634+
633635
// If this function was called, there better not be any
634636
// previous decomposition of the matrix.
635637
libmesh_assert_equal_to (this->_decomposition_type, NONE);
@@ -648,11 +650,11 @@ void DenseMatrix<T>::_lu_decompose ()
648650
// Find the pivot row by searching down the i'th column
649651
_pivots[i] = i;
650652

651-
// std::abs(complex) must return a Real!
652-
auto the_max = std::abs( A(i,i) );
653+
// abs(complex) must return a Real!
654+
auto the_max = abs( A(i,i) );
653655
for (unsigned int j=i+1; j<n_rows; ++j)
654656
{
655-
auto candidate_max = std::abs( A(j,i) );
657+
auto candidate_max = abs( A(j,i) );
656658
if (the_max < candidate_max)
657659
{
658660
the_max = candidate_max;
@@ -872,6 +874,8 @@ void DenseMatrix<T>::cholesky_solve (const DenseVector<T2> & b,
872874
template<typename T>
873875
void DenseMatrix<T>::_cholesky_decompose ()
874876
{
877+
using std::sqrt;
878+
875879
// If we called this function, there better not be any
876880
// previous decomposition of the matrix.
877881
libmesh_assert_equal_to (this->_decomposition_type, NONE);
@@ -901,7 +905,7 @@ void DenseMatrix<T>::_cholesky_decompose ()
901905
"Error! Can only use Cholesky decomposition with symmetric positive definite matrices.");
902906
#endif
903907

904-
A(i,i) = std::sqrt(A(i,j));
908+
A(i,i) = sqrt(A(i,j));
905909
}
906910
else
907911
A(j,i) = A(i,j) / A(i,i);

include/numerics/tensor_tools.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,61 +71,61 @@ inner_product(const TypeNTensor<N,T> & a, const TypeNTensor<N,T2> & b)
7171

7272
template<typename T>
7373
inline
74-
auto norm(const T & a) -> decltype(std::abs(a))
75-
{ return std::abs(a); }
74+
auto norm(const T & a)
75+
{ using std::abs; return abs(a); }
7676

7777
template<typename T>
7878
inline
79-
T norm(std::complex<T> a) { return std::abs(a); }
79+
T norm(std::complex<T> a) { using std::abs; return abs(a); }
8080

8181
template <typename T>
8282
inline
8383
auto norm(const TypeVector<T> & a) -> decltype(TensorTools::norm(T()))
84-
{return std::sqrt(a.norm_sq());}
84+
{using std::sqrt; return sqrt(a.norm_sq());}
8585

8686
template <typename T>
8787
inline
8888
auto norm(const VectorValue<T> & a) -> decltype(TensorTools::norm(T()))
89-
{return std::sqrt(a.norm_sq());}
89+
{using std::sqrt; return sqrt(a.norm_sq());}
9090

9191
template <typename T>
9292
inline
9393
auto norm(const TypeTensor<T> & a) -> decltype(TensorTools::norm(T()))
94-
{return std::sqrt(a.norm_sq());}
94+
{using std::sqrt; return sqrt(a.norm_sq());}
9595

9696
template <typename T>
9797
inline
9898
auto norm(const TensorValue<T> & a) -> decltype(TensorTools::norm(T()))
99-
{return std::sqrt(a.norm_sq());}
99+
{using std::sqrt; return sqrt(a.norm_sq());}
100100

101101

102102
template<typename T>
103103
inline
104-
auto norm_sq(const T & a) -> decltype(std::norm(a))
105-
{ return std::norm(a); }
104+
auto norm_sq(const T & a)
105+
{ using std::norm; return norm(a); }
106106

107107
template<typename T>
108108
inline
109-
T norm_sq(std::complex<T> a) { return std::norm(a); }
109+
T norm_sq(std::complex<T> a) { using std::norm; return norm(a); }
110110

111111
template <typename T>
112112
inline
113-
auto norm_sq(const TypeVector<T> & a) -> decltype(std::norm(T()))
113+
auto norm_sq(const TypeVector<T> & a)
114114
{return a.norm_sq();}
115115

116116
template <typename T>
117117
inline
118-
auto norm_sq(const VectorValue<T> & a) -> decltype(std::norm(T()))
118+
auto norm_sq(const VectorValue<T> & a)
119119
{return a.norm_sq();}
120120

121121
template <typename T>
122122
inline
123-
auto norm_sq(const TypeTensor<T> & a) -> decltype(std::norm(T()))
123+
auto norm_sq(const TypeTensor<T> & a)
124124
{return a.norm_sq();}
125125

126126
template <typename T>
127127
inline
128-
auto norm_sq(const TensorValue<T> & a) -> decltype(std::norm(T()))
128+
auto norm_sq(const TensorValue<T> & a)
129129
{return a.norm_sq();}
130130

131131

include/numerics/type_n_tensor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class TypeNTensor
218218
* \returns The Frobenius norm of the tensor, i.e. the square-root of
219219
* the sum of the elements squared.
220220
*/
221-
auto norm() const -> decltype(std::norm(T()))
221+
auto norm() const
222222
{
223223
libmesh_not_implemented();
224224
return 0.;
@@ -228,7 +228,7 @@ class TypeNTensor
228228
* \returns The Frobenius norm of the tensor squared, i.e. the sum of the
229229
* entry magnitudes squared.
230230
*/
231-
auto norm_sq() const -> decltype(std::norm(T()))
231+
auto norm_sq() const
232232
{
233233
libmesh_not_implemented();
234234
return 0.;

include/numerics/type_tensor.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,13 @@ class TypeTensor
364364
* \returns The Frobenius norm of the tensor, i.e. the square-root of
365365
* the sum of the elements squared.
366366
*/
367-
auto norm() const -> decltype(std::norm(T()));
367+
auto norm() const;
368368

369369
/**
370370
* \returns The Frobenius norm of the tensor squared, i.e. sum of the
371371
* element magnitudes squared.
372372
*/
373-
auto norm_sq() const -> decltype(std::norm(T()));
373+
auto norm_sq() const;
374374

375375
/**
376376
* \returns True if all values in the tensor are zero
@@ -1277,9 +1277,10 @@ TypeTensor<T>::contract (const TypeTensor<T2> & t) const
12771277

12781278
template <typename T>
12791279
inline
1280-
auto TypeTensor<T>::norm() const -> decltype(std::norm(T()))
1280+
auto TypeTensor<T>::norm() const
12811281
{
1282-
return std::sqrt(this->norm_sq());
1282+
using std::sqrt;
1283+
return sqrt(this->norm_sq());
12831284
}
12841285

12851286

@@ -1345,7 +1346,7 @@ void TypeTensor<T>::zero()
13451346

13461347
template <typename T>
13471348
inline
1348-
auto TypeTensor<T>::norm_sq () const -> decltype(std::norm(T()))
1349+
auto TypeTensor<T>::norm_sq () const
13491350
{
13501351
Real sum = 0.;
13511352
for (unsigned int i=0; i<LIBMESH_DIM*LIBMESH_DIM; i++)

include/numerics/type_vector.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,13 @@ class TypeVector
298298
* \returns The magnitude of the vector, i.e. the square-root of the
299299
* sum of the elements squared.
300300
*/
301-
auto norm() const -> decltype(std::norm(T()));
301+
auto norm() const;
302302

303303
/**
304304
* \returns The magnitude of the vector squared, i.e. the sum of the
305305
* element magnitudes squared.
306306
*/
307-
auto norm_sq() const -> decltype(std::norm(T()));
307+
auto norm_sq() const;
308308

309309
/**
310310
* \returns The L1 norm of the vector
@@ -904,9 +904,10 @@ TypeVector<T>::cross(const TypeVector<T2> & p) const
904904

905905
template <typename T>
906906
inline
907-
auto TypeVector<T>::norm() const -> decltype(std::norm(T()))
907+
auto TypeVector<T>::norm() const
908908
{
909-
return std::sqrt(this->norm_sq());
909+
using std::sqrt;
910+
return sqrt(this->norm_sq());
910911
}
911912

912913

@@ -923,7 +924,7 @@ void TypeVector<T>::zero()
923924

924925
template <typename T>
925926
inline
926-
auto TypeVector<T>::norm_sq() const -> decltype(std::norm(T()))
927+
auto TypeVector<T>::norm_sq() const
927928
{
928929
#if LIBMESH_DIM == 1
929930
return (TensorTools::norm_sq(_coords[0]));

0 commit comments

Comments
 (0)