Skip to content

Commit 7deb282

Browse files
committed
documentation of MatrixDynamicSize
1 parent 3d5c282 commit 7deb282

4 files changed

Lines changed: 147 additions & 15 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace: `OptimT`
66

77
Modules:
88
1. [Genetic](./docs/Genetic.md)
9-
2. Global
10-
3. SimpleMatrix
9+
2. [Global](./docs/Genetic.md)
10+
3. [SimpleMatrix](./docs/SimpleMatrix.md)
1111

1212

1313
Implemented :

docs/SimpleMatrix.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Simple 2d array
2+
3+
This module provides simple template 2d array of fixed-size and dynamic-size. It fits any element type and thus no math computation provided.
4+
5+
## Struct/Classes
6+
1. [MatrixFixedSize](./SimpleMatrix/MatrixFixedSize.md)
7+
2. [MatrixDynamicSize](./SimpleMatrix/MatrixDynamicSize.md)
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# MatrixDynamicSize
2+
Col-major dynamic-size 2d array template implementation.
3+
4+
| Header: | `#include<SimpleMatrix>` |
5+
| ----: | :---- |
6+
| Location: | [MatrixDynamicSize.hpp](../../SimpleMatrix/MatrixDynamicSize.hpp) |
7+
8+
<br>
9+
10+
## Defination
11+
```cpp
12+
template<class Scalar_t> class OptimT::MatrixDynamicSize;
13+
```
14+
<br>
15+
16+
## Types
17+
| Access | Name | Type | Defination |
18+
| :----: | :----: | ----: | :---- |
19+
| | [`Scalar_t`](#scalar_t) | template `typename` | |
20+
| public | [`iterator`](#iterator) | `typedef` | `using iterator = Scalar_t*;` |
21+
| public | [`citerator`](#citerator) |`typedef` | `using citerator = const Scalar_t*;` |
22+
23+
<br>
24+
25+
## Members
26+
| Access | Type | Name | Default value |
27+
| :----: | ----: | :---- | :----: |
28+
| protected | `Scalar_t *` | [`dataPtr`](#dataptr) | `nullptr` |
29+
| protected | `size_t` | [`rowNum`](#rownum) | 0 |
30+
| protected | `size_t *` | [`colNum`](#colnum) | 0 |
31+
32+
<br>
33+
34+
## Member functions
35+
| Access | Return type | Defination |
36+
| :----: | ----: | :---- |
37+
| public | | [`MatrixDynamicSize()`](#matrixfixedsize) |
38+
| public | | [`~MatrixDynamicSize()`](#\~matrixfixedsize) |
39+
| public | `explicit` | [`MatrixDynamicSize(const MatrixDynamicSize &)`](#matrixdynamicsizeconst-matrixdynamicsize--src) |
40+
| public | `iterator` | [`begin()`](#begin) |
41+
| public | `iterator` | [`end()`](#end) |
42+
| public | `size_t` | [`size()`](#size) |
43+
| public | `size_t` | [`rows()`](#rows) |
44+
| public | `size_t` | [`cols()`](#cols) |
45+
| public | `void` | [`resize(size_t r,size_t c)`](#resizesize_t-rsize_t-c) |
46+
| public | `Scalar_t &` | [`operator()(size_t n)`](#operatorsize_t-n) |
47+
| public | `Scalar_t &` | [`operator()(size_t r,size_t c)`](#operatorsize_t-rsize_t-c) |
48+
| public | `Scalar_t *` | [`data()`](#data) |
49+
| public | `const Scalar_t *` | [`cdata()`](#cdata) |
50+
| public | `const MatrixDynamicSize &` | [`operator=(const MatrixDynamicSize &)`](#operatorconst-matrixfixedsize--src) |
51+
52+
<br>
53+
54+
## Detailed description
55+
A simple dynamic-size 2d array of any type, without math computation. It is a col-major one.
56+
57+
<br>
58+
59+
## Type details
60+
### `Scalar_t`
61+
Type of element.
62+
63+
### `iterator`
64+
STL-like Iterator.
65+
66+
### `citerator`
67+
STL-like constant iterator.
68+
69+
<br>
70+
71+
## Member details
72+
### `dataPtr`
73+
Data pointer to the first element.
74+
75+
### `rowNum`
76+
Number of rows.
77+
78+
### `colNum`
79+
Number of coloums.
80+
81+
<br>
82+
83+
## Function details
84+
### `MatrixFixedSize()`
85+
Default constructor. Matrix size will be set to zero so no memory allocation in this function.
86+
87+
### `~MatrixFixedSize()`
88+
Default destructor. Memory will be freed.
89+
90+
### `MatrixDynamicSize(const MatrixDynamicSize & src)`
91+
Deep-copy constructor.
92+
93+
### `begin()`
94+
STL-like begin function that return an iterator to the first element.
95+
96+
### `end()`
97+
STL-like end function that return an iterator after the last element.
98+
99+
### `size()`
100+
Count of elements.
101+
102+
### `rows()`
103+
Count of rows.
104+
105+
### `cols()`
106+
Count of coloumns.
107+
108+
### `resize(size_t r,size_t c)`
109+
Resize matrix. If element count is not changed, it beheaves like conservative resize; otherwise every element will be set to undefined value.
110+
111+
### `operator()(size_t n)`
112+
Random access to the n-th element.
113+
114+
### `operator()(size_t r,size_t c)`
115+
Random access.
116+
117+
### `data()`
118+
Writeable data pointer.
119+
120+
### `cdata()`
121+
Readonly data pointer.
122+
123+
### `operator=(const MatrixFixedSize & src)`
124+
Deep copy function.
125+

docs/SimpleMatrix/MatrixFixedSize.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ template<class Scalar_t,size_t Rows,size_t Cols> class MatrixFixedSize;
3434
## Member functions
3535
| Access | Return type | Defination |
3636
| :----: | ----: | :---- |
37-
| public | | `MatrixFixedSize()` |
38-
| public | | `~MatrixFixedSize()` |
39-
| public | `explicit` | `MatrixFixedSize(const MatrixFixedSize & src)` |
40-
| public | `iterator` | `begin()` |
41-
| public | `iterator` | `end()` |
42-
| public | `static size_t` | `size()` |
43-
| public | `static size_t` | `rows()` |
44-
| public | `static size_t` | `cols()` |
45-
| public | `Scalar_t &` | `operator()(size_t n)` |
46-
| public | `Scalar_t &` | `operator()(size_t r,size_t c)` |
47-
| public | `Scalar_t *` | `data()` |
48-
| public | `const Scalar_t *` | `cdata()` |
49-
| public | `const MatrixFixedSize &` | `operator=(const MatrixFixedSize & src)` |
37+
| public | | [`MatrixFixedSize()`](#matrixfixedsize) |
38+
| public | | [`~MatrixFixedSize()`](#\~matrixfixedsize) |
39+
| public | `explicit` | [`MatrixFixedSize(const MatrixFixedSize & src)`](#matrixfixedsizeconst-matrixfixedsize--src) |
40+
| public | `iterator` | [`begin()`](#begin) |
41+
| public | `iterator` | [`end()`](#end) |
42+
| public | `static size_t` | [`size()`](#size) |
43+
| public | `static size_t` | [`rows()`](#rows) |
44+
| public | `static size_t` | [`cols()`](#cols) |
45+
| public | `Scalar_t &` | [`operator()(size_t n)`](#operatorsize_t-n) |
46+
| public | `Scalar_t &` | [`operator()(size_t r,size_t c)`](#operatorsize_t-rsize_t-c) |
47+
| public | `Scalar_t *` | [`data()`](#data) |
48+
| public | `const Scalar_t *` | [`cdata()`](#cdata) |
49+
| public | `const MatrixFixedSize &` | [`operator=(const MatrixFixedSize & src)`](#operatorconst-matrixfixedsize--src) |
5050
5151
<br>
5252

0 commit comments

Comments
 (0)