diff options
-rw-r--r-- | examples/mmatrix_example.lua | 1 | ||||
-rw-r--r-- | matrix/generic/matrix.c | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/examples/mmatrix_example.lua b/examples/mmatrix_example.lua index 679fde3..53b7fed 100644 --- a/examples/mmatrix_example.lua +++ b/examples/mmatrix_example.lua @@ -10,6 +10,7 @@ for i = 0, m - 1 do dm[i][j] = t end end +print("test fm:get_dataref_value:", fm:get_dataref_value()) print(fm) -- print(fm:softmax()) print(dm) diff --git a/matrix/generic/matrix.c b/matrix/generic/matrix.c index 417c534..c3838d2 100644 --- a/matrix/generic/matrix.c +++ b/matrix/generic/matrix.c @@ -122,12 +122,18 @@ static int nerv_matrix_(nrow)(lua_State *L) { return 1; } +static int nerv_matrix_(get_dataref_value)(lua_State *L) { + Matrix *self = luaT_checkudata(L, 1, nerv_matrix_(tname)); + lua_pushinteger(L, *(self->data_ref)); + return 1; +} static const luaL_Reg nerv_matrix_(methods)[] = { {"get_elem", nerv_matrix_(get_elem)}, {"set_elem", nerv_matrix_(set_elem)}, {"ncol", nerv_matrix_(ncol)}, {"nrow", nerv_matrix_(nrow)}, + {"get_dataref_value", nerv_matrix_(get_dataref_value)}, {"__index__", nerv_matrix_(index)}, {"__newindex__", nerv_matrix_(newindex)}, {NULL, NULL} |