Trilinos based (stochastic) FEM solvers
main.cpp
Go to the documentation of this file.
1 #include "Epetra_ConfigDefs.h"
2 #ifdef HAVE_MPI
3 #include "mpi.h"
4 #include "Epetra_MpiComm.h"
5 #else
6 #include "Epetra_SerialComm.h"
7 #endif
8 
9 #include "Teuchos_CommandLineProcessor.hpp"
10 #include "Teuchos_StandardCatchMacros.hpp"
11 #include "Teuchos_ParameterList.hpp"
12 #include "Teuchos_XMLParameterListCoreHelpers.hpp"
13 
14 #include <boost/random/mersenne_twister.hpp>
15 #include <boost/random/uniform_real_distribution.hpp>
16 #include <boost/math/special_functions/erf.hpp>
17 #include <boost/random/normal_distribution.hpp>
18 #include <boost/math/special_functions/gamma.hpp>
19 #include <boost/math/special_functions/beta.hpp>
20 
21 #include "meshpp.hpp"
22 
23 int main(int argc, char *argv[]){
24 
25 #ifdef HAVE_MPI
26  MPI_Init(&argc, &argv);
27  Epetra_MpiComm Comm(MPI_COMM_WORLD);
28 #else
29  Epetra_SerialComm Comm;
30 #endif
31 
32  double mean = 0.0;
33  double stan = 1.0;
34  int nmc = 1000;
35  int n = 3;
36 
37  boost::random::normal_distribution<double> x(mean,stan);
38  boost::random::mt19937 rng;
39  rng.seed(std::time(0));
40 
41  Epetra_SerialDenseVector X(n);
42  Epetra_SerialDenseVector Y(n);
43  Epetra_SerialDenseVector c(n);
44  Epetra_SerialDenseMatrix Z(nmc,n);
45  c(0) = 0.0; c(1) = 0.0; c(2) = 0.0;
46  double radius = 1.0;
47 
48  for (unsigned int i=0; i<nmc; ++i){
49  for (unsigned int j=0; j<n; ++j){
50  X(j) = x(rng);
51  }
52  double s = X.Norm2();
53  double gammainc = boost::math::gamma_p<double,double>(s*s/2.0,double(n)/2.0);
54  for (unsigned int j=0; j<n; ++j){
55  Y(j) = X(j)*(radius*std::pow(gammainc,1.0/double(n))/s);
56  Z(i,j) = Y(j) + c(j);
57  std::cout << std::setw(20) << Z(i,j);
58  }
59  std::cout << "\n";
60  }
61 
62 
63 #ifdef HAVE_MPI
64  MPI_Finalize();
65 #endif
66 return 0;
67 
68 }
output Y
Definition: costFunction.m:49
s
Definition: run.m:11
for j
Definition: costFunction.m:42
optimParameters nmc
int main(int argc, char *argv[])
Definition: main.cpp:23
for i
Definition: costFunction.m:38