Math() - OpenSource please!!!

Everything else that doesn't fall into one of the other PB categories.
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Math() - OpenSource please!!!

Post by Ralf »

Hello Fred!
I would like to write a small tool in purebasic using the mathlib commands random(), randomseed() and save all the datas like following into an ini file:

Code: Select all

; File
rand = 12     ; Random value
seed = 612   ; RandomSeed value
...
Later i would like to read the inifiles with the values for random and randomseed (c based) and import into my C++/C# projects! Could you share us a working asm/c/c++/c# version of your purebasic random and randomseed (100% compatible) commands? So everybody could use this commands in purebasic and c/c++/c# and having everytime the same results! This is my problem! I dont know on which way you managed it! Many thanks in advance!
User avatar
aszid
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 01, 2003 8:38 pm
Location: California, USA
Contact:

Post by aszid »

i'm pretty sure the answer you will get will be "no"

quite simply, the user agreement for PB says you cannot use pb to simply wrap commands for use with other languages. and that sounds pretty much exactly what you're asking for in this case...

i could be wrong though i suppose...

good luck
--Aszid--

Making crazy people sane, starting tomorrow.
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post by Ralf »

aszid wrote:i'm pretty sure the answer you will get will be "no"

quite simply, the user agreement for PB says you cannot use pb to simply wrap commands for use with other languages. and that sounds pretty much exactly what you're asking for in this case...

i could be wrong though i suppose...

good luck
Aeehmm, i will still wait for Freds answer! I dont want wrap the full math lib or any other purebasic related stuff. Still only want to know how to write a Random and RandomSeed command that gives 100% same results in pb/asm/c/c++/c#... I think this should be no problem to share this routine to write tools in purebasic and produce the same results from the datafiles in any other language. I still think fred would be so friendly and help..!?
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

It was a similar thread about this random routine and the best for you if you want crossplatform random is to rewrite your own (not difficult, lot of example on the web) as the PB one can change without any notices for speed/size reason so it will break the compatibility.
Andy Amaya
New User
New User
Posts: 2
Joined: Wed Jul 23, 2003 3:42 am

Post by Andy Amaya »

There's a publicly available random number generator called the 'Mersenne Twister'. It's probably one of the best random number generators available, if not the best.

Have a look at: http://www.math.keio.ac.jp/~matumoto/emt.html

It's already been coded in many computer languages and looks to me like it's just what you need.

Hope this helps

Andy
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post by Ralf »

Thanks to Andy Amaya. Can someone post a purebasic and a c# version of the random and randomseed algo?

Fred: your random and randomseed dont produces same results when using the commands on win/linux/amiga??? I only need it for win32 system and maybe any day for linux!? I would like to use a c# converted version of the purebasic commands due fact pure is fast and i dont know how to implent a c/c++ routine (random/randomseed) to pure nor having any knowledge about assembler :roll:
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post by Ralf »

someone so nice here to post a random() and randomseed() function for purebasic (inline asm?) and a version for c/c++/c# (inline asm?), having same result on both languages?

10x a lot for help
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Did you visit the Resources Site?

Just go there and type "random" the the search box :)

There is a nice example written in ASM.
Image Image
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

www.rentacoder.com can be the solution
SPAMINATOR NR.1
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post by Ralf »

Paul wrote:Did you visit the Resources Site?

Just go there and type "random" the the search box :)

There is a nice example written in ASM.

cool! 10x paul! :wink: now i have a working asm random function in asm but can someone show me how to use this asm code as function inside c++/c#!? have never tried to mix asm and any c related stuff. Thanks for more input :wink:
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

Andy Amaya wrote:Have a look at: http://www.math.keio.ac.jp/~matumoto/emt.html
that link was broken, but there are many sites that have it. I found it here:
http://www-personal.engin.umich.edu/~wa ... ister.html
I just did a search for MersenneTwister
Joe
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
Post Reply