Cindy Liu | b492914 | 2023-10-20 11:36:04 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2023 Google LLC |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Henry Herman | 4112b6f | 2021-08-13 20:50:37 +0000 | [diff] [blame] | 17 | #ifndef SOFTRVV_VSUB_H |
| 18 | #define SOFTRVV_VSUB_H |
| 19 | |
| 20 | #include <stddef.h> |
| 21 | |
| 22 | namespace softrvv { |
| 23 | |
| 24 | template <typename T> |
| 25 | void vsub_vx(T *dest, T *src1, const T *src2, int32_t avl) { |
| 26 | for (int idx = 0; idx < avl; idx++) { |
| 27 | dest[idx] = src1[idx] - *src2; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | template <typename T> |
| 32 | void vsub_vv(T *dest, T *src1, T *src2, int32_t avl) { |
| 33 | for (int32_t idx = 0; idx < avl; idx++) { |
| 34 | dest[idx] = src1[idx] - src2[idx]; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | template <typename T> |
| 39 | void vrsub_vx(T *dest, T *src1, const T *src2, int32_t avl) { |
| 40 | for (int32_t idx = 0; idx < avl; idx++) { |
| 41 | dest[idx] = *src2 - src1[idx]; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | } // namespace softrvv |
| 46 | |
| 47 | #endif // SOFTRVV_VSUB_H |