32#include <gtest/gtest.h>
44#define EXAMPLE_DIR "/Users/mike/src/git-from-others/msolve/MES-examples/"
50TEST(MatrixIO, readPolynomial)
52 std::string polyStr {
"13*x^2*y-x*y-2" };
53 std::vector<std::string> varnames = {
"x",
"y",
"z"};
55 EXPECT_TRUE(
result.termCount() == 3);
56 std::cout <<
"poly: ";
57 std::cout <<
result.toString(varnames);
59 EXPECT_TRUE(polyStr ==
result.toString(varnames));
61 polyStr =
"-x+y^2-13*x*y*z+1";
63 std::cout <<
"poly: " <<
result.toString(varnames) <<
'\n';
64 EXPECT_TRUE(
result.toString(varnames) == polyStr);
65 std::cout <<
"bytes used: " <<
result.bytesUsed() <<
'\n';
68 polyStr =
"2*x+y^2-13*x*y*z-1";
70 std::cout <<
"poly: " <<
result.toString(varnames) <<
'\n';
71 EXPECT_TRUE(
result.toString(varnames) == polyStr);
74TEST(MatrixIO, readPolynomialErrors)
76 std::vector<std::string> varnames = {
"x",
"y",
"z"};
81 std::cout <<
"expected parse error: " << e.what() << std::endl;
88 std::cout <<
"expected parse error: " << e.what() << std::endl;
95 std::cout <<
"expected parse error: " << e.what() << std::endl;
103 std::string contents = R
"(#Reduced Groebner basis data
105#field characteristic: 1235952427
106#variable order: x, y, z
107#monomial order: graded reverse lexicographical
108#length of basis: 4 elements sorted by increasing leading monomials
110[1*x^1+2*y^1+2*z^1+1235952426,
1111*y^1*z^1+494380972*z^2+370785728*y^1+247190485*z^1,
1121*y^2+988761941*z^2+741571456*y^1+494380971*z^1,
1131*z^3+924021576*z^2+700373042*y^1+653289140*z^1]:
117 std::cout <<
"bytes used for poly list: " <<
bytesUsed(
result) <<
'\n';
118 EXPECT_TRUE(
result.size() == 4);
123 EXPECT_TRUE(M->n_rows() == 1);
124 EXPECT_TRUE(M->n_cols() == 4);
128TEST(MatrixIO, readMsolveBig1)
130 std::string filename {
EXAMPLE_DIR"6pts-a-gb.ms" };
132 EXPECT_TRUE(B.size() == 1019);
133 std::cout <<
"bytes used for poly list: " <<
bytesUsed(B) <<
'\n';
136 std::vector<std::string> varnames {
"t12",
"t13",
"t14",
"t15",
"t16",
137 "t23",
"t24",
"t25",
"t26",
"t34",
"t35",
"t36",
"t45",
"t46",
"t56",
"z1",
"z2"};
146 std::cout <<
"Number of monomials: " << monHashTable.
size() << std::endl;
154TEST(MatrixIO, readMsolveBig2)
156 std::string filename {
EXAMPLE_DIR"6pts-b-gb.ms" };
158 EXPECT_TRUE(B.size() == 1391);
159 std::cout <<
"bytes used: " <<
bytesUsed(B) <<
'\n';
161 std::vector<std::string> varnames {
"t12",
"t13",
"t14",
"t15",
"t16",
162 "t23",
"t24",
"t25",
"t26",
"t34",
"t35",
"t36",
"t45",
"t46",
"t56",
"z1",
"z2"};
171 std::cout <<
"Number of monomials: " << monHashTable.
size() << std::endl;
180TEST(MatrixIO, readMsolveBig3)
184 EXPECT_TRUE(B.size() == 4761);
185 std::cout <<
"bytes used: " <<
bytesUsed(B) <<
'\n';
188 std::vector<std::string> varnames {
189 "a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
190 "n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
191 "A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
192 "M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V"
210 gbInterface.computation().dumpBasisMonomials();
228TEST(MatrixIO, readPolys)
230 std::string contents = R
"(1*x^1+2*y^1+2*z^1+1235952426
2311*y^1*z^1+494380972*z^2+370785728*y^1+247190485*z^1
2321*y^2+988761941*z^2+741571456*y^1+494380971*z^1
2331*z^3+924021576*z^2+700373042*y^1+653289140*z^1
236 std::vector<std::string> varnames = {"x",
"y",
"z"};
238 EXPECT_TRUE(
result.size() == 4);
243 EXPECT_TRUE(M->
n_rows() == 1);
244 EXPECT_TRUE(M->
n_cols() == 4);
248 std::cout << o.
str() << std::endl;
253dot = (e) -> (sum
for i from 0 to 19 list ((e#i * vals#i) % 2^64)) % 2^20
254 dot = (e) -> ((sum
for i from 0 to 19 list ((e#i * vals#i) % 2^64)) >> 25) % 2^20
255vals = {12550986463692465404, 3911555212215091238, 15090669942851505316, 16174113364685515424, 18172793978567602378, 4970727551569665824, 15244287395755336378, 3641586221293608170, 5697307520845005385, 17982501052917221133, 4205210476184990958, 3995014217224167515, 10391875845945764299, 17483720614571824287, 1115562083531405255, 7842315096810324507, 673864007402015535, 15878473700446701422, 15632675738063166334, 17700395182034373329}
256 R =
ZZ/101[t_0..t_19]
257 exps = (flatten entries basis(0,6,R))/
exponents/first;
258 allhashes =
for e in exps list dot e;
259(#allhashes, #unique allhashes)
261max values tally allhashes
BasicPoly parseBasicPoly(std::string poly, std::vector< std::string > varnames)
long bytesUsed(const BasicPolyList &F)
const Matrix * toMatrix(const FreeModule *target, const BasicPolyList &Fs)
void toStream(const BasicPolyList &Fs, S &str)
Ring-agnostic polynomial-list transport type plus its streaming collector and emitter.
BasicPolyList parseMsolveFile(std::string filename)
BasicPolyList parseMsolveFromString(std::string contents)
BasicPolyList parseBasicPolyListFromString(std::string contents, const IdentifierHash &idenMap)
Parsers from text (string or file) into a BasicPolyList, including the Msolve input format.
ExponentVector< int, true > exponents
Legacy-to-new-F4 adapter exposing GBF4Computation through the engine's GBComputation API.
TEST(MatrixIO, readPolynomial)
Hash-table-keyed polynomial storage for the new F4.
Coefficient-ring-erased arithmetic dispatcher used by F4, GB, and resolution code.
void text_out(buffer &o) const
virtual const Ring * getCoefficients() const
Abstract base for the engine's polynomial-ring hierarchy.
virtual FreeModule * make_FreeModule() const
Runtime dispatcher that hides the concrete coefficient ring behind a std::variant of ConcreteVectorAr...
void dump() const
stats and debugging information.
auto size() const -> size_t
The actual number of monomials in the table.
implements the stream functions for creating a PolynomialList from a stream
VALGRIND_MAKE_MEM_DEFINED & result(result)
Matrix — the engine's immutable homomorphism F -> G between free modules.
const PolynomialRing * simplePolynomialRing(const Ring *kk, const std::vector< std::string > &names, MonomialOrdering *monorder)
One-line helpers for building degree monoids and polynomial rings inside gtest cases.