tAdded argv check - numeric - C++ library with numerical algorithms
(HTM) git clone git://src.adamsgaard.dk/numeric
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 95c6e4f090aa65daa2e9897a7824f4800d756c29
(DIR) parent 8eb9f011db2f840dba75241b112b9bbb96d87ae9
(HTM) Author: Anders Damsgaard Christensen <adc@geo.au.dk>
Date: Tue, 22 Jan 2013 17:27:15 +0100
Added argv check
Diffstat:
M matrixmul/lua-arrofarrs.lua | 9 +++------
M matrixmul/lua-linarr.lua | 9 +++------
2 files changed, 6 insertions(+), 12 deletions(-)
---
(DIR) diff --git a/matrixmul/lua-arrofarrs.lua b/matrixmul/lua-arrofarrs.lua
t@@ -1,9 +1,8 @@
-#!/usr/bin/lua
+#!/usr/bin/env lua
-N = arg[1]
+N = tonumber(arg[1])
+if N == nil then error("Sorry, I need matrix width as command line argument") end
--- Initialize the matrix A with two's,
--- matrix B with random numbers
A = {}
B = {}
C = {}
t@@ -17,8 +16,6 @@ for i=1,N do
end
end
--- Multiply matrix A with matrix B,
--- store result in matrix C
for i=1,N do
for j=1,N do
sum = 0.0
(DIR) diff --git a/matrixmul/lua-linarr.lua b/matrixmul/lua-linarr.lua
t@@ -1,9 +1,8 @@
-#!/usr/bin/lua
+#!/usr/bin/env lua
-N = arg[1]
+N = tonumber(arg[1])
+if N == nil then error("Sorry, I need matrix width as command line argument") end
--- Initialize the matrix A with two's,
--- matrix B with random numbers
A = {}
B = {}
for i=1,(N*N) do
t@@ -11,8 +10,6 @@ for i=1,(N*N) do
B[i] = math.random()
end
--- Multiply matrix A with matrix B,
--- store result in matrix C
C = {}
for i=1,N do
for j=1,N do