QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Macros | Functions | Variables
mersenne-twister.cpp File Reference
#include <stdio.h>
#include "mersenne-twister.h"
Include dependency graph for mersenne-twister.cpp:

Go to the source code of this file.

Macros

#define M32(x)   (0x80000000 & x)
 
#define L31(x)   (0x7FFFFFFF & x)
 
#define ODD(x)   (x & 1)
 
#define MD_UINT32_MAX   std::numeric_limits<uint32_t>::max()
 
#define UNROLL
 

Functions

static void generate_numbers ()
 
void seed (uint32_t value)
 
uint32_t rand_u32 ()
 
int mt_rand ()
 
void mt_srand (unsigned value)
 
float randf_cc ()
 
float randf_co ()
 
float randf_oo ()
 
double randd_cc ()
 
double randd_co ()
 
double randd_oo ()
 
uint64_t rand_u64 ()
 

Variables

static const unsigned SIZE = 624
 
static const unsigned PERIOD = 397
 
static const unsigned DIFF = SIZE - PERIOD
 
static uint32_t MT [SIZE]
 
static unsigned index = 0
 

Macro Definition Documentation

#define L31 (   x)    (0x7FFFFFFF & x)

Definition at line 39 of file mersenne-twister.cpp.

Referenced by generate_numbers().

#define M32 (   x)    (0x80000000 & x)

Definition at line 38 of file mersenne-twister.cpp.

Referenced by generate_numbers().

#define MD_UINT32_MAX   std::numeric_limits<uint32_t>::max()

Definition at line 42 of file mersenne-twister.cpp.

Referenced by randd_cc(), randd_co(), randd_oo(), randf_cc(), randf_co(), and randf_oo().

#define ODD (   x)    (x & 1)

Definition at line 40 of file mersenne-twister.cpp.

Referenced by generate_numbers().

#define UNROLL
Value:
y = M32(MT[i]) | L31(MT[i+1]); \
MT[i] = MT[i-DIFF] ^ (y>>1) ^ MATRIX[ODD(y)]; \
++i;
static const unsigned DIFF
#define M32(x)
static uint32_t MT[SIZE]
#define L31(x)
#define ODD(x)

Referenced by generate_numbers().

Function Documentation

static void generate_numbers ( )
inlinestatic

Definition at line 44 of file mersenne-twister.cpp.

References DIFF, L31, M32, MT, ODD, PERIOD, SIZE, and UNROLL.

Referenced by rand_u32().

int mt_rand ( )

Definition at line 168 of file mersenne-twister.cpp.

References rand_u32().

Referenced by QgsPointSample::addSamplePoints(), and QgsTransectSample::createSample().

void mt_srand ( unsigned  value)

Definition at line 188 of file mersenne-twister.cpp.

References seed().

Referenced by QgsPointSample::createRandomPoints(), and QgsTransectSample::createSample().

uint32_t rand_u32 ( )

Definition at line 149 of file mersenne-twister.cpp.

References generate_numbers(), index, MT, and SIZE.

Referenced by mt_rand(), rand_u64(), randd_cc(), randd_co(), randd_oo(), randf_cc(), randf_co(), and randf_oo().

uint64_t rand_u64 ( )

Definition at line 223 of file mersenne-twister.cpp.

References rand_u32().

double randd_cc ( )

Definition at line 208 of file mersenne-twister.cpp.

References MD_UINT32_MAX, and rand_u32().

double randd_co ( )

Definition at line 213 of file mersenne-twister.cpp.

References MD_UINT32_MAX, and rand_u32().

double randd_oo ( )

Definition at line 218 of file mersenne-twister.cpp.

References MD_UINT32_MAX, and rand_u32().

float randf_cc ( )

Definition at line 193 of file mersenne-twister.cpp.

References MD_UINT32_MAX, and rand_u32().

float randf_co ( )

Definition at line 198 of file mersenne-twister.cpp.

References MD_UINT32_MAX, and rand_u32().

float randf_oo ( )

Definition at line 203 of file mersenne-twister.cpp.

References MD_UINT32_MAX, and rand_u32().

void seed ( uint32_t  value)

Variable Documentation

const unsigned DIFF = SIZE - PERIOD
static

Definition at line 33 of file mersenne-twister.cpp.

Referenced by generate_numbers().

unsigned index = 0
static

Definition at line 36 of file mersenne-twister.cpp.

