Skip to content

Commit 2551fb2

Browse files
committed
Add into_vector to documentation
1 parent b236a52 commit 2551fb2

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

docs/build_api.py

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def build_index_page(groups):
8484
"broadcast",
8585
"convert",
8686
"make_vec",
87+
"into_vector",
8788
"concat",
8889
"select",
8990
"for_each",

include/kernel_float/vector.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ struct vector: public S {
275275
*
276276
* - For vectors `vec<T, N>`, it simply returns the original vector.
277277
* - For primitive types `T` (e.g., `int`, `float`, `double`), it returns a `vec<T, 1>`.
278-
* - For array-like types (e.g., `int2`, `std::array<float, 3>`, `T[N]`), it returns `vec<T, N>`.
278+
* - For array-like types (e.g., `std::array<T, N>`, `T[N]`), it returns `vec<T, N>`.
279+
* - For vector-like types (e.g., `int2`, `dim3`), it returns `vec<T, N>`.
279280
*/
280281
template<typename V>
281282
KERNEL_FLOAT_INLINE into_vector_type<V> into_vector(V&& input) {

single_include/kernel_float.h

+28-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//================================================================================
22
// this file has been auto-generated, do not modify its contents!
3-
// date: 2023-08-15 14:44:32.635916
4-
// git hash: 35d55328fd0cd6644f23137ea17dd4dd470a870d
3+
// date: 2023-08-16 12:43:52.493856
4+
// git hash: b236a521d5decdd59b17361febbb7ee39803b715
55
//================================================================================
66

77
#ifndef KERNEL_FLOAT_MACROS_H
@@ -507,6 +507,24 @@ struct into_vector_traits {
507507
}
508508
};
509509

510+
template<typename T, size_t N>
511+
struct into_vector_traits<T[N]> {
512+
using value_type = T;
513+
using extent_type = extent<N>;
514+
515+
KERNEL_FLOAT_INLINE
516+
static vector_storage<T, N> call(const T (&input)[N]) {
517+
return call(input, make_index_sequence<N>());
518+
}
519+
520+
private:
521+
template<size_t... Is>
522+
KERNEL_FLOAT_INLINE static vector_storage<T, N>
523+
call(const T (&input)[N], index_sequence<Is...>) {
524+
return {input[Is]...};
525+
}
526+
};
527+
510528
template<typename V>
511529
struct into_vector_traits<const V>: into_vector_traits<V> {};
512530

@@ -1731,10 +1749,10 @@ struct cast<constant<T>, R, m> {
17311749
return constant<T>(operator OP(T(left.get()), T(right.get()))); \
17321750
}
17331751

1734-
KERNEL_FLOAT_CONSTANT_DEFINE_OP(+)
1735-
KERNEL_FLOAT_CONSTANT_DEFINE_OP(-)
1736-
KERNEL_FLOAT_CONSTANT_DEFINE_OP(*)
1737-
KERNEL_FLOAT_CONSTANT_DEFINE_OP(/)
1752+
//KERNEL_FLOAT_CONSTANT_DEFINE_OP(+)
1753+
//KERNEL_FLOAT_CONSTANT_DEFINE_OP(-)
1754+
//KERNEL_FLOAT_CONSTANT_DEFINE_OP(*)
1755+
//KERNEL_FLOAT_CONSTANT_DEFINE_OP(/)
17381756

17391757
} // namespace kernel_float
17401758

@@ -2964,7 +2982,8 @@ struct vector: public S {
29642982
*
29652983
* - For vectors `vec<T, N>`, it simply returns the original vector.
29662984
* - For primitive types `T` (e.g., `int`, `float`, `double`), it returns a `vec<T, 1>`.
2967-
* - For array-like types (e.g., `int2`, `std::array<float, 3>`, `T[N]`), it returns `vec<T, N>`.
2985+
* - For array-like types (e.g., `std::array<T, N>`, `T[N]`), it returns `vec<T, N>`.
2986+
* - For vector-like types (e.g., `int2`, `dim3`), it returns `vec<T, N>`.
29682987
*/
29692988
template<typename V>
29702989
KERNEL_FLOAT_INLINE into_vector_type<V> into_vector(V&& input) {
@@ -3664,10 +3683,12 @@ KERNEL_FLOAT_INLINE constexpr kconstant<T> kconst(T value) {
36643683
return value;
36653684
}
36663685

3686+
KERNEL_FLOAT_INLINE
36673687
static constexpr kconstant<double> operator""_c(long double v) {
36683688
return static_cast<double>(v);
36693689
}
36703690

3691+
KERNEL_FLOAT_INLINE
36713692
static constexpr kconstant<long long int> operator""_c(unsigned long long int v) {
36723693
return static_cast<long long int>(v);
36733694
}

0 commit comments

Comments
 (0)