コード例 #1
0
BitVector<dim> Subspace<dim>::representative
(const BitVector<dim>& v) const
{
    assert(v.size()==rank());

    // get projection to subspace expressed in d_basis
    BitVector<dim> pv = v;
    pv.slice(d_support);

    assert(pv.size()==dimension()); // |slice| set it to |d_support.count()|

    // expand that linear combination to an element of $(Z/2Z)^n$
    BitVector<dim> w = combination(d_basis,rank(),pv.data());

    assert(w.size()==rank());

    return v+w; // set |r| to original vector minus (or plus) correction |w|
}