From c001832be1e3462ea77efbf68d18b1b405723b35 Mon Sep 17 00:00:00 2001 From: txh18 Date: Mon, 26 Oct 2015 17:31:14 +0800 Subject: discovered a copy_rows_fromd_by_idx that can be used --- nerv/doc/nerv_matrix.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nerv/doc/nerv_matrix.md b/nerv/doc/nerv_matrix.md index 22971d2..54bf440 100644 --- a/nerv/doc/nerv_matrix.md +++ b/nerv/doc/nerv_matrix.md @@ -63,6 +63,10 @@ Copy the content of a __CuMatrix__ `a` to __Matrix__ `self`, they should be of t Copy the content of the __Matrix__ `self` to a __MMatrix__ `a`. * __void Matrix.copy_tod(Matrix self, CuMatrix a)__ Copy the content of the __Matrix__ `self` to a __CuMatrix__ `a`. +* __void Matrix.copy_rows_fromh_by_idx(Matrix self, MMatrix ma, MMatrixInt idx)__ +`idx` should be a row vector. This function copy the rows of `ma` to `self` according to `idx`, in other words, it assigns `ma[idx[i]]` to `self[i]`. +* __void Matrix.copy_rows_fromd_by_idx(Matrix self, CuMatrix b, CuMatrix idx)__ +`idx` needs to a row vector matrix, it stacks the rows of index `idx` of the __CuMatrix__ `b` and copies to `self`. * __void Matrix.add(Matrix self, Matrix ma, Matrix mb, Element_type alpha, Element_type beta)__ It sets the content of __Matrix__ `self` to be `alpha * ma + beta * mb`.__Matrix__ `ma,mb,self` should be of the same size. * __void Matrix.mul(Matrix self, Matrix ma, Matrix mb, Element_type alpha, Element_type beta, [string ta, string tb])__ @@ -81,8 +85,6 @@ Calculate a row-by-row softmax of __Matrix__ `a` and save the result in `self`. Calculate element-wise multiplication of __Matrix__ `ma` and `mb`, store the result in `self`. * __void Matrix.log_elem(Matrix self, Matrix ma)__ Calculate element-wise log of __Matrix__ `ma`, store the result in `self`. -* __void Matrix.copy_rows_fromh_by_idx(Matrix self, MMatrix ma, MMatrixInt idx)__ -`idx` should be a row vector. This function copy the rows of `ma` to `self` according to `idx`, in other words, it assigns `ma[idx[i]]` to `self[i]`. * __void Matrix.expand_frm(Matrix self, Matrix a, int context)__ Treating each row of `a` as speech feature, and do a feature expansion. The `self` should of size `(a.nrow, a.ncol * (context * 2 + 1))`. `self[i]` will be `(a[i-context] a[i-context+1] ... a[i] a[i+1] a[i+context])`. `a[0]` and `a[nrow]` will be copied to extend the index range. * __void Matrix.rearrange_frm(Matrix self, Matrix a, int step)__ @@ -162,4 +164,4 @@ a:mul_elem(fs, fs) print(a) a:log_elem(fs) print(a) -``` \ No newline at end of file +``` -- cgit v1.2.3-70-g09d2