Skip to content

Commit

Permalink
Some resolution of a painful bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuDutSik committed Sep 11, 2023
1 parent 353e25b commit 3528c61
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
11 changes: 0 additions & 11 deletions src_matrix/MAT_Matrix_SubsetSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ struct SubsetRankOneSolver_Acceleration {
//
// Faster modular version of EXT_red
//
std::cerr << "SubsetRankOneSolver_Acceleration, constructor, step 1\n";
max_bits = 0;
EXT_fast = MyMatrix<Tfast>(nbRow, nbCol);
EXT_lift = MyMatrix<Tlift>(nbRow, nbCol);
Expand All @@ -70,16 +69,13 @@ struct SubsetRankOneSolver_Acceleration {
}
try_int = (max_bits <= 30);
max_bits += get_bit(static_cast<int64_t>(nbCol));
std::cerr << "SubsetRankOneSolver_Acceleration, constructor, step 2\n";
}

MyVector<Tint> GetKernelVector(Face const& sInc) {
std::cerr << "SubsetRankOneSolver_Acceleration, GetKernelVector, step 1\n";
size_t nb = sInc.count();
MyVector<Tint> Vkernel(nbCol);
bool failed_int = false;
if (try_int) {
std::cerr << "SubsetRankOneSolver_Acceleration, GetKernelVector, step 2\n";
boost::dynamic_bitset<>::size_type jRow = sInc.find_first();
auto f = [&](MyMatrix<Tfast> &M, size_t eRank,
[[maybe_unused]] size_t iRow) -> void {
Expand All @@ -88,7 +84,6 @@ struct SubsetRankOneSolver_Acceleration {
};
MyVector<Tfast> Vzero_Tfast =
NullspaceTrMatTargetOne_Kernel<Tfast, decltype(f)>(nb, nbCol, f);
std::cerr << "SubsetRankOneSolver_Acceleration, GetKernelVector, step 3\n";
// check result at full precision in case of overflows
bool allzero = true;
for (int iCol = 0; iCol < nbCol; iCol++) {
Expand All @@ -97,28 +92,23 @@ struct SubsetRankOneSolver_Acceleration {
break;
}
}
std::cerr << "SubsetRankOneSolver_Acceleration, GetKernelVector, step 4\n";
if (allzero) {
failed_int = true;
} else {
std::cerr << "SubsetRankOneSolver_Acceleration, GetKernelVector, step 5\n";
MyVector<Tlift> VZ_lift(nbCol);
// reconstruct the vector
size_t max_bits_NSP = 0;
std::cerr << "nbCol=" << nbCol << " |Vzero_Tfast|=" << Vzero_Tfast.size() << " |lifts|=" << lifts.size() << "\n";
lifts[0] = Vzero_Tfast(0, 0).rational_lift();
Tlift lcm = lifts[0].second;
for (int iCol = 1; iCol < nbCol; iCol++) {
lifts[iCol] = Vzero_Tfast(iCol).rational_lift();
lcm = LCMpair(lcm, lifts[iCol].second);
}
std::cerr << "SubsetRankOneSolver_Acceleration, GetKernelVector, step 6\n";
for (int iCol = 0; iCol < nbCol; iCol++) {
VZ_lift(iCol) = lifts[iCol].first * (lcm / lifts[iCol].second);
Vkernel(iCol) = UniversalScalarConversion<Tint,Tlift>(VZ_lift(iCol));
max_bits_NSP = std::max(max_bits_NSP, get_bit(VZ_lift(iCol)));
}
std::cerr << "SubsetRankOneSolver_Acceleration, GetKernelVector, step 7\n";
// check if elements are small enough to do computation in
if (max_bits + max_bits_NSP <= 60) {
// check if part of kernel
Expand All @@ -134,7 +124,6 @@ struct SubsetRankOneSolver_Acceleration {
}
jRow = sInc.find_next(jRow);
}
std::cerr << "SubsetRankOneSolver_Acceleration, GetKernelVector, step 8\n";
} else {
failed_int = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src_number/NumberTheoryGmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ mpz_class convert_mpz_class_int64_t(int64_t const& val) {
if (val > 0) {
return convert_mpz_class_uint64_t(val);
}
return convert_mpz_class_uint64_t(-val);
return -convert_mpz_class_uint64_t(-val);
}

#ifdef __APPLE__
Expand Down

0 comments on commit 3528c61

Please sign in to comment.