Last active
July 23, 2016 10:23
-
-
Save karlnapf/28e1ea447d3d625f2205d303599fa4ff 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
// actual implementation | |
void scale(const Vector& a, float scale, Vector& output) | |
{ | |
for (auto i=0; i<a.vlen; i++) | |
output[i]=a[i]*scale; | |
} | |
// wrapper, for syntatic ease, should be auto-generated | |
Vector& scale(const Vector& a, float scale) | |
{ | |
output = allocate(a.vlen); | |
scale(a, scale, output); | |
retun output; | |
} | |
int size=2; | |
Vector a(size); | |
float scale=2; | |
// auto allocation | |
Vector b=scale(a, scale); | |
// manual buffer | |
Vector buffer(size); | |
scale(a, scale, output); | |
// inplace | |
scale(a, scale, a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment