home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 August / macformat-053.iso / mac / Shareware Plus / Developers / FuncComp.f / FuncComp.h next >
Encoding:
C/C++ Source or Header  |  1997-04-19  |  3.2 KB  |  93 lines  |  [TEXT/CWIE]

  1. // Copyright ©1997 Zdzisiek Losvik, Gdynia 81-523, Przemyslawa 12a, POLAND
  2. // All rights reserved.
  3.  
  4. // ********************************************************************************
  5. // **                    Header to the FuncComp.Lib Library              ** 02.1997 **
  6. // ********************************************************************************
  7. // ** This small lib contains two very useful functions that:                     **
  8. // **                                                                             **
  9. // **  (i) Convert string of characters into a fast computable internal form     **
  10. // ** (ii) Fast computes the value of converted string given the value of X         **
  11. // **                                                                             **
  12. // ********************************************************************************
  13.  
  14. // ** THIS IS NOT FREE, I have spend few days on creating it and I think it's worth $5
  15. // ** Please send me the money if you are going to write something using this lib
  16.  
  17. // • All data is kept in global variables (1.2kB)
  18. // • All operations are performed using 'double' data type
  19. // • Errors are returned via global variable funcErr
  20. // • ANSI math is used to perform opertions (math.h)
  21. // • I wish, it was also PowerPC native but I haven't got the right compilator
  22. //     so I'm waiting to get some money and to buy one
  23.  
  24. // • Operators: +, -, *, /, ^
  25. // • Backets - over 20
  26. // • Functions: SIN,     COS,     TAN,     COT,    trigonometric functions
  27. //                SINH,     COSH,     TANH,     COTH,        hyperbolic trigonometric functions    
  28. //                ARCSIN, ARCCOS, ARCTAN,    ARCCOT,    arc trig. func.
  29. //                ARCSINH,ARCCOSH,ARCTANH,ARCCOTH,arc hyp. trig. func.
  30. //                EXP,    LOG,    LN,        INT,
  31. //                FRAC,    SQRT,    ABS,    !,        fraction, square root, absolute value, factorial
  32. //                °,        X,        E,        PI        degree, X, base of the exponential, pi                    
  33.  
  34. // • Example :    1° (sin):        x-x^3/3!+x^5/5!-x^7/7!+x^9/9!
  35. //                2° (parabola):    2x^2-3x+5
  36. //                3° (any other):    2(5x-2)(3x+5)-2ln(x^2-3x)+xx
  37.  
  38.  
  39. // Don't know how to use it ??? Look at the example.
  40.  
  41. /*
  42.  
  43. void main(void)
  44. {
  45.     Str255 s = "2x^2-3x+5";  // any math C-style string
  46.     double y;
  47.     
  48.     BuildFunction(s);         // build it (internally)
  49.     
  50.     y = CalcFunc(10);
  51.     }
  52.  
  53. */
  54.  
  55. // ********************************************************************************
  56. // ***                                The glue                                    ***
  57. // ********************************************************************************
  58.  
  59. // ERROR codes returned while BUILDING function
  60.  
  61. enum {    badSyntaxErr = 1,    // 
  62.         missingLBErr,        // unpaired right bracket
  63.         missingRBErr,        // unpaired left bracket
  64.         unknownErr,            // unknown operation/function
  65.                             // global var. 'funcInPos' contains the begining of unknown string
  66.         anExtraPointErr,    // too many points in a number
  67.         tooComplexErr         // this should never occur
  68.         };
  69.  
  70. // ERROR code returned while performing mathematic operations
  71.  
  72. #define noValueErr        1
  73.  
  74.  
  75. // *******************************************************************************
  76. // Global variables
  77.  
  78. extern short funcInPos;    // Where was the problem (if there was)
  79. extern short funcErr;        // Contains an error of last operation
  80.  
  81.  
  82. // *******************************************************************************
  83. // Functions
  84.  
  85. // Convert the function
  86. extern void BuildFunction (char * inS); // inS  C-style string
  87.  
  88. // Compute it's value given X
  89. extern double CalcFunc(double X);
  90.  
  91. // Send me any comments
  92.  
  93.