#include <stdio.h>#include "lsutil.h"Include dependency graph for testlsutil.c:

Go to the source code of this file.
Defines | |
| #define | MAX_PAIRS 1024 |
Functions | |
| char | __attribute__ ((unused)) ident[]="$Id |
|
|
|
|
|
Definition at line 17 of file testlsutil.c. 00017 : testlsutil.c,v 1.3 2000/10/27 20:34:42 terrylr Exp $";
00018
00019 /*
00020 reads from stdin, expecting pairs <x> <y> <RET>, until EOF.
00021 Writes the LSBF <x> <y'> <RET>, where y' is the new best fit
00022 for each x.
00023
00024 Max pairs is defined in MAX_PAIRS, currently 1024.
00025 */
00026
00027 #define MAX_PAIRS 1024
00028
00029 int main(int argc, char *argv[])
00030 {
00031 double x[1024], y[1024];
00032 int n = 0;
00033 double a, b;
00034 double d;
00035 int dflag = 0;
00036 int t;
00037
00038 if (argc > 1)
00039 {
00040 /* d offset provided */
00041 if (1 != sscanf (argv[1], "%lf", &d))
00042 {
00043 return -1;
00044 }
00045
00046 dflag = 1;
00047 }
00048
00049 while (!feof(stdin) &&
00050 n < MAX_PAIRS)
00051 {
00052 if (2 != scanf("%lf %lf", &x[n], &y[n]))
00053 {
00054 break;
00055 }
00056 else
00057 {
00058 n++;
00059 }
00060 }
00061
00062 if (dflag)
00063 {
00064 if (0 == lsCoeffOD(x, y, n, d, &a))
00065 {
00066 printf("TitleText: y = %f (x - %f)\n", a, d);
00067 for (t = 0; t < n; t++)
00068 {
00069 printf("%f\t%f\n", x[t], a*(x[t]-d));
00070 }
00071 }
00072 }
00073 else
00074 {
00075 if (0 == lsCoeff(x, y, n, &a, &b))
00076 {
00077 printf("TitleText: y = %f x + %f\n", a, b);
00078 for (t = 0; t < n; t++)
00079 {
00080 printf("%f\t%f\n", x[t], a*x[t]+b);
00081 }
00082 }
00083 }
00084
00085 return 0;
00086 }
|
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001