Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
8450a99c
Kaydet (Commit)
8450a99c
authored
Ara 06, 2012
tarafından
tino
Kaydeden (comit)
Markus Mohrhard
Ara 08, 2012
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fdo#33365 added wrapper for boost random, use that in RAND()
Change-Id: Iafc524d12c76423f74dc16b42595e52fbc5a1e54
üst
e9b21193
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
1 deletion
+87
-1
Library_sc.mk
sc/Library_sc.mk
+1
-0
global.cxx
sc/source/core/data/global.cxx
+2
-0
random.hxx
sc/source/core/inc/random.hxx
+29
-0
interpr1.cxx
sc/source/core/tool/interpr1.cxx
+2
-1
random.cxx
sc/source/core/tool/random.cxx
+53
-0
No files found.
sc/Library_sc.mk
Dosyayı görüntüle @
8450a99c
...
...
@@ -213,6 +213,7 @@ $(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 \
...
...
sc/source/core/data/global.cxx
Dosyayı görüntüle @
8450a99c
...
...
@@ -75,6 +75,7 @@
#include "sc.hrc"
#include "scmod.hxx"
#include "appoptio.hxx"
#include "random.hxx"
// -----------------------------------------------------------------------
...
...
@@ -557,6 +558,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
InitAddIns
();
...
...
sc/source/core/inc/random.hxx
0 → 100644
Dosyayı görüntüle @
8450a99c
/* -*- 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 SC_RANDOM_HXX
#define SC_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: */
sc/source/core/tool/interpr1.cxx
Dosyayı görüntüle @
8450a99c
...
...
@@ -44,6 +44,7 @@
#include "globstr.hrc"
#include "attrib.hxx"
#include "jumpmatrix.hxx"
#include "random.hxx"
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
...
...
@@ -1711,7 +1712,7 @@ void ScInterpreter::ScPi()
void ScInterpreter::ScRandom()
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScRandom" );
PushDouble(
(double)rand() / ((double)RAND_MAX+1.0
));
PushDouble(
sc::rng::uniform(
));
}
...
...
sc/source/core/tool/random.cxx
0 → 100644
Dosyayı görüntüle @
8450a99c
/* -*- 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>
// 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: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment