UNPKG

double-double

Version:

Pure double-double precision functions *with strict error bounds*.

1 lines 5.28 kB
(window.webpackJsonp=window.webpackJsonp||[]).push([[20],{157:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return b})),n.d(t,"metadata",(function(){return c})),n.d(t,"rightToc",(function(){return l})),n.d(t,"default",(function(){return i}));var r=n(2),a=n(9),o=(n(0),n(207)),b={id:"_basic_two_sum_",title:"twoSum",sidebar_label:"twoSum"},c={id:"modules/_basic_two_sum_",isDocsHomePage:!1,title:"twoSum",description:"twoSum(a number): number[]",source:"@site/docs\\modules\\_basic_two_sum_.md",permalink:"/double-double/docs/modules/_basic_two_sum_",sidebar_label:"twoSum",sidebar:"sidebar",previous:{title:"twoSquare",permalink:"/double-double/docs/modules/_basic_two_square_"},next:{title:"ddAbs",permalink:"/double-double/docs/modules/_double_double_unary_dd_abs_"}},l=[],u={rightToc:l};function i(e){var t=e.components,n=Object(a.a)(e,["components"]);return Object(o.b)("wrapper",Object(r.a)({},u,n,{components:t,mdxType:"MDXLayout"}),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"twoSum"),"(",Object(o.b)("inlineCode",{parentName:"p"},"a"),": number, ",Object(o.b)("inlineCode",{parentName:"p"},"b"),": number): ",Object(o.b)("em",{parentName:"p"},"number[]")),Object(o.b)("p",null,Object(o.b)("em",{parentName:"p"},"Defined in ",Object(o.b)("a",Object(r.a)({parentName:"em"},{href:"https://github.com/FlorisSteenkamp/double-double/blob/d35ae52/src/basic/two-sum.ts#L14"}),"basic/two-sum.ts:14"))),Object(o.b)("p",null,"Returns the exact result of adding two doubles."),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"the resulting array is the reverse of the standard twoSum in the literature.")),Object(o.b)("p",null,"Theorem 7 (Knuth): Let a and b be p-bit floating-point numbers. Then the\nfollowing algorithm will produce a nonoverlapping expansion x + y such that\na + b = x + y, where x is an approximation to a + b and y is the roundoff\nerror in the calculation of x."),Object(o.b)("p",null,"See ",Object(o.b)("a",Object(r.a)({parentName:"p"},{href:"https://people.eecs.berkeley.edu/~jrs/papers/robustr.pdf"}),"https://people.eecs.berkeley.edu/~jrs/papers/robustr.pdf")),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"Parameters:")),Object(o.b)("table",null,Object(o.b)("thead",{parentName:"table"},Object(o.b)("tr",{parentName:"thead"},Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Name"),Object(o.b)("th",Object(r.a)({parentName:"tr"},{align:null}),"Type"))),Object(o.b)("tbody",{parentName:"table"},Object(o.b)("tr",{parentName:"tbody"},Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),Object(o.b)("inlineCode",{parentName:"td"},"a")),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"number")),Object(o.b)("tr",{parentName:"tbody"},Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),Object(o.b)("inlineCode",{parentName:"td"},"b")),Object(o.b)("td",Object(r.a)({parentName:"tr"},{align:null}),"number")))),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"Returns:")," ",Object(o.b)("em",{parentName:"p"},"number[]")))}i.isMDXComponent=!0},207:function(e,t,n){"use strict";n.d(t,"a",(function(){return p})),n.d(t,"b",(function(){return d}));var r=n(0),a=n.n(r);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?b(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var u=a.a.createContext({}),i=function(e){var t=a.a.useContext(u),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},p=function(e){var t=i(e.components);return a.a.createElement(u.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},m=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,b=e.parentName,u=l(e,["components","mdxType","originalType","parentName"]),p=i(n),m=r,d=p["".concat(b,".").concat(m)]||p[m]||s[m]||o;return n?a.a.createElement(d,c(c({ref:t},u),{},{components:n})):a.a.createElement(d,c({ref:t},u))}));function d(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,b=new Array(o);b[0]=m;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c.mdxType="string"==typeof e?e:r,b[1]=c;for(var u=2;u<o;u++)b[u]=n[u];return a.a.createElement.apply(null,b)}return a.a.createElement.apply(null,n)}m.displayName="MDXCreateElement"}}]);