Integrate Refactor solver sources and dual MSVC CMake builds
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
@@ -83,5 +84,31 @@ TEST(DenseMath, VectorOwnsAndChecksContiguousStorage) {
|
||||
EXPECT_THROW(original.Axpy(1.0, Vector{2}), std::invalid_argument);
|
||||
}
|
||||
|
||||
|
||||
TEST(DenseMath, VectorRobustNormSelfAliasAndNonfinitePropagation) {
|
||||
Vector large{2U, 1.0e308};
|
||||
EXPECT_NEAR(large.Norm() / 1.0e308, std::sqrt(2.0), 4.0e-16);
|
||||
Vector tiny{2U, 1.0e-300};
|
||||
EXPECT_NEAR(tiny.Norm() / 1.0e-300, std::sqrt(2.0), 4.0e-16);
|
||||
Vector values{2U};
|
||||
values[0] = 2.0;
|
||||
values[1] = -3.0;
|
||||
values.Axpy(-2.0, values);
|
||||
EXPECT_DOUBLE_EQ(values[0], -2.0);
|
||||
EXPECT_DOUBLE_EQ(values[1], 3.0);
|
||||
const Vector* same = &values;
|
||||
values = *same;
|
||||
Vector* mutable_same = &values;
|
||||
values = std::move(*mutable_same);
|
||||
EXPECT_DOUBLE_EQ(values.Dot(values), 13.0);
|
||||
Vector nonfinite{1U, (std::numeric_limits<double>::quiet_NaN)()};
|
||||
EXPECT_TRUE(std::isnan(nonfinite.Dot(Vector{1U, 1.0})));
|
||||
EXPECT_TRUE(std::isnan(nonfinite.Norm()));
|
||||
EXPECT_NO_THROW(nonfinite.Scale(2.0));
|
||||
EXPECT_NO_THROW(nonfinite.Axpy(1.0, Vector{1U, 1.0}));
|
||||
EXPECT_TRUE(std::isnan(nonfinite[0]));
|
||||
EXPECT_DOUBLE_EQ(Vector{0U}.Dot(Vector{0U}), 0.0);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace fesa
|
||||
|
||||
Reference in New Issue
Block a user