diff options
author | Determinant <[email protected]> | 2015-06-22 19:01:29 +0800 |
---|---|---|
committer | Determinant <[email protected]> | 2015-06-22 19:01:29 +0800 |
commit | 2497fd9e7a0fae5ee4887890d7a312e0e08a93b8 (patch) | |
tree | 382f97575bd2df9ee6abb1662b11b279fc22d72b /matrix/mmatrix.c | |
parent | 196e9b48a3541caccdffc5743001cced70667091 (diff) |
major change: use luarocks to manage project
Diffstat (limited to 'matrix/mmatrix.c')
-rw-r--r-- | matrix/mmatrix.c | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/matrix/mmatrix.c b/matrix/mmatrix.c deleted file mode 100644 index d1d68b9..0000000 --- a/matrix/mmatrix.c +++ /dev/null @@ -1,77 +0,0 @@ -#define NERV_GENERIC_MMATRIX -#include <stdlib.h> -#include "../common.h" -void nerv_matrix_host_float_init(lua_State *L); -void nerv_matrix_host_double_init(lua_State *L); -void nerv_matrix_host_int_init(lua_State *L); - -void nerv_mmatrix_init(lua_State *L) { - srand(1); - nerv_matrix_host_float_init(L); - nerv_matrix_host_double_init(L); - nerv_matrix_host_int_init(L); -} - -#define MATRIX_USE_FLOAT -#define host_matrix_(NAME) host_matrix_float_##NAME -#define nerv_matrix_(NAME) nerv_matrix_host_float_##NAME -const char *nerv_matrix_(tname) = "nerv.MMatrixFloat"; -#include "generic/mmatrix.c" -#undef nerv_matrix_ -#undef host_matrix_ -#undef MATRIX_USE_FLOAT -#undef MATRIX_ELEM -#undef MATRIX_ELEM_PTR -#undef MATRIX_ELEM_FMT -#undef MATRIX_ELEM_WRITE_FMT - -#define NERV_GENERIC_MMATRIX -#define MATRIX_USE_DOUBLE -#define host_matrix_(NAME) host_matrix_double_##NAME -#define nerv_matrix_(NAME) nerv_matrix_host_double_##NAME -const char *nerv_matrix_(tname) = "nerv.MMatrixDouble"; -#include "generic/mmatrix.c" -#undef nerv_matrix_ -#undef host_matrix_ -#undef MATRIX_USE_DOUBLE -#undef MATRIX_ELEM -#undef MATRIX_ELEM_PTR -#undef MATRIX_ELEM_FMT -#undef MATRIX_ELEM_WRITE_FMT - -#define NERV_GENERIC_MMATRIX -#define MATRIX_USE_INT -#define host_matrix_(NAME) host_matrix_int_##NAME -#define nerv_matrix_(NAME) nerv_matrix_host_int_##NAME -const char *nerv_matrix_(tname) = "nerv.MMatrixInt"; -#define MMATRIX_INIT(L) host_matrix_(init_extra)(L) - -static const luaL_Reg nerv_matrix_(extra_methods_int)[]; -static void host_matrix_(init_extra)(lua_State *L) { - luaN_append_methods(L, nerv_matrix_(extra_methods_int)); -} - -#include "generic/mmatrix.c" - -static int nerv_matrix_(perm_gen)(lua_State *L) { - int i, ncol = luaL_checkinteger(L, 1); - Matrix *self = nerv_matrix_(new_)(L, 1, ncol); - long *prow = self->data.i; - for (i = 0; i < ncol; i++) - prow[i] = i; - for (i = ncol - 1; i >= 0; i--) - { - size_t j = rand() % (i + 1); - long tmp = prow[i]; - prow[i] = prow[j]; - prow[j] = tmp; - } - luaT_pushudata(L, self, nerv_matrix_(tname)); - return 1; -} - -static const luaL_Reg nerv_matrix_(extra_methods_int)[] = { - {"perm_gen", nerv_matrix_(perm_gen)}, - {NULL, NULL} -}; - |