libsc  1.6.0
src/sc_functions.h
00001 /*
00002   This file is part of the SC Library.
00003   The SC Library provides support for parallel scientific applications.
00004 
00005   Copyright (C) 2010 The University of Texas System
00006 
00007   The SC Library is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU Lesser General Public
00009   License as published by the Free Software Foundation; either
00010   version 2.1 of the License, or (at your option) any later version.
00011 
00012   The SC Library is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015   Lesser General Public License for more details.
00016 
00017   You should have received a copy of the GNU Lesser General Public
00018   License along with the SC Library; if not, write to the Free Software
00019   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020   02110-1301, USA.
00021 */
00022 
00023 #ifndef SC_FUNCTIONS_H
00024 #define SC_FUNCTIONS_H
00025 
00026 #include <sc.h>
00027 
00028 SC_EXTERN_C_BEGIN;
00029 
00030 typedef double      (*sc_function1_t) (double x, void *data);
00031 
00032 typedef double      (*sc_function3_t) (double x, double y, double z,
00033                                        void *data);
00034 
00035 /*
00036  * this structure is used as data element for the meta functions.
00037  * for _sum and _product:
00038  * f1 needs to be a valid function.
00039  * f2 can be a function, then it is used,
00040  *    or NULL, in which case parameter2 is used.
00041  * for _tensor: f1, f2, f3 need to be valid functions.
00042  */
00043 typedef struct sc_function3_meta
00044 {
00045   sc_function3_t      f1;
00046   sc_function3_t      f2;
00047   double              parameter2;
00048   sc_function3_t      f3;
00049   void               *data;
00050 }
00051 sc_function3_meta_t;
00052 
00053 /* Evaluate the inverse function with regula falsi: x = func^{-1}(y) */
00054 double              sc_function1_invert (sc_function1_t func, void *data,
00055                                          double x_low, double x_high,
00056                                          double y, double rtol);
00057 
00064 void                sc_srand (unsigned int seed);
00065 
00070 void                sc_srand_time ();
00071 
00076 double              sc_rand_uniform (void);
00077 
00083 double              sc_rand_normal (void);
00084 
00085 /* Some basic 3D functions */
00086 double              sc_zero3 (double x, double y, double z, void *data);
00087 double              sc_one3 (double x, double y, double z, void *data);
00088 double              sc_two3 (double x, double y, double z, void *data);
00089 double              sc_ten3 (double x, double y, double z, void *data);
00090 
00094 double              sc_constant3 (double x, double y, double z, void *data);
00095 
00096 double              sc_x3 (double x, double y, double z, void *data);
00097 double              sc_y3 (double x, double y, double z, void *data);
00098 double              sc_z3 (double x, double y, double z, void *data);
00099 
00100 double              sc_sum3 (double x, double y, double z, void *data);
00101 double              sc_product3 (double x, double y, double z, void *data);
00102 double              sc_tensor3 (double x, double y, double z, void *data);
00103 
00104 SC_EXTERN_C_END;
00105 
00106 #endif /* !SC_FUNCTIONS_H */
 All Data Structures Files Functions Variables Typedefs Defines