1
0
Fork 0

Prepairing for C++ integration.

This commit is contained in:
curt 1998-04-21 17:03:41 +00:00
parent efcd77da4a
commit d365ac9aff
3 changed files with 95 additions and 71 deletions

View file

@ -28,6 +28,11 @@
#define _DEM_H #define _DEM_H
#ifndef __cplusplus
# error This library requires C++
#endif
#include <stdio.h> #include <stdio.h>
#include <Bucket/bucketutils.h> #include <Bucket/bucketutils.h>
@ -125,6 +130,9 @@ public:
// $Log$ // $Log$
// Revision 1.4 1998/04/21 17:03:41 curt
// Prepairing for C++ integration.
//
// Revision 1.3 1998/04/18 03:53:06 curt // Revision 1.3 1998/04/18 03:53:06 curt
// Added zlib support. // Added zlib support.
// //

View file

@ -1,26 +1,26 @@
/* leastsqs.c -- Implements a simple linear least squares best fit routine // leastsqs.c -- Implements a simple linear least squares best fit routine
* //
* Written by Curtis Olson, started September 1997. // Written by Curtis Olson, started September 1997.
* //
* Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
* //
* This program is free software; you can redistribute it and/or modify // This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. // (at your option) any later version.
* //
* This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. // GNU General Public License for more details.
* //
* You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* //
* $Id$ // $Id$
* (Log is kept at end of this file) // (Log is kept at end of this file)
*/ //
#include <stdio.h> #include <stdio.h>
@ -81,7 +81,7 @@ double least_squares_error(double *x, double *y, int n, double m, double b) {
for ( i = 0; i < n; i++ ) { for ( i = 0; i < n; i++ ) {
error = y[i] - (m * x[i] + b); error = y[i] - (m * x[i] + b);
sum += error * error; sum += error * error;
/* printf("%.2f %.2f\n", error, sum); */ // printf("%.2f %.2f\n", error, sum);
} }
return ( sum / (double)n ); return ( sum / (double)n );
@ -111,14 +111,16 @@ double least_squares_max_error(double *x, double *y, int n, double m, double b){
} }
/* $Log$ // $Log$
/* Revision 1.1 1998/04/08 22:57:24 curt // Revision 1.2 1998/04/21 17:03:41 curt
/* Adopted Gnu automake/autoconf system. // Prepairing for C++ integration.
/* //
* Revision 1.1 1998/03/19 02:54:47 curt // Revision 1.1 1998/04/08 22:57:24 curt
* Reorganized into a class lib called fgDEM. // Adopted Gnu automake/autoconf system.
* //
* Revision 1.1 1997/10/13 17:02:35 curt // Revision 1.1 1998/03/19 02:54:47 curt
* Initial revision. // Reorganized into a class lib called fgDEM.
* //
*/ // Revision 1.1 1997/10/13 17:02:35 curt
// Initial revision.
//

View file

@ -1,26 +1,35 @@
/* leastsqs.h -- Implements a simple linear least squares best fit routine // leastsqs.h -- Implements a simple linear least squares best fit routine
* //
* Written by Curtis Olson, started September 1997. // Written by Curtis Olson, started September 1997.
* //
* Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
* //
* This program is free software; you can redistribute it and/or modify // This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. // (at your option) any later version.
* //
* This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. // GNU General Public License for more details.
* //
* You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* //
* $Id$ // $Id$
* (Log is kept at end of this file) // (Log is kept at end of this file)
*/ ///
#ifndef _LEASTSQS_H
#define _LEASTSQS_H
#ifndef __cplusplus
# error This library requires C++
#endif
/* /*
@ -45,7 +54,7 @@ void least_squares(double *x, double *y, int n, double *m, double *b);
(y[i] - y_hat[i])^2 (y[i] - y_hat[i])^2
------------------- -------------------
n n
*/ */
double least_squares_error(double *x, double *y, int n, double m, double b); double least_squares_error(double *x, double *y, int n, double m, double b);
@ -53,18 +62,23 @@ double least_squares_error(double *x, double *y, int n, double m, double b);
return the maximum least squares error: return the maximum least squares error:
(y[i] - y_hat[i])^2 (y[i] - y_hat[i])^2
*/ */
double least_squares_max_error(double *x, double *y, int n, double m, double b); double least_squares_max_error(double *x, double *y, int n, double m, double b);
/* $Log$ #endif // _LEASTSQS_H
/* Revision 1.1 1998/04/08 22:57:25 curt
/* Adopted Gnu automake/autoconf system.
/* // $Log$
* Revision 1.1 1998/03/19 02:54:48 curt // Revision 1.2 1998/04/21 17:03:42 curt
* Reorganized into a class lib called fgDEM. // Prepairing for C++ integration.
* //
* Revision 1.1 1997/10/13 17:02:35 curt // Revision 1.1 1998/04/08 22:57:25 curt
* Initial revision. // Adopted Gnu automake/autoconf system.
* //
*/ // Revision 1.1 1998/03/19 02:54:48 curt
// Reorganized into a class lib called fgDEM.
//
// Revision 1.1 1997/10/13 17:02:35 curt
// Initial revision.
//