File: generate_sindat.sh

package info (click to toggle)
vc 1.4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,552 kB
  • sloc: cpp: 19,220; ansic: 15,669; sh: 453; xml: 186; makefile: 30
file content (36 lines) | stat: -rwxr-xr-x 593 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/zsh

cd "${0%/*}"

function usage() {
  cat <<EOF
Usage: $0

Options:
  --help|-h        this message

EOF
}

while (( $# > 0 )); do
  case "$1" in
    --help|-h) usage; exit ;;
  esac
  shift
done

octave <<EOF
ff=fopen("sincosf.dat", "w");
fd=fopen("sincosd.dat", "w");

printf("Generating 100000 dp & sp sincos values [0, π/4]     ");
for i = 1:100000
  x=i * pi / 400000;
  fprintf(fd, "%.60f\t%.60f\t%.60f\n", x, sin(x), cos(x));
  x=round_to_float(x);
  fprintf(ff, "%.40f\t%.50f\t%.50f\n", x, sin(x), cos(x));
  printf("\033[4D%3i%%", floor(i/1000));
endfor
EOF

# vim: sw=2 et