Пример #1
0
double SparseRow::timesColumn(const SparseVector &v) const  
{
    double sum = 0;
    int loc;
    for (int cnt = 0; cnt < this->size; ++cnt)
        if (v.isNonZero( loc = nb[cnt].getIx() ))
            sum += v.getValue( loc ) * nb[cnt].getWeight();
    return sum;
}
Пример #2
0
void SparseVector::addTimes(const SparseVector &v, const double &w)  {

    for (int cnt = 0; cnt < v.getNzEntries(); ++cnt)  {

        int ix = v.getIx(cnt);

        this->plusAt( ix, v.getValue(ix) * w );

    }

}