\ -*- mode: forth -*- \ $Id: matrix.gforth,v 1.2 2001/06/28 02:01:56 doug Exp $ \ http://www.bagley.org/~doug/shootout/ \ from Jorge Acereda Maciá 0. argc @ 1- arg >number 2drop drop constant iterations 30 constant size size dup * floats constant mat-byte-size : row-size size postpone literal ; immediate : row-stride float postpone literal ; immediate : col-stride size floats postpone literal ; immediate : mkmatrix 1.e mat-byte-size bounds do fdup i f! 1e f+ float +loop fdrop ; : }}? rot row-size * rot + floats + f@ f>d d>s 1 u.r ; : mat* -rot mat-byte-size bounds do over col-stride bounds do i col-stride j row-stride row-size v* dup f! float+ float +loop col-stride +loop 2drop ; create a mat-byte-size allot a mkmatrix create b mat-byte-size allot b mkmatrix create r mat-byte-size allot : test iterations 0 do r a b mat* loop ; test 0 0 r }}? space 2 3 r }}? space 3 2 r }}? space 4 4 r }}? cr bye