sqlmath 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.gitconfig +2 -2
  2. package/.github/workflows/ci.yml +73 -15
  3. package/.github/workflows/publish.yml +66 -0
  4. package/.gitignore +1 -5
  5. package/CHANGELOG.md +53 -2
  6. package/LICENSE +16 -22
  7. package/README.md +18 -219
  8. package/asset_image_folder_open_solid.svg +1 -0
  9. package/jslint.mjs +10998 -0
  10. package/jslint_ci.sh +1542 -728
  11. package/package.json +23 -8
  12. package/{sqlite-autoconf-3360000/sqlite3.c → sqlite3.c} +13116 -85
  13. package/sqlite3_ext.c +8372 -0
  14. package/{sqlite-autoconf-3360000/shell.c → sqlite3_shell.c} +330 -275
  15. package/sqlmath.mjs +1713 -0
  16. package/sqlmath_base.c +1832 -0
  17. package/sqlmath_custom.c +78 -0
  18. package/sqlmath_custom.cpp +0 -0
  19. package/sqlmath_custom.mjs +4 -0
  20. package/sqlmath_old.js +31038 -0
  21. package/extension-functions.c +0 -2047
  22. package/node_sqlite3.cc +0 -11877
  23. package/sqlite-autoconf-3360000/INSTALL +0 -370
  24. package/sqlite-autoconf-3360000/Makefile.am +0 -20
  25. package/sqlite-autoconf-3360000/Makefile.fallback +0 -19
  26. package/sqlite-autoconf-3360000/Makefile.in +0 -1028
  27. package/sqlite-autoconf-3360000/Makefile.msc +0 -1037
  28. package/sqlite-autoconf-3360000/README.txt +0 -113
  29. package/sqlite-autoconf-3360000/Replace.cs +0 -223
  30. package/sqlite-autoconf-3360000/aclocal.m4 +0 -10199
  31. package/sqlite-autoconf-3360000/compile +0 -347
  32. package/sqlite-autoconf-3360000/config.guess +0 -1480
  33. package/sqlite-autoconf-3360000/config.sub +0 -1801
  34. package/sqlite-autoconf-3360000/configure +0 -16135
  35. package/sqlite-autoconf-3360000/configure.ac +0 -285
  36. package/sqlite-autoconf-3360000/depcomp +0 -791
  37. package/sqlite-autoconf-3360000/install-sh +0 -508
  38. package/sqlite-autoconf-3360000/ltmain.sh +0 -11156
  39. package/sqlite-autoconf-3360000/missing +0 -215
  40. package/sqlite-autoconf-3360000/sqlite3.1 +0 -286
  41. package/sqlite-autoconf-3360000/sqlite3.h +0 -12353
  42. package/sqlite-autoconf-3360000/sqlite3.pc.in +0 -13
  43. package/sqlite-autoconf-3360000/sqlite3.rc +0 -83
  44. package/sqlite-autoconf-3360000/sqlite3ext.h +0 -663
  45. package/sqlite-autoconf-3360000/sqlite3rc.h +0 -3
  46. package/sqlite-autoconf-3360000/tea/Makefile.in +0 -440
  47. package/sqlite-autoconf-3360000/tea/README +0 -36
  48. package/sqlite-autoconf-3360000/tea/aclocal.m4 +0 -9
  49. package/sqlite-autoconf-3360000/tea/configure +0 -9989
  50. package/sqlite-autoconf-3360000/tea/configure.ac +0 -201
  51. package/sqlite-autoconf-3360000/tea/doc/sqlite3.n +0 -15
  52. package/sqlite-autoconf-3360000/tea/generic/tclsqlite3.c +0 -4016
  53. package/sqlite-autoconf-3360000/tea/license.terms +0 -6
  54. package/sqlite-autoconf-3360000/tea/pkgIndex.tcl.in +0 -7
  55. package/sqlite-autoconf-3360000/tea/tclconfig/install-sh +0 -528
  56. package/sqlite-autoconf-3360000/tea/tclconfig/tcl.m4 +0 -4168
  57. package/sqlite-autoconf-3360000/tea/win/makefile.vc +0 -419
  58. package/sqlite-autoconf-3360000/tea/win/nmakehlp.c +0 -815
  59. package/sqlite-autoconf-3360000/tea/win/rules.vc +0 -711
  60. package/sqlmath.js +0 -238
  61. package/test/backup.test.js +0 -279
  62. package/test/blob.test.js +0 -54
  63. package/test/cache.test.js +0 -42
  64. package/test/constants.test.js +0 -44
  65. package/test/database_fail.test.js +0 -153
  66. package/test/each.test.js +0 -39
  67. package/test/exec.test.js +0 -39
  68. package/test/extension.test.js +0 -26
  69. package/test/extension_functions.test.js +0 -29
  70. package/test/fts-content.test.js +0 -13
  71. package/test/interrupt.test.js +0 -80
  72. package/test/issue-108.test.js +0 -28
  73. package/test/json.test.js +0 -22
  74. package/test/map.test.js +0 -63
  75. package/test/named_columns.test.js +0 -38
  76. package/test/named_params.test.js +0 -69
  77. package/test/null_error.test.js +0 -41
  78. package/test/nw/.gitignore +0 -3
  79. package/test/nw/Makefile +0 -39
  80. package/test/nw/index.html +0 -14
  81. package/test/nw/package.json +0 -9
  82. package/test/open_close.test.js +0 -187
  83. package/test/other_objects.test.js +0 -98
  84. package/test/parallel_insert.test.js +0 -44
  85. package/test/prepare.test.js +0 -427
  86. package/test/profile.test.js +0 -57
  87. package/test/rerun.test.js +0 -50
  88. package/test/scheduling.test.js +0 -44
  89. package/test/serialization.test.js +0 -104
  90. package/test/support/createdb-electron.js +0 -10
  91. package/test/support/createdb.js +0 -47
  92. package/test/support/elmo.png +0 -0
  93. package/test/support/helper.js +0 -37
  94. package/test/support/script.sql +0 -70
  95. package/test/trace.test.js +0 -67
  96. package/test/unicode.test.js +0 -114
  97. package/test/upsert.test.js +0 -27
  98. package/test/verbose.test.js +0 -60
  99. package/test.js +0 -141
  100. package/test.slr.mjs +0 -212
