moments.h

Go to the documentation of this file.
00001 
00002 
00003 //
00008 
00009 //--------------------------------------------------------------------------
00010 //--------------------------------------------------------------------------
00011 //  
00012 //  libMoM Library - a library for stochastic simulations in engineering.
00013 // 
00014 //  Copyright (C) 2010 Rochan R. Upadhyay
00015 // 
00016 //  This library is free software; you can redistribute it and/or
00017 //  modify it under the terms of the Version 2.1 GNU Lesser General
00018 //  Public License as published by the Free Software Foundation.
00019 // 
00020 //  This library is distributed in the hope that it will be useful,
00021 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00023 //  Lesser General Public License for more details.
00024 // 
00025 //  You should have received a copy of the GNU Lesser General Public
00026 //  License along with this library; if not, write to the Free Software
00027 //  Foundation, Inc. 51 Franklin Street, Fifth Floor, 
00028 //  Boston, MA  02110-1301  USA
00029 // 
00030 //--------------------------------------------------------------------------
00031 
00032 
00033 #ifndef _MOMENTS_H
00034 #define _MOMENTS_H
00035 
00036 #include <stdio.h>
00037 #include <stdlib.h>
00038 #include <gsl/gsl_multiroots.h>
00039 #include "gsl_vector_integer.h"
00040 #include "gsl_vector_double.h"
00041 #include "gsl_matrix_double.h"
00042 #include "gsl_matrix_integer.h"
00043 #include "gsl_vector_matrix_ops.h"
00044 #include "gsl_multidim_fminimizer.h"
00045 #include "gsl_special_functions.h"
00046 #include "sobol_sequences.h"
00047 #include "quadpts.h" 
00048 
00049 class quadpts;
00050 
00052 //
00054 
00055 class moments : public vector
00056 {
00057 
00058  private: 
00059  
00061 //
00062  
00063  vector moms;
00064  
00065  public:
00066  
00068  //
00069  
00070  moments();
00071  
00073  // 
00075  //
00076  
00077  moments( size_t a );
00078  
00080  //
00087  //
00088  
00089  quadpts product_difference( size_t dimension, size_t num_points ) const;
00090 
00092  //
00098  //
00099  
00100  quadpts three_term_recurrence (size_t dimension, size_t num_points) const;
00101 
00103  //
00110  //
00111  
00112  quadpts get_quadpts_univariate_Gaussian (size_t dimension, size_t num_points) const;
00113  
00115  //
00122  // 
00123  
00124  quadpts get_quadpts( size_t dimension, size_t num_points) const;
00125 
00127 //
00131 //
00132  
00133  vector get_source ( size_t dimension, size_t num_points ) const;
00134 
00136 //
00142 //
00143  
00144  void solve ( size_t dimension, size_t num_points, 
00145                                   double dt, long int num_steps, int print_interval );
00146                                   
00147  void solve_with_gsl ( size_t dimension, size_t num_points, double dt,
00148                                     long int num_steps, int print_interval );
00149                                     
00151 //
00157 //
00158 
00159  void post_process_moments (size_t dimension, size_t num_points, double time) const;
00160 
00162 //
00168 //
00170 //
00171  
00172  moments beta( size_t dimension, size_t num_points, double b1, double b2);
00173 
00175 //
00182 //
00184 //
00185 
00186  moments generalized_beta( size_t dimension, size_t num_points, double b1, double b2, double b3);
00187  
00189 //
00193  
00194  
00195  moments exp_t3(  size_t dimension, size_t num_points );
00196 
00198 //
00202 //
00205 //
00206 
00207  matrix get_cdf_gld(size_t num_intervals, char* param_type) const; 
00208 
00210 //
00216 //
00218 //
00219 
00220  moments univariate_lognormal ( size_t dimension, size_t num_points, double mu_g, double std_g);
00221  
00223 //
00231 //
00233 //
00234 
00235  moments univariate_lognormal_fractional ( size_t dimension, size_t num_points, double mu_g, double std_g, double start, double increment);
00236 
00238 //
00244 //
00246 //
00247  
00248  moments univariate_gaussian_raw ( size_t dimension, size_t num_points, double mu, double std_dev);
00249 
00251 //
00257 //
00259 //
00260  
00261  moments uniform_distribution( size_t dimension, size_t num_points, double left, double right);
00262 
00264 //
00267 //
00269 
00270  moments get_moments_upto_order(size_t dimension, size_t orig_dimension);
00271 
00273 //
00276 //
00277  
00278  vector parameters () const;
00279  
00281 //
00283 //
00284  
00285  vector get_gld_four_lambdas(char* param_type) const;
00286  
00287 };
00288 
00291 //
00292 
00293 class multivariate_moments : public matrix
00294 {
00295 
00296  private: 
00297  
00298  matrix multivar_moms;
00299  
00300  public:
00301  
00303 //
00304  
00305  multivariate_moments();
00306 
00308 // 
00311 // 
00312  
00313  multivariate_moments( size_t a, size_t b );   
00314   
00316 //
00318 //
00321 
00322  moments multivariate_moment_set_independent (size_t return_order);  
00323  
00325 //
00328 //
00331  
00332  moments extract_univariate_moments (size_t row_number);
00333  
00334 };
00335 
00337 //
00338 
00339 class my_multimin_f_fmkl : public multimin_f
00340 {
00341    public:
00342    
00344 //
00346 //
00347    
00348    double operator()(const vector& x);
00349    
00350 };
00351 
00353 //
00354 
00355 class my_multimin_f_rs : public multimin_f
00356 {
00357    public:
00358    
00360 //
00362 //   
00363    
00364    double operator()(const vector& x);
00365    
00366 };
00367 
00368 class my_qmom_ode_function : public ode_function
00369 {
00370    public:   
00371 
00372    vector operator()(double time, const vector& x);   
00373 
00374 };
00375 
00376 #endif // MOMENTS_H
00377 
All Classes Files Functions Variables Typedefs Friends Defines