A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
34
Task/Matrix-multiplication/EGL/matrix-multiplication.egl
Normal file
34
Task/Matrix-multiplication/EGL/matrix-multiplication.egl
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
program Matrix_multiplication type BasicProgram {}
|
||||
|
||||
function main()
|
||||
a float[][] = [[1,2,3],[4,5,6]];
|
||||
b float[][] = [[1,2],[3,4],[5,6]];
|
||||
c float[][] = mult(a, b);
|
||||
end
|
||||
|
||||
function mult(a float[][], b float[][]) returns(float[][])
|
||||
if(a.getSize() == 0)
|
||||
return (new float[0][0]);
|
||||
end
|
||||
if(a[1].getSize() != b.getSize())
|
||||
return (null); //invalid dims
|
||||
end
|
||||
|
||||
n int = a[1].getSize();
|
||||
m int = a.getSize();
|
||||
p int = b[1].getSize();
|
||||
|
||||
ans float[0][0];
|
||||
ans.resizeAll([m, p]);
|
||||
|
||||
// Calculate dot product.
|
||||
for(i int from 1 to m)
|
||||
for(j int from 1 to p)
|
||||
for(k int from 1 to n)
|
||||
ans[i][j] += a[i][k] * b[k][j];
|
||||
end
|
||||
end
|
||||
end
|
||||
return (ans);
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue