Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDT as a lua library #31

Open
ketigid opened this issue Sep 7, 2016 · 6 comments
Open

GDT as a lua library #31

ketigid opened this issue Sep 7, 2016 · 6 comments

Comments

@ketigid
Copy link

ketigid commented Sep 7, 2016

Hi,

I have only recently discovered GSL-Shell. Thank you for your great work.

I'm very interested in the GDT module in GSL-Shell as I work with tabular data quite frequently.

Currently, I have LuaJIT embedded in my workflow. I have a configuration lua script that parses and pre-processes the input tabular data before passing it to the C++ program.

How can I use GDT module in this case? I hope to be able to use gdt = require('gdt').

@franko
Copy link
Owner

franko commented Sep 7, 2016

Hello,

I am glad you are interested in the GSL Shell and the GDT module. This latter has not been thought as a stand-alone Lua module but it can be easily adapted to this purpose.

Inside the gdt directory there are a few C files that should be compiled into a small DLL. Then the Lua counterpart gdt.lua call the functions in the DLL with the FFI module to implement the gdt functions and that's all! So technically it wouldn't be a Lua module but a LuaJIT module since it needs the FFI capabilities of LuaJIT.

In addition some other functions are implemented in the other gdt-*.lua file but these are easy to gather together.

I am wondering now if you could be interested to create the gdt module by yourself and to publish it on github. Of course I would participate and the amount of work required is quite limited.

Otherwise I'm curious about the usage you make of the GDT module. Which functions do you actually use ?

@ketigid
Copy link
Author

ketigid commented Sep 8, 2016

Hi,

Thank you for your quick reply.

I have no experience in C and building DLL, but I will try. I have created a repository for this experiment at gsl-shell-gdt.

I have changed the gdt_table.h file to support DLL export. Also, commented the register_ffi_type lines in gdt.lua. And added ffi.load('libgdt') to cgdt.lua.

Now, the following command works:
gdt = require('gdt')
require('gdt-parse-csv')
data = gdt.read_csv('examples/exam.csv)

But I can't access data. How do I proceed from here?

Many thanks.

As to your question, I am using read_csv and plot.

@franko
Copy link
Owner

franko commented Sep 8, 2016

Hi,

I have checkout out the gsl-shell-gdt repository and everything seems right. So I have made the test and I was able to read a CSV file as you did. Once you obtain the data table (the "data" variable in the code above) you can use the methods "get" or "set" on it to extract or set values. Otherwise you can write

= data:show()

to print the data in a readable, tabular form. LuaJIT will not pretty-print the tables, only GSL Shell do so by default.

Otherwise I am quite pleased of what you did, thank you! :-) I think I'm going to contribute to your repository by providing a Makefile and some improvements.

@franko
Copy link
Owner

franko commented Sep 8, 2016

I've seen your comments about the need of copying the libgcc and winpthreads DLLs. I recommend to use TDM-GCC to get rid of these annoyances, it is an excellent project and they are improving these kind of things.

I don't use any longer MSYS. I'm very happy using the binary git distribution for windows + tdm-gcc. They works well together the git on windows comes with a lot of goodies that can replace MSYS. They provides out-of-the-box many of the utilities one is used to have on Linux :-)

@ketigid
Copy link
Author

ketigid commented Sep 9, 2016

I've tested building with TDM-GCC, it works great.

You mentioned about other gdt-*.lua files, I tried integrating them, but they seem to have many other dependencies. What do you recommend?

@franko
Copy link
Owner

franko commented Sep 9, 2016

As you want to use the module as a standalone you should probably exclude the gdt functions that requires matrix computations (because the GSL library is needed) or plotting (because the graphics subsystem is needed).

So I guess that you should leave out the « lm » module (linear regression) and everything that is related to « plotting ». You can probably include the « reduce » function which is implemented in the gdt-plot.lua file. It is a function that does not require the graphics module. I may be interesting to include this function but it is up to you to decide, it does require some code « surgery » to separate it from the gdt’s plotting functions.

If you decide to leave out the "reduce" function from gdt-plot.lua the number of required files should be very limited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants