Commit e2d772f
Extend macros with rand to support custom samplers (#1210)
* Extend macros with rand to support custom samplers
* Fix tests
* Update Project.toml
Co-authored-by: Yuto Horikawa <hyrodium@gmail.com>
* Update test/arraymath.jl
Co-authored-by: Yuto Horikawa <hyrodium@gmail.com>
* Update src/SVector.jl
Co-authored-by: Yuto Horikawa <hyrodium@gmail.com>
* Update src/SMatrix.jl
Co-authored-by: Yuto Horikawa <hyrodium@gmail.com>
* Update `SArray` macro
* fix reported issue; support rng in SArray and SMatrix
* Code suggestions for #1210 (#1213)
* move `ex.args[2] isa Integer`
* split `if` block
* simplify :zeros and :ones
* refactor :rand
* refactor :randn and :randexp
* update comments
* add _isnonnegvec
* update with `_isnonnegvec`
* add `_isnonnegvec(args, n)` method to check the size of `args`
* fix `@SArray` for `@SArray rand(rng,T,dim)` etc.
* update comments
* update `@SVector` macro
* update `@SMatrix`
* update `@SVector`
* update `@SArray`
* introduce `fargs` variable
* avoid `_isnonnegvec` in `static_matrix_gen`
* avoid `_isnonnegvec` in `static_vector_gen`
* remove unnecessary `_isnonnegvec`
* add `_rng()` function
* update tests on `@SVector` macro
* update tests on `@MVector` macro
* organize test/MMatrix.jl and test/SMatrix.jl
* organize test/MMatrix.jl and test/SMatrix.jl
* update with broken tests
* organize test/MMatrix.jl and test/SMatrix.jl for `rand*` functions
* fix around `broken` key for `@test` macro
* fix zero-length tests
* update `test/SArray.jl` to match `test/MArray.jl`
* update tests for `@SArray ones` etc.
* add supports for `@SArray ones(3-1,2)` etc.
* move block for `fill`
* update macro `@SArray rand(rng,2,3)` to use ordinary dispatches
* update around `@SArray randn` etc.
* remove unnecessary dollars
* simplify `@SArray fill`
* add `@testset "expand_error"`
* update tests for `@SArray rand(...)` etc.
* fix bug in `rand*_with_Val`
* cleanup tests
* update macro `@SMatrix rand(rng,2,3)` to use ordinary dispatches
* update macro `@SVector rand(rng,3)` to use ordinary dispatches
* move block for `fill`
* simplify `_randexp_with_Val`
---------
Co-authored-by: Yuto Horikawa <hyrodium@gmail.com>1 parent 3fd8fb9 commit e2d772f
File tree
13 files changed
+826
-179
lines changed- src
- test
13 files changed
+826
-179
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
145 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
146 | 189 | | |
147 | 190 | | |
148 | 191 | | |
149 | 192 | | |
150 | 193 | | |
151 | 194 | | |
152 | | - | |
| 195 | + | |
153 | 196 | | |
154 | | - | |
| 197 | + | |
155 | 198 | | |
156 | 199 | | |
157 | | - | |
| 200 | + | |
158 | 201 | | |
159 | 202 | | |
160 | | - | |
| 203 | + | |
161 | 204 | | |
162 | 205 | | |
163 | 206 | | |
| |||
173 | 216 | | |
174 | 217 | | |
175 | 218 | | |
176 | | - | |
| 219 | + | |
177 | 220 | | |
178 | 221 | | |
179 | 222 | | |
| |||
192 | 235 | | |
193 | 236 | | |
194 | 237 | | |
195 | | - | |
| 238 | + | |
196 | 239 | | |
197 | 240 | | |
198 | 241 | | |
199 | 242 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
211 | 256 | | |
212 | 257 | | |
213 | | - | |
214 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
215 | 290 | | |
216 | 291 | | |
217 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
18 | 33 | | |
19 | 34 | | |
20 | 35 | | |
| |||
69 | 84 | | |
70 | 85 | | |
71 | 86 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
77 | 95 | | |
78 | | - | |
| 96 | + | |
79 | 97 | | |
80 | | - | |
81 | | - | |
82 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
83 | 102 | | |
84 | 103 | | |
85 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
86 | 130 | | |
87 | | - | |
| 131 | + | |
88 | 132 | | |
89 | 133 | | |
90 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
19 | 34 | | |
20 | 35 | | |
21 | 36 | | |
| |||
74 | 89 | | |
75 | 90 | | |
76 | 91 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
82 | 100 | | |
83 | | - | |
| 101 | + | |
84 | 102 | | |
85 | | - | |
86 | | - | |
87 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
88 | 107 | | |
89 | 108 | | |
90 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
91 | 135 | | |
92 | | - | |
| 136 | + | |
93 | 137 | | |
94 | 138 | | |
95 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
84 | | - | |
| 83 | + | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
0 commit comments