Created
November 26, 2015 14:03
-
-
Save wrr/ee28edd317f34e833e62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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