void generateM( Mat &M, MatDom &MD, PolyRing &R, PolyElement &f, PolyElement &g, size_t n, size_t e ) { integer max; R.convert(max, f); max *= 10; Mat L(R, n, n); for (size_t i = 0; i < n; i++) { for (size_t j = 0; j < i; j++) { PolyElement e; R.init(e, rand() % max); R.modin(e, f); L.setEntry(i, j, e); } } for (size_t i = 0; i < n; i++) { L.setEntry(i, i, R.one); } Mat T(R, n, n); for (size_t i = 0; i < n; i++) { for (size_t j = i+1; j < n; j++) { PolyElement e; R.init(e, rand() % max); R.modin(e, f); T.setEntry(i, j, e); } } for (size_t i = 0; i < n; i++) { T.setEntry(i, i, R.one); } Mat D(R, n, n); for (size_t i = 0; i < n; i++) { size_t ei = rand() % e; PolyElement di; R.assign(di, R.one); for (size_t j = 0; j < ei; j++) { R.mulin(di, g); } D.setEntry(i, i, di); if (VERBOSE > 1) { R.write(cout << i << ", " << i << ": ", di) << endl; } } MD.mul(M, L, D); MD.mulin(M, T); if (VERBOSE > 1) { cout << endl; for (size_t i = 0; i < n; i++) { for (size_t j = 0; j < n; j++) { PolyElement e; M.getEntry(e, i, j); R.write(cout << i << ", " << j << ": ", e) << endl; } } } }