diff options
Diffstat (limited to 'nerv/doc/nerv_matrix.md')
-rw-r--r-- | nerv/doc/nerv_matrix.md | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/nerv/doc/nerv_matrix.md b/nerv/doc/nerv_matrix.md index dfd843d..7555e6c 100644 --- a/nerv/doc/nerv_matrix.md +++ b/nerv/doc/nerv_matrix.md @@ -1,8 +1,8 @@ -#The Nerv Matrix Package# +# The Nerv Matrix Package Part of the [Nerv](../README.md) toolkit. -##Description## -###Underlying structure### +## Description +### Underlying structure In the begining is could be useful to know something about the underlying structure of a __Nerv__ matrix. Please keep in mind that matrice in __Nerv__ is row-major. Every matrix object is a encapsulation of a C struct that describes the attributes of this matrix. ``` @@ -20,12 +20,12 @@ typedef struct Matrix { It is worth mentioning that that `data_ref` is a counter which counts the number of references to its memory space, mind that it will also be increased when a row of the matrix is referenced(`col = m[2]`). A __Nerv__ matrix will deallocate its space when this counter is decreased to zero. Also note that all assigning operation in __Nerv__ is reference copy, you can use `copy_tod` or `copy_toh` method to copy value. Also, row assigning operations like `m1[2]=m2[3]` is forbidden in __Nerv__. -###Class hierarchy### +### Class hierarchy The class hierarchy of the matrix classes can be clearly observed in `matrix/init.c`. First there is a abstract base class __Nerv.Matrix__, which is inherited by __Nerv.CuMatrix__ and __Nerv.MMatrix__(also abstract). Finally, there is __Nerv.CuMatrixFloat__, __Nerv.CuMatrixDouble__, inheriting __Nerv.CuMatrix__, and __Nerv.MMatrixFloat__, __Nerv.MMatrixDouble__, __Nerv.MMatrixInt__ , inheriting __Nerv.MMatrix__. -##Methods## +## Methods Mind that usually a matrix object can only do calculation with matrix of its own type(a __Nerv.CuMatrixFloat__ matrix can only do add operation with a __Nerv.CuMatrixFloat__). In the methods description below, __Matrix__ could be __Nerv.CuMatrixFloat__, __Nerv.CuMatrixDouble__, __Nerv.MMatrixFloat__ or __Nerv.MMatrixDouble__. __Element_type__ could be `float` or `double`, respectively. * __Matrix = Matrix(int nrow, int ncol)__ @@ -113,7 +113,7 @@ Write `self` to the file position in `chunk`. * __void MMatrix.copy_from(MMatrix ma, MMatrix mb,[int b_bgein, int b_end, int a_begin])__ Copy a part of `mb`(rows of index `[b_begin..b_end)`) to `ma` beginning at row index `a_begin`. If not specified, `b_begin` will be `0`, `b_end` will be `b.nrow`, `a_begin` will be `0`. -##Examples## +## Examples * Use `get_dataref_value` to test __Nerv__'s matrix space allocation. ``` m = 10 @@ -134,6 +134,7 @@ print("test fm:get_dataref_value:", fm:get_dataref_value()) print(fm) print(dm) ``` + * Test some __Matrix__ calculations. ``` m = 4 @@ -167,3 +168,4 @@ print(a) a:log_elem(fs) print(a) ``` + |