In file linalg.lua I have this function declaration:
function dot(A,B) return sum(mult(A,B),2); -- sum along second dimension end And then in another file I have these calls:
require 'linalg' -- First fundamental Coeffecients of the surface (E,F,G) local E = dot(Xu,Xu,2) local F = dot(Xu,Xv,2) local G = dot(Xv,Xv,2) local m = cross(Xu,Xv,2) local p = sqrt( dot(m,m,2) ) local n = div(m,concath(p, p, p)) -- Second fundamental Coeffecients of the surface (L,M,N) local L = dot(Xuu,n,2) local M = dot(Xuv,n,2) local N = dot(Xvv,n,2) What I don't understand is:
Why the
dotfunction is called with three arguments (being 2 always the last of them) if the function is declared with two arguments? Is it some Lua idiom?
The code runs fine inside a system where it gives correct results, and now I have the task to translate it to Python/Numpy.
print a, b, c, ...in python. The extra arguments are ignored when you're calling a function. Less number of arguments won't raise an error either. They will be assigned a nil value.def function(args)and then you unpack args, or check its length. That doesn't seem to be the case,function dot (A,B)states that you should call it with two arguments exactely. It's possible that former programmer thought the2parameter was needed when actually it's not, but then I wonder if that would generate an error, or the program would run properly, in the Lua case.