diff options
author | Thomas Arnhold <thomas@arnhold.org> | 2014-05-13 08:42:21 +0200 |
---|---|---|
committer | Thomas Arnhold <thomas@arnhold.org> | 2014-05-17 12:40:39 +0000 |
commit | 9c3e819f066acaf9f5a416630fa7dd83fdc2539d (patch) | |
tree | b5d4e013b34d2a0f42cf9926b4c2919bd3c414db /sc | |
parent | 3c1e30b77df4f34c4954bff37a08439ace7f2434 (diff) |
move boost rng wrapper from sc to comphelper
so we can re-use it in other modules
Change-Id: I6057b1e955f745019fd48f91a754279df0f2b948
Reviewed-on: https://gerrit.libreoffice.org/9348
Reviewed-by: Thomas Arnhold <thomas@arnhold.org>
Tested-by: Thomas Arnhold <thomas@arnhold.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/Library_sc.mk | 1 | ||||
-rw-r--r-- | sc/source/core/data/global.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/inc/random.hxx | 29 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/random.cxx | 54 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/FTestDialog.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/SamplingDialog.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/StatisticsDialogs/TTestDialog.cxx | 1 |
16 files changed, 4 insertions, 99 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index ef092804baf0..9b55aa4380b3 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -249,7 +249,6 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/core/tool/progress \ sc/source/core/tool/queryentry \ sc/source/core/tool/queryparam \ - sc/source/core/tool/random \ sc/source/core/tool/rangelst \ sc/source/core/tool/rangenam \ sc/source/core/tool/rangeseq \ diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index d3b2bd173f23..5e081a00e12d 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -49,6 +49,7 @@ #include <i18nlangtag/mslangid.hxx> #include <com/sun/star/lang/Locale.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/random.hxx> #include <comphelper/string.hxx> #include <unotools/calendarwrapper.hxx> #include <unotools/collatorwrapper.hxx> @@ -77,7 +78,6 @@ #include "sc.hrc" #include "scmod.hxx" #include "appoptio.hxx" -#include "random.hxx" #include "editutil.hxx" @@ -529,7 +529,7 @@ void ScGlobal::Init() // names from the compiler. ScParameterClassification::Init(); srand( (unsigned) time( NULL ) ); // Random Seed Init fuer Interpreter - sc::rng::seed( time( NULL ) ); // seed for libc rand() replacement + ::comphelper::rng::seed( time( NULL ) ); // seed for libc rand() replacement InitAddIns(); diff --git a/sc/source/core/inc/random.hxx b/sc/source/core/inc/random.hxx deleted file mode 100644 index 00765dbaf930..000000000000 --- a/sc/source/core/inc/random.hxx +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_SC_SOURCE_CORE_INC_RANDOM_HXX -#define INCLUDED_SC_SOURCE_CORE_INC_RANDOM_HXX - -namespace sc -{ - -namespace rng -{ - -void seed(int i); // set initial seed (equivalent of libc srand()) - -double uniform(); // uniform distribution in [0,1) - -} // namespace - -} // namespace - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index ab82fc3f92f2..9223dc62853a 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -46,7 +46,6 @@ #include "globstr.hrc" #include "attrib.hxx" #include "jumpmatrix.hxx" -#include "random.hxx" #include "cellkeytranslator.hxx" #include "lookupcache.hxx" #include "rangenam.hxx" @@ -61,6 +60,7 @@ #include "compare.hxx" #include <comphelper/processfactory.hxx> +#include <comphelper/random.hxx> #include <comphelper/string.hxx> #include <svl/sharedstringpool.hxx> @@ -1680,7 +1680,7 @@ void ScInterpreter::ScPi() void ScInterpreter::ScRandom() { - PushDouble(sc::rng::uniform()); + PushDouble(::comphelper::rng::uniform()); } diff --git a/sc/source/core/tool/random.cxx b/sc/source/core/tool/random.cxx deleted file mode 100644 index 5affe374828e..000000000000 --- a/sc/source/core/tool/random.cxx +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Contributor(s): - * Copyright (C) 2012 Tino Kluge <tino.kluge@hrz.tu-chemnitz.de> - */ - -#include <boost/random.hpp> - -#include <random.hxx> - -// this is nothing but a simple wrapper around -// the boost random generators - -namespace sc -{ -namespace rng -{ - -// underlying random number generator -// boost::mt19937 implements the Mersenne twister algorithm which -// is fast and has good statistical properties, it produces integers -// in the range of [0, 2^32-1] internally -// memory requirement: 625*sizeof(uint32_t) -// http://en.wikipedia.org/wiki/Mersenne_twister -#define BOOST_RNG_ALGO boost::mt19937 -BOOST_RNG_ALGO global_rng; - -// initialises the state of the global random number generator -// should only be called once at the start of the main programme -// (note, a few boost::variate_generator<> (like normal) have their -// own state which would need a reset as well to guarantee identical -// sequence of numbers, e.g. via myrand.distribution().reset()) -void seed(int i) -{ - global_rng.seed(i); -} - -// uniform [0,1) or [a,b) distribution -double uniform() -{ - static boost::uniform_01<BOOST_RNG_ALGO&> myrand(global_rng); - return myrand(); -} - -} // namespace -} // namespace - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx index 77a8f55d9d63..09617603beb9 100644 --- a/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx @@ -20,7 +20,6 @@ #include "uiitems.hxx" #include "reffact.hxx" #include "strload.hxx" -#include "random.hxx" #include "docfunc.hxx" #include "StatisticsDialogs.hrc" #include "TableFillingAndNavigationTools.hxx" diff --git a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx index 84d493ae5029..3c56be5d48bc 100644 --- a/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/DescriptiveStatisticsDialog.cxx @@ -22,7 +22,6 @@ #include "uiitems.hxx" #include "reffact.hxx" #include "strload.hxx" -#include "random.hxx" #include "docfunc.hxx" #include "StatisticsDialogs.hrc" #include "TableFillingAndNavigationTools.hxx" diff --git a/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx b/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx index a97a48cc1c69..9f2b8e2aac05 100644 --- a/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/ExponentialSmoothingDialog.cxx @@ -20,7 +20,6 @@ #include "uiitems.hxx" #include "reffact.hxx" #include "strload.hxx" -#include "random.hxx" #include "docfunc.hxx" #include "StatisticsDialogs.hrc" #include "TableFillingAndNavigationTools.hxx" diff --git a/sc/source/ui/StatisticsDialogs/FTestDialog.cxx b/sc/source/ui/StatisticsDialogs/FTestDialog.cxx index feba4eb019c6..407037669f3d 100644 --- a/sc/source/ui/StatisticsDialogs/FTestDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/FTestDialog.cxx @@ -22,7 +22,6 @@ #include "uiitems.hxx" #include "reffact.hxx" #include "strload.hxx" -#include "random.hxx" #include "docfunc.hxx" #include "StatisticsDialogs.hrc" #include "TableFillingAndNavigationTools.hxx" diff --git a/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx index 8757c2e50362..d779f67fe422 100644 --- a/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx +++ b/sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx @@ -20,7 +20,6 @@ #include "uiitems.hxx" #include "reffact.hxx" #include "strload.hxx" -#include "random.hxx" #include "docfunc.hxx" #include "StatisticsDialogs.hrc" #include "TableFillingAndNavigationTools.hxx" diff --git a/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx b/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx index fe0cf52aaf44..aafe29060525 100644 --- a/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/MovingAverageDialog.cxx @@ -20,7 +20,6 @@ #include "uiitems.hxx" #include "reffact.hxx" #include "strload.hxx" -#include "random.hxx" #include "docfunc.hxx" #include "StatisticsDialogs.hrc" #include "TableFillingAndNavigationTools.hxx" diff --git a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx index b58d34ab8b7a..35b72f8aed2a 100644 --- a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx @@ -20,7 +20,6 @@ #include "uiitems.hxx" #include "reffact.hxx" #include "strload.hxx" -#include "random.hxx" #include "docfunc.hxx" #include "StatisticsDialogs.hrc" diff --git a/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx b/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx index 3602376fa344..24eb99deb5bd 100644 --- a/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx @@ -19,7 +19,6 @@ #include "uiitems.hxx" #include "reffact.hxx" #include "strload.hxx" -#include "random.hxx" #include "docfunc.hxx" #include "StatisticsDialogs.hrc" diff --git a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx index 0b20ae08ad89..5d2518bf1908 100644 --- a/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx @@ -20,7 +20,6 @@ #include "uiitems.hxx" #include "reffact.hxx" #include "scresid.hxx" -#include "random.hxx" #include "docfunc.hxx" #include "strload.hxx" diff --git a/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx b/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx index fa9ce7239d51..5d9d5b044e72 100644 --- a/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx @@ -20,7 +20,6 @@ #include "uiitems.hxx" #include "reffact.hxx" #include "scresid.hxx" -#include "random.hxx" #include "docfunc.hxx" #include "strload.hxx" diff --git a/sc/source/ui/StatisticsDialogs/TTestDialog.cxx b/sc/source/ui/StatisticsDialogs/TTestDialog.cxx index c79ff5e99075..228063d6a07b 100644 --- a/sc/source/ui/StatisticsDialogs/TTestDialog.cxx +++ b/sc/source/ui/StatisticsDialogs/TTestDialog.cxx @@ -22,7 +22,6 @@ #include "uiitems.hxx" #include "reffact.hxx" #include "strload.hxx" -#include "random.hxx" #include "docfunc.hxx" #include "StatisticsDialogs.hrc" #include "TableFillingAndNavigationTools.hxx" |