Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
struct Row {
float& operator[](int column) {
return coeffs[column];
}
typedef std::tr1::unordered_map<int, float> RowData;
RowData coeffs;
};
static float Dot(const VectorX &x, const Row &row) {
float sum = 0.0f;
for (Row::RowData::const_iterator it = row.coeffs.begin();
it != row.coeffs.end(); ++it) {
sum += x[it->first] * it->second;
}
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.