tlua-arrofarrs.lua - numeric - C++ library with numerical algorithms | |
git clone git://src.adamsgaard.dk/numeric | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
tlua-arrofarrs.lua (441B) | |
--- | |
1 #!/usr/bin/env lua | |
2 | |
3 N = tonumber(arg[1]) | |
4 if N == nil then error("Sorry, I need matrix width as command line argum… | |
5 | |
6 A = {} | |
7 B = {} | |
8 C = {} | |
9 for i=1,N do | |
10 A[i] = {} | |
11 B[i] = {} | |
12 C[i] = {} | |
13 for j=1,N do | |
14 A[i][j] = 2 | |
15 B[i][j] = N * (j-1) + i-1 | |
16 end | |
17 end | |
18 | |
19 for i=1,N do | |
20 for j=1,N do | |
21 sum = 0.0 | |
22 for k=1,N do | |
23 sum = sum + A[i][k] * B[k][j] | |
24 end | |
25 C[i][j] = sum | |
26 end | |
27 end |