| |
|
|
p.specht
| as preparation to allfällligen Beschleunigung through Assembler...
Windowtitle "MATMUL - Matrixmultiplikation as Proc"
Windowstyle 24
Window 0,0-%maxx,%maxy:print
Declare s&,sz&,z&,err&
'z&=53 : sz&=50 : s&=17
z&=53 : sz&=1 : s&=10
set("decimals",0):set("numwidth",8)
dec z&:dec sz&:dec s&
Declare u![z&,sz&],v![sz&,s&],w![z&,s&]
inc z&:inc sz&:inc s&
u![]=&index : v![]=3*&index
Check MATMUL(u![],v![],w![],s&,sz&,z&)
font 2
Check MATPRNT(w![],s&,z&)
waitinput
END
Proc MATMUL :parameters a![],b![],c![],s&,sz&,z&
case (s&<1) or (sz&<1) or (s&<1):return -2
case (s&*sz&*z&)>50000:return -1
Declare sum!,prod!,i&,j&,k&
dec s&:dec sz&:dec z&
Whileloop 0,z&:i&=&Loop
whileloop 0,s&:j&=&Loop
sum!=0
whileloop 0,sz&:k&=&Loop
prod!=a![i&,k&]*b![k&,j&]
sum!=sum!+prod!
EndWhile
c![i&,j&]=sum!
EndWhile
EndWhile
return 0
ENDPROC
Proc MATPRNT
parameters c![],s&,z&
case (s&<1) or (s&<1):return -2
case (s&*z&)>50000:return -3
case (z&>53) or (s&>17):return -4
declare i&,j&
dec s&:dec z&
Whileloop 0,z&:i&=&Loop
whileloop 0,s&:j&=&Loop
print c![i&,j&],
EndWhile:print
EndWhile
return 0
ENDPROC
proc Check:parameters err&
select err&
caseof 0:return
caseof -1:Print " Error: *** index Overflow ***"
caseof -2:Print " Error: *** index <=0 ***"
caseof -3:Print " Error: *** Mat too big for RAM ***"
caseof -4:Print " trouble: *** Mat too big for Screen ***"
otherwise :Print " Error: *** unknown ***"
endselect
endproc
|
|
|
| XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 05/26/21 ▲ |
|
|
|