Read and respond to this message at: 
https://sourceforge.net/projects/gnuwin32/forums/forum/74807/topic/5012933
By: jj2007

See it the other way round: Why should a Masm coder want to use the GSL library?
Simply because occasionally you may need some math functions. Besides, while
the code below is assembler (i.e. ML.EXE recognises it as valid code and
[i]assembles[/i] it...), it undeniably bears some resemblence to, well, BASIC
;-)
include \masm32\MasmBasic\MasmBasic.inc [color=grey];
[/color][url=http://www.masm32.com/board/index.php?topic=12460]download[/url]
; [url=http://gnuwin32.sourceforge.net/packages/gsl.htm]libgsl.dll 
download[/url]
: open Binaries zip, and extract the two files
; libgsl.dll and libgslcblas.dll to \masm32\MasmBasic\GnuScLib\DLL
[color=grey]; define your required gsl function(s) using the syntax of
the [/color][url=http://www.gnu.org/software/gsl/manual/gsl-ref.html]GNU 
Scientific
Library Reference[/url]
[color=blue]gsl[/color] double [color=red]gsl_stats_mean[/color] (const double
data[], size_t [color=red]stride[/color], size_t [color=blue]n[/color]) 
[color=grey];
stride in doubles[/color]
[color=blue]gsl[/color] double [color=red]gsl_stats_variance[/color] (const
double data[], size_t [color=red]stride[/color], size_t [color=blue]n[/color])
[color=blue]gsl[/color] double [color=red]gsl_stats_sd[/color] (const double
data[], size_t [color=red]stride[/color], size_t [color=blue]n[/color])
[color=blue]gsl[/color] double [color=red]gsl_stats_skew[/color] (const double
data[], size_t [color=red]stride[/color], size_t [color=blue]n[/color])
[color=blue]gsl[/color] double [color=red]gsl_sf_bessel_J0[/color] (double
x)              [color=grey]; double x means a pointer to a REAL8 is 
required[/color]

[b]     [color=blue]Init
[/color]        [color=blue]gsl_INIT[/color]
[/b]    ; [color=blue]Kill[/color] "MyDoubles.dat"              [color=grey]; 
activate if you
want to create a new file with every run[/color]
        .if ![color=blue]Exist[/color]("MyDoubles.dat")         [color=grey]; 
generate a new
data file in \Masm32\MasmBasic\GnuScLib\DLL[/color]
                
[color=blue]NumDoubles=1[/color][color=red]000[/color][color=blue]000           
[/color
][color=grey]; one Million items - should take a while...[/color]
                [color=blue]Rand[/color]()              [color=grey]; optional: 
set a seed using rdtsc
[/color]                [color=blue]Dim[/color] 
MyDoubles([color=blue]NumDoubles-1[/color])
As REAL8
                [color=blue]For_[/color] ebx=0 To 
[color=blue]NumDoubles-1[/color]
                        [color=blue]Rand[/color](0, 200, MyDoubles(ebx))        
        [color=grey]; create a
double between 0 (inclusive) and 200 (exclusive)[/color]
[color=blue]            Next[/color]
                [color=grey]; for numeric arrays, Recall and Store need the #x 
syntax, i.e.
Store "myfile.dat", MyDoubles() is not possible
[/color]                [color=blue]Open[/color] "O", [color=blue]#1,[/color]
"MyDoubles.dat"         [color=grey]; write the
[/color][color=blue]NumDoubles[/color][color=grey] items to file[/color]
                [color=blue]Store[/color] #1, MyDoubles()
                [color=blue]Close[/color] #1
                [color=blue]Erase[/color] MyDoubles()           [color=grey]; 
this array no longer
needed[/color]
                [color=blue]PrintLine[/color] "New dataset created in
", [color=blue]CurDir$[/color](0), CrLf$
        .endif
        [color=blue]Open[/color] "I", [color=blue]#1,[/color] "MyDoubles.dat"
        mov [color=blue]ebx[/color],
[color=blue]Lof[/color]([color=blue]#1)[/color]         [color=grey]; we need 
the size
in a permanent register[/color]
        sar [color=blue]ebx[/color], 3          [color=grey]; divide size by 
8[/color]
        [color=blue]PrintLine[/color] "Analysing ", 
[color=blue]CurDir$[/color](),
[color=blue]Str$[/color]("MyDoubles.dat with %i entries",
[color=blue]ebx[/color])
        [color=blue]Dim[/color] 
MyDoubles[color=red]2[/color]([color=blue]ebx[/color])
As REAL8                [color=grey]; read an array of doubles from file[/color]
        [color=blue]Recall[/color] #1, MyDoubles2()
        [color=blue]Close[/color] #1

        lea ecx, MyDoubles2(0)          [color=grey]; get pointer to start of 
data
[/color][color=blue]    [/color][color=red]gsl_stats_mean[/color](ecx,
[color=red]1[/color], [color=blue]ebx[/color])          [color=grey];
[/color][color=red]stride 1 double[/color][color=grey],
[/color][color=blue]NumDoubles items[/color]
        [color=blue]Print Str$[/color]("\nstats_mean= \t 
[color=blue]%5f[/color]",
ST(0))  [color=grey]; show as float, [/color][color=blue]5[/color][color=grey]
digits precision[/color]
        [color=blue]fstp st             [/color][color=grey]; clean up the FPU 
- gsl uses many,
sometimes all 8 FPU registers[/color]
[color=blue]    [/color][color=red]gsl_stats_variance[/color](ecx, 
[color=red]1[/color],
[color=blue]ebx[/color])                [color=grey]; [/color][color=red]stride
1 double[/color][color=grey], [/color][color=blue]NumDoubles items[/color]
        [color=blue]Print Str$[/color]("\ns_variance= \t 
[color=blue]%5f[/color]",
ST(0))          [color=grey]; show as float, 
[/color][color=blue]5[/color][color=grey]
digits precision[/color]
        [color=blue]fstp st[/color]
[color=blue]    [/color][color=red]gsl_stats_sd[/color](ecx, 
[color=red]1[/color],
[color=blue]ebx[/color])                [color=grey]; [/color][color=red]stride
1 double[/color][color=grey], [/color][color=blue]NumDoubles items

_____________________________________________________________________________________
You are receiving this email because you elected to monitor this topic or 
entire forum.
To stop monitoring this topic visit: 
https://sourceforge.net/projects/gnuwin32/forums/forum/74807/topic/5012933/unmonitor
To stop monitoring this forum visit: 
https://sourceforge.net/projects/gnuwin32/forums/forum/74807/unmonitor

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
GnuWin32-Users mailing list
GnuWin32-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnuwin32-users

Reply via email to