work_utrunc.c

来自「该文件为c++的数学函数库!是一个非常有用的编程工具.它含有各种数学函数,为科学」· C语言 代码 · 共 68 行

C
68
字号
#include <config.h>#include <gsl/gsl_math.h>#include <gsl/gsl_errno.h>#include <gsl/gsl_sum.h>gsl_sum_levin_utrunc_workspace * gsl_sum_levin_utrunc_alloc (size_t n){  gsl_sum_levin_utrunc_workspace * w;  if (n == 0)    {      GSL_ERROR_VAL ("length n must be positive integer", GSL_EDOM, 0);    }  w = (gsl_sum_levin_utrunc_workspace *) malloc(sizeof(gsl_sum_levin_utrunc_workspace));  if (w == NULL)    {      GSL_ERROR_VAL ("failed to allocate struct", GSL_ENOMEM, 0);    }  w->q_num = (double *) malloc (n * sizeof (double));  if (w->q_num == NULL)    {      free(w) ; /* error in constructor, prevent memory leak */      GSL_ERROR_VAL ("failed to allocate space for q_num", GSL_ENOMEM, 0);    }  w->q_den = (double *) malloc (n * sizeof (double));  if (w->q_den == NULL)    {      free (w->q_num);      free (w) ; /* error in constructor, prevent memory leak */      GSL_ERROR_VAL ("failed to allocate space for q_den", GSL_ENOMEM, 0);    }  w->dsum = (double *) malloc (n * sizeof (double));  if (w->dsum == NULL)    {      free (w->q_den);      free (w->q_num);      free (w) ; /* error in constructor, prevent memory leak */      GSL_ERROR_VAL ("failed to allocate space for dsum", GSL_ENOMEM, 0);    }  w->size = n;  w->terms_used = 0;  w->sum_plain = 0;  return w;}voidgsl_sum_levin_utrunc_free (gsl_sum_levin_utrunc_workspace * w){  free (w->dsum);  free (w->q_den);  free (w->q_num);  free (w);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?