Skip to content

Commit

Permalink
added operator for adding 2 vecs
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeMyst committed Jun 20, 2020
1 parent 0ebe133 commit 00a8da5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/cosmomyst/math/vector.d
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ struct vec(ulong n) if (n >= 1) {
return res;
}

/++
+ returns the sum of 2 vectors
+/
@nogc vec!n opBinary(string s) (const vec!n other) const if (s == "+") {
vec!n res;
for (int i = 0; i < n; i++) {
res.v[i] = v[i] + other.v[i];
}
return res;
}

/++
+ returns the sub of 2 vectors.
+/
Expand Down

0 comments on commit 00a8da5

Please sign in to comment.