1 | var R = require("./lib/math");
|
2 | var _ = R._ = require("lodash");
|
3 | R.Symbol = require("./lib/symbolic");
|
4 | R.NN = require("./plugin/neural");
|
5 | R.NN.RBM = require("./plugin/neural/rbm");
|
6 |
|
7 |
|
8 | R.samples = function(space, size, arg) {
|
9 | var arg = _.defaults(arg, {replace:true});
|
10 | if (arg.replace)
|
11 | return _.times(size, ()=>_.sample(space));
|
12 | else
|
13 | return _.sampleSize(space, size);
|
14 | }
|
15 |
|
16 |
|
17 | R.debug = debug = function() {
|
18 | var arg = _.slice(arguments);
|
19 | console.debug.apply(console, arg);
|
20 | }
|
21 |
|
22 | R.print = print = function() {
|
23 | var arg = _.slice(arguments);
|
24 | console.log.apply(console, arg);
|
25 | }
|
26 |
|
27 | p = R.parse;
|
28 | be = R.be;
|
29 |
|
30 | R.mixThisMap(Array.prototype, R, {
|
31 | lu:"lu",
|
32 | luSolve:"luSolve",
|
33 | svd:"svd",
|
34 |
|
35 |
|
36 | rows:"rows",
|
37 | cols:"cols",
|
38 | row:"row",
|
39 | col:"col",
|
40 | tr:"tr",
|
41 | inv:"inv",
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | det:"det",
|
50 |
|
51 |
|
52 |
|
53 | dot:"dot",
|
54 |
|
55 | eig:"eig",
|
56 |
|
57 | rowSum:"rowSum",
|
58 | colSum:"colSum",
|
59 | rowMean:"rowMean",
|
60 | colMean:"colMean",
|
61 | addMV:"addMV",
|
62 | mapM:"mapM",
|
63 | mapMM:"mapMM",
|
64 | flatM:"flatM",
|
65 | fillVM:"fillVM",
|
66 | fillMM:"fillMM",
|
67 | getBlock:"getBlock",
|
68 | setBlock:"setBlock",
|
69 | getDiag:"getDiag",
|
70 | diag:"diag",
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | mstr:"mstr",
|
76 |
|
77 | str:'astr',
|
78 | print:'print',
|
79 | });
|
80 |
|
81 | R.mixThis(Array.prototype, R, [
|
82 | "max",
|
83 | "min",
|
84 | "sum",
|
85 | "product",
|
86 | "norm",
|
87 | "mean",
|
88 | "range",
|
89 | "median",
|
90 | "variance",
|
91 | "deviation",
|
92 | "sd",
|
93 | "cov",
|
94 | "cor",
|
95 | "normalize",
|
96 | "curve",
|
97 | "hist",
|
98 | "ihist",
|
99 | "eval",
|
100 |
|
101 |
|
102 | "add",
|
103 | "sub",
|
104 | "mul",
|
105 | "div",
|
106 | "mod",
|
107 | "neg",
|
108 |
|
109 |
|
110 | "and",
|
111 | "or",
|
112 | "xor",
|
113 | "not",
|
114 |
|
115 | "bnot",
|
116 | "band",
|
117 | "bor",
|
118 | "bxor",
|
119 |
|
120 | "power",
|
121 |
|
122 | "sqrt",
|
123 | "log",
|
124 | "exp",
|
125 | "abs",
|
126 | "sin",
|
127 | "cos",
|
128 | "tan",
|
129 | "asin",
|
130 | "acos",
|
131 | "atan",
|
132 | "ceil",
|
133 | "floor",
|
134 | "round",
|
135 | ]);
|
136 |
|
137 | R.mixThisMap(Number.prototype, R, {
|
138 | str:'nstr',
|
139 | print:'print',
|
140 | });
|
141 |
|
142 | R.mixThis(Number.prototype, R, [
|
143 | 'map',
|
144 | 'add',
|
145 | 'sub',
|
146 | 'mul',
|
147 | 'div',
|
148 | 'mod',
|
149 | 'power',
|
150 | 'neg',
|
151 | 'inv',
|
152 | 'sqrt',
|
153 | 'log',
|
154 | 'exp',
|
155 | 'abs',
|
156 | 'sin',
|
157 | 'cos',
|
158 | 'tan',
|
159 | 'asin',
|
160 | 'acos',
|
161 | 'atan',
|
162 | 'ceil',
|
163 | 'floor',
|
164 | 'round',
|
165 | ]);
|
166 | R.mixThisMap(Function.prototype, R, {
|
167 | add:'fadd',
|
168 | sub:'fsub',
|
169 | mul:'fmul',
|
170 | div:'fdiv',
|
171 | compose:'fcompose',
|
172 | eval:'feval',
|
173 | diff:'fdiff',
|
174 | integral:'fintegral',
|
175 | });
|
176 | R.mixThisMap(String.prototype, R, {str:'sstr',print:'print'});
|
177 | R.mixThisMap(Object.prototype, R, {str:'ostr',print:'print'});
|
178 | R.mixThisMap(Object.prototype, R, {
|
179 | proto:'proto',
|
180 | eq:'eq',
|
181 | neq:'neq',
|
182 | geq:'geq',
|
183 | leq:'leq',
|
184 | gt:'gt',
|
185 | lt:'lt',
|
186 | });
|
187 |
|
188 | R.mixThisMap(Array.prototype, R._, {
|
189 |
|
190 | _chunk:'chunk',
|
191 | _compact:'compact',
|
192 | _concat:'concat',
|
193 | _difference:'difference',
|
194 | _differenceBy:'differenceBy',
|
195 | _differenceWith:'differenceWith',
|
196 | _drop:'drop',
|
197 | _dropRight:'dropRight',
|
198 | _dropRightWhile:'dropRightWhile',
|
199 | _dropWhile:'dropWhile',
|
200 | _fill:'fill',
|
201 | _findIndex:'findIndex',
|
202 | _findLastIndex:'findLastIndex',
|
203 | _flatten:'flatten',
|
204 | _flattenDeep:'flattenDeep',
|
205 | _flattenDepth:'flattenDepth',
|
206 | _fromPairs:'flattenPairs',
|
207 | _head:'head',
|
208 | _indexOf:'indexOf',
|
209 | _initial:'initial',
|
210 | _intersection:'intersection',
|
211 | _intersectionBy:'intersectonBy',
|
212 | _intersectionWith:'intersectionWith',
|
213 | _join:'join',
|
214 | _last:'last',
|
215 | _lastIndexOf:'lastIndexOf',
|
216 | _nth:'nth',
|
217 | _pull:'pull',
|
218 | _pullAll:'pullAll',
|
219 | _pullAllBy:'pullAllBy',
|
220 | _pullAllWith:'pullAllWith',
|
221 | _pullAt:'pullAt',
|
222 | _remove:'remove',
|
223 | _reverse:'reverse',
|
224 | _slice:'slice',
|
225 | _sortedIndex:'sortedIndex',
|
226 | _sortedIndexBy:'sortedIndexBy',
|
227 | _sortedIndexOf:'sortedIndexOf',
|
228 | _sortedLastIndex:'sortedLastIndex',
|
229 | _sortedLastIndexBy:'sortedLastIndexBy',
|
230 | _sortedLastIndexOf:'sortedLastIndexOf',
|
231 | _sortedUniq:'sortedUniq',
|
232 | _sortedUniqBy:'sortedUniqBy',
|
233 | _tail:'tail',
|
234 | _take:'take',
|
235 | _takeRight:'takeRight',
|
236 | _takeRightWhile:'takeRightWhile',
|
237 | _takeWhile:'takeWhile',
|
238 | _union:'union',
|
239 | _unionBy:'unionBy',
|
240 | _unionWith:'unionWith',
|
241 | _uniq:'uniq',
|
242 | _uniqBy:'uniqBy',
|
243 | _uniqWith:'uniqWith',
|
244 | _unzip:'unzip',
|
245 | _unzipWith:'unzipWith',
|
246 | _without:'without',
|
247 | _xor:'xor',
|
248 | _xorBy:'xorBy',
|
249 | _xorWith:'xorWith',
|
250 | _zip:'zip',
|
251 | _zipObject:'zipObject',
|
252 | _zipObjectDeep:'zipObjectDeep',
|
253 | _zipWith:'zipWith',
|
254 |
|
255 | _countBy:'countBy',
|
256 |
|
257 |
|
258 | _every:'every',
|
259 | _filter:'filter',
|
260 | _find:'find',
|
261 | _findLast:'findLast',
|
262 | _flatMap:'flatMap',
|
263 | _flatMapDeep:'flatMapDeep',
|
264 | _flatMapDepth:'flatMapDepth',
|
265 | _forEach:'forEach',
|
266 | _forEachRight:'forEachRight',
|
267 | _groupBy:'groupBy',
|
268 | _includes:'includes',
|
269 | _invokeMap:'invokeMap',
|
270 | _keyBy:'keyBy',
|
271 | _map:'map',
|
272 | _orderBy:'orderBy',
|
273 | _partition:'partition',
|
274 | _reduce:'reduce',
|
275 | _reduceRight:'reduceRight',
|
276 | _reject:'reject',
|
277 | _sample:'sample',
|
278 | _sampleSize:'sampleSize',
|
279 | _shuffle:'shuffle',
|
280 | _size:'size',
|
281 | _some:'some',
|
282 | _sortBy:'sortBy',
|
283 | });
|
284 |
|
285 | module.exports = R;
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|