|
funkalicious 0.1
|
00001 /* 00002 *1D density routines 00003 00004 Copyright (C) 2010 Joseph Pingenot 00005 00006 This program is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU Affero General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU Affero General Public License for more details. 00015 00016 You should have received a copy of the GNU Affero General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 00019 * 00020 */ 00021 00022 #ifndef ____DENSITY_1D_H__ 00023 #define ____DENSITY_1D_H__ 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #define restrict 00028 #endif 00029 00030 #include <glib-2.0/glib.h> 00031 #include <gio/gio.h> 00032 #include <libpostproc/density_common.h> 00033 00034 struct density_1d { 00035 unsigned int N; 00036 double dx; 00037 double* storage; 00038 }; 00039 00040 /**Density distribution hints. These help ensure numerical accuracy. 00041 *constant: there is roughly an even distribution across the structure 00042 *centered: there is very very little at the edges and much more at the center. 00043 *anticentered: there is very little at the center and much more at the edges. 00044 */ 00045 enum density_1d_distribution_hint { 00046 CONSTANT, 00047 CENTERED, 00048 ANTICENTERED 00049 }; 00050 00051 void init_density_1d(struct density_1d* d, double initial_value); 00052 void density_1d_mul_by_const(struct density_1d* d, double c); 00053 void density_1d_add_const(struct density_1d* d, double c); 00054 struct density_1d* new_density_1d(int N, double dx, double initial_value); 00055 struct density_1d* new_density_1d_copy(const struct density_1d* orig); 00056 void free_density_1d(struct density_1d* d); 00057 int op_density_1d_to_density_1d(struct density_1d* to, enum density_op op, const struct density_1d* from); 00058 /**Allows the caller to specify a callback to perform a more advanced manipulation. 00059 *\param to density to which values are saved and from which values are drawn 00060 *\param from density from which values are drawn 00061 *\param callback function to call at each point 00062 *\param privdat private data to send to the callback 00063 *\note CALLBACK MUST NOT SAVE STATE; callback may be called in numerous threads! 00064 *\note that to and from CANNOT be the same or overlap! (restrict keyword) 00065 */ 00066 int op_density_1d_to_density_1d_cb(struct density_1d *restrict to, const struct density_1d *restrict from, void(*callback)(int X, unsigned N, double dx, double *restrict to, double from, void *restrict privdat), void *restrict privdat); 00067 /**Gets the sum of the density, using distribution hint.*/ 00068 double density_1d_sum(const struct density_1d* d, enum density_1d_distribution_hint hint); 00069 double density_1d_integrate_density(const struct density_1d* d, double abserr, double relerr, double* ierr, GError **e, int filename_index); 00070 00071 /*These ops are not yet supported; we don't need them anytime soon.*/ 00072 /* 00073 void put_density_1d_into_metadensity_1d(struct density_1d* md, struct density_1d* d, int *Nn, int x, int y, int z, gboolean invert_x, gboolean invert_y, gboolean invert_z); 00074 00075 void write_density_1d_slice(enum coord c, int* index, struct density_1d* d, char** filename, GError **err, GFile *location, char sepchar, const char* coord_units, const char* density_1d_units); 00076 void write_density_1d_sweep(enum coord c, struct density_1d* d, char** filename, GError **err, GFile* location, gboolean sweep_log); 00077 00078 void get_density_1d_from_metadensity_1d(struct density_1d* md, struct density_1d* d, int* buffzone, int *Nn, int x, int y, int z); 00079 00080 struct density_1d* expand_density_1d_box_with_value(const struct density_1d* od, const int* I, double value, GError **err); 00081 00082 struct density_1d* expand_density_1d_box(const struct density_1d* od, const int* I, GError **err); 00083 */ 00084 00085 #ifdef __cplusplus 00086 } 00087 #endif 00088 00089 #endif