Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
34
Task/Matrix-multiplication/11l/matrix-multiplication.11l
Normal file
34
Task/Matrix-multiplication/11l/matrix-multiplication.11l
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
F matrix_mul(m1, m2)
|
||||
assert(m1[0].len == m2.len)
|
||||
V r = [[0.0] * m2[0].len] * m1.len
|
||||
L(j) 0 .< m1.len
|
||||
L(i) 0 .< m2[0].len
|
||||
V s = 0.0
|
||||
L(k) 0 .< m2.len
|
||||
s += m1[j][k] * m2[k][i]
|
||||
r[j][i] = s
|
||||
R r
|
||||
|
||||
F to_str(m)
|
||||
V result = ‘([’
|
||||
L(r) m
|
||||
I result.len > 2
|
||||
result ‘’= "]\n ["
|
||||
L(val) r
|
||||
result ‘’= ‘#5.2’.format(val)
|
||||
R result‘])’
|
||||
|
||||
V a = [[1.0, 1.0, 1.0, 1.0],
|
||||
[2.0, 4.0, 8.0, 16.0],
|
||||
[3.0, 9.0, 27.0, 81.0],
|
||||
[4.0, 16.0, 64.0, 256.0]]
|
||||
|
||||
V b = [[ 4.0, -3.0 , 4/3.0, -1/4.0],
|
||||
[-13/3.0, 19/4.0, -7/3.0, 11/24.0],
|
||||
[ 3/2.0, -2.0 , 7/6.0, -1/4.0],
|
||||
[ -1/6.0, 1/4.0, -1/6.0, 1/24.0]]
|
||||
|
||||
print(to_str(a))
|
||||
print(to_str(b))
|
||||
print(to_str(matrix_mul(a, b)))
|
||||
print(to_str(matrix_mul(b, a)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue