/*
 * 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_VMIN_H
#define SOFTRVV_VMIN_H

#include <stddef.h>

namespace softrvv {

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

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

}  // namespace softrvv

#endif  // SOFTRVV_VMIN_H
