std:: expint, std:: expintf, std:: expintl
|
헤더에 정의됨
<cmath>
|
||
| (1) | ||
|
float
expint
(
float
num
)
;
double
expint
(
double
num
)
;
|
(C++17부터)
(C++23까지) |
|
|
/* floating-point-type */
expint
(
/* floating-point-type */
num
)
;
|
(C++23부터) | |
|
float
expintf
(
float
num
)
;
|
(2) | (C++17부터) |
|
long
double
expintl
(
long
double
num
)
;
|
(3) | (C++17부터) |
|
헤더에 정의됨
<cmath>
|
||
|
template
<
class
Integer
>
double expint ( Integer num ) ; |
(A) | (C++17부터) |
std::expint
의 오버로드를 제공합니다.
(C++23부터)
목차 |
매개변수
| num | - | 부동 소수점 또는 정수 값 |
반환값
If no errors occur, value of the exponential integral of num , that is - ∫ ∞-num
| e -t |
| t |
오류 처리
오류는 math_errhandling 에 명시된 대로 보고될 수 있습니다.
- 인수가 NaN이면, NaN이 반환되고 도메인 오류가 보고되지 않습니다.
- 인수가 ±0이면, -∞가 반환됩니다.
참고 사항
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) 와 동일하게 제공될 필요가 없습니다. 정수 타입의 인수 num 에 대해 std :: expint ( num ) 가 std :: expint ( static_cast < double > ( num ) ) 와 동일한 효과를 가지도록 보장하기에 충분하기만 하면 됩니다.
예제
#include <algorithm> #include <cmath> #include <iostream> #include <vector> template<int Height = 5, int BarWidth = 1, int Padding = 1, int Offset = 0, class Seq> void draw_vbars(Seq&& s, const bool DrawMinMax = true) { static_assert(0 < Height and 0 < BarWidth and 0 <= Padding and 0 <= Offset); auto cout_n = [](auto&& v, int n = 1) { while (n-- > 0) std::cout << v; }; const auto [min, max] = std::minmax_element(std::cbegin(s), std::cend(s)); std::vector<std::div_t> qr; for (typedef decltype(*std::cbegin(s)) V; V e : s) qr.push_back(std::div(std::lerp(V(0), 8 * Height, (e - *min) / (*max - *min)), 8)); for (auto h{Height}; h-- > 0; cout_n('\n')) { cout_n(' ', Offset); for (auto dv : qr) { const auto q{dv.quot}, r{dv.rem}; unsigned char d[]{0xe2, 0x96, 0x88, 0}; // 전체 블록: '█' q < h ? d[0] = ' ', d[1] = 0 : q == h ? d[2] -= (7 - r) : 0; cout_n(d, BarWidth), cout_n(' ', Padding); } if (DrawMinMax && Height > 1) Height - 1 == h ? std::cout << "┬ " << *max: h ? std::cout << "│ " : std::cout << "┴ " << *min; } } int main() { std::cout << "Ei(0) = " << std::expint(0) << '\n' << "Ei(1) = " << std::expint(1) << '\n' << "곰페르츠 상수 = " << -std::exp(1) * std::expint(-1) << '\n'; std::vector<float> v; for (float x{1.f}; x < 8.8f; x += 0.3565f) v.push_back(std::expint(x)); draw_vbars<9, 1, 1>(v); }
출력:
Ei(0) = -inf
Ei(1) = 1.89512
곰퍼츠 상수 = 0.596347
█ ┬ 666.505
█ │
▆ █ │
█ █ │
█ █ █ │
▆ █ █ █ │
▁ ▆ █ █ █ █ │
▂ ▅ █ █ █ █ █ █ │
▁ ▁ ▁ ▁ ▁ ▁ ▁ ▂ ▂ ▃ ▃ ▄ ▆ ▇ █ █ █ █ █ █ █ █ ┴ 1.89512
외부 링크
| Weisstein, Eric W. "Exponential Integral." MathWorld — Wolfram 웹 리소스에서 발췌. |