- Trying to get better frequency distributions... - 4 Updates
- Trying to get better frequency distributions... - 2 Updates
- Lambdas and template parameter deduction - 4 Updates
- "Bjarne Stroustrup announces C++ Core Guidelines" - 1 Update
- copy constructor and move constructor - 1 Update
- template classes and .h file - 1 Update
- A small quiz (1) - 1 Update
bartekltg <bartek@gmail.com>: Sep 22 02:15AM +0200 On 21.09.2015 23:29, Chris M. Thomasson wrote: > between the average > minimum and maximum values of a frequency distribution: > http://codepad.org/ZZhBc65N Where is a problem? You have (pseudo)random process (not much, because of " std::srand(123);") so number of hits in one particular bucket also will be a random variable. For every run (or seed) you get slighty different results. Stefan is right, use <random>. mt19937 _is_ better PRGN than rand(); For very strongly uncorrelated numbers you can use ranlux24/ranlux48. > I will explain this further very soon. It has to do with encryption. Mersenne twister is not a "cryptographic secure" PRNG. I dont know about randlux, but also probably not. pzdr bartekltg |
"Chris M. Thomasson" <nospam@nospam.nospam>: Sep 22 01:19PM -0700 > of " std::srand(123);") so number of hits in one particular bucket > also will be a random variable. For every run (or seed) you get slighty > different results. I am trying to fill the counters up to a point where they are all basically equal, and reduce the spikes in the freq graph. I want the difference between the average max and min frequency counts to be as small as possible. WRT the encryption angle, here is what I am trying to do: https://groups.google.com/d/topic/sci.crypt/g6CPhD9mh24/discussion https://groups.google.com/d/topic/sci.crypt/KH1A8KeWlvw/discussion https://groups.google.com/d/topic/sci.crypt/AlM10CzGclQ/discussion [...] |
"Chris M. Thomasson" <nospam@nospam.nospam>: Sep 22 03:55PM -0700 > are either 0 or 1, and the difference between the count of 0s > and 1s will be 1 at most, which is as small as possible. > int random(){ static int i = 0; return *i++ % 2; } After I set rid of the (*i++): int random(){ static int i = 0; return i++ % 2; } it produces: 0, 1, 0, 1, ... The pattern is too easily spotted... ;^) BTW, I am not advocating the use of prng's for encryption. I want to use fractals. I am just trying to explore a way to get flat frequency distributions of bytes out of any random source. |
JiiPee <no@notvalid.com>: Sep 22 11:55PM +0100 On 22/09/2015 23:39, Stefan Ram wrote: > int random(){ static int i = 0; return *i++ % 2; } does not compile, gives an error: error: invalid type argument of unary '*' (have 'int') |
ram@zedat.fu-berlin.de (Stefan Ram): Sep 22 10:39PM >I want the difference between the average max and min frequency counts to be >as small as possible. The following function will yield pseudo-random numbers that are either 0 or 1, and the difference between the count of 0s and 1s will be 1 at most, which is as small as possible. int random(){ static int i = 0; return *i++ % 2; } (untested). |
ram@zedat.fu-berlin.de (Stefan Ram): Sep 22 10:49PM >int random(){ static int i = 0; return *i++ % 2; } >(untested). (Too much pointers! The asterisks should be removed, and »int« should become »unsigned int«.) |
Juha Nieminen <nospam@thanks.invalid>: Sep 22 01:56PM Consider the following: //-------------------------------------------------------------------- template<int Amount, typename Elem_t> void foo(Elem_t(*func)(int)) {} int bar(int i) { return i; } int main() { foo<10>(bar); // Compiles foo<10>([](int i)->int { return i; }); // Does not compile foo<10, int>([](int i)->int { return i; }); // Compiles } //-------------------------------------------------------------------- (At least so with clang.) With the regular old function, foo() can be called without having to specify the second template parameter. However, with lambdas it has to be specified. Why? --- news://freenews.netfront.net/ - complaints: news@netfront.net --- |
"Öö Tiib" <ootiib@hot.ee>: Sep 22 07:45AM -0700 On Tuesday, 22 September 2015 16:57:02 UTC+3, Juha Nieminen wrote: > With the regular old function, foo() can be called without having to > specify the second template parameter. However, with lambdas it has > to be specified. Why? Seems that you hope template argument deduction to be too wise? AFAIK implicit conversions are not considered during template argument deduction. With explicit conversion it works: foo<10>((int(*)(int))[](int i)->int { return i; }); |
Vir Campestris <vir.campestris@invalid.invalid>: Sep 22 09:41PM +0100 On 22/09/2015 15:45, Öö Tiib wrote: > AFAIK implicit conversions are not considered during template > argument deduction. With explicit conversion it works: > foo<10>((int(*)(int))[](int i)->int { return i; }); I'm puzzled too. He's explicitly stated that his lambda returns an int; it looks to me as if the type of his lambda ought to be int(*)(int), which ought to be enough for the deduction. Andy |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Sep 22 10:57PM +0100 On Tue, 22 Sep 2015 21:41:31 +0100 > I'm puzzled too. He's explicitly stated that his lambda returns an > int; it looks to me as if the type of his lambda ought to be > int(*)(int), which ought to be enough for the deduction. Its type is not int(*)(int). The type of a lambda expression is a function object of unspecified type (namely it "is a unique, unnamed non-union class type" which "has a public inline function call operator"). (Quotes are from the C++ standard.) Because in the case referred to in the original posting there is no captured environment (the capture list is empty), the lambda expression is implicitly convertible to a function pointer of type int(*)(int), which is not the same thing at all. Chris |
Lynn McGuire <lmc@winsim.com>: Sep 22 03:42PM -0500 "Bjarne Stroustrup announces C++ Core Guidelines" https://isocpp.org/blog/2015/09/bjarne-stroustrup-announces-cpp-core-guidelines "This morning in his opening keynote at CppCon, Bjarne Stroustrup announced the C++ Core Guidelines (github.com/isocpp/CppCoreGuidelines), the start of a new open source project on GitHub to build modern authoritative guidelines for writing C++ code. The guidelines are designed to be modern, machine-enforceable wherever possible, and open to contributions and forking so that organizations can easily incorporate them into their own corporate coding guidelines." "The initial primary authors and maintainers are Bjarne Stroustrup and Herb Sutter, and the guidelines so far were developed with contributions from experts at CERN, Microsoft, Morgan Stanley, and several other organizations. The guidelines are currently in a "0.6" state, and contributions are welcome. As Stroustrup said: "We need help!"" Lynn |
legalize+jeeves@mail.xmission.com (Richard): Sep 22 05:20PM [Please do not mail me a copy of your followup] Sui Huang <hailiyouyu.hs@gmail.com> spake the secret code >> > #2. HasPtr ptr2(HasPtr()); //outpus nothing >> There you declare a function. >thanks, that is really a vexing parse. C++11 brace initialization gives you what you want, so another reason to prefer that for initializing a variable. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
Rosario19 <Ros@invalid.invalid>: Sep 22 05:31PM +0200 On Tue, 22 Sep 2015 10:42:46 +1200, Ian Collins wrote: >> #define cout thatandthis[0] >> etc >That's an easy fix: don't use pointless macros... i already fix it... it was only write thahandthis[0] in the place of cout in the header file where was the template class but in other code cout is ok... possible in template classes some #define macro expansion have some problem... |
thullu <thullu@no.pe>: Sep 22 09:48AM +0200 > Yes, the correct answers were given in this thread, Was auxo correct? > and it's correct that I got both ideas from the same book. Which book? On 09/22/2015 12:31 AM, Stefan Ram wrote: |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment