-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
746 additions
and
566 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// MIT License | ||
// | ||
// Copyright (c) 2023-2024 有个小小杜 | ||
// | ||
// Created by 有个小小杜 | ||
// | ||
|
||
#ifndef _KTM_VECTOR_INL_ | ||
#define _KTM_VECTOR_INL_ | ||
|
||
#include "vector_fwd.h" | ||
#include "../loop_util.h" | ||
#include "../../type/vec_fwd.h" | ||
#include "../../function/arithmetic.h" | ||
|
||
template<size_t N, typename T, typename Void> | ||
struct ktm::detail::vector_implement::reduce_add | ||
{ | ||
using V = vec<N, T>; | ||
static KTM_INLINE T call(const V& x) noexcept | ||
{ | ||
T ret = x[0]; | ||
loop_op<N - 1, void>::call( | ||
[&ret](const T& x) -> void { ret += x; }, &x[1]); | ||
return ret; | ||
} | ||
}; | ||
|
||
template<size_t N, typename T, typename Void> | ||
struct ktm::detail::vector_implement::reduce_min | ||
{ | ||
using V = vec<N, T>; | ||
static KTM_INLINE T call(const V& x) noexcept | ||
{ | ||
T ret = x[0]; | ||
loop_op<N - 1, void>::call( | ||
[&ret](const T& x) -> void { ret = ktm::min<T>(ret, x); }, &x[1]); | ||
return ret; | ||
} | ||
}; | ||
|
||
template<size_t N, typename T, typename Void> | ||
struct ktm::detail::vector_implement::reduce_max | ||
{ | ||
using V = vec<N, T>; | ||
static KTM_INLINE T call(const V& x) noexcept | ||
{ | ||
T ret = x[0]; | ||
loop_op<N - 1, void>::call( | ||
[&ret](const T& x) -> void { ret = ktm::max<T>(ret, x); }, &x[1]); | ||
return ret; | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.