diff options
author | Determinant <ted.sybil@gmail.com> | 2015-06-22 19:01:29 +0800 |
---|---|---|
committer | Determinant <ted.sybil@gmail.com> | 2015-06-22 19:01:29 +0800 |
commit | 2497fd9e7a0fae5ee4887890d7a312e0e08a93b8 (patch) | |
tree | 382f97575bd2df9ee6abb1662b11b279fc22d72b /nerv/matrix/init.c | |
parent | 196e9b48a3541caccdffc5743001cced70667091 (diff) |
major change: use luarocks to manage project
Diffstat (limited to 'nerv/matrix/init.c')
-rw-r--r-- | nerv/matrix/init.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/nerv/matrix/init.c b/nerv/matrix/init.c new file mode 100644 index 0000000..c29d7e9 --- /dev/null +++ b/nerv/matrix/init.c @@ -0,0 +1,35 @@ +#include "../common.h" +#include "generic/matrix.h" + +const char *nerv_matrix_tname = "nerv.Matrix"; +const char *nerv_matrix_cuda_tname = "nerv.CuMatrix"; +const char *nerv_matrix_host_tname = "nerv.MMatrix"; + +void nerv_cumatrix_init(lua_State *L); +void nerv_mmatrix_init(lua_State *L); + +static const luaL_Reg matrix_methods[] = { + {"__tostring__", nerv_error_method_not_implemented }, + {"__add__", nerv_error_method_not_implemented }, + {"__sub__", nerv_error_method_not_implemented }, + {"__mul__", nerv_error_method_not_implemented }, + {NULL, NULL} +}; + +void nerv_matrix_init(lua_State *L) { + /* abstract base class: Matrix */ + luaT_newmetatable(L, nerv_matrix_tname, NULL, NULL, NULL, NULL); + luaL_register(L, NULL, matrix_methods); + lua_pop(L, 1); + + /* CuMatrix inherits from Matrix */ + luaT_newmetatable(L, nerv_matrix_cuda_tname, nerv_matrix_tname, + NULL, NULL, NULL); + nerv_cumatrix_init(L); + lua_pop(L, 1); + /* MMatrix inherits from Matrix */ + luaT_newmetatable(L, nerv_matrix_host_tname, nerv_matrix_tname, + NULL, NULL, NULL); + nerv_mmatrix_init(L); + lua_pop(L, 1); +} |