Skip to content
Snippets Groups Projects
Commit 12ea79e8 authored by Tobias Leibner's avatar Tobias Leibner
Browse files

[algorithms.cholesky] use is_zero from dune-xt-common

parent 60dc842d
No related branches found
No related tags found
No related merge requests found
...@@ -4,23 +4,23 @@ status = 1a3bcab04b011a5d6e44f9983cae6ff89fa695e8 bin (heads/master) ...@@ -4,23 +4,23 @@ status = 1a3bcab04b011a5d6e44f9983cae6ff89fa695e8 bin (heads/master)
20a673b9dad7e2e25bd97defa8849debb59d247c config.opts (heads/master) 20a673b9dad7e2e25bd97defa8849debb59d247c config.opts (heads/master)
8f2c5aba441417bf2c42f22272f538c68a89cc4a dune-alugrid (remotes/origin/releases/2.5) 8f2c5aba441417bf2c42f22272f538c68a89cc4a dune-alugrid (remotes/origin/releases/2.5)
707acf201d5a754c80f87cc4d71aa36bf29a6e3f dune-common (v2.5.1-9-g707acf20) 707acf201d5a754c80f87cc4d71aa36bf29a6e3f dune-common (v2.5.1-9-g707acf20)
+17ce566cb99f1be9bb0e9990dbf280a4375cd973 dune-gdt (heads/entropy_flux_even_newer) +b970966098de3d96005a3a09cdfd3ca8c5874d26 dune-gdt (heads/entropy_flux_even_newer)
390a2c503783bbed778a8ff610f8c5ca09c238d0 dune-geometry (v2.5.1-5-g390a2c5) 390a2c503783bbed778a8ff610f8c5ca09c238d0 dune-geometry (v2.5.1-5-g390a2c5)
d7b20bbc5f6fdcfc312beb0ea5d16d39ea26904e dune-grid (v2.5.1-2-gd7b20bbc5) d7b20bbc5f6fdcfc312beb0ea5d16d39ea26904e dune-grid (v2.5.1-2-gd7b20bbc5)
+e9d9a3336735090648637e044e279866bbea3597 dune-grid-glue (v2.4.0-60-ge9d9a33) 9e29a333e8af02382d80b95335a784d5ce1ea2c8 dune-grid-glue (v2.4.0-70-g9e29a33)
63df56a54f81eda308233a683eb329e77e69f0a9 dune-istl (v2.5.1rc1) 63df56a54f81eda308233a683eb329e77e69f0a9 dune-istl (v2.5.1rc1)
0d757d65e5d57134a7ecf304e35d063f4ccc7116 dune-localfunctions (v2.5.1rc1) 0d757d65e5d57134a7ecf304e35d063f4ccc7116 dune-localfunctions (v2.5.1rc1)
8a69fc68165780921bbba77da338b6932daf983c dune-pybindxi (v2.2.1-16-g8a69fc6) 8a69fc68165780921bbba77da338b6932daf983c dune-pybindxi (v2.2.1-16-g8a69fc6)
741e4f8e53bdd3e1b6e19d84eb22b6e3dc48526c dune-python (remotes/origin/releases/2.5) 741e4f8e53bdd3e1b6e19d84eb22b6e3dc48526c dune-python (remotes/origin/releases/2.5)
26cc8cb4161a3a51002ab2a81b8c81d2c951ee79 dune-testtools (remotes/origin/p/renemilk/testname_listing_hack_no-skiptest) 26cc8cb4161a3a51002ab2a81b8c81d2c951ee79 dune-testtools (remotes/origin/p/renemilk/testname_listing_hack_no-skiptest)
0a74e7dd0b2115778a5d490dab08a2ed07fcaa1e dune-uggrid (v2.5.2) 0a74e7dd0b2115778a5d490dab08a2ed07fcaa1e dune-uggrid (v2.5.2)
aa99fc15ae0bc467e0f0df0e48721ab66a9bb74a dune-xt-common (heads/dailywork_tleibner) +84d7fed4cae2675c20a76a0e308045d85ffcc631 dune-xt-common (heads/dailywork_tleibner)
f93419066883a68c4e0ba96acc3d451ba971876a dune-xt-data (heads/dailywork_tleibner) f93419066883a68c4e0ba96acc3d451ba971876a dune-xt-data (heads/dailywork_tleibner)
83b29cbe84d0af6579d6904f59598ad3dd132996 dune-xt-functions (heads/dailywork_tleibner) 83b29cbe84d0af6579d6904f59598ad3dd132996 dune-xt-functions (heads/dailywork_tleibner)
9432a18b5de2931e06bf1b4eeefa8de1d1820c0f dune-xt-grid (heads/dailywork_tleibner) 9432a18b5de2931e06bf1b4eeefa8de1d1820c0f dune-xt-grid (heads/dailywork_tleibner)
+e8e217cac638356cc267d1833f076adca7169fb4 dune-xt-la (heads/remove_cow) 60dc842dba1233c5d767e7dcfa796280bd43bb82 dune-xt-la (heads/dailywork-tleibner)
09d0378f616b94d68bcdd9fc6114813181849ec0 scripts (heads/master) 09d0378f616b94d68bcdd9fc6114813181849ec0 scripts (heads/master)
commit = ef338bb43fc2435c08479109d90f65d46ea484e6 commit = 2967bdedc638aa2ba19ebfcaf4dd5735758aeba0
[submodule.bin] [submodule.bin]
remote = git@github.com:dune-community/local-bin.git remote = git@github.com:dune-community/local-bin.git
...@@ -45,7 +45,7 @@ commit = 707acf201d5a754c80f87cc4d71aa36bf29a6e3f ...@@ -45,7 +45,7 @@ commit = 707acf201d5a754c80f87cc4d71aa36bf29a6e3f
[submodule.dune-gdt] [submodule.dune-gdt]
remote = git@github.com:dune-community/dune-gdt.git remote = git@github.com:dune-community/dune-gdt.git
status = 2424627f0ad5de7e4aaa5e7f48bc2a02414d95a1 .vcsetup (heads/master) status = 2424627f0ad5de7e4aaa5e7f48bc2a02414d95a1 .vcsetup (heads/master)
commit = 17ce566cb99f1be9bb0e9990dbf280a4375cd973 commit = b970966098de3d96005a3a09cdfd3ca8c5874d26
[submodule.dune-geometry] [submodule.dune-geometry]
remote = git@github.com:dune-community/dune-geometry.git remote = git@github.com:dune-community/dune-geometry.git
...@@ -60,7 +60,7 @@ commit = d7b20bbc5f6fdcfc312beb0ea5d16d39ea26904e ...@@ -60,7 +60,7 @@ commit = d7b20bbc5f6fdcfc312beb0ea5d16d39ea26904e
[submodule.dune-grid-glue] [submodule.dune-grid-glue]
remote = https://github.com/dune-mirrors/dune-grid-glue.git remote = https://github.com/dune-mirrors/dune-grid-glue.git
status = status =
commit = e9d9a3336735090648637e044e279866bbea3597 commit = 9e29a333e8af02382d80b95335a784d5ce1ea2c8
[submodule.dune-istl] [submodule.dune-istl]
remote = https://github.com/dune-mirrors/dune-istl.git remote = https://github.com/dune-mirrors/dune-istl.git
...@@ -95,7 +95,7 @@ commit = 0a74e7dd0b2115778a5d490dab08a2ed07fcaa1e ...@@ -95,7 +95,7 @@ commit = 0a74e7dd0b2115778a5d490dab08a2ed07fcaa1e
[submodule.dune-xt-common] [submodule.dune-xt-common]
remote = git@github.com:dune-community/dune-xt-common.git remote = git@github.com:dune-community/dune-xt-common.git
status = 2424627f0ad5de7e4aaa5e7f48bc2a02414d95a1 .vcsetup (heads/master) status = 2424627f0ad5de7e4aaa5e7f48bc2a02414d95a1 .vcsetup (heads/master)
commit = aa99fc15ae0bc467e0f0df0e48721ab66a9bb74a commit = 84d7fed4cae2675c20a76a0e308045d85ffcc631
[submodule.dune-xt-data] [submodule.dune-xt-data]
remote = git@github.com:dune-community/dune-xt-data remote = git@github.com:dune-community/dune-xt-data
...@@ -115,7 +115,7 @@ commit = 9432a18b5de2931e06bf1b4eeefa8de1d1820c0f ...@@ -115,7 +115,7 @@ commit = 9432a18b5de2931e06bf1b4eeefa8de1d1820c0f
[submodule.dune-xt-la] [submodule.dune-xt-la]
remote = git@github.com:dune-community/dune-xt-la.git remote = git@github.com:dune-community/dune-xt-la.git
status = 2424627f0ad5de7e4aaa5e7f48bc2a02414d95a1 .vcsetup (heads/master) status = 2424627f0ad5de7e4aaa5e7f48bc2a02414d95a1 .vcsetup (heads/master)
commit = e8e217cac638356cc267d1833f076adca7169fb4 commit = 60dc842dba1233c5d767e7dcfa796280bd43bb82
[submodule.scripts] [submodule.scripts]
remote = https://github.com/wwu-numerik/scripts.git remote = https://github.com/wwu-numerik/scripts.git
......
...@@ -28,14 +28,6 @@ namespace XT { ...@@ -28,14 +28,6 @@ namespace XT {
namespace LA { namespace LA {
namespace internal { namespace internal {
// avoid Wfloat-equal warning
template <class FieldType>
inline bool is_zero(const FieldType& val)
{
return std::equal_to<FieldType>()(val, FieldType(0));
}
// computes the LDL^T factorization of a tridiagonal matrix // computes the LDL^T factorization of a tridiagonal matrix
template <class FirstVectorType, class SecondVectorType> template <class FirstVectorType, class SecondVectorType>
void tridiagonal_ldlt(FirstVectorType& diag, SecondVectorType& subdiag) void tridiagonal_ldlt(FirstVectorType& diag, SecondVectorType& subdiag)
...@@ -105,7 +97,7 @@ void cholesky_rowwise(MatrixType& A) ...@@ -105,7 +97,7 @@ void cholesky_rowwise(MatrixType& A)
for (size_t kk = 0; kk < jj; ++kk) for (size_t kk = 0; kk < jj; ++kk)
L_ij -= M::get_entry(L, ii, kk) * M::get_entry(L, jj, kk); L_ij -= M::get_entry(L, ii, kk) * M::get_entry(L, jj, kk);
L_ij /= M::get_entry(L, jj, jj); L_ij /= M::get_entry(L, jj, jj);
if (!only_set_nonzero || !is_zero(L_ij)) if (!only_set_nonzero || !XT::Common::is_zero(L_ij))
M::set_entry(L, ii, jj, L_ij); M::set_entry(L, ii, jj, L_ij);
} // jj } // jj
auto L_ii = M::get_entry(A, ii, ii); auto L_ii = M::get_entry(A, ii, ii);
...@@ -137,7 +129,7 @@ void cholesky_colwise(MatrixType& A) ...@@ -137,7 +129,7 @@ void cholesky_colwise(MatrixType& A)
for (size_t kk = 0; kk < jj; ++kk) for (size_t kk = 0; kk < jj; ++kk)
L_ij -= M::get_entry(L, ii, kk) * M::get_entry(L, jj, kk); L_ij -= M::get_entry(L, ii, kk) * M::get_entry(L, jj, kk);
L_ij *= L_jj_inv; L_ij *= L_jj_inv;
if (!only_set_nonzero || !is_zero(L_ij)) if (!only_set_nonzero || !XT::Common::is_zero(L_ij))
M::set_entry(L, ii, jj, L_ij); M::set_entry(L, ii, jj, L_ij);
} // ii } // ii
} // jj } // jj
...@@ -167,7 +159,7 @@ cholesky_csr(MatrixType& A) ...@@ -167,7 +159,7 @@ cholesky_csr(MatrixType& A)
L_ij -= entries[ll++] * entries[kk++]; L_ij -= entries[ll++] * entries[kk++];
} }
L_ij /= M::get_entry(L, jj, jj); L_ij /= M::get_entry(L, jj, jj);
if (!is_zero(L_ij)) if (!XT::Common::is_zero(L_ij))
M::set_entry(L, ii, jj, L_ij); M::set_entry(L, ii, jj, L_ij);
} // jj } // jj
auto L_ii = M::get_entry(A, ii, ii); auto L_ii = M::get_entry(A, ii, ii);
......
...@@ -47,14 +47,14 @@ namespace internal { ...@@ -47,14 +47,14 @@ namespace internal {
template <class ScalarType> template <class ScalarType>
struct MatrixBackendBase struct MatrixBackendBase
{ {
MatrixBackendBase(size_t num_rows, size_t num_cols, const ScalarType value) MatrixBackendBase(const size_t num_rows, const size_t num_cols, const ScalarType value)
: num_rows_(num_rows) : num_rows_(num_rows)
, num_cols_(num_cols) , num_cols_(num_cols)
, entries_(num_rows_ * num_cols_, value) , entries_(num_rows_ * num_cols_, value)
{ {
} }
void resize(size_t num_rows, size_t num_cols) void resize(const size_t num_rows, const size_t num_cols)
{ {
num_rows_ = num_rows; num_rows_ = num_rows;
num_cols_ = num_cols; num_cols_ = num_cols;
...@@ -75,17 +75,17 @@ struct CommonDenseMatrixBackend<ScalarType, Common::StorageLayout::dense_row_maj ...@@ -75,17 +75,17 @@ struct CommonDenseMatrixBackend<ScalarType, Common::StorageLayout::dense_row_maj
{ {
using BaseType = MatrixBackendBase<ScalarType>; using BaseType = MatrixBackendBase<ScalarType>;
CommonDenseMatrixBackend(size_t num_rows, size_t num_cols, const ScalarType value = ScalarType(0)) CommonDenseMatrixBackend(const size_t num_rows, const size_t num_cols, const ScalarType value = ScalarType(0))
: BaseType(num_rows, num_cols, value) : BaseType(num_rows, num_cols, value)
{ {
} }
ScalarType& get_entry_ref(size_t rr, size_t cc) ScalarType& get_entry_ref(const size_t rr, const size_t cc)
{ {
return entries_[rr * num_cols_ + cc]; return entries_[rr * num_cols_ + cc];
} }
const ScalarType& get_entry_ref(size_t rr, size_t cc) const const ScalarType& get_entry_ref(const size_t rr, const size_t cc) const
{ {
return entries_[rr * num_cols_ + cc]; return entries_[rr * num_cols_ + cc];
} }
...@@ -101,17 +101,17 @@ struct CommonDenseMatrixBackend<ScalarType, Common::StorageLayout::dense_column_ ...@@ -101,17 +101,17 @@ struct CommonDenseMatrixBackend<ScalarType, Common::StorageLayout::dense_column_
{ {
using BaseType = MatrixBackendBase<ScalarType>; using BaseType = MatrixBackendBase<ScalarType>;
CommonDenseMatrixBackend(size_t num_rows, size_t num_cols, const ScalarType value = ScalarType(0)) CommonDenseMatrixBackend(const size_t num_rows, const size_t num_cols, const ScalarType value = ScalarType(0))
: BaseType(num_rows, num_cols, value) : BaseType(num_rows, num_cols, value)
{ {
} }
ScalarType& get_entry_ref(size_t rr, size_t cc) ScalarType& get_entry_ref(const size_t rr, const size_t cc)
{ {
return entries_[cc * num_rows_ + rr]; return entries_[cc * num_rows_ + rr];
} }
const ScalarType& get_entry_ref(size_t rr, size_t cc) const const ScalarType& get_entry_ref(const size_t rr, const size_t cc) const
{ {
return entries_[cc * num_rows_ + rr]; return entries_[cc * num_rows_ + rr];
} }
...@@ -540,6 +540,27 @@ public: ...@@ -540,6 +540,27 @@ public:
} }
} // ... ensure_uniqueness(...) } // ... ensure_uniqueness(...)
ScalarType& get_entry_ref(const size_t rr, const size_t cc)
{
return backend_.get_entry_ref(rr, cc);
}
const ScalarType& get_entry_ref(const size_t rr, const size_t cc) const
{
return backend_.get_entry_ref(rr, cc);
}
// get pointer to begin of row (row major backend) or column (column major backend)
ScalarType* get_ptr(const size_t row_or_col)
{
return &(backend_->get_entry_ref(row_or_col, 0));
}
const ScalarType* get_ptr(const size_t row_or_col) const
{
return &(backend_->get_entry_ref(row_or_col, 0));
}
private: private:
mutable std::shared_ptr<BackendType> backend_; mutable std::shared_ptr<BackendType> backend_;
mutable std::shared_ptr<std::vector<std::mutex>> mutexes_; mutable std::shared_ptr<std::vector<std::mutex>> mutexes_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment