Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. export const epsilon = 1.1102230246251565e-16;
  2. export const splitter = 134217729;
  3. export const resulterrbound = (3 + 8 * epsilon) * epsilon;
  4. // fast_expansion_sum_zeroelim routine from oritinal code
  5. export function sum(elen, e, flen, f, h) {
  6. let Q, Qnew, hh, bvirt;
  7. let enow = e[0];
  8. let fnow = f[0];
  9. let eindex = 0;
  10. let findex = 0;
  11. if ((fnow > enow) === (fnow > -enow)) {
  12. Q = enow;
  13. enow = e[++eindex];
  14. } else {
  15. Q = fnow;
  16. fnow = f[++findex];
  17. }
  18. let hindex = 0;
  19. if (eindex < elen && findex < flen) {
  20. if ((fnow > enow) === (fnow > -enow)) {
  21. Qnew = enow + Q;
  22. hh = Q - (Qnew - enow);
  23. enow = e[++eindex];
  24. } else {
  25. Qnew = fnow + Q;
  26. hh = Q - (Qnew - fnow);
  27. fnow = f[++findex];
  28. }
  29. Q = Qnew;
  30. if (hh !== 0) {
  31. h[hindex++] = hh;
  32. }
  33. while (eindex < elen && findex < flen) {
  34. if ((fnow > enow) === (fnow > -enow)) {
  35. Qnew = Q + enow;
  36. bvirt = Qnew - Q;
  37. hh = Q - (Qnew - bvirt) + (enow - bvirt);
  38. enow = e[++eindex];
  39. } else {
  40. Qnew = Q + fnow;
  41. bvirt = Qnew - Q;
  42. hh = Q - (Qnew - bvirt) + (fnow - bvirt);
  43. fnow = f[++findex];
  44. }
  45. Q = Qnew;
  46. if (hh !== 0) {
  47. h[hindex++] = hh;
  48. }
  49. }
  50. }
  51. while (eindex < elen) {
  52. Qnew = Q + enow;
  53. bvirt = Qnew - Q;
  54. hh = Q - (Qnew - bvirt) + (enow - bvirt);
  55. enow = e[++eindex];
  56. Q = Qnew;
  57. if (hh !== 0) {
  58. h[hindex++] = hh;
  59. }
  60. }
  61. while (findex < flen) {
  62. Qnew = Q + fnow;
  63. bvirt = Qnew - Q;
  64. hh = Q - (Qnew - bvirt) + (fnow - bvirt);
  65. fnow = f[++findex];
  66. Q = Qnew;
  67. if (hh !== 0) {
  68. h[hindex++] = hh;
  69. }
  70. }
  71. if (Q !== 0 || hindex === 0) {
  72. h[hindex++] = Q;
  73. }
  74. return hindex;
  75. }
  76. export function sum_three(alen, a, blen, b, clen, c, tmp, out) {
  77. return sum(sum(alen, a, blen, b, tmp), tmp, clen, c, out);
  78. }
  79. // scale_expansion_zeroelim routine from oritinal code
  80. export function scale(elen, e, b, h) {
  81. let Q, sum, hh, product1, product0;
  82. let bvirt, c, ahi, alo, bhi, blo;
  83. c = splitter * b;
  84. bhi = c - (c - b);
  85. blo = b - bhi;
  86. let enow = e[0];
  87. Q = enow * b;
  88. c = splitter * enow;
  89. ahi = c - (c - enow);
  90. alo = enow - ahi;
  91. hh = alo * blo - (Q - ahi * bhi - alo * bhi - ahi * blo);
  92. let hindex = 0;
  93. if (hh !== 0) {
  94. h[hindex++] = hh;
  95. }
  96. for (let i = 1; i < elen; i++) {
  97. enow = e[i];
  98. product1 = enow * b;
  99. c = splitter * enow;
  100. ahi = c - (c - enow);
  101. alo = enow - ahi;
  102. product0 = alo * blo - (product1 - ahi * bhi - alo * bhi - ahi * blo);
  103. sum = Q + product0;
  104. bvirt = sum - Q;
  105. hh = Q - (sum - bvirt) + (product0 - bvirt);
  106. if (hh !== 0) {
  107. h[hindex++] = hh;
  108. }
  109. Q = product1 + sum;
  110. hh = sum - (Q - product1);
  111. if (hh !== 0) {
  112. h[hindex++] = hh;
  113. }
  114. }
  115. if (Q !== 0 || hindex === 0) {
  116. h[hindex++] = Q;
  117. }
  118. return hindex;
  119. }
  120. export function negate(elen, e) {
  121. for (let i = 0; i < elen; i++) e[i] = -e[i];
  122. return elen;
  123. }
  124. export function estimate(elen, e) {
  125. let Q = e[0];
  126. for (let i = 1; i < elen; i++) Q += e[i];
  127. return Q;
  128. }
  129. export function vec(n) {
  130. return new Float64Array(n);
  131. }