Skip to content

Instantly share code, notes, and snippets.

@geraintluff
Last active Jul 20, 2021
Embed
What would you like to do?
/// Example code for in-place multiplcation by a Householder matrix
void inPlaceHouseholder(double *arr, int size) {
// Division is slower, so compute this statically if you can
const double factor = -2.0/size;
double sum = 0;
for (int i = 0; i < size; ++i) {
sum += arr[i];
}
sum *= factor;
for (int i = 0; i < size; ++i) {
arr[i] += sum;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment