diff options
author | Adrian Kummerlaender | 2018-04-02 17:57:20 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2018-04-02 17:57:20 +0200 |
commit | b17ca1d07d5726469e247e9326a56f8b2ee1644f (patch) | |
tree | 965d829cd5591d7eadb0386a06d572f667df3f5f /src | |
parent | 79d97560ccebb3f90a580030c9f06b16e280f4ba (diff) | |
download | boltzbub-b17ca1d07d5726469e247e9326a56f8b2ee1644f.tar boltzbub-b17ca1d07d5726469e247e9326a56f8b2ee1644f.tar.gz boltzbub-b17ca1d07d5726469e247e9326a56f8b2ee1644f.tar.bz2 boltzbub-b17ca1d07d5726469e247e9326a56f8b2ee1644f.tar.lz boltzbub-b17ca1d07d5726469e247e9326a56f8b2ee1644f.tar.xz boltzbub-b17ca1d07d5726469e247e9326a56f8b2ee1644f.tar.zst boltzbub-b17ca1d07d5726469e247e9326a56f8b2ee1644f.zip |
Improve boundary cond impl via better vector support
Diffstat (limited to 'src')
-rw-r--r-- | src/vector.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/vector.h b/src/vector.h index e0dc239..3a3ed5c 100644 --- a/src/vector.h +++ b/src/vector.h @@ -31,6 +31,10 @@ struct Vector { }; } + Vector<T> operator-() const { + return -1 * *this; + } + Vector<T>& operator+=(const Vector<T>& rhs) { data[0] += rhs[0]; data[1] += rhs[1]; @@ -39,9 +43,25 @@ struct Vector { }; template <typename T> -Vector<T> operator*(T scalar, const Vector<T>& vec) { +Vector<T> operator*(T scalar, const Vector<T>& v) { + return Vector<T>{ + v[0] * scalar, + v[1] * scalar + }; +} + +template <typename T, typename W> +Vector<T> operator-(const Vector<T>& a, const Vector<W>& b) { + return Vector<T>{ + a[0] - b[0], + a[1] - b[1] + }; +} + +template <typename T, typename W> +Vector<T> operator+(const Vector<T>& a, const Vector<W>& b) { return Vector<T>{ - vec[0] * scalar, - vec[1] * scalar + a[0] + b[0], + a[1] + b[1] }; } |