| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 3 * Distributed under the terms of the GNU General Public License v2 | 3 * Distributed under the terms of the GNU General Public License v2 |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 #include <float.h> | 6 #include <float.h> |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <ncurses.h> | 8 #include <ncurses.h> |
| 9 #include <signal.h> | 9 #include <signal.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 { | 93 { |
| 94 return sin(x/3) + 1; | 94 return sin(x/3) + 1; |
| 95 } | 95 } |
| 96 | 96 |
| 97 vector_s vinit(int n, double f(double)) | 97 vector_s vinit(int n, double f(double)) |
| 98 { | 98 { |
| 99 vector_s v = new_vector(n); | 99 vector_s v = new_vector(n); |
| 100 point_s *p = v.p; | 100 point_s *p = v.p; |
| 101 point_s *end; | 101 point_s *end; |
| 102 double x; | 102 double x; |
| 103 » | 103 |
| 104 for (x = 0, end = &v.p[n]; p < end; p++, x++) { | 104 for (x = 0, end = &v.p[n]; p < end; p++, x++) { |
| 105 p->x = x; | 105 p->x = x; |
| 106 p->y = f(x); | 106 p->y = f(x); |
| 107 } | 107 } |
| 108 return v; | 108 return v; |
| 109 } | 109 } |
| 110 | 110 |
| 111 void graph(void) | 111 void graph(void) |
| 112 { | 112 { |
| 113 graph_s g = { {0, 0}, { {10, 10}, {80, 10} } }; | 113 graph_s g = { {0, 0}, { {10, 10}, {80, 10} } }; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 { | 154 { |
| 155 set_signals(); | 155 set_signals(); |
| 156 init(); | 156 init(); |
| 157 graph(); | 157 graph(); |
| 158 refresh(); | 158 refresh(); |
| 159 getchar(); | 159 getchar(); |
| 160 cleanup(0); | 160 cleanup(0); |
| 161 return 0; | 161 return 0; |
| 162 } | 162 } |
| 163 #endif | 163 #endif |
| OLD | NEW |