void testMultiplicationSquares(std::size_t noBits, DynamicElementStorageType lhsStorage, DynamicElementStorageType rhsStorage)
{
    Bitset activeBits;
    for(std::size_t i = 0; i < noBits; ++i)
        activeBits[std::rand() & MAX_K_VALUE] = true;

    Element lhs(activeBits, lhsStorage);

    // get a non-zero value
    Z2k value;
    while(value.getValue() == 0)
        value = Z2k( rand() & activeBits.to_ulong() );

    // get a coeff
    GaloisField coeff( rand() & 255 );

    lhs.setCoefficient(value, coeff);
    lhs.setCoefficient(Z2k(), coeff);


    Element rhs(lhs, rhsStorage);

    Element prod;
    algebra.multiply(lhs, rhs, prod);

    BOOST_CHECK_EQUAL(prod.isZero(), true);
}
Beispiel #2
0
void initializeElement(Element & element, const Bitset & activeBits, std::size_t noElements)
{
    for(std::size_t i = 0; i < noElements; ++i)
        element.setCoefficient(Z2k( rand() & activeBits.to_ulong() ), GaloisField( rand() & 255 ));
}