Integrate Refactor solver sources and dual MSVC CMake builds

This commit is contained in:
KOKO\Mimi
2026-10-18 02:10:51 +09:00
parent 7ee32e5837
commit 12d51480de
218 changed files with 17842 additions and 9689 deletions
+16 -3
View File
@@ -88,6 +88,12 @@ inline double Rounded(HighLow value) {
/// @brief Adds normalized expansions; rounding of discarded tail is bounded.
inline HighLow Add(HighLow left, HighLow right) {
if (!IsNormalized(left) || !IsNormalized(right)) return InvalidHighLow();
// Exact-zero additions only normalize signed zero in the retained pair.
// The nonzero graph and its discarded-tail association stay unchanged.
if (left.high == 0 && left.low == 0)
return {right.high, right.low == 0 ? 0.0 : right.low};
if (right.high == 0 && right.low == 0)
return {left.high, left.low == 0 ? 0.0 : left.low};
const auto head = TwoSum(left.high, right.high);
const auto tail = TwoSum(left.low, right.low);
const auto middle = TwoSum(head.low, tail.high);
@@ -164,9 +170,16 @@ inline HighLow TwoProduct(double left, double right) {
inline HighLow Multiply(HighLow left, HighLow right) {
if (!IsNormalized(left) || !IsNormalized(right)) return InvalidHighLow();
auto product = TwoProduct(left.high, right.high);
product = Add(product, TwoProduct(left.high, right.low));
product = Add(product, TwoProduct(left.low, right.high));
return Add(product, TwoProduct(left.low, right.low));
// Omitted terms are exact zero; retain the zero normalization that preceded
// a nonzero low-high term and the final canonicalization/invalid check.
if (right.low != 0)
product = Add(product, TwoProduct(left.high, right.low));
else if (left.low != 0)
product = Add(product, HighLow{});
if (left.low != 0)
product = Add(product, TwoProduct(left.low, right.high));
return Add(product, left.low != 0 && right.low != 0
? TwoProduct(left.low, right.low) : HighLow{});
}
/// @brief Orders canonical values; 2 means unordered/unsupported input.
inline int Compare(HighLow left, HighLow right) {