Skip to content
Snippets Groups Projects
Commit ae0f8560 authored by Timo Koch's avatar Timo Koch
Browse files

[test] Use constexpr if instead of ifElse

parent da53c670
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,6 @@
#include <dune/common/classname.hh>
#include <dune/common/std/type_traits.hh>
#include <dune/common/test/testsuite.hh>
#include <dune/common/hybridutilities.hh>
#include <dune/common/scalarvectorview.hh>
template<typename T>
......@@ -70,40 +69,36 @@ Dune::TestSuite DotProductTest(const size_t numBlocks,const size_t blockSizeOrCa
ct result = ct();
// blockwise dot tests
Dune::Hybrid::ifElse(Dune::Std::negation<Dune::IsNumber<RealBlockType>>(),
[&](auto id) {
result = ct();
for(size_type i=0; i < numBlocks; ++i) {
result += dot(id(one[i]),id(one[i])) + (id(one[i])).dot(id(one[i]));
}
t.check(std::abs(result-ct(2)*ctlength)<= myEps);
if constexpr (!Dune::IsNumber<RealBlockType>{}){
result = ct();
for(size_type i=0; i < numBlocks; ++i) {
result += dot(one[i],one[i]) + (one[i]).dot(one[i]);
}
result = ct();
for(size_type i=0; i < numBlocks; ++i) {
result += dot(id(iVec[i]),id(iVec[i]))+ (id(iVec[i])).dot(id(iVec[i]));
}
t.check(std::abs(result-ct(2)*ctlength)<= myEps);
t.check(std::abs(result-ct(2)*ctlength)<= myEps);
result = ct();
for(size_type i=0; i < numBlocks; ++i) {
result += dot(iVec[i],iVec[i])+ (iVec[i]).dot(iVec[i]);
}
// blockwise dotT / operator * tests
result = ct();
for(size_type i=0; i < numBlocks; ++i) {
result += dotT(id(one[i]),id(one[i])) + id(one[i])*id(one[i]);
}
t.check(std::abs(result-ct(2)*ctlength)<= myEps);
t.check(std::abs(result-ct(2)*ctlength)<= myEps);
// blockwise dotT / operator * tests
result = ct();
for(size_type i=0; i < numBlocks; ++i) {
result += dotT(one[i],one[i]) + one[i]*one[i];
}
result = ct();
for(size_type i=0; i < numBlocks; ++i) {
result += dotT(id(iVec[i]),id(iVec[i])) + id(iVec[i])*id(iVec[i]);
}
t.check(std::abs(result-ct(2)*ctlength)<= myEps);
t.check(std::abs(result-complexSign*ct(2)*ctlength)<= myEps);
result = ct();
for(size_type i=0; i < numBlocks; ++i) {
result += dotT(iVec[i],iVec[i]) + iVec[i]*iVec[i];
}
,
[&](auto id){}
); // end Hybrid::ifElse
t.check(std::abs(result-complexSign*ct(2)*ctlength)<= myEps);
}
// global operator * tests
result = one*one + dotT(one,one);
......
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