Should I write ffi interface for using gsl_poly_complex_solve or is there
something better to do?
Is there any documentation about templates?
In the meanwhile I did
'''
local ffi = require 'ffi'
local gsl = require 'gsl'
ffi.cdef[[
typedef long gsl_poly_complex_workspace;
typedef double* gsl_complex_packed_ptr;
gsl_poly_complex_workspace * gsl_poly_complex_workspace_alloc (size_t n);
void gsl_poly_complex_workspace_free (gsl_poly_complex_workspace * w);
int gsl_poly_complex_solve (const double * a, size_t n, gsl_poly_complex_workspace * w, gsl_complex_packed_ptr z);
]]
function solvePoly(t)
local n = #t
local coefs = ffi.new("double[?]", n)
local roots = ffi.new("double[?]", 2_(n-1))
for i=1,n do coefs[i-1]=t[i] end
local ws = gsl.gsl_poly_complex_workspace_alloc (n)
if gsl.GSL_SUCCESS~=gsl.gsl_poly_complex_solve (coefs,n,ws, roots) then
print("no convergence")
end
gsl.gsl_poly_complex_workspacefree(ws)
local res = {}
for i=1,n-1 do
res[i]=complex.new(roots[2(i-1)],roots[2*(i-1)+1])
end
return res
end
'''
but I am afraid that if it was not in gsl-shell it is because there is a better alternative (roots.lua??) and is inacurate in multiple roots.
I still dont undestand templates.
I am also working in a library for digital filter design and I dont know if there is any interest in
incorporating the library
I did post to gsl-shell-info@nongnu.org after subscribing and checked at http://lists.nongnu.org/archive/html/gsl-shell-info/ but there was not my email. It was:
Should I write ffi interface for using gsl_poly_complex_solve or is there something better to do?
Is there any documentation about templates?
In the meanwhile I did
''' local ffi = require 'ffi' local gsl = require 'gsl' ffi.cdef[[ typedef long gsl_poly_complex_workspace; typedef double* gsl_complex_packed_ptr; gsl_poly_complex_workspace * gsl_poly_complex_workspace_alloc (size_t n); void gsl_poly_complex_workspace_free (gsl_poly_complex_workspace * w); int gsl_poly_complex_solve (const double * a, size_t n, gsl_poly_complex_workspace * w, gsl_complex_packed_ptr z); ]]
function solvePoly(t) local n = #t local coefs = ffi.new("double[?]", n) local roots = ffi.new("double[?]", 2_(n-1)) for i=1,n do coefs[i-1]=t[i] end local ws = gsl.gsl_poly_complex_workspace_alloc (n) if gsl.GSL_SUCCESS~=gsl.gsl_poly_complex_solve (coefs,n,ws, roots) then print("no convergence") end gsl.gsl_poly_complex_workspacefree(ws) local res = {} for i=1,n-1 do res[i]=complex.new(roots[2(i-1)],roots[2*(i-1)+1]) end return res end '''
but I am afraid that if it was not in gsl-shell it is because there is a better alternative (roots.lua??) and is inacurate in multiple roots. I still dont undestand templates.
I am also working in a library for digital filter design and I dont know if there is any interest in incorporating the library
Best Regards Victor Bombi