File: cheb.ml

package info (click to toggle)
ocamlgsl 0.3.5-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,444 kB
  • ctags: 2,901
  • sloc: ml: 7,956; ansic: 6,796; makefile: 303; sh: 87; awk: 13
file content (20 lines) | stat: -rw-r--r-- 394 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
let f x = 
  if x < 0.5
  then 0.25
  else 0.75

let test n = 
  let cs = Gsl_cheb.make 40 in
  let gslfun = f in
  Gsl_cheb.init cs gslfun 0. 1. ;
  for i=0 to pred n do
    let x = float i /. float n in
    let r10 = Gsl_cheb.eval cs ~order:10 x in
    let r40 = Gsl_cheb.eval cs x in
    Printf.printf "%g %g %g %g\n"
      x (f x) r10 r40 
  done

let _ = 
  Gsl_error.init ();
  test 1000