-
-
Save geraintluff/663e42e2519465e8b94df47793076f23 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
/// 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