@@ -952,7 +952,7 @@ void kad_sgemm_simple(int trans_A, int trans_B, int M, int N, int K, const float | |||
} | |||
#endif | |||
bool kad_ssyev_simple(int N, float *A, float *eugenvals) | |||
bool kad_ssyev_simple(int N, float *A, float *eigenvals) | |||
{ | |||
#ifndef HAVE_CBLAS | |||
return false; | |||
@@ -963,10 +963,10 @@ bool kad_ssyev_simple(int N, float *A, float *eugenvals) | |||
/* Query and allocate the optimal workspace */ | |||
lwork = -1; | |||
ssyev ("Vectors", "Upper", &n, A, &lda, eugenvals, &wkopt, &lwork, &info); | |||
ssyev ("Vectors", "Upper", &n, A, &lda, eigenvals, &wkopt, &lwork, &info); | |||
lwork = wkopt; | |||
work = (float*) g_malloc(lwork * sizeof(double)); | |||
ssyev ("Vectors", "Upper", &n, A, &lda, eugenvals, work, &lwork, &info); | |||
ssyev ("Vectors", "Upper", &n, A, &lda, eigenvals, work, &lwork, &info); | |||
/* Check for convergence */ | |||
if (info > 0) { | |||
g_free (work); |
@@ -246,11 +246,11 @@ static inline int kad_len(const kad_node_t *p) /* calculate the size of p->x */ | |||
/* Additions by Rspamd */ | |||
void kad_sgemm_simple (int trans_A, int trans_B, int M, int N, int K, const float *A, const float *B, float *C); | |||
/** | |||
* Calculate eugenvectors and eugenvalues | |||
* Calculate eigenvectors and eigenvalues | |||
* @param N dimensions of A (must be NxN) | |||
* @param A input matrix (part of it will be destroyed, so copy if needed), on finish the first `nwork` columns will have eugenvectors | |||
* @param eugenvals eugenvalues, must be N elements vector | |||
* @param A input matrix (part of it will be destroyed, so copy if needed), on finish the first `nwork` columns will have eigenvectors | |||
* @param eigenvals eigenvalues, must be N elements vector | |||
*/ | |||
bool kad_ssyev_simple (int N, float *A, float *eugenvals); | |||
bool kad_ssyev_simple (int N, float *A, float *eigenvals); | |||
#endif |
@@ -65,7 +65,7 @@ exports.sgemm = function(a, m, b, n, k, trans_a, trans_b) | |||
return res | |||
end | |||
exports.eugen = function(a, n) | |||
exports.eigen = function(a, n) | |||
if type(a) == 'table' then | |||
-- Need to convert, slow! | |||
n = n or #a |
@@ -35,7 +35,7 @@ LUA_FUNCTION_DEF (tensor, tostring); | |||
LUA_FUNCTION_DEF (tensor, index); | |||
LUA_FUNCTION_DEF (tensor, newindex); | |||
LUA_FUNCTION_DEF (tensor, len); | |||
LUA_FUNCTION_DEF (tensor, eugen); | |||
LUA_FUNCTION_DEF (tensor, eigen); | |||
LUA_FUNCTION_DEF (tensor, mean); | |||
LUA_FUNCTION_DEF (tensor, transpose); | |||
@@ -56,7 +56,7 @@ static luaL_reg rspamd_tensor_m[] = { | |||
{"__index", lua_tensor_index}, | |||
{"__newindex", lua_tensor_newindex}, | |||
{"__len", lua_tensor_len}, | |||
LUA_INTERFACE_DEF (tensor, eugen), | |||
LUA_INTERFACE_DEF (tensor, eigen), | |||
LUA_INTERFACE_DEF (tensor, mean), | |||
LUA_INTERFACE_DEF (tensor, transpose), | |||
{NULL, NULL}, | |||
@@ -604,9 +604,9 @@ lua_tensor_len (lua_State *L) | |||
} | |||
static gint | |||
lua_tensor_eugen (lua_State *L) | |||
lua_tensor_eigen (lua_State *L) | |||
{ | |||
struct rspamd_lua_tensor *t = lua_check_tensor (L, 1), *eugen; | |||
struct rspamd_lua_tensor *t = lua_check_tensor (L, 1), *eigen; | |||
if (t) { | |||
if (t->ndims != 2 || t->dim[0] != t->dim[1]) { | |||
@@ -614,9 +614,9 @@ lua_tensor_eugen (lua_State *L) | |||
t->dim[0], t->dim[1]); | |||
} | |||
eugen = lua_newtensor (L, 1, &t->dim[0], true, true); | |||
eigen = lua_newtensor (L, 1, &t->dim[0], true, true); | |||
if (!kad_ssyev_simple (t->dim[0], t->data, eugen->data)) { | |||
if (!kad_ssyev_simple (t->dim[0], t->data, eigen->data)) { | |||
lua_pop (L, 1); | |||
return luaL_error (L, "kad_ssyev_simple failed (no blas?)"); | |||
} |