Skip to content

Commit a08b3f6

Browse files
committed
fixup! WIP: Schoenhage-Strassen debugging
1 parent 5290671 commit a08b3f6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/solvers/flattening/bv_utils.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,7 +2190,7 @@ bvt bv_utilst::unsigned_schoenhage_strassen_multiplier(
21902190
bvt b = a;
21912191
PRECONDITION(a.size() == b.size());
21922192

2193-
// Running examples: we want to multiple 213 by 15 as 8- or 9-bit integers.
2193+
// Running example: we want to multiply 213 by 15 as 8- or 9-bit integers.
21942194
// That is, we seek to multiply 11010101 (011010101) by 00001111 (000001111).
21952195
// ^bit 7 ^bit 0
21962196
// The expected result is 123 as both an 8-bit and 9-bit result (001111011).
@@ -2245,8 +2245,10 @@ bvt bv_utilst::unsigned_schoenhage_strassen_multiplier(
22452245
{
22462246
a_rho.emplace_back(
22472247
a_ext.begin() + i * chunk_size, a_ext.begin() + (i + 1) * chunk_size);
2248+
std::cerr << "a_rho[" << i << "]: " << beautify(a_rho.back()) << std::endl;
22482249
b_sigma.emplace_back(
22492250
b_ext.begin() + i * chunk_size, b_ext.begin() + (i + 1) * chunk_size);
2251+
std::cerr << "b_sigma[" << i << "]: " << beautify(b_sigma.back()) << std::endl;
22502252
}
22512253
// For our example we now have
22522254
// a_rho = [ 0101, 1101, 0000, ..., 0000 ]
@@ -2268,11 +2270,13 @@ bvt bv_utilst::unsigned_schoenhage_strassen_multiplier(
22682270
++rho)
22692271
{
22702272
const std::size_t sigma = tau - rho;
2273+
std::cerr << "Inner multiplication a_" << rho << " * b_" << sigma << std::endl;
22712274
gamma_tau[tau] = add(
22722275
gamma_tau[tau],
2276+
zero_extension(
22732277
unsigned_multiplier(
2274-
zero_extension(a_rho[rho], 3 * n + 5),
2275-
zero_extension(b_sigma[sigma], 3 * n + 5)));
2278+
zero_extension(a_rho[rho], chunk_size * 2),
2279+
zero_extension(b_sigma[sigma], chunk_size * 2)), 3 * n + 5));
22762280
}
22772281
}
22782282
// For our example we obtain
@@ -2284,6 +2288,7 @@ bvt bv_utilst::unsigned_schoenhage_strassen_multiplier(
22842288
c_tau.reserve(num_chunks);
22852289
for(std::size_t tau = 0; tau < num_chunks; ++tau)
22862290
{
2291+
std::cerr << "gamma_tau[" << tau << "]: " << beautify(gamma_tau[tau]) << std::endl;
22872292
c_tau.push_back(add(gamma_tau[tau], gamma_tau[tau + num_chunks]));
22882293
CHECK_RETURN(c_tau.back().size() >= address_bits(num_chunks) + 1);
22892294
c_tau.back().resize(address_bits(num_chunks) + 1);
@@ -2292,6 +2297,10 @@ bvt bv_utilst::unsigned_schoenhage_strassen_multiplier(
22922297
// For our example we obtain
22932298
// c_tau = [ 01011, 00011, 0... ]
22942299

2300+
// XXX 19*19 seems ok up to here with
2301+
// http://malte-leip.net/beschreibung_ssa.pdf,
2302+
// https://de.wikipedia.org/wiki/Sch%C3%B6nhage-Strassen-Algorithmus
2303+
22952304
// Compute z_j = c_j - c_{j + 2^n} (mod 2^(n + 2)) (mod 2^(n + 1) and c_{j +
22962305
// 2^(n - 1)} when m is even)
22972306
std::vector<bvt> z_j;

0 commit comments

Comments
 (0)