🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
MathOperator.hpp 文件参考
#include "AstGlobal.h"
#include <cmath>
#include <assert.h>
#include <type_traits>
#include <array>
#include <iterator>
#include <cassert>

浏览该文件的源代码.

struct  ast::math::is_vector_like< T >
 

命名空间

namespace  ast
 
namespace  ast::math
 

宏定义

#define _AST_DEF_OP_SV(OP)
 
#define _AST_DEF_OP_VS(OP)
 
#define _AST_DEF_OP_VV(OP)
 
#define _AST_DEF_OP(OP)
 
#define _ASTMATH   _AST math::
 

类型定义

typedef std::array< double, 3 > ast::array3d
 
typedef std::array< double, 6 > ast::array6d
 

函数

std::pair< double, double > ast::math::twoSum (double a, double b)
 
double ast::math::eps (double t)
 
template<typename Container >
auto ast::math::size (const Container &vec) noexcept -> decltype(vec.size())
 
template<class _Scalar , size_t N>
constexpr size_t ast::math::size (const _Scalar(&)[N]) noexcept
 
template<typename _Scalar >
int ast::math::sign (_Scalar val)
 
template<typename T >
std::enable_if< std::is_arithmetic< T >::value, T >::type ast::math::rem (T x, T y)
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, T >::type ast::math::mod (T x, T y)
 
template<typename T >
std::enable_if< std::is_arithmetic< T >::value, T >::type ast::math::fix (T x)
 
double ast::math::cot (double a)
 
double ast::math::acot (double a)
 
template<typename Container1 , typename Container2 >
double ast::math::dot (const Container1 &vec1, const Container2 &vec2)
 
template<size_t N1, size_t N2>
double ast::math::dot (const double(&vec1)[N1], const double(&vec2)[N2])
 
double ast::math::dot (const double *vec1, const double *vec2, size_t N)
 
double ast::math::dot3 (const double *vec1, const double *vec2)
 
template<typename Vector3D1 , typename Vector3D2 >
auto ast::math::cross (const Vector3D1 &vec1, const Vector3D2 &vec2) -> typename std::enable_if<!std::is_pointer< Vector3D1 >::value &&!std::is_pointer< Vector3D2 >::value, Vector3D1 >::type
 
void ast::math::cross (double *res, const double *vec1, const double *vec2)
 
template<size_t N1, size_t N2>
std::array< double, 3 > ast::math::cross (const double(&vec1)[N1], const double(&vec2)[N2])
 
std::array< double, 3 > ast::math::cross3 (const double *vec1, const double *vec2)
 
double ast::math::squaredNorm (const double *vec, size_t N)
 
template<typename Vector >
auto ast::math::squaredNorm (const Vector &vec) -> typename std::enable_if<!std::is_pointer< Vector >::value, double >::type
 
template<size_t N>
double ast::math::squaredNorm (const double(&vec)[N])
 
double ast::math::norm (const double *vec, size_t N)
 
template<typename Vector >
auto ast::math::norm (const Vector &vec) -> typename std::enable_if<!std::is_pointer< Vector >::value, double >::type
 
template<size_t N>
double ast::math::norm (const double(&vec)[N])
 
double ast::math::normalize (double *vec, size_t N)
 
template<typename Vector >
auto ast::math::normalize (Vector &vec) -> typename std::enable_if<!std::is_pointer< Vector >::value, double >::type
 
template<size_t N>
double ast::math::normalize (double(&vec)[N])
 
template<typename Vector >
auto ast::math::normalized (const Vector &vec) -> typename std::enable_if<!std::is_pointer< Vector >::value, Vector >::type
 
template<size_t N>
std::array< double, Nast::math::normalized (double(&vec)[N])
 
template<size_t N>
std::array< double, Nast::math::normalized (const double *vec)
 
template<typename _Scalar , size_t I, size_t J, size_t K>
std::array< std::array< _Scalar, K >, I > ast::math::mtimes (const _Scalar(&left)[I][J], const _Scalar(&right)[J][K])
 
template<typename _Scalar , size_t I, size_t J, size_t K>
MatrixMN< _Scalar, I, K > ast::operator* (const MatrixMN< _Scalar, I, J > &left, const MatrixMN< _Scalar, J, K > &right)
 
template<typename _Scalar , size_t I, size_t J>
VectorN< _Scalar, I > ast::operator* (const MatrixMN< _Scalar, I, J > &left, const VectorN< _Scalar, J > &right)
 
template<typename _Scalar , size_t I, size_t J>
VectorN< _Scalar, J > ast::operator* (const VectorN< _Scalar, I > &left, const MatrixMN< _Scalar, I, J > &right)
 
template<typename T >
A_CONSTEXPR_CXX14 const T & ast::clamp (const T &val, const T &low, const T &high)
 

详细描述

定义向量运算实用函数

~

作者
axel
日期
15.11.2025

本项目基于 Apache 2.0 开源许可证分发。 您可在遵守许可证条款的前提下使用、修改和分发本软件。 许可证全文请见:

http://www.apache.org/licenses/LICENSE-2.0

重要须知: 软件按“现有状态”提供,无任何明示或暗示的担保条件。 除非法律要求或书面同意,作者与贡献者不承担任何责任。 使用本软件所产生的风险,需由您自行承担。

宏定义说明

◆ _AST_DEF_OP

#define _AST_DEF_OP ( OP)
值:
_AST_DEF_OP_VS(OP) \
_AST_DEF_OP_VV(OP) \
#define _AST_DEF_OP_SV(OP)
定义 MathOperator.hpp:421

◆ _AST_DEF_OP_SV

#define _AST_DEF_OP_SV ( OP)
值:
template<typename Scalar, typename Vector> \
inline auto operator OP(Scalar scalar, const Vector& vec) \
-> typename std::enable_if<std::is_arithmetic<Scalar>::value && is_vector_like<Vector>::value, Vector>::type \
{ \
Vector retval{ vec }; \
size_t s = size(vec); \
for (size_t i = 0; i < s; i++) \
{ \
retval[i] OP##= scalar; \
} \
return retval; \
}
  • - * /

◆ _AST_DEF_OP_VS

#define _AST_DEF_OP_VS ( OP)
值:
template<typename Vector, typename Scalar> \
inline auto operator OP(const Vector& vec, Scalar scalar) \
-> typename std::enable_if<std::is_arithmetic<Scalar>::value && is_vector_like<Vector>::value, Vector>::type \
{ \
Vector retval{ vec }; \
size_t s = size(vec); \
for (size_t i = 0; i < s; i++) \
{ \
retval[i] OP##= scalar; \
} \
return retval; \
}

◆ _AST_DEF_OP_VV

#define _AST_DEF_OP_VV ( OP)
值:
template<typename Vector1, typename Vector2> \
inline auto operator OP(const Vector1& vec1, const Vector2& vec2)\
-> typename std::enable_if<is_vector_like<Vector1>::value && is_vector_like<Vector2>::value, Vector1>::type \
{ \
assert(size(vec1) == size(vec2)); \
Vector1 retval{ vec1 }; \
size_t s = size(vec1); \
for (size_t i = 0; i < s; i++) \
{ \
retval[i] OP##= vec2[i]; \
} \
return retval; \
}