package/test.slr.mjs DELETED
@@ -1,212 +0,0 @@
1
- /*jslint beta, devel*/
2
- (function () {
3
- function assertOrThrow(passed, msg) {
4
-
5
- // This function will throw <msg> if <passed> is falsy.
6
-
7
- if (!passed) {
8
- throw (
9
- (msg && msg.stack)
10
- ? msg
11
- : new Error(msg)
12
- );
13
- }
14
- }
15
-
16
- function simpleLinearRegressionCreate(size = 8192) {
17
-
18
- // This function will create an object for calculating simple-linear-regression
19
- // statistics.
20
- // https://en.wikipedia.org/wiki/Simple_linear_regression
21
-
22
- let nn = 0;
23
- let sxx = 0;
24
- let sxy = 0;
25
- let syy = 0;
26
- let xavg = 0;
27
- let xx2 = 0;
28
- let xyList = new Float64Array(size * 2);
29
- let yavg = 0;
30
-
31
- function pass1(xx, yy) {
32
-
33
- // This function will calculate simple-linear-regression in one pass using
34
- // Wellford's algorithm.
35
- // For a new value xx, compute the new nn, new xavg, the new sxx.
36
- // xavg accumulates the xavg of the entire dataset
37
- // sxx aggregates the squared distance from the xavg
38
- // nn aggregates the number of samples seen so far
39
-
40
- let dx;
41
- let dy;
42
- xyList[2 * nn] = xx;
43
- xyList[2 * nn + 1] = yy;
44
- nn += 1;
45
- xx2 += xx * xx;
46
-
47
- // calculate sxx
48
-
49
- dx = xx - xavg;
50
- xavg += dx / nn;
51
- sxx += dx * (xx - xavg);
52
-
53
- // calculate syy
54
-
55
- dy = yy - yavg;
56
- yavg += dy / nn;
57
- syy += dy * (yy - yavg);
58
-
59
- // calculate sxy
60
-
61
- sxy += dx * (yy - yavg);
62
- }
63
-
64
- function pass2(xyList2) {
65
-
66
- // This function will calculate simple-linear-regression in two passes.
67
-
68
- let ii;
69
- let nn2;
70
- let xx;
71
- let yy;
72
- nn = xyList2.length / 2;
73
- nn2 = xyList2.length;
74
-
75
- // pass #1
76
-
77
- ii = 0;
78
- while (ii < nn2) {
79
- xx = xyList2[ii];
80
- yy = xyList2[ii + 1];
81
- xyList[ii] = xx;
82
- xyList[ii + 1] = yy;
83
- xavg += xx;
84
- yavg += yy;
85
- xx2 += xx * xx;
86
- ii += 2;
87
- }
88
- xavg = xavg / nn;
89
- yavg = yavg / nn;
90
-
91
- // pass #2
92
-
93
- ii = 0;
94
- while (ii < nn2) {
95
- xx = xyList[ii] - xavg;
96
- yy = xyList[ii + 1] - yavg;
97
- sxx += xx * xx;
98
- syy += yy * yy;
99
- sxy += xx * yy;
100
- ii += 2;
101
- }
102
- }
103
-
104
- function result() {
105
- let alpha;
106
- let beta;
107
- let ii = 0;
108
- let nn2 = nn * 2;
109
- let salpha2;
110
- let sbeta2;
111
- let see = 0;
112
- beta = sxy / sxx;
113
- alpha = yavg - beta * xavg;
114
- while (ii < nn2) {
115
- see += (alpha + beta * xyList[ii] - xyList[ii + 1]) ** 2;
116
- ii += 2;
117
- }
118
- see = see / (nn - 2);
119
- sbeta2 = see / sxx;
120
- salpha2 = sbeta2 * xx2 / nn;
121
- return {
122
- alpha,
123
- beta,
124
- correlation: sxy / Math.sqrt(sxx * syy),
125
- nn,
126
- salpha2,
127
- sbeta2,
128
- see,
129
- sxx,
130
- sxy,
131
- syy,
132
- xavg,
133
- yavg
134
- };
135
- }
136
-
137
- return {
138
- pass1,
139
- pass2,
140
- result
141
- };
142
- }
143
-
144
- // test
145
-
146
- (function () {
147
- let slr1;
148
- let xxList;
149
- let yyList;
150
-
151
- function round(num, decimal) {
152
- return Math.round(num / decimal) * decimal;
153
- }
154
-
155
- function validate() {
156
- let state = slr1.result();
157
- console.error(state);
158
- assertOrThrow(round(state.beta, 0.001) === 61.272, state.beta);
159
- assertOrThrow(round(state.alpha, 0.001) === -39.062, state.alpha);
160
- assertOrThrow(round(state.see, 0.0001) === 0.5762, state.see);
161
- assertOrThrow(round(state.sbeta2, 0.0001) === 3.1539, state.sbeta2);
162
- assertOrThrow(
163
- round(state.salpha2, 0.00001) === 8.63185,
164
- state.salpha2
165
- );
166
- assertOrThrow(
167
- round(state.correlation, 0.0001) === 0.9946,
168
- state.correlation
169
- );
170
- }
171
-
172
- xxList = [
173
- 1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65,
174
- 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83
175
- ];
176
- yyList = [
177
- 52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29,
178
- 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46
179
- ];
180
-
181
- // validate pass1
182
-
183
- slr1 = simpleLinearRegressionCreate(xxList.length);
184
- xxList.forEach(function (xx, ii) {
185
- slr1.pass1(xx, yyList[ii]);
186
- });
187
- validate();
188
-
189
- // validate pass2
190
-
191
- slr1 = simpleLinearRegressionCreate(xxList.length);
192
- slr1.pass2(xxList.flatMap(function (xx, ii) {
193
- return [
194
- xx, yyList[ii]
195
- ];
196
- }));
197
- validate();
198
-
199
- // validate pass1 and pass2
200
-
201
- slr1 = simpleLinearRegressionCreate(xxList.length);
202
- slr1.pass2(xxList.slice(2).flatMap(function (xx, ii) {
203
- return [
204
- xx, yyList[ii + 2]
205
- ];
206
- }));
207
- xxList.slice(0, 2).forEach(function (xx, ii) {
208
- slr1.pass1(xx, yyList[ii]);
209
- });
210
- validate();
211
- }());
212
- }());