1 | var _ = require("lodash");
|
2 | var R = require("./lib/R");
|
3 | var M = require("./lib/matrix");
|
4 | var T = require("./lib/test");
|
5 | R.NN = require("./plugin/neural");
|
6 | R.NN.RBM = require("./plugin/neural/rbm");
|
7 |
|
8 | R.M = M;
|
9 | R.T = T;
|
10 | R._ = _;
|
11 |
|
12 | R.samples = function(space, size, arg) {
|
13 | var arg = _.defaults(arg, {replace:true});
|
14 | if (arg.replace)
|
15 | return R.calls(size, function() { return _.sample(space); });
|
16 | else
|
17 | return _.sampleSize(space, size);
|
18 | }
|
19 |
|
20 | R.fmix(Array.prototype, {
|
21 |
|
22 | rows:M.rows,
|
23 | cols:M.cols,
|
24 | row:M.row,
|
25 | col:M.col,
|
26 | tr:M.tr,
|
27 | strM:M.str,
|
28 | not:M.not,
|
29 | bnot:M.bnot,
|
30 | neg:M.neg,
|
31 | abs:M.abs,
|
32 | sin:M.sin,
|
33 | cos:M.cos,
|
34 | tan:M.tan,
|
35 | asin:M.asin,
|
36 | acos:M.acos,
|
37 | atan:M.atan,
|
38 | inv:M.inv,
|
39 | all:M.all,
|
40 | any:M.any,
|
41 | same:M.same,
|
42 | isFinite:M.isFinite,
|
43 | isNaN:M.isNaN,
|
44 | sqrt:M.sqrt,
|
45 | ceil:M.ceil,
|
46 | floor:M.floor,
|
47 | round:M.round,
|
48 | log:M.log,
|
49 | exp:M.exp,
|
50 | pow:M.pow,
|
51 | mapreduce:M.mapreduce,
|
52 | lshifteq:M.lshifteq,
|
53 | rshifteq:M.rshifteq,
|
54 | add:M.add,
|
55 | sub:M.sub,
|
56 | mul:M.mul,
|
57 | div:M.div,
|
58 | mod:M.mod,
|
59 | and:M.and,
|
60 | or:M.or,
|
61 | xor:M.xor,
|
62 | band:M.band,
|
63 | bor:M.bor,
|
64 | bxor:M.bxor,
|
65 | eq:M.eq,
|
66 | neq:M.neq,
|
67 | geq:M.geq,
|
68 | leq:M.leq,
|
69 | lt:M.lt,
|
70 | gt:M.gt,
|
71 | t:M.t,
|
72 | det:M.det,
|
73 | norm2:M.norm2,
|
74 | norm2Squared:M.norm2Squared,
|
75 | norm2inf:M.norm2inf,
|
76 | dot:M.dot,
|
77 | det:M.det,
|
78 | dim:M.dim,
|
79 | eig:M.eig,
|
80 | LU:M.LU,
|
81 | svd:M.svd,
|
82 | sumM:M.sum,
|
83 | rowSum:M.rowSum,
|
84 | colSum:M.colSum,
|
85 | rowMean:M.rowMean,
|
86 | colMean:M.colMean,
|
87 | addMV:M.addMV,
|
88 | mapM:M.mapM,
|
89 | mapMM:M.mapMM,
|
90 | flatM:M.flatM,
|
91 | getBlock:M.getBlock,
|
92 | setBlock:M.setBlock,
|
93 | getDiag:M.getDiag,
|
94 | diag:M.diag,
|
95 | parseFloat:M.parseFloat,
|
96 | parseDate:M.parseDate,
|
97 | parseCSV:M.parseCSV,
|
98 | toCSV:M.toCSV,
|
99 |
|
100 | max:R.max,
|
101 | min:R.min,
|
102 | sum:R.sum,
|
103 | product:R.product,
|
104 | mean:R.mean,
|
105 | range:R.range,
|
106 | unique:R.unique,
|
107 | median:R.median,
|
108 | variance:R.variance,
|
109 | deviation:R.deviation,
|
110 | sd:R.sd,
|
111 | cov:R.cov,
|
112 | cor:R.cor,
|
113 | normalize:R.normalize,
|
114 |
|
115 | chunk:_.chunk,
|
116 | compact:_.compact,
|
117 |
|
118 | difference:_.difference,
|
119 | differenceBy:_.differenceBy,
|
120 | differenceWith:_.differenceWith,
|
121 | drop:_.drop,
|
122 | dropRight:_.dropRight,
|
123 | dropRightWhile:_.dropRightWhile,
|
124 | dropWhile:_.dropWhile,
|
125 |
|
126 |
|
127 | findLastIndex:_.findLastIndex,
|
128 | flatten:_.flatten,
|
129 | flattenDeep:_.flattenDeep,
|
130 | flattenDepth:_.flattenDepth,
|
131 | fromPairs:_.fromPairs,
|
132 | head:_.head,
|
133 |
|
134 | initial:_.initial,
|
135 | intersection:_.intersection,
|
136 | intersectionBy:_.intersectionBy,
|
137 | intersectionWith:_.intersectionWith,
|
138 |
|
139 | last:_.last,
|
140 |
|
141 | nth:_.nth,
|
142 | pull:_.pull,
|
143 | pullAll:_.pullAll,
|
144 | pullAllBy:_.pullAllBy,
|
145 | pullAllWith:_.pullAllWith,
|
146 | pullAt:_.pullAt,
|
147 | remove:_.remove,
|
148 |
|
149 |
|
150 | sortedIndex:_.sortedIndex,
|
151 | sortedIndexBy:_.sortedIndexBy,
|
152 | sortedIndexOf:_.sortedIndexOf,
|
153 | sortedLastIndex:_.sortedLastIndex,
|
154 | sortedLastIndexBy:_.sortedLastIndexBy,
|
155 | sortedLastIndexOf:_.sortedLastIndexOf,
|
156 | sortedUniq:_.sortedUniq,
|
157 | sortedUniqBy:_.sortedUniqBy,
|
158 | tail:_.tail,
|
159 | take:_.take,
|
160 | takeRight:_.takeRight,
|
161 | takeRightWhile:_.takeRightWhile,
|
162 | takeWhile:_.takeWhile,
|
163 | union:_.union,
|
164 | unionBy:_.unionBy,
|
165 | unionWith:_.unionWith,
|
166 | uniq:_.uniq,
|
167 | uniqBy:_.uniqBy,
|
168 | uniqWith:_.uniqWith,
|
169 | unzip:_.unzip,
|
170 | unzipWith:_.unzipWith,
|
171 | without:_.without,
|
172 |
|
173 |
|
174 |
|
175 | zip:_.zip,
|
176 | zipObject:_.zipObject,
|
177 | zipObjectDeep:_.zipObjectDeep,
|
178 | zipWith:_.zipWith,
|
179 |
|
180 | countBy:_.countBy,
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 | findLast:_.findLast,
|
187 | flatMap:_.flatMap,
|
188 | flatMapDeep:_.flatMapDeep,
|
189 | flatMapDepth:_.flatMapDepth,
|
190 |
|
191 | forEachRight:_.forEachRight,
|
192 | groupBy:_.groupBy,
|
193 |
|
194 | invokeMap:_.invokeMap,
|
195 | keyBy:_.keyBy,
|
196 |
|
197 | orderBy:_.orderBy,
|
198 | partition:_.partition,
|
199 |
|
200 |
|
201 | reject:_.reject,
|
202 | sample:_.sample,
|
203 | sampleSize:_.sampleSize,
|
204 | shuffle:_.shuffle,
|
205 | size:_.size,
|
206 |
|
207 | sortBy:_.sortBy,
|
208 | });
|
209 |
|
210 | B = R;
|
211 | B.precision=4;
|
212 |
|
213 | B.mix(Number.prototype, { str:function(n) {
|
214 | return this.toFixed(B.precision);
|
215 | }});
|
216 |
|
217 | B.mix(Array.prototype, { str:function(a) {
|
218 | var s="";
|
219 | for (var i in this) {
|
220 | s+=this[i].str()+",";
|
221 | }
|
222 | return "["+B.ctrim(s, ',')+"]";
|
223 | }});
|
224 |
|
225 | B.mix(String.prototype, {
|
226 | str:function() {
|
227 | return this.toString();
|
228 | },
|
229 | lpad:B.curryThis(B.lpad),
|
230 | });
|
231 |
|
232 | B.mix(Object.prototype, { str:function(o) {
|
233 | var s = "";
|
234 | for (var k in o)
|
235 | s+= k+":"+B.str(o[k])+",";
|
236 | return "{"+B.ctrim(s,",")+"}";
|
237 | }});
|
238 |
|
239 | B.str=function(o) { return o.str(); }
|
240 |
|
241 | module.exports = R; |
\ | No newline at end of file |