Skip to content

Instantly share code, notes, and snippets.

@wrr
Created November 26, 2015 14:03
Show Gist options
  • Save wrr/ee28edd317f34e833e62 to your computer and use it in GitHub Desktop.
Save wrr/ee28edd317f34e833e62 to your computer and use it in GitHub Desktop.
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