fbpx
维基百科

tgmath.h

tgmath.hC標準函数庫中的头文件,提供了数学函数的类型通用的宏定义。使用这些宏调用数学函数时,会根据参数自动对应到类型适合的数学函数,其效果类似于C++函数重载,使得编程者不必繁琐地去调用数学库函数的单精度、双精度、长双精度、单精度复数、双精度复数、长双精度复数等各个版本。

宏定义 编辑

math.h与complex.h共有 编辑

一些常见数学函数既在math.h有实数版本,也在complex.h有复数版本。tgmath.h提供了下述类型通用的宏定义:

  • acos
  • asin
  • atan
  • acosh
  • asinh
  • atanh
  • cos
  • sin
  • tan
  • cosh
  • sinh
  • tanh
  • exp
  • log
  • pow
  • sqrt
  • fabs

math.h专用 编辑

对于包含在math.h中,但在complex.h中没有对应的函数,提供了下述通用类型的宏:

  • atan2
  • cbrt
  • ceil
  • copysign
  • erf
  • erfc
  • exp2
  • expm1
  • fdim
  • floor
  • fma
  • fmax
  • fmin
  • fmod
  • frexp
  • hypot
  • ilogb
  • ldexp
  • lgamma
  • llrint
  • llround
  • log10
  • log1p
  • log2
  • logb
  • lrint
  • lround
  • nearbyint
  • nextafter
  • nexttoward
  • remainder
  • remquo
  • rint
  • round
  • scalbn
  • scalbln
  • tgamma
  • trunc

complex.h专用 编辑

对于包含在complex.h中,但在math.h中没有对应的函数,提供了下述通用类型的宏:

  • carg
  • cimag
  • conj
  • cproj
  • creal

例子 编辑

#include <tgmath.h> int n; float f; double d; long double ld; float complex fc; double complex dc; long double complex ldc;  //实际调用了: exp(n); //exp(n) acosh(f); // acoshf(f) sin(d); // sin(d)  atan(ld); // atanl(ld) log(fc); // clogf(fc) sqrt(dc); // csqrt(dc) pow(ldc, f); // cpowl(ldc, f) remainder(n, n); // remainder(n, n)  nextafter(d, f); // nextafter(d, f)  nexttoward(f, ld); // nexttowardf(f, ld) copysign(n, ld); // copysignl(n, ld) ceil(fc); // 未定义 rint(dc); // 未定义 fmax(ldc, ld); // 未定义 carg(n); // carg(n)  cproj(f); // cprojf(f) creal(d); // creal(d)  cimag(ld); // cimagl(ld) cabs(fc); // cabsf(fc) carg(dc); // carg(dc)  cproj(ldc); // cprojl(ldc) 

参考文献 编辑

tgmath, 是c標準函数庫中的头文件, 提供了数学函数的类型通用的宏定义, 使用这些宏调用数学函数时, 会根据参数自动对应到类型适合的数学函数, 其效果类似于c, 的函数重载, 使得编程者不必繁琐地去调用数学库函数的单精度, 双精度, 长双精度, 单精度复数, 双精度复数, 长双精度复数等各个版本, 目录, 宏定义, math, h与complex, h共有, math, h专用, complex, h专用, 例子, 参考文献宏定义, 编辑math, h与complex, h共有, 编辑, 一些常见数学函数既在. tgmath h是C標準函数庫中的头文件 提供了数学函数的类型通用的宏定义 使用这些宏调用数学函数时 会根据参数自动对应到类型适合的数学函数 其效果类似于C 的函数重载 使得编程者不必繁琐地去调用数学库函数的单精度 双精度 长双精度 单精度复数 双精度复数 长双精度复数等各个版本 目录 1 宏定义 1 1 math h与complex h共有 1 2 math h专用 1 3 complex h专用 2 例子 3 参考文献宏定义 编辑math h与complex h共有 编辑 一些常见数学函数既在math h有实数版本 也在complex h有复数版本 tgmath h提供了下述类型通用的宏定义 acos asin atan acosh asinh atanh cos sin tan cosh sinh tanh exp log pow sqrt fabsmath h专用 编辑 对于包含在math h中 但在complex h中没有对应的函数 提供了下述通用类型的宏 atan2 cbrt ceil copysign erf erfc exp2 expm1 fdim floor fma fmax fmin fmod frexp hypot ilogb ldexp lgamma llrint llround log10 log1p log2 logb lrint lround nearbyint nextafter nexttoward remainder remquo rint round scalbn scalbln tgamma trunccomplex h专用 编辑 对于包含在complex h中 但在math h中没有对应的函数 提供了下述通用类型的宏 carg cimag conj cproj creal例子 编辑 include lt tgmath h gt int n float f double d long double ld float complex fc double complex dc long double complex ldc 实际调用了 exp n exp n acosh f acoshf f sin d sin d atan ld atanl ld log fc clogf fc sqrt dc csqrt dc pow ldc f cpowl ldc f remainder n n remainder n n nextafter d f nextafter d f nexttoward f ld nexttowardf f ld copysign n ld copysignl n ld ceil fc 未定义 rint dc 未定义 fmax ldc ld 未定义 carg n carg n cproj f cprojf f creal d creal d cimag ld cimagl ld cabs fc cabsf fc carg dc carg dc cproj ldc cprojl ldc 参考文献 编辑 取自 https zh wikipedia org w index php title Tgmath h amp oldid 60465578, 维基百科,wiki,书籍,书籍,图书馆,

文章

,阅读,下载,免费,免费下载,mp3,视频,mp4,3gp, jpg,jpeg,gif,png,图片,音乐,歌曲,电影,书籍,游戏,游戏。