Skip to content

Commit

Permalink
[configuration] Allow multiplication by negative numbers
Browse files Browse the repository at this point in the history
In SOCC, final solutions are linear combinations of particular solutions
with not necessarily positive coefficients.
  • Loading branch information
krivenko committed May 17, 2022
1 parent 4bf7155 commit b3a2360
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 6 deletions.
3 changes: 0 additions & 3 deletions c++/som/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ configuration configuration::operator+(configuration const& c) const {
}

configuration& configuration::operator*=(double alpha) {
if(alpha < 0)
TRIQS_RUNTIME_ERROR
<< "Cannot multiply a configuration by a negative number " << alpha;
std::transform(rects.begin(), rects.end(), rects.begin(),
[&](rectangle const& r) { return r * alpha; });
cache_ptr.invalidate_entry();
Expand Down
3 changes: 0 additions & 3 deletions test/c++/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ TEST(configuration, Detached) {
TEST(configuration, Arithmetics) {
EXPECT_PRINT(conf1_str + "," + conf2_str, conf1 + conf2);

EXPECT_THROW(-2.0 * conf1, triqs::runtime_error);
EXPECT_THROW(conf1 * (-2.0), triqs::runtime_error);

EXPECT_PRINT("(c:-2, w:2.6, h:0.6),(c:1.3, w:2.6, h:1.2),(c:2, w:2.6, h:1.4)",
2.0 * conf1);
EXPECT_PRINT(
Expand Down

0 comments on commit b3a2360

Please sign in to comment.