/*
 * Copyright 2023 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SOFTRVV_INCLUDE_SOFTRVV_VADD_H_
#define SOFTRVV_INCLUDE_SOFTRVV_VADD_H_

#include <stddef.h>

namespace softrvv {

template <typename T>
void vadd_vi(T *dest, T *src1, T src2, int32_t avl) {
  for (int32_t idx = 0; idx < avl; idx++) {
    dest[idx] = src1[idx] + src2;
  }
}

template <typename T>
void vadd_vx(T *dest, T *src1, const T *src2, int32_t avl) {
  for (int32_t idx = 0; idx < avl; idx++) {
    dest[idx] = src1[idx] + *src2;
  }
}

template <typename T>
void vadd_vv(T *dest, T *src1, T *src2, int32_t avl) {
  for (int32_t idx = 0; idx < avl; idx++) {
    dest[idx] = src1[idx] + src2[idx];
  }
}

}  // namespace softrvv

#endif  // SOFTRVV_INCLUDE_SOFTRVV_VADD_H_
