Task

Multiply two matrices together.

They can be of any dimensions, so long as the number of columns of the first matrix is equal to the number of rows of the second matrix.




 
  '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
 