aboutsummaryrefslogtreecommitdiff
path: root/nerv/matrix/generic/mmatrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'nerv/matrix/generic/mmatrix.c')
-rw-r--r--nerv/matrix/generic/mmatrix.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/nerv/matrix/generic/mmatrix.c b/nerv/matrix/generic/mmatrix.c
index 93562d0..69000b7 100644
--- a/nerv/matrix/generic/mmatrix.c
+++ b/nerv/matrix/generic/mmatrix.c
@@ -1,4 +1,5 @@
#ifdef NERV_GENERIC_MMATRIX
+#include "../matrix.h"
#include "../../lib/matrix/generic/matrix.h"
#include "../../lib/matrix/generic/elem_type.h"
#define MATRIX_DATA_WRITE(L, data, idx, val) (data[idx] = val)
@@ -48,8 +49,10 @@ static void host_matrix_(init)(lua_State *L) {
static int nerv_matrix_(lua_load)(lua_State *L) {
Status status;
+ MATRIX_CONTEXT *context;
+ MATRIX_GET_CONTEXT(L, 2);
ChunkData *cdp = luaT_checkudata(L, 1, nerv_chunk_data_tname);
- Matrix *self = nerv_matrix_(load)(cdp, &status);
+ Matrix *self = nerv_matrix_(load)(cdp, context, &status);
NERV_LUA_CHECK_STATUS(L, status);
luaT_pushudata(L, self, nerv_matrix_(tname));
return 1;
@@ -57,23 +60,27 @@ static int nerv_matrix_(lua_load)(lua_State *L) {
static int nerv_matrix_(lua_save)(lua_State *L) {
Status status;
+ MATRIX_CONTEXT *context;
+ MATRIX_GET_CONTEXT(L, 3);
ChunkFile *cfp = luaT_checkudata(L, 2,
nerv_chunk_file_handle_tname);
Matrix *self = luaT_checkudata(L, 1, nerv_matrix_(tname));
- nerv_matrix_(save)(self, cfp, &status);
+ nerv_matrix_(save)(self, cfp, context, &status);
NERV_LUA_CHECK_STATUS(L, status);
return 0;
}
static int nerv_matrix_(lua_copy_fromh)(lua_State *L) {
Status status;
+ MATRIX_CONTEXT *context;
+ MATRIX_GET_CONTEXT(L, 6);
Matrix *a = luaT_checkudata(L, 1, nerv_matrix_(tname));
const Matrix *b = luaT_checkudata(L, 2, nerv_matrix_(tname));
int nargs = lua_gettop(L);
int b_begin = nargs > 2 ? luaL_checkinteger(L, 3) : 0;
int b_end = nargs > 3 ? luaL_checkinteger(L, 4) : b->nrow;
int a_begin = nargs > 4 ? luaL_checkinteger(L, 5) : 0;
- nerv_matrix_(copy_fromh)(a, b, a_begin, b_begin, b_end, &status);
+ nerv_matrix_(copy_fromh)(a, b, a_begin, b_begin, b_end, context, &status);
NERV_LUA_CHECK_STATUS(L, status);
return 0;
}
@@ -81,12 +88,14 @@ static int nerv_matrix_(lua_copy_fromh)(lua_State *L) {
static int nerv_matrix_(lua_copy_rows_fromh_by_idx)(lua_State *L)
{
Status status;
- Matrix *a=luaT_checkudata(L,1,nerv_matrix_(tname));
- const Matrix *b=luaT_checkudata(L,2,nerv_matrix_(tname));
- const Matrix *idx=luaT_checkudata(L,3,nerv_matrix_(tname));
- int b_begin=lua_gettop(L)>3?luaL_checkinteger(L,4):0;
- nerv_matrix_(copy_rows_fromh_by_idx)(a,b,idx,b_begin,&status);
- NERV_LUA_CHECK_STATUS(L,status);
+ MATRIX_CONTEXT *context;
+ MATRIX_GET_CONTEXT(L, 5);
+ Matrix *a = luaT_checkudata(L, 1, nerv_matrix_(tname));
+ const Matrix *b = luaT_checkudata(L, 2, nerv_matrix_(tname));
+ const Matrix *idx = luaT_checkudata(L, 3, nerv_matrix_(tname));
+ int b_begin = lua_gettop(L) > 3 ? luaL_checkinteger(L, 4) : 0;
+ nerv_matrix_(copy_rows_fromh_by_idx)(a, b, idx, b_begin, context, &status);
+ NERV_LUA_CHECK_STATUS(L, status);
return 0;
}