Jpp  17.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
JMARKOV::JCombinedGenerator Class Reference

Implementation of the JGenerator interface. More...

#include <JMarkovGenerator.hh>

Inheritance diagram for JMARKOV::JCombinedGenerator:
JMARKOV::JGenerator

Public Member Functions

 JCombinedGenerator (double _c1, JGenerator *_g1, double _c2, JGenerator *_g2)
 Constructor. More...
 
JPosition3D getPosition ()
 Return a randomly generated position. More...
 
double getWeight (JPosition3D pos)
 return the weight (=probability density dP/dV) for the given position. More...
 

Protected Attributes

JGeneratorg1
 
JGeneratorg2
 
double p1
 
double p2
 

Detailed Description

Implementation of the JGenerator interface.

Generates positions by combining two other JGenerators

Definition at line 396 of file JMarkovGenerator.hh.

Constructor & Destructor Documentation

JMARKOV::JCombinedGenerator::JCombinedGenerator ( double  _c1,
JGenerator _g1,
double  _c2,
JGenerator _g2 
)
inline

Constructor.

The arguments _gn are pointers to the two JGenerators to use. Note that ownership is not transferred, i.e.

  • the memory taken by the _gn is not freed when JCombinedGenerator is deleted
  • changes made to the instances pointed to by the _gn will affect the behaviour of the JCombinedGenerator

The arguments _cn are the relative weights of the two generators. They do not have to add up to 1. The probability that a value is generated from g1 is c1/(c1+c2).

Definition at line 414 of file JMarkovGenerator.hh.

414  : g1(_g1), g2(_g2) {
415  p1 = _c1/(_c1+_c2) ;
416  p2 = 1-p1 ;
417  }

Member Function Documentation

JPosition3D JMARKOV::JCombinedGenerator::getPosition ( )
inlinevirtual

Return a randomly generated position.

Implements JMARKOV::JGenerator.

Definition at line 419 of file JMarkovGenerator.hh.

419  {
420  if( gRandom->Uniform()<p1 ) {
421  return g1->getPosition() ;
422  } else {
423  return g2->getPosition() ;
424  }
425  }
virtual JPosition3D getPosition()=0
Return a randomly generated position.
double JMARKOV::JCombinedGenerator::getWeight ( JPosition3D  pos)
inlinevirtual

return the weight (=probability density dP/dV) for the given position.

When the generator is properly normalized, the integral of this quantity over the whole space is 1.

Implements JMARKOV::JGenerator.

Definition at line 427 of file JMarkovGenerator.hh.

427  {
428  double w1 = g1->getWeight(pos) ;
429  double w2 = g2->getWeight(pos) ;
430  return p1*w1 + p2*w2 ;
431  }
virtual double getWeight(JPosition3D pos)=0
return the weight (=probability density dP/dV) for the given position.

Member Data Documentation

JGenerator* JMARKOV::JCombinedGenerator::g1
protected

Definition at line 435 of file JMarkovGenerator.hh.

JGenerator* JMARKOV::JCombinedGenerator::g2
protected

Definition at line 436 of file JMarkovGenerator.hh.

double JMARKOV::JCombinedGenerator::p1
protected

Definition at line 437 of file JMarkovGenerator.hh.

double JMARKOV::JCombinedGenerator::p2
protected

Definition at line 438 of file JMarkovGenerator.hh.


The documentation for this class was generated from the following file: