Namespaces
Variants

std:: ellint_1, std:: ellint_1f, std:: ellint_1l

From cppreference.net
定义于头文件 <cmath>
(1)
float ellint_1 ( float k, float phi ) ;

double ellint_1 ( double k, double phi ) ;

long double ellint_1 ( long double k, long double phi ) ;
(C++17 起)
(C++23 前)
/* floating-point-type */ ellint_1 ( /* floating-point-type */ k,
/* floating-point-type */ phi ) ;
(C++23 起)
float ellint_1f ( float k, float phi ) ;
(2) (C++17 起)
long double ellint_1l ( long double k, long double phi ) ;
(3) (C++17 起)
定义于头文件 <cmath>
template < class Arithmetic1, class Arithmetic2 >

/* common-floating-point-type */

ellint_1 ( Arithmetic1 k, Arithmetic2 phi ) ;
(A) (C++17 起)
1-3) 计算 k phi 第一类不完全椭圆积分 该库为所有cv未限定浮点类型提供 std::ellint_1 的重载,作为参数 k phi 的类型。 (C++23 起)
A) 为所有其他算术类型组合提供了额外的重载。

目录

参数

k - 椭圆模量或离心率(浮点数或整数值)
phi - 雅可比振幅(浮点数或整数值,以弧度为单位)

返回值

If no errors occur, value of the incomplete elliptic integral of the first kind of k and phi , that is phi
0
1-k 2
sin 2
θ
, is returned.

错误处理

错误报告方式可能按照 math_errhandling 中的规定执行:

  • 如果参数为 NaN,则返回 NaN 且不报告定义域错误。
  • 如果 |k|>1 ,可能出现定义域错误。

注释

不支持C++17但支持 ISO 29124:2010 的实现,若实现将 __STDCPP_MATH_SPEC_FUNCS__ 定义为至少201003L的值,且用户在包含任何标准库头文件之前定义了 __STDCPP_WANT_MATH_SPEC_FUNCS__ ,则提供此函数。

不支持 ISO 29124:2010 但支持 TR 19768:2007 (TR1) 的实现,会在头文件 tr1/cmath 和命名空间 std::tr1 中提供此函数。

该函数的实现也可在 boost.math 库中找到。

额外的重载不需要完全按照 (A) 的形式提供。它们只需确保对于第一个参数 num1 和第二个参数 num2 满足:

  • num1 num2 具有类型 long double ,则 std :: ellint_1 ( num1, num2 ) 的效果等同于 std :: ellint_1 ( static_cast < long double > ( num1 ) ,
    static_cast < long double > ( num2 ) )
  • 否则,若 num1 和/或 num2 具有类型 double 或整数类型,则 std :: ellint_1 ( num1, num2 ) 的效果等同于 std :: ellint_1 ( static_cast < double > ( num1 ) ,
    static_cast < double > ( num2 ) )
  • 否则,若 num1 num2 具有类型 float ,则 std :: ellint_1 ( num1, num2 ) 的效果等同于 std :: ellint_1 ( static_cast < float > ( num1 ) ,
    static_cast < float > ( num2 ) )
(C++23 前)

num1 num2 具有算术类型,则 std :: ellint_1 ( num1, num2 ) 的效果等同于 std :: ellint_1 ( static_cast < /* common-floating-point-type */ > ( num1 ) ,
static_cast < /* common-floating-point-type */ > ( num2 ) )
,其中 /* common-floating-point-type */ num1 num2 类型之间具有最高 浮点转换等级 和最高 浮点转换子等级 的浮点类型,整数类型的实参被认为具有与 double 相同的浮点转换等级。

若不存在具有最高等级和子等级的此类浮点类型,则 重载决议 不会从提供的重载中得到可用候选。

(C++23 起)

示例

#include <cmath>
#include <iostream>
#include <numbers>
int main()
{
    const double hpi = std::numbers::pi / 2.0;
    std::cout << "F(0,π/2)  = " << std::ellint_1(0, hpi) << '\n'
              << "F(0,-π/2) = " << std::ellint_1(0, -hpi) << '\n'
              << "π/2       = " << hpi << '\n'
              << "F(0.7,0)  = " << std::ellint_1(0.7, 0) << '\n';
}

输出:

F(0,π/2)  = 1.5708
F(0,-π/2) = -1.5708
π/2       = 1.5708
F(0.7,0)  = 0

参见

(完全)第一类椭圆积分
(函数)

外部链接

魏斯坦, 埃里克·W。《第一类椭圆积分》。 摘自 MathWorld —— 一个 Wolfram 网络资源。