home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 41 / IOPROG_41.ISO / soft / c++ / NUMCPP11.ZIP / kernels.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-17  |  1.4 KB  |  75 lines

  1. //===================================================================
  2. // kernels.cpp
  3. //
  4. // Version 1.1
  5. //
  6. // Written by:
  7. //   Brent Worden
  8. //   WordenWare
  9. //   email:  Brent@Worden.org
  10. //
  11. // Copyright (c) 1998-1999 WordenWare
  12. //
  13. // Created:  August 28, 1998
  14. // Revised:  April 10, 1999
  15. //===================================================================
  16.  
  17. #include <cmath>
  18.  
  19. #include "kernels.h"
  20. #include "mathx.h"
  21.  
  22. NUM_BEGIN
  23.  
  24. double biweight(double t)
  25. {
  26.     double tmp;
  27.     
  28.     if(-1.0 <= t && t <= 1.0){
  29.         tmp = (1.0 - t * t);
  30.         return .3125 * tmp * tmp;
  31.     }
  32.     
  33.     return 0.0;
  34. }
  35.  
  36. double cosine(double x)
  37. {
  38.     if(-1.0 <= x && x <= 1.0) return .5 + .5 * cos(NUMERICS_PI * x);
  39.     return 0.0;
  40. }
  41.  
  42. double epanech(double x)
  43. {
  44.     if(-1.0 <= x && x <= 1.0) return .75 - .75 * x * x;
  45.     return 0.0;
  46. }
  47.  
  48. double gaussian(double x)
  49. {
  50.     return 0.3989422804014327 * exp(-x*x*.5);
  51. }
  52.  
  53. double rectangle(double x)
  54. {
  55.     if(-1.0 <= x && x <= 1.0) return 0.5;
  56.     return 0.0;
  57. }
  58.  
  59. double triangle(double x)
  60. {
  61.     if(-1.0 <= x && x <= 1.0) return fabs(1.0 - x);
  62.     return 0.0;
  63. }
  64.  
  65. NUM_END
  66.  
  67. //===================================================================
  68. // Revision History
  69. //
  70. // Version 1.0 - 08/28/1998 - New.
  71. // Version 1.1 - 04/10/1999 - Added Numerics namespace.
  72. //===================================================================
  73.  
  74.  
  75.