home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / VideoToolbox 95.04.18 / Utilities / Quick3 / Quick3.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-05  |  2.0 KB  |  61 lines  |  [TEXT/MMCC]

  1. /* Quick3.h
  2. HISTORY:
  3. 3/10/92 dgp    Cast PARAMS to be a short int.
  4.             If appropriate, use the 68881 log and exp instructions for speed.
  5.             For speed, defined exp10(), and use exp and log to compute pow.
  6.             These changes speed up the computation enormously, perhaps 50-fold,
  7.             yet when run on "sample.data" the resulting "sample.fit" is unchanged.
  8. */
  9. #pragma once    /* prevent multiple inclusions of this file */
  10. #include <math.h>
  11. #include <stdio.h>    /* needed for prototypes */
  12. #include <stdlib.h>
  13. #define MAX_CONTRASTS 200
  14. #define ILLEGAL_PARAMETERS -1.0    /* unique value indicating parameters out of bounds */
  15. #define MACINTOSH 1
  16. #include "mc68881.h"
  17. #if (THINK_C || THINK_CPLUS) && mc68881
  18.     #define exp _exp    /* use fast 68881 instruction instead of SANE */
  19.     #define log _log    /* use fast 68881 instruction instead of SANE */
  20. #endif
  21. #ifndef exp10
  22.     #define exp10(x) exp(LOG10*(x))            /* faster than pow(10.0,x) */
  23. #endif
  24. #undef pow
  25. #define pow(x,y) exp(log(x)*(y))            /* faster by use of 68881 instructions */
  26. #if !defined(LOG10)
  27.     #define LOG10    2.30258509299404568402    /* computed in Mathematica */
  28. #endif
  29.  
  30. typedef struct {
  31.     double contrast;
  32.     long trials;
  33.     long correct;
  34. } contrastRecord;
  35.  
  36. typedef struct {
  37.     long contrasts;
  38.     contrastRecord c[MAX_CONTRASTS];    /* an array of records is easier to sort */
  39. } dataRecord;
  40.  
  41. typedef struct {
  42.     double logAlpha;
  43.     double beta;
  44.     double gamma;
  45.     double delta;
  46. } paramRecord;
  47.  
  48. #define PARAMS ((short)(sizeof(paramRecord)/sizeof(double)))
  49.  
  50. typedef double (*PsychometricFunctionPtr)(double contrast,paramRecord *paramPtr);
  51.  
  52. double Weibull(double contrast,paramRecord *paramPtr);
  53. double LogLikelihood(dataRecord *data,paramRecord *params,
  54.     PsychometricFunctionPtr PsychFun);
  55. double PsychometricFit(paramRecord *paramPtr
  56.     ,PsychometricFunctionPtr PsychFun
  57.     ,dataRecord *dataPtr,double *logLikelihoodPtr,int degreesOfFreedom
  58.     ,double *chiSquarePtr,int *chiSquareDFPtr);
  59. void MonotonicFit(dataRecord *data,double *logLikelihoodPtr,int *degreesOfFreedomPtr);
  60. void SortAndMergeContrasts(dataRecord *dataPtr);
  61.