Skip to content

Instantly share code, notes, and snippets.

@sbugrov
Created July 5, 2017 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbugrov/e121fccb3f6f4adf9625c487f58ea035 to your computer and use it in GitHub Desktop.
Save sbugrov/e121fccb3f6f4adf9625c487f58ea035 to your computer and use it in GitHub Desktop.
vector <float> operator+(const vector <float>& m1, const vector <float>& m2){
/* Returns the elementwise sum of two vectors.
Inputs:
m1: a vector
m2: a vector
Output: a vector, sum of the vectors m1 and m2.
*/
const unsigned long VECTOR_SIZE = m1.size();
vector <float> sum (VECTOR_SIZE);
for (unsigned i = 0; i != VECTOR_SIZE; ++i){
sum[i] = m1[i] + m2[i];
};
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment