1 // Copyright (c) 2015-2016, Massachusetts Institute of Technology
2 // Copyright (c) 2016-2017 Sandia Corporation
3 // Copyright (c) 2017 NTESS, LLC.
4 
5 // This file is part of the Compressed Continuous Computation (C3) Library
6 // Author: Alex A. Gorodetsky
7 // Contact: alex@alexgorodetsky.com
8 
9 // All rights reserved.
10 
11 // Redistribution and use in source and binary forms, with or without modification,
12 // are permitted provided that the following conditions are met:
13 
14 // 1. Redistributions of source code must retain the above copyright notice,
15 //    this list of conditions and the following disclaimer.
16 
17 // 2. Redistributions in binary form must reproduce the above copyright notice,
18 //    this list of conditions and the following disclaimer in the documentation
19 //    and/or other materials provided with the distribution.
20 
21 // 3. Neither the name of the copyright holder nor the names of its contributors
22 //    may be used to endorse or promote products derived from this software
23 //    without specific prior written permission.
24 
25 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 
36 //Code
37 
38 
39 /** \file fwrap.h
40  * Provides header files and structure definitions for functions in fwrap.c
41  */
42 
43 #ifndef FWRAP_H
44 #define FWRAP_H
45 
46 #include <stddef.h>
47 
48 struct Fwrap;
49 struct Fwrap * fwrap_create(size_t, const char *);
50 int fwrap_get_type(const struct Fwrap *);
51 void fwrap_set_f(struct Fwrap *, double(*)(const double*,void*),void*);
52 void fwrap_set_findex(struct Fwrap *,double(*)(const size_t*,void*),void*);
53 void fwrap_set_fvec(struct Fwrap *,
54                     int (*)(size_t, const double*,double*,void*),void*);
55 void fwrap_set_mofvec(struct Fwrap *,
56                       int (*)(size_t,size_t,const double*,double*,void*),
57                       void*);
58 void fwrap_set_which_eval(struct Fwrap *, size_t);
59 size_t fwrap_get_which_eval(const struct Fwrap *);
60 
61 void fwrap_set_num_funcs(struct Fwrap *, size_t);
62 void fwrap_set_func_array(struct Fwrap *,size_t,
63                           int (*)(size_t,const double*,double*,void *),
64                           void *);
65 void fwrap_destroy(struct Fwrap *);
66 /* int fwrap_eval(size_t, const double *, double *, void *); */
67 int fwrap_eval(size_t, const void *, double *, void *);
68 
69 // fibers
70 void fwrap_initialize_fiber_approx(struct Fwrap *, size_t, size_t);
71 /* void fwrap_add_fiber(struct Fwrap *, size_t,  */
72 /*                      size_t, const double *,  */
73 /*                      size_t, const double *); */
74 void fwrap_add_fiber(struct Fwrap *, size_t,
75                      size_t, const void *,
76                      size_t, const void *);
77 void fwrap_set_which_fiber(struct Fwrap *, size_t);
78 void fwrap_clean_fiber_approx(struct Fwrap *);
79 /* int fwrap_eval_fiber(size_t, const double *, double *, void *); */
80 int fwrap_eval_fiber(size_t, const void *, double *, void *);
81 
82 
83 // Interface stuff
84 
85 #ifdef COMPILE_WITH_PYTHON
86 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
87 #include <Python.h>
88 #include "numpy/arrayobject.h"
89 #include "numpy/ndarraytypes.h"
90 
91 int c3py_wrapped_eval(size_t N, const double * x, double * out, void * args);
92 void fwrap_set_pyfunc(struct Fwrap *, PyObject *);
93 
94 #endif
95 
96 
97 #endif
98