Matrix multiplication: Difference between revisions
Content added Content deleted
Alpha bravo (talk | contribs) m (→Using Objects) |
|||
Line 669: | Line 669: | ||
===Using Objects=== |
===Using Objects=== |
||
<lang AutoHotkey>Multiply_Matrix(A,B){ |
<lang AutoHotkey>Multiply_Matrix(A,B){ |
||
if (A[1]. |
if (A[1].Count() <> B.Count()) |
||
return |
return ["Dimension Error"] |
||
R := [], RRows := A.Count(), RCols:= b[1].Count() |
|||
RRows := A.MaxIndex()>B.MaxIndex()?A.MaxIndex():B.MaxIndex(), R := [] |
|||
Loop, % RRows { |
Loop, % RRows { |
||
RRow:=A_Index |
RRow:=A_Index |
||
loop, % RCols { |
loop, % RCols { |
||
RCol:=A_Index, |
RCol:=A_Index, v := 0 |
||
loop % A[1]. |
loop % A[1].Count() |
||
col := A_Index, |
col := A_Index, v += A[RRow, col] * B[col, RCol] |
||
R[RRow,RCol] := v |
R[RRow,RCol] := v |
||
} |
} |