Mersenne Twister in BASIC
Return to Versions of MT
Carmine Arturo Sangiovanni gave us an implementation of Mersenne Twister in Visual Basic.(2004/9/6)(revised 2010/1/4)
Pablo M. Ronchi (pmronchi @ yahoo.com.ar) implemented mt19937ar (2002 new version)
in Visual Basic.
"This version of the Mersenne Twister algorithm with initialization array is for Visual Basic for Applications (VBA), the interpreted form of Visual Basic (VB) that is used in the components of the MS Office suit, such as MS Access and MS Excel, and can be easily included as a module in the corresponding databases and worksheets. It can also be compiled with a VB compiler without modifications.
Its main features are: It strictly follows as close as possible the original C code, which is kept commented out for easy verification (a block of one or a few lines of VBA follows the corresponding -commented out- block of C lines). It has been thouroughly and succesfully tested against the output of the original C functions (more than 100 million numbers generated, both in C and VBA). It is fully documented within the VBA source file. This new version is 9% faster than the previous one (Apr 2005)"
Here is his code:
He also send us the test source files (C and VBA) he used. His comments:
"The code is easily adaptable and provides a way to check the validity of the
VBA version of the Mersenne Twister algorithm. It is parameterized and easily
adaptable to particular needs." Here is his test code:
Greg Lyon kindly wrote a FreeBASIC version(mt19937arFB.zip) of mt19937ar.(2006/5/2)
- Ron Charlton kindly wrote a
Visual Basic .NET version of mt19937ar.
I translated Pablo Ronchi's VBA implementation of MT to Visual Basic
.NET. I then modified it so it is 18 times faster than my exact
translation of Ronchi's VBA code when /both are compiled/ with VB.NET.
Pablo Ronchi emulated unsigned integers with signed integers, whereas I
modified MT to use native Visual Basic .NET unsigned integers.
I made MT a Visual Basic class; it allows simultaneous, independent MT
generators in one program.
(2008/10/22) (2008/12/4 updated 2005 to .NET) (2017-07-27 link address changed)
Jerry Wang kindly wrote an Excel VBA version of Mersenne Twister,
MTwister.xlsb.(2014/10/27) (updated 2015/2/28)