Tuesday 13 August 2013

nmod_matxx and some

This morning I started out by writing codegen tests for nmod_polyxx. The results are in line with my expectations: the C++ code is generally a bit longer than handwritten C, but not much. Specifically

void test_nmod_polyxx_1(nmod_polyxx& to, const nmod_polyxx& p1,
            const nmod_polyxx& p2)
{
    to = (p1*p1) + (p2*p2);
}

void test_nmod_polyxx_3(nmod_polyxx& to, const nmod_polyxx& p1,
            const nmod_polyxx& p2)
{
    to = ((p1*p1) + (p2*p2)) + ((p1*p2) + (p2*p1));
}

Both come out about 20% longer than C equivalents, and using a few more stack spill frames (and precisely the same FLINT function calls). Recall that for fmpzxx and similar the code usually gets 10% longer; I attribute this to the fact that nmod_polyxx instantiation requires an additional argument (the modulus) which has to be kept track of.


After that, I wrote a new helper file flintxx/matrix.h encapsulating some code common to (probably) all matrix classes, updated fmpz_matxx to use it, and then I started nmod_matxx (using this new helper). I'm about 75% through with the nmod_matxx functions, will finish and document this tomorrow.

No comments:

Post a Comment