e576bb2002-10-11Martin Nilsson /* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. */
c5e7291999-03-31Mirar (Pontus Hagland)  #include "global.h" #include "config.h" #include "program.h"
51ef5c2002-10-21Marcus Comstedt #include "module.h"
c5e7291999-03-31Mirar (Pontus Hagland) 
02eb461999-03-31Mirar (Pontus Hagland) #include "math_module.h"
10b9262002-05-09Marcus Agehall #include "transforms.h"
c5e7291999-03-31Mirar (Pontus Hagland) 
6dc2772000-07-28Fredrik Hübinette (Hubbe) 
c5e7291999-03-31Mirar (Pontus Hagland) /*** module init & exit & stuff *****************************************/ /* add other parsers here */
6a33fa1999-03-31Mirar (Pontus Hagland) struct program *math_matrix_program;
c186d22001-07-15Per Hedbor struct program *math_imatrix_program; struct program *math_fmatrix_program; struct program *math_smatrix_program;
a8b9f42001-07-16Henrik Grubbström (Grubba) #ifdef INT64
c186d22001-07-15Per Hedbor struct program *math_lmatrix_program;
a8b9f42001-07-16Henrik Grubbström (Grubba) #endif /* INT64 */
10b9262002-05-09Marcus Agehall struct program *math_transforms_program;
6a33fa1999-03-31Mirar (Pontus Hagland) 
0d765c2004-09-19Martin Nilsson static const struct math_class
c5e7291999-03-31Mirar (Pontus Hagland) { char *name; void (*func)(void);
6a33fa1999-03-31Mirar (Pontus Hagland)  struct program **pd;
c5e7291999-03-31Mirar (Pontus Hagland) } sub[] = {
6a33fa1999-03-31Mirar (Pontus Hagland)  {"Matrix",init_math_matrix,&math_matrix_program},
c186d22001-07-15Per Hedbor  {"IMatrix",init_math_imatrix,&math_imatrix_program},
a8b9f42001-07-16Henrik Grubbström (Grubba) #ifdef INT64
c186d22001-07-15Per Hedbor  {"LMatrix",init_math_lmatrix,&math_lmatrix_program},
a8b9f42001-07-16Henrik Grubbström (Grubba) #endif /* INT64 */
c186d22001-07-15Per Hedbor  {"FMatrix",init_math_fmatrix,&math_fmatrix_program}, {"SMatrix",init_math_smatrix,&math_smatrix_program},
10b9262002-05-09Marcus Agehall  {"Transforms",init_math_transforms,&math_transforms_program},
c5e7291999-03-31Mirar (Pontus Hagland) };
a88aa82003-11-08Martin Nilsson /*! @module Math */ /*! @decl constant pi *! The constant pi (3.14159265358979323846). */ /*! @decl constant e *! The constant e (2.7182818284590452354). */ /*! @decl constant inf *! Floating point infinity. */ /*! @decl constant nan *! Floating point not-a-number (e.g. inf/inf). */ /*! @endmodule */
51ef5c2002-10-21Marcus Comstedt PIKE_MODULE_EXIT
c5e7291999-03-31Mirar (Pontus Hagland) {
6a33fa1999-03-31Mirar (Pontus Hagland)  int i; for (i=0; i<(int)(sizeof(sub)/sizeof(sub[0])); i++) if (sub[i].pd && sub[i].pd[0]) free_program(sub[i].pd[0]);
cfada31999-11-08Henrik Grubbström (Grubba)  exit_math_matrix();
c186d22001-07-15Per Hedbor  exit_math_imatrix(); exit_math_fmatrix(); exit_math_smatrix();
10b9262002-05-09Marcus Agehall  exit_math_transforms();
c5e7291999-03-31Mirar (Pontus Hagland) }
51ef5c2002-10-21Marcus Comstedt PIKE_MODULE_INIT
c5e7291999-03-31Mirar (Pontus Hagland) { int i;
2ebc5a2001-07-31Marcus Comstedt  DECLARE_INF DECLARE_NAN
13670c2015-05-25Martin Nilsson 
c5e7291999-03-31Mirar (Pontus Hagland)  for (i=0; i<(int)(sizeof(sub)/sizeof(sub[0])); i++) { struct program *p; start_new_program(); sub[i].func(); p=end_program(); add_program_constant(sub[i].name,p,0);
6a33fa1999-03-31Mirar (Pontus Hagland)  if (sub[i].pd) sub[i].pd[0]=p; else free_program(p);
c5e7291999-03-31Mirar (Pontus Hagland)  }
405beb1999-10-25Mirar (Pontus Hagland)  add_float_constant("pi",3.14159265358979323846 ,0); add_float_constant("e", 2.7182818284590452354 ,0);
2ebc5a2001-07-31Marcus Comstedt  add_float_constant("inf", MAKE_INF(1), 0); add_float_constant("nan", MAKE_NAN(), 0);
c5e7291999-03-31Mirar (Pontus Hagland) }