Skip to content

Commit 11fae57

Browse files
author
Sami Hatna
committed
Merge branch 'main' into 'Tadej-Review'
# Conflicts: # README.md # external/Actor.cpp # external/Actor.hpp # external/CMakeLists.txt # external/DifferentialEq.cpp # external/DifferentialEq.hpp # external/Heatmap.cpp # external/Heatmap.hpp # external/MathHelper.cpp # external/MathHelper.hpp # external/ParseInputFile.cpp # external/ParseInputFile.hpp # external/Path.cpp # external/Path.hpp # external/RandomNumber.cpp # external/RandomNumber.hpp # external/Room.cpp # external/Room.hpp # external/Stats.cpp # external/Stats.hpp # scripts/InputFileGenerator.py # src/main.cpp
2 parents 28e5136 + dd78644 commit 11fae57

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

external/VectorMaths.cpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/***************************************************************************
2+
*
3+
* Copyright (C) 2022 Codeplay Software Ltd.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* Codeplay's crowd-simulation
18+
*
19+
* VectorMaths.cpp
20+
*
21+
* Description:
22+
* Operator overloading for common operators on vectors
23+
*
24+
**************************************************************************/
25+
26+
#include "VectorMaths.hpp"
27+
28+
SYCL_EXTERNAL vecType operator*=(vecType &a, vecType b) {
29+
a[0] *= b[0];
30+
a[1] *= b[1];
31+
return a;
32+
}
33+
34+
SYCL_EXTERNAL vecType operator*(vecType a, vecType b) { return a *= b; }
35+
36+
SYCL_EXTERNAL vecType operator+=(vecType &a, vecType b) {
37+
a[0] += b[0];
38+
a[1] += b[1];
39+
return a;
40+
}
41+
42+
SYCL_EXTERNAL vecType operator+(vecType a, vecType b) { return a += b; }
43+
44+
SYCL_EXTERNAL vecType operator-=(vecType &a, vecType b) {
45+
a[0] -= b[0];
46+
a[1] -= b[1];
47+
return a;
48+
}
49+
50+
SYCL_EXTERNAL vecType operator-(vecType a, vecType b) { return a -= b; }
51+
52+
SYCL_EXTERNAL vecType operator*=(vecType &a, float s) {
53+
a[0] *= s;
54+
a[1] *= s;
55+
return a;
56+
}
57+
58+
SYCL_EXTERNAL vecType operator*(vecType a, float s) { return a *= s; }
59+
60+
SYCL_EXTERNAL vecType operator*=(float s, vecType &a) {
61+
a[0] *= s;
62+
a[1] *= s;
63+
return a;
64+
}
65+
66+
SYCL_EXTERNAL vecType operator*(float s, vecType a) { return a *= s; }
67+
68+
SYCL_EXTERNAL vecType operator/=(vecType &a, float s) {
69+
a[0] /= s;
70+
a[1] /= s;
71+
return a;
72+
}
73+
74+
SYCL_EXTERNAL vecType operator/(vecType a, float s) { return a /= s; }

external/VectorMaths.hpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/***************************************************************************
2+
*
3+
* Copyright (C) 2022 Codeplay Software Ltd.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* Codeplay's crowd-simulation
18+
*
19+
* VectorMaths.hpp
20+
*
21+
* Description:
22+
* Operator overloading for common operators on vectors
23+
*
24+
**************************************************************************/
25+
26+
#ifndef VectorMaths_hpp
27+
#define VectorMaths_hpp
28+
29+
#include <array>
30+
#include <cmath>
31+
#include <iostream>
32+
#include <sycl/sycl.hpp>
33+
34+
// Any file which includes VectorMaths.hpp will have this alias
35+
using vecType = std::array<float, 2>;
36+
37+
SYCL_EXTERNAL vecType operator*=(vecType &a, vecType b);
38+
SYCL_EXTERNAL vecType operator*(vecType a, vecType b);
39+
40+
SYCL_EXTERNAL vecType operator+=(vecType &a, vecType b);
41+
SYCL_EXTERNAL vecType operator+(vecType a, vecType b);
42+
43+
SYCL_EXTERNAL vecType operator-=(vecType &a, vecType b);
44+
SYCL_EXTERNAL vecType operator-(vecType a, vecType b);
45+
46+
SYCL_EXTERNAL vecType operator*=(vecType &a, float s);
47+
SYCL_EXTERNAL vecType operator*(vecType a, float s);
48+
SYCL_EXTERNAL vecType operator*=(float s, vecType &a);
49+
SYCL_EXTERNAL vecType operator*(float s, vecType a);
50+
51+
SYCL_EXTERNAL vecType operator/=(vecType &a, float s);
52+
SYCL_EXTERNAL vecType operator/(vecType a, float s);
53+
54+
#endif

0 commit comments

Comments
 (0)