Open sonoro1234 opened 1 year ago
Trying to perform res = A*x + y
I have defined
local function matdims(x)
return x:nrow().."x"..x:ncol()
end
local function same_type_check_3(x, y, z)
local ct = x:elementct()
if ct ~= y:elementct() or ct ~= z:elementct() then
error('constant element type required')
end
end
-- matrix, vector, vector : res = A*x + y
local function muladdv(A,x,y)
print("muladdv",matdims(A),matdims(x),matdims(y))
assert(A:ncol() == x:nrow() and y:nrow()== A:nrow() and y:ncol() == x:ncol() and y:ncol()==1)
local res = y:copy()
assert(not(rawequal(res, x) or rawequal(res, x) or rawequal(res,y)))
same_type_check_3(A,x,res)
res:_gemv(A, x, 0, 1, 1)
return res
end
The program, after performing several muladdv, suddenly stops (perhaps bad memory access?) without any error message or assert. Which could be the reason?
Another question: why __add and related where not used in scilua?
This is continuation of #4 with several related questions
How this should be done without sci syntax extensions? For multiplication we should use alg.mul but which should be used for sums?
Also: with and without sci syntax extensions, how to exponentiate (math.exp) all elements in a matrix?
How to get matrix transposed without sci syntax? Related to that, (while I was trying to self answer the above question) I found an error with sci-lang in the script:
with error:
Of course it can be done as in:
but I had the impression that using OpenBlas was for using functions from the library to multiply, transpose or sum matrixes?