Esempio n. 1
0
    // must accumulate all blocks
    void accumVector(const BlockVector<T>& At,
                     const BlockVector<T>& Bt,
                     const BlockVector<T>& Ct) {
#ifdef USE_ASSERT
        assert(At.space() == Bt.space() &&
               Bt.space() == Ct.space() &&
               At.block() == Bt.block() &&
               Bt.block() == Ct.block());
#endif

        for (std::size_t i = At.startIndex(); i < At.stopIndex(); ++i) {
            m_vec[i] =
                m_random_beta_rA * At[i] +
                m_random_beta_rB * Bt[i] +
                m_random_beta_rC * Ct[i];
        }
    }
Esempio n. 2
0
    // only need to accumulate blocks within number of circuit inputs
    // returns true if At is modified, false otherwise
    bool accumVector(BlockVector<T>& At) {
        const auto limit = std::min(At.stopIndex(), m_vec.size());
        if (At.startIndex() >= limit) {
            return false;

        } else {
            for (std::size_t i = At.startIndex(); i < limit; ++i) {
                m_vec[i] = At[3 + i] * m_random_rA;
#ifdef USE_ASSERT
                assert(! m_vec[i].isZero());
#endif
                At[3 + i] = T::zero();
            }

            return true;
        }
    }