Matrix multiplication: Difference between revisions

Line 4,659:
 
=={{header|OxygenBasic}}==
Generic MatMul:
<lang>
'generic with striding pointers
'def typ float
typedef float typ
'
function MatMul(typ *r,*a,*b, int n=4) 'NxN MATRIX : N=1..
============================================================
int ystep=sizeof typ
int xstep=n*sizeof typ
int i,j,k
sys px
for i=1 to n
px=@a
for j=1 to n
r=0
for k=1 to n
r+=(a*b)
@a+=xstep
@b+=ystep
next
@r+=ystep
px+=ystep
@a=px
@b-=xstep
next
@a-=xstep
@b+=xstep
next
end function
</lang>
 
When using matrices in Video graphics, speed is important. Here is a matrix multiplier written in OxygenBasics's x86 Assembly code.
<lang oxygenbasic>
54

edits