From 0e738af4bb1eda301564d8469178a7581b0cbcce Mon Sep 17 00:00:00 2001 From: Determinant Date: Tue, 19 May 2015 15:09:06 +0800 Subject: ... --- matrix/generic/mmatrix.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'matrix/generic') diff --git a/matrix/generic/mmatrix.c b/matrix/generic/mmatrix.c index ac71c3d..e981ffc 100644 --- a/matrix/generic/mmatrix.c +++ b/matrix/generic/mmatrix.c @@ -4,17 +4,15 @@ #define MATRIX_DATA_FREE(ptr) free(ptr) #define MATRIX_DATA_ALLOC(dptr, stride, width, height) \ host_matrix_(alloc)(dptr, stride, width, height) -#define MATRIX_DATA_STRIDE(ncol) (sizeof(float) * (ncol)) +#define MATRIX_DATA_STRIDE(ncol) (sizeof(MATRIX_ELEM) * (ncol)) #define MATRIX_DATA_WRITE(data, idx, val) (data[idx] = val) #define MATRIX_DATA_READ(data, idx) (data[idx]) #define NERV_GENERIC_MATRIX #include "../../common.h" -const char *nerv_matrix_(tname) = "nerv.FloatMMatrix"; - -static void host_matrix_(alloc)(float **dptr, size_t *stride, +static void host_matrix_(alloc)(MATRIX_ELEM **dptr, size_t *stride, long width, long height) { - *dptr = (float *)malloc(width * height); + *dptr = (MATRIX_ELEM *)malloc(width * height); *stride = width; } @@ -30,7 +28,7 @@ int nerv_matrix_(get_elem)(lua_State *L) { int nerv_matrix_(set_elem)(lua_State *L) { Matrix *self = luaT_checkudata(L, 1, nerv_matrix_(tname)); int idx = luaL_checkinteger(L, 2); - float v = luaL_checknumber(L, 3); + MATRIX_ELEM v = luaL_checknumber(L, 3); if (idx < 0 || idx >= self->nmax) nerv_error(L, "index must be within range [0, %d)", self->nmax); self->data.f[idx] = v; -- cgit v1.2.3