void DenseVectorN::from(const VectorN &source) { int length = source.length(); x.resize({length}, 0.0); Offsets offsets = source.getNonZeroOffsets(); for (Offset offset : offsets) { x[offset.first] = offset.second; } }
double DenseVectorN::dot(const VectorN& vec) const { if (vec.getType() == DENSE) { return ddot((const DenseVectorN&)vec); } auto acc = 0.; for (auto offset : vec.getNonZeroOffsets()) { acc += x[offset.first] * offset.second; } return acc; }