Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90448814
ncp_functions.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 1, 18:56
Size
1 KB
Mime Type
text/x-c
Expires
Sun, Nov 3, 18:56 (2 d)
Engine
blob
Format
Raw Data
Handle
22076060
Attached To
rSPECMICP SpecMiCP / ReactMiCP
ncp_functions.cpp
View Options
#include "catch.hpp"
#include "micpsolver/ncp_function.hpp"
using specmicp::micpsolver::fisher_burmeister;
using specmicp::micpsolver::penalized_fisher_burmeister;
TEST_CASE("NCP functions") {
SECTION("fisher Burmeister") {
CHECK(fisher_burmeister(0.0, 0.0) == 0.0);
CHECK(fisher_burmeister(0.0, 1.0) == 0.0);
CHECK(fisher_burmeister(0.0, 3.4) == 0.0);
CHECK(std::abs(fisher_burmeister(1.0, 1.0)-std::sqrt(2)+2) == Approx(0.0));
CHECK(std::abs(fisher_burmeister(2.0, 1.0)-std::sqrt(5)+3) == Approx(0.0));
}
SECTION("Penalized Fischer Burmeister") {
CHECK(penalized_fisher_burmeister(0.0, 0.0, 0.5) == 0.0);
CHECK(penalized_fisher_burmeister(0.0, 1.0, 0.3) == 0.0);
CHECK(penalized_fisher_burmeister(0.0, 3.4, 0.5) == 0.0);
CHECK(penalized_fisher_burmeister(8.4, 0.0, 0.2) == 0.0);
CHECK(std::abs(fisher_burmeister(1.0, 1.0)-penalized_fisher_burmeister(1.0, 1.0, 1.0)) == Approx(0.0));
CHECK(std::abs(penalized_fisher_burmeister(2.0, 1.0, 0.5)-0.5*(std::sqrt(5)-3)+0.5*2.0) == Approx(0.0));
}
}
Event Timeline
Log In to Comment