|
| 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