Skip to content

Commit

Permalink
function file grade
Browse files Browse the repository at this point in the history
  • Loading branch information
YGXXD committed Dec 26, 2024
1 parent 6fe4a78 commit 21ebf93
Show file tree
Hide file tree
Showing 41 changed files with 864 additions and 269 deletions.
3 changes: 1 addition & 2 deletions ktm/detail/function/geometric.inl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#include "geometric_fwd.h"
#include "../../type/basic.h"
#include "../../type/vec_fwd.h"
#include "../../function/exponential.h"
#include "../../function/vector.h"
#include "../../function/common.h"

template<size_t N, typename T, typename Void>
struct ktm::detail::geometric_implement::dot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
// Created by 有个小小杜
//

#ifndef _KTM_MATRIX_INL_
#define _KTM_MATRIX_INL_
#ifndef _KTM_MATRIX_ALGEBRA_INL_
#define _KTM_MATRIX_ALGEBRA_INL_

#include <utility>
#include "matrix_fwd.h"
#include "matrix_algebra_fwd.h"
#include "../../setup.h"
#include "../../type/basic.h"
#include "../../type/vec_fwd.h"
#include "../../type/mat_fwd.h"

template<size_t Row, size_t Col, typename T, typename Void>
struct ktm::detail::matrix_implement::transpose
struct ktm::detail::matrix_algebra_implement::transpose
{
using M = mat<Row, Col, T>;
using RetM = mat<Col, Row, T>;
Expand All @@ -43,7 +43,7 @@ private:
};

template<size_t N, typename T, typename Void>
struct ktm::detail::matrix_implement::diagonal
struct ktm::detail::matrix_algebra_implement::diagonal
{
using M = mat<N, N, T>;
using ColV = vec<N, T>;
Expand All @@ -68,7 +68,7 @@ private:
};

template<typename T>
struct ktm::detail::matrix_implement::determinant<2, T>
struct ktm::detail::matrix_algebra_implement::determinant<2, T>
{
using M = mat<2, 2, T>;
static KTM_INLINE T call(const M& m) noexcept
Expand All @@ -78,7 +78,7 @@ struct ktm::detail::matrix_implement::determinant<2, T>
};

template<typename T>
struct ktm::detail::matrix_implement::determinant<3, T>
struct ktm::detail::matrix_algebra_implement::determinant<3, T>
{
using M = mat<3, 3, T>;
static KTM_INLINE T call(const M& m) noexcept
Expand All @@ -90,7 +90,7 @@ struct ktm::detail::matrix_implement::determinant<3, T>
};

template<typename T>
struct ktm::detail::matrix_implement::determinant<4, T>
struct ktm::detail::matrix_algebra_implement::determinant<4, T>
{
using M = mat<4, 4, T>;
static KTM_INLINE T call(const M& m) noexcept
Expand All @@ -112,7 +112,7 @@ struct ktm::detail::matrix_implement::determinant<4, T>
};

template<size_t N, typename T>
struct ktm::detail::matrix_implement::determinant<N, T, std::enable_if_t<std::is_floating_point_v<T> && (N > 4)>>
struct ktm::detail::matrix_algebra_implement::determinant<N, T, std::enable_if_t<std::is_floating_point_v<T> && (N > 4)>>
{
using M = mat<N, N, T>;
static KTM_NOINLINE T call(const M& m) noexcept
Expand All @@ -137,7 +137,7 @@ struct ktm::detail::matrix_implement::determinant<N, T, std::enable_if_t<std::is
};

template<size_t N, typename T>
struct ktm::detail::matrix_implement::determinant<N, T, std::enable_if_t<!std::is_floating_point_v<T> && (N > 4)>>
struct ktm::detail::matrix_algebra_implement::determinant<N, T, std::enable_if_t<!std::is_floating_point_v<T> && (N > 4)>>
{
using M = mat<N, N, T>;
static KTM_NOINLINE T call(const M& m) noexcept
Expand All @@ -164,7 +164,7 @@ struct ktm::detail::matrix_implement::determinant<N, T, std::enable_if_t<!std::i
};

template<typename T>
struct ktm::detail::matrix_implement::inverse<2, T>
struct ktm::detail::matrix_algebra_implement::inverse<2, T>
{
using M = mat<2, 2, T>;
static KTM_INLINE M call(const M& m) noexcept
Expand All @@ -180,7 +180,7 @@ struct ktm::detail::matrix_implement::inverse<2, T>
};

