aboutsummaryrefslogtreecommitdiff
path: root/nerv/lib/matrix/generic/mmatrix.c
diff options
context:
space:
mode:
authorQi Liu <liuq901@163.com>2016-03-11 21:28:29 +0800
committerQi Liu <liuq901@163.com>2016-03-11 21:28:29 +0800
commit442e261a0f2cb8836e2859bd814a267cc8aa5db2 (patch)
tree112dd3932a8d23fc2e36f67c347f13bb2d19232a /nerv/lib/matrix/generic/mmatrix.c
parente2a9af061db485d4388902d738c9d8be3f94ab34 (diff)
parent14c1997203e04838b1737716dc385e1aa08fe91f (diff)
update diagonlal lstm
Diffstat (limited to 'nerv/lib/matrix/generic/mmatrix.c')
-rw-r--r--nerv/lib/matrix/generic/mmatrix.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/nerv/lib/matrix/generic/mmatrix.c b/nerv/lib/matrix/generic/mmatrix.c
index fb99b53..6272cbe 100644
--- a/nerv/lib/matrix/generic/mmatrix.c
+++ b/nerv/lib/matrix/generic/mmatrix.c
@@ -274,6 +274,23 @@ void nerv_matrix_(fill)(Matrix *self, double val,
NERV_SET_STATUS(status, NERV_NORMAL, 0);
}
+void nerv_matrix_(diagonalize)(Matrix *selfa,
+ MContext *context, Status *status) {
+ if (self->nrow != self->ncol)
+ NERV_EXIT_STATUS(status, MAT_MISMATCH_DIM, 0);
+ int i, j;
+ size_t astride = self->stride;
+ MATRIX_ELEM *arow = MATRIX_ELEM_PTR(self);
+ for (i = 0; i < self->nrow; i++)
+ {
+ for (j = 0; j < self->ncol; j++)
+ if (i != j)
+ arow[j] = 0;
+ arow = MATRIX_NEXT_ROW_PTR(arow, astride);
+ }
+ NERV_SET_STATUS(status, NERV_NORMAL, 0);
+}
+
void nerv_matrix_(sigmoid)(Matrix *a, const Matrix *b,
MContext *context, Status *status) {
CHECK_SAME_DIMENSION(a, b, status);