March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -0,0 +1,16 @@
|
|||
Multiply_Matrix(A,B){
|
||||
if (A[1].MaxIndex() <> B.MaxIndex())
|
||||
return
|
||||
RCols := A[1].MaxIndex()>B[1].MaxIndex()?A[1].MaxIndex():B[1].MaxIndex()
|
||||
RRows := A.MaxIndex()>B.MaxIndex()?A.MaxIndex():B.MaxIndex(), R := []
|
||||
Loop, % RRows {
|
||||
RRow:=A_Index
|
||||
loop, % RCols {
|
||||
RCol:=A_Index, v := 0
|
||||
loop % A[1].MaxIndex()
|
||||
col := A_Index, v += A[RRow, col] * B[col,RCol]
|
||||
R[RRow,RCol] := v
|
||||
}
|
||||
}
|
||||
return R
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
A := [[1,2]
|
||||
, [3,4]
|
||||
, [5,6]
|
||||
, [7,8]]
|
||||
|
||||
B := [[1,2,3]
|
||||
, [4,5,6]]
|
||||
|
||||
if Res := Multiply_Matrix(A,B)
|
||||
MsgBox % Print(Res)
|
||||
else
|
||||
MsgBox Error
|
||||
return
|
||||
Print(M){
|
||||
for i, row in M
|
||||
for j, col in row
|
||||
Res .= (A_Index=1?"":"`t") col (Mod(A_Index,M[1].MaxIndex())?"":"`n")
|
||||
return Trim(Res,"`n")
|
||||
}
|
||||
|
|
@ -3,8 +3,7 @@ import std.stdio, std.range, std.numeric, std.algorithm;
|
|||
T[][] matMul(T)(immutable T[][] A, immutable T[][] B) pure nothrow {
|
||||
immutable Bt = B[0].length.iota.map!(i=> B.transversal(i).array)
|
||||
.array;
|
||||
return A.map!((immutable T[] a) => Bt.map!(b => a.dotProduct(b))
|
||||
.array).array;
|
||||
return A.map!((in a) => Bt.map!(b => a.dotProduct(b)).array).array;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
|
|
|||
|
|
@ -7,14 +7,9 @@ matprod[a is array, b is array] :=
|
|||
b_col = length[b]-1
|
||||
|
||||
for row = 0 to a_row
|
||||
{
|
||||
for col = 0 to b_col
|
||||
{
|
||||
for inc = 0 to a_col
|
||||
{
|
||||
c@row@col = c@row@col + (a@row@inc * b@inc@col)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
A := <<1|2|3>,<4|5|6>>;
|
||||
|
||||
B := <<1,2,3>|<4,5,6>|<7,8,9>|<10,11,12>>;
|
||||
|
||||
A . B;
|
||||
Loading…
Add table
Add a link
Reference in a new issue