SERVING THE QUANTITATIVE FINANCE COMMUNITY

  • 1
  • 2
  • 3
  • 4
  • 5
  • 8
 
User avatar
Cuchulainn
Topic Author
Posts: 61498
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

User feedback Mr. sitmo's prng

December 12th, 2013, 6:23 pm

1. #include <thread> not on VS2010Can I use boost thread for for the time being?2. for(auto& thread : threads){auto is cute; VS2010 I need to use the type of 'thread' .. is that boost::thread?I would expect change of namespace boost::thread to std::thread.3. Do you have a special case of main(); just 1 thread for starters?
Last edited by Cuchulainn on December 11th, 2013, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Topic Author
Posts: 61498
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

User feedback Mr. sitmo's prng

December 12th, 2013, 7:33 pm

>c:\daniel\software\prng\prng_engine.hpp(342): warning C4521: 'sitmo:rng_engine' : multiple copy constructors specified1>c:\daniel\software\prng\prng_engine.hpp(167): warning C4244: 'return' : conversion from 'uint64_t' to 'uint32_t', possible loss of data1>c:\daniel\software\prng\prng_engine.hpp(174): warning C4244: 'return' : conversion from 'uint64_t' to 'uint32_t', possible loss of data1>c:\daniel\software\prng\prng_engine.hpp(188): warning C4244: '+=' : conversion from 'uint64_t' to 'short', possible loss of data1> PRNG.vcxproj -> C:\VSProjects\PRNG\Debug\PRNG.exe // OUTPUT 128 000 000 rns SUM = 2093428117
Last edited by Cuchulainn on December 11th, 2013, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Topic Author
Posts: 61498
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

User feedback Mr. sitmo's prng

December 12th, 2013, 7:38 pm

Maybe put a std::thread into a boost::thread_group?
Last edited by Cuchulainn on December 11th, 2013, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Topic Author
Posts: 61498
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

User feedback Mr. sitmo's prng

December 12th, 2013, 7:58 pm

Next for me is 2 and 31. Download your native C++ code (easy as Boost yes?) DONE2. Create a Managed C++ wrapper class with a minimal interface to 13. Call 2 from MC in C#
Last edited by Cuchulainn on December 11th, 2013, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Topic Author
Posts: 61498
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

User feedback Mr. sitmo's prng

December 12th, 2013, 8:20 pm

QuoteOriginally posted by: outrunThis is great!!I'll get back to all issues, here is the first>c:\daniel\software\prng\prng_engine.hpp(342): warning C4521: 'sitmo:rng_engine' : multiple copy constructors specifiedI initially has a single copy constructorexplicit prng_engine(const prng_engine& x)but I also need to have a constructor that accepts a seed_sequence argument, and that seed_sequence could be any typetemplate<class Seq> explicit prng_engine(Seq& q)the problem was that for some reason the copy constructor was called with a non-const argument, so it didn't match with, and hence instantiated the template constructor.I decided to explicitly add a non-const copy constructor to prevent this,.. but now you get a warning. Maybe I need to study this cause a bit more.Maye ctors witha) const &b) pointer *??
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Topic Author
Posts: 61498
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

User feedback Mr. sitmo's prng

December 12th, 2013, 8:22 pm

QuoteOriginally posted by: outrunArgh! On 32bit machines the global long like "total_sum" are 32 bit, on my machine they are 64 bit, and I thought a long was *always* 64 bit.The solution is to change the type of total_samples and total_sum with these types below (these types are the new C++11 types, and I also define them in the prng_engine.hpp for old compilers)uint64_t total_samples;uint64_t total_sum;Maybe use a <T> and numeric_limits to infer how many bits? (?) It's a compiler/h/w thing?
Last edited by Cuchulainn on December 11th, 2013, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Topic Author
Posts: 61498
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

User feedback Mr. sitmo's prng

December 13th, 2013, 3:44 am

QuoteOriginally posted by: outrun.. I've managed to get it working on Visual C++ 2008 (version 9), the trick was to replace long with uint64_t.I have also uploaded a new version of the prnd_engine.hpp (v 4), that fixes the type conversion warnings. .. the only issue left (for now ) is the constructor warning.The version below should work on your machine and give 274892645070220693 as output.yep, same output on VS2010>c:\daniel\software\prng\prng_enginev4.hpp(365): warning C4521: 'sitmo:rng_engine' : multiple copy constructors specified
Last edited by Cuchulainn on December 12th, 2013, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Topic Author
Posts: 61498
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

User feedback Mr. sitmo's prng

December 13th, 2013, 8:31 am

The warning is OK for the moment. But I am not surprised that the compiler complains about the stripped down copy ctor. I would try to find a more elegant solution. Maybe you have somewhere else a function that is not const but should be const? Or just imagine modifying the input argument as you simultaneously create the new object!It's almost like prng_engine(prng_engine x).Remark: both ctors have the same body.
Last edited by Cuchulainn on December 12th, 2013, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On