GSL切比雪夫级数

#include <stdio.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_chebyshev.h>

#pragma comment(lib, "libgsl_d.lib")
#pragma comment(lib, "libgslcblas_d.lib")

double
f (double x, void *p)
{
  if (x < 0.5)
    return 0.25;
  else
    return 0.75;
}

int
main (void)
{
  int i, n = 10000; 

  gsl_cheb_series *cs = gsl_cheb_alloc (40);

  gsl_function F;

  F.function = f;
  F.params = 0;

  gsl_cheb_init (cs, &F, 0.0, 1.0);

  for (i = 0; i < n; i++)
    {
      double x = i / (double)n;
      double r10 = gsl_cheb_eval_n (cs, 10, x);
      double r40 = gsl_cheb_eval (cs, x);
      printf ("%g %g %g %g\n", 
              x, GSL_FN_EVAL (&F, x), r10, r40);
    }

  gsl_cheb_free (cs);

  return 0;
}

GSL 开源 科学计算库 学习笔记(分享部分译稿) GSL是GNU Scientific Libary的简写,是一组专门为数值科学计算而设计的程序库。该程序库用C语言写就,C程序员提供了API。不过 可以对其使用swig工具进行封装,以便能被更高级的语言使用,比如C#,java等。读者可以在网上找到很多swig的例子。 GSL原码是以GPL协议发布的,获取与使用都非常地方便,这也是我们之所以选取GSL学习的根本原因。 GSL库涵盖了数值计算领域的方方面面,主要包括下面的计算领域,还有一些新的程序代码会不断纳入到GSL中。 Complex Numbers 复数; Roots of Polynomials 多项式求根; Special Functions 特殊函数; Vectors and Matrices 向量与距阵; Permutations 排列; Combinations 组合; Sorting 排序; BLAS Support 基础线性代数程序集(向量间运算,向量距阵运算,距阵间运算); Linear Algebra CBLAS Library 线性代数库; Fast Fourier Transforms 快速傅利叶变换; Eigensystems 特征值; Random Numbers 随机数; Quadrature 积分; Random Distributions 随机分布; Quasi-Random Sequences 近似随机分布序列; Histograms 直方图; Statistics 统计; Monte Carlo Integration Monte Carlo积分; N-Tuples N元组; Differential Equations 微分方程; Simulated Annealing 模拟退火算法; Numerical Differentiation 数值差分; Interpolation 拟合与插值; Series Acceleration; Chebyshev Approximations Chebyshev逼近; Root-Finding 求根; Discrete Hankel Transforms 离散Hankel转换; Least-Squares Fitting 最小二乘算法拟合; Minimization 最小值; IEEE Floating-Point IEEE浮点运输; Physical Constants 物理常量; Basis Splines 基本样条曲线; Wavelets 小波变换。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值