Referenced by QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesCached(), QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesDirect(), QgsVectorFileWriter::addRendererAttributes(), QgsInterpolator::addVerticesToCache(), QgsGeometry::adjacentVertices(), QgsAttributeTableModel::attributeValueChanged(), QgsRasterDataProvider::block(), QgsSymbolV2::changeSymbolLayer(), QgsGeometry::closestSegmentWithContext(), QgsGeometry::closestVertex(), QgsDxfExport::color_distance(), QgsComposerTableSortColumnsProxyModel::columnFromRow(), QgsColorSchemeList::copyColors(), QgsAttributeForm::createWidgetFromDef(), QgsStyleV2ManagerDialog::currentItemName(), QgsMapLayerComboBox::currentLayer(), pal::FeaturePart::curvedPlacementAtOffset(), QgsSymbolV2::deleteSymbolLayer(), QgsColorSwatchGrid::draw(), QgsLegendModel::dropMimeData(), QgsAttributeAction::expandAction(), QgsAttributeTableModel::feature(), QgsAttributeTableModel::featureAdded(), QgsExpressionItemSearchProxy::filterAcceptsRow(), QgsFieldProxyModel::filterAcceptsRow(), QgsMapLayerProxyModel::filterAcceptsRow(), QgsComposerTableSortColumnsProxyModel::filterAcceptsRow(), QgsAttributeTableFilterModel::filteredFeatures(), QgsStyleV2ManagerDialog::grouptreeContextMenu(), QgsComposerMultiFrame::handleFrameRemoval(), QgsExpressionHighlighter::highlightBlock(), QgsAttributeTableModel::idToIndex(), QgsAttributeTableModel::idToIndexList(), QgsTINInterpolator::insertData(), QgsOverlayAnalyzer::intersection(), QgsStyleV2ManagerDialog::listitemsContextMenu(), QgsSingleBandGrayRendererWidget::max(), QgsRasterRendererWidget::max(), QgsVectorDataProvider::maximumValue(), QgsVectorLayer::maximumValue(), CustomLayerOrderModel::mimeData(), QgsSingleBandGrayRendererWidget::min(), QgsRasterRendererWidget::min(), QgsVectorDataProvider::minimumValue(), QgsVectorLayer::minimumValue(), QgsFeatureListView::mouseMoveEvent(), QgsFeatureListView::mousePressEvent(), QgsComposerMap::moveGridDown(), QgsComposerMap::moveGridUp(), QgsComposerMap::moveOverviewDown(), QgsComposerMap::moveOverviewUp(), QgsRubberBand::movePoint(), QgsStyleV2ExportImportDialog::moveStyles(), QgsRasterFormatSaveOptionsWidget::on_mProfileDeleteButton_clicked(), QgsConnectionPoolGroup< T >::onConnectionExpired(), QgsRuleBasedRendererV2Widget::paste(), QgsCptCityColorRampV2Dialog::populateVariants(), QgsCategorizedSymbolRendererV2Widget::QgsCategorizedSymbolRendererV2Widget(), QgsGml::QgsGml(), QgsGraduatedSymbolRendererV2Widget::QgsGraduatedSymbolRendererV2Widget(), rand_u32(), QgsVectorLayer::readSymbology(), QgsRasterBlock::readValue(), QgsComposerAttributeTable::readXML(), QgsRuleBasedRendererV2Widget::refineRule(), QgsRuleBasedRendererV2Widget::refineRuleCategoriesGui(), QgsRuleBasedRendererV2Widget::refineRuleRangesGui(), QgsRuleBasedRendererV2Widget::refineRuleScalesGui(), QgsStyleV2ManagerDialog::removeGroup(), QgsRubberBand::removePoint(), QgsColorSchemeList::removeSelection(), QgsVectorGradientColorRampV2Dialog::removeStop(), QgsStyleV2ManagerDialog::removeSymbol(), QgsAttributeTableView::repaintRequested(), QgsFeatureListView::repaintRequested(), QgsExpression::replaceExpressionText(), seed(), QgsSingleBandGrayRendererWidget::selectedBand(), QgsRasterRendererWidget::selectedBand(), QgsFeatureSelectionModel::selectFeatures(), QgsAttributeTableView::selectRow(), QgsLinearlyInterpolatedDiagramRenderer::setClassificationAttribute(), QgsRasterBlock::setColor(), QgsPalettedRendererWidget::setFromRenderer(), QgsLayerTreeRegistryBridge::setLayerInsertionPoint(), QgsSingleBandGrayRendererWidget::setMax(), QgsRasterRendererWidget::setMax(), QgsSingleBandGrayRendererWidget::setMin(), QgsRasterRendererWidget::setMin(), QgsSymbolV2SelectorDialog::setWidget(), QgsScaleComboBox::showPopup(), QgsStyleV2ManagerDialog::tagsChanged(), QgsGeometry::transform(), QgsGeometry::translate(), QgsVectorLayerUndoCommandAddAttribute::undo(), QgsVectorLayer::uniqueValues(), QgsExpressionFieldBuffer::updateFields(), CustomLayerOrderModel::updateLayerVisibility(), QgsBlendModeComboBox::updateModes(), QgsRasterBlock::writeValue(), QgsCubicRasterResampler::xDerivativeMatrix(), and QgsCubicRasterResampler::yDerivativeMatrix().

uint32_t MT[SIZE]
static

Definition at line 35 of file mersenne-twister.cpp.

Referenced by generate_numbers(), rand_u32(), and seed().

const unsigned PERIOD = 397
static

Definition at line 32 of file mersenne-twister.cpp.

Referenced by generate_numbers().

const unsigned SIZE = 624
static

Definition at line 31 of file mersenne-twister.cpp.

Referenced by generate_numbers(), rand_u32(), and seed().