template<typename T>
struct ktm::detail::matrix_implement::inverse<3, T>
struct ktm::detail::matrix_algebra_implement::inverse<3, T>
{
using M = mat<3, 3, T>;
static KTM_INLINE M call(const M& m) noexcept
Expand All @@ -201,7 +201,7 @@ struct ktm::detail::matrix_implement::inverse<3, T>
};

template<typename T>
struct ktm::detail::matrix_implement::inverse<4, T>
struct ktm::detail::matrix_algebra_implement::inverse<4, T>
{
using M = mat<4, 4, T>;
static KTM_INLINE M call(const M& m) noexcept
Expand Down Expand Up @@ -261,7 +261,7 @@ struct ktm::detail::matrix_implement::inverse<4, T>
};

template<size_t N, typename T>
struct ktm::detail::matrix_implement::inverse<N, T, std::enable_if_t<(N > 4)>>
struct ktm::detail::matrix_algebra_implement::inverse<N, T, std::enable_if_t<(N > 4)>>
{
using M = mat<N, N, T>;
static KTM_NOINLINE M call(const M& m) noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by 有个小小杜
//

#ifndef _KTM_MATRIX_FWD_H_
#define _KTM_MATRIX_FWD_H_
#ifndef _KTM_MATRIX_ALGEBRA_FWD_H_
#define _KTM_MATRIX_ALGEBRA_FWD_H_

#include <cstddef>
#include <type_traits>
Expand All @@ -15,7 +15,7 @@ namespace ktm
{
namespace detail
{
namespace matrix_implement
namespace matrix_algebra_implement
{

template<size_t Row, size_t Col, typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
// Created by 有个小小杜
//

#ifndef _KTM_MATRIX_SIMD_INL_
#define _KTM_MATRIX_SIMD_INL_
#ifndef _KTM_MATRIX_ALGEBRA_SIMD_INL_
#define _KTM_MATRIX_ALGEBRA_SIMD_INL_

#include "matrix_fwd.h"
#include "matrix_algebra_fwd.h"
#include "../../simd/skv.h"

#if KTM_SIMD_ENABLE(KTM_SIMD_NEON | KTM_SIMD_SSE | KTM_SIMD_WASM)

template<>
struct ktm::detail::matrix_implement::transpose<2, 2, float>
struct ktm::detail::matrix_algebra_implement::transpose<2, 2, float>
{
using M = mat<2, 2, float>;
using RetM = M;
Expand All @@ -29,7 +29,7 @@ struct ktm::detail::matrix_implement::transpose<2, 2, float>
};

template<>
struct ktm::detail::matrix_implement::transpose<3, 3, float>
struct ktm::detail::matrix_algebra_implement::transpose<3, 3, float>
{
using M = mat<3, 3, float>;
using RetM = M;
Expand All @@ -50,7 +50,7 @@ struct ktm::detail::matrix_implement::transpose<3, 3, float>
};

template<>
struct ktm::detail::matrix_implement::transpose<4, 4, float>
struct ktm::detail::matrix_algebra_implement::transpose<4, 4, float>
{
using M = mat<4, 4, float>;
using RetM = M;
Expand All @@ -74,7 +74,7 @@ struct ktm::detail::matrix_implement::transpose<4, 4, float>
};

template<size_t N, typename T>
struct ktm::detail::matrix_implement::transpose<N, N, T, std::enable_if_t<sizeof(T) == sizeof(float) && !std::is_same_v<T, float> && N >= 2 && N <=4>>
struct ktm::detail::matrix_algebra_implement::transpose<N, N, T, std::enable_if_t<sizeof(T) == sizeof(float) && !std::is_same_v<T, float> && N >= 2 && N <=4>>
{
using M = mat<N, N, T>;
using RetM = M;
Expand All @@ -88,7 +88,7 @@ struct ktm::detail::matrix_implement::transpose<N, N, T, std::enable_if_t<sizeof
};

template<>
struct ktm::detail::matrix_implement::determinant<3, float>
struct ktm::detail::matrix_algebra_implement::determinant<3, float>
{
using M = mat<3, 3, float>;
static KTM_INLINE float call(const M& m) noexcept
Expand All @@ -105,7 +105,7 @@ struct ktm::detail::matrix_implement::determinant<3, float>
};

template<>
struct ktm::detail::matrix_implement::determinant<4, float>
struct ktm::detail::matrix_algebra_implement::determinant<4, float>
{
using M = mat<4, 4, float>;
static KTM_INLINE float call(const M& m) noexcept
Expand Down Expand Up @@ -145,7 +145,7 @@ struct ktm::detail::matrix_implement::determinant<4, float>
};

template<>
struct ktm::detail::matrix_implement::inverse<4, float>
struct ktm::detail::matrix_algebra_implement::inverse<4, float>
{
using M = mat<4, 4, float>;
static KTM_INLINE M call(const M& m) noexcept
Expand Down Expand Up @@ -350,7 +350,7 @@ struct ktm::detail::matrix_implement::inverse<4, float>
#if KTM_SIMD_ENABLE(KTM_SIMD_NEON | KTM_SIMD_SSE4_1 | KTM_SIMD_WASM)

template<>
struct ktm::detail::matrix_implement::determinant<3, int>
struct ktm::detail::matrix_algebra_implement::determinant<3, int>
{
using M = mat<3, 3, int>;
static KTM_INLINE int call(const M& m) noexcept
Expand All @@ -366,7 +366,7 @@ struct ktm::detail::matrix_implement::determinant<3, int>
};

template<>
struct ktm::detail::matrix_implement::determinant<4, int>
struct ktm::detail::matrix_algebra_implement::determinant<4, int>
{
using M = mat<4, 4, int>;
static KTM_INLINE int call(const M& m) noexcept
Expand Down
2 changes: 1 addition & 1 deletion ktm/detail/function/vector_arithmetic.inl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "vector_arithmetic_fwd.h"
#include "../loop_util.h"
#include "../../type/vec_fwd.h"
#include "../../function/arithmetic.h"
#include "../../function/common/arithmetic.h"

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_arithmetic_implement::abs
Expand Down
122 changes: 121 additions & 1 deletion ktm/detail/function/vector_exponential.inl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "vector_exponential_fwd.h"
#include "../loop_util.h"
#include "../../type/vec_fwd.h"
#include "../../function/exponential.h"
#include "../../function/common/exponential.h"

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::sqrt
Expand Down Expand Up @@ -49,6 +49,126 @@ struct ktm::detail::vector_exponential_implement::recip
}
};

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::cbrt
{
using V = vec<N, T>;
static KTM_INLINE V call(const V& x) noexcept
{
V ret;
loop_op<N, V>::call(ret, ktm::cbrt<T>, x);
return ret;
}
};

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::pow
{
using V = vec<N, T>;
static KTM_INLINE V call(const V& x, const V& y) noexcept
{
V ret;
loop_op<N, V>::call(ret, ktm::pow<T>, x, y);
return ret;
}
};

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::exp
{
using V = vec<N, T>;
static KTM_INLINE V call(const V& x) noexcept
{
V ret;
loop_op<N, V>::call(ret, ktm::exp<T>, x);
return ret;
}
};

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::exp2
{
using V = vec<N, T>;
static KTM_INLINE V call(const V& x) noexcept
{
V ret;
loop_op<N, V>::call(ret, ktm::exp2<T>, x);
return ret;
}
};

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::expm1
{
using V = vec<N, T>;
static KTM_INLINE V call(const V& x) noexcept
{
V ret;
loop_op<N, V>::call(ret, ktm::expm1<T>, x);
return ret;
}
};

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::log
{
using V = vec<N, T>;
static KTM_INLINE V call(const V& x) noexcept
{
V ret;
loop_op<N, V>::call(ret, ktm::log<T>, x);
return ret;
}
};

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::log10
{
using V = vec<N, T>;
static KTM_INLINE V call(const V& x) noexcept
{
V ret;
loop_op<N, V>::call(ret, ktm::log10<T>, x);
return ret;
}
};

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::log2
{
using V = vec<N, T>;
static KTM_INLINE V call(const V& x) noexcept
{
V ret;
loop_op<N, V>::call(ret, ktm::log2<T>, x);
return ret;
}
};

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::log1p
{
using V = vec<N, T>;
static KTM_INLINE V call(const V& x) noexcept
{
V ret;
loop_op<N, V>::call(ret, ktm::log1p<T>, x);
return ret;
}
};

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::logb
{
using V = vec<N, T>;
static KTM_INLINE V call(const V& x) noexcept
{
V ret;
loop_op<N, V>::call(ret, ktm::logb<T>, x);
return ret;
}
};

template<size_t N, typename T, typename Void>
struct ktm::detail::vector_exponential_implement::fast_sqrt
{
Expand Down
Loading

0 comments on commit 21ebf93

Please sign in to comment.