/* Basic definitions. */ /* Last edited on 2007-12-26 15:18:43 by stolfi */ #ifndef basis_H #define basis_H /* Copyright © 2007 by the State University of Campinas (UNICAMP). */ /* See the copyright, authorship, and warranty notice at end of file. */ /* Last edited on 2007-04-16 17:30:29 by stolfi */ #include #include #include #include /* Created apr/2007 by Jorge Stolfi, UNICAMP */ typedef int32_t basis_index_t; /* Identifies one element of a basis. */ /* BASIS OBJECT */ typedef struct basis_t basis_t; /* A {basis_t} object {bas} describes a family of functions defined on some domain {dom} supplied externally. The elements of the basis are identified by indices in the range {0..num-1} where {num = bas->size(bas)}. The support interval of an element with index {ix} is {bas->supp(bas, ix)}, and its value at a point {t} of the domain is {bas->eval(bas,ix,t)}. A concrete instance of a {basis_t} is any {struct} that has a {basis_t} as the first field. The string {bas->type} should identify the concrete instance type. */ #define basis_TYPE "basis." /* The required prefix of {b->type} for any concrete instance {b} of {basis_t}. */ /* METHODS OF A BASIS OBJECT */ typedef char *basis_name_fn_t(basis_t *bas); /* A succint string that identifies the basis, suitable for file names and such. */ typedef int32_t basis_size_fn_t(basis_t *bas); /* Returns the number of elements in the basis {bas}. */ typedef void basis_show_fn_t(basis_t *bas, FILE *wr); /* Prints a description of {bas} to file {wr}. */ typedef interval_t basis_supp_fn_t(basis_t *bas, basis_index_t ix); /* An interval {r} such that the element with index {ix} of basis {bas} is zero for {t < r.end[0]} or {t > r.end[1]}. */ typedef double basis_eval_fn_t(basis_t *bas, basis_index_t ix, double t[]); /* Evaluates the element with index {ix} of basis {bas} at the argument {t[]}. */ struct basis_def_t { basis_size_fn_t *size; /* Returns the number of elements in the family. */ basis_supp_fn_t *supp; /* Returns the support interval. */ basis_eval_fn_t *eval; /* Evaluates a member of the family. */ basis_name_fn_t *name; /* Returns the family's name. */ basis_show_fn_t *show; /* Prints a description of the basis. */ char *type; /* Concrete type. */ }; /* USEFUL TYPES */ typedef int8_t basis_degree_t; /* Degree of a polynomial or spline, max order of a trig series, etc.. */ typedef int8_t basis_cont_t; /* Continuity order of a spline. Value {-1} means discontinuous.. */ #endif