queso-0.51.1
Macros | Functions
TestVectorRV_gsl.C File Reference
#include <boost/test/included/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
#include <queso/VectorSpace.h>
#include <queso/VectorRV.h>
#include <queso/GslMatrix.h>
Include dependency graph for TestVectorRV_gsl.C:

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE
 

Functions

 BOOST_AUTO_TEST_CASE (test_uqGaussianVectorRV)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE

Definition at line 1 of file TestVectorRV_gsl.C.

Function Documentation

BOOST_AUTO_TEST_CASE ( test_uqGaussianVectorRV  )

Definition at line 11 of file TestVectorRV_gsl.C.

12 {
13  // Initialize
14  MPI_Init(NULL, NULL);
15  uqFullEnvironment env;
16  uqVectorSpace<uqGslVector, uqGslMatrix> imageSpace(env, "test_space", 2, NULL);
17  uqMap eMap(2, 0, env.comm());
18 
19  uqGslVector imageMinVal(env, eMap, -INFINITY);
20  uqGslVector imageMaxVal(env, eMap, INFINITY);
21 
22  uqGslVector initExpectedValues(env, eMap, 0.0);
23  uqGslMatrix initCovMatrix(env, eMap, 1.0);
24 
25  uqGslVector finalExpectedValues(env, eMap, 1.0);
26  uqGslMatrix finalCovMatrix(env, eMap, 3.0);
27 
28  uqGslVector testValues(env, eMap, 0.0);
29 
30  uqGaussianVectorRV<uqGslVector, uqGslMatrix> gaussianRV("test_rv", imageSpace, imageMinVal, imageMaxVal,
31  initExpectedValues, initCovMatrix);
32  double tolClose = 1e-13, tolSmall = 1e-16;
33 
34  //***********************************************************************
35  // Test pdf
36  // NOTE: pdf is not normalized
37  //***********************************************************************
38 
39  // mean = [0; 0], var = [1; 1], testValues = [0; 0]
40  BOOST_REQUIRE_CLOSE(gaussianRV.pdf().actualDensity(testValues), 1.0, tolClose);
41 
42  // change mean and check that new pdf is correct
43  gaussianRV.updateExpectedValues(finalExpectedValues);
44  BOOST_REQUIRE_CLOSE(gaussianRV.pdf().actualDensity(testValues), std::exp(-1.0), tolClose);
45 
46  //***********************************************************************
47  // Test realizer
48  // NOTE: just calls it... doesn't check values
49  //***********************************************************************
50  uqGslVector myRealization(testValues);
51  gaussianRV.realizer().realization(myRealization);
52 
53  std::cout << myRealization;
54 
55  // finalize
56  MPI_Finalize();
57 }

Generated on Thu Apr 23 2015 19:26:16 for queso-0.51.1 by  doxygen 1.8.5