You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/complex/float64/base/div/test/test.assign.js
+195Lines changed: 195 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -24,11 +24,13 @@
24
24
25
25
var tape = require( 'tape' );
26
26
var abs = require( '@stdlib/math/base/special/abs' );
27
+
var pow = require( '@stdlib/math/base/special/pow' );
27
28
var EPS = require( '@stdlib/constants/float64/eps' );
28
29
var PINF = require( '@stdlib/constants/float64/pinf' );
29
30
var NINF = require( '@stdlib/constants/float64/ninf' );
30
31
var isnan = require( '@stdlib/math/base/assert/is-nan' );
31
32
var isAlmostEqualFloat64Array = require( '@stdlib/assert/is-almost-equal-float64array' );
33
+
var toBinaryString = require( '@stdlib/number/float64/base/to-binary-string' );
32
34
var Float64Array = require( '@stdlib/array/float64' );
33
35
var cdiv = require( './../lib/assign.js' );
34
36
@@ -50,6 +52,34 @@ var tinyPositiveImaginaryComponents = require( './fixtures/julia/tiny_positive_i
50
52
var tinyPositiveRealComponents = require( './fixtures/julia/tiny_positive_real_components.json' );
51
53
52
54
55
+
// FUNCTIONS //
56
+
57
+
/**
58
+
* Compares the binary representations of two double-precision floating-point numbers and returns the first index of a differing bit. If all bits match, the function returns `-1`.
59
+
*
60
+
* TODO: revisit once ULP distance fcn is written
61
+
*
62
+
* @private
63
+
* @param {number} a - first number
64
+
* @param {number} b - second number
65
+
* @returns {integer} index
66
+
*/
67
+
function bitdiff( a, b ) {
68
+
var astr;
69
+
var bstr;
70
+
var i;
71
+
72
+
astr = toBinaryString( a );
73
+
bstr = toBinaryString( b );
74
+
for ( i = 0; i < 64; i++ ) {
75
+
if ( astr[ i ] !== bstr[ i ] ) {
76
+
return i;
77
+
}
78
+
}
79
+
return -1;
80
+
}
81
+
82
+
53
83
// TESTS //
54
84
55
85
tape( 'main export is a function', function test( t ) {
@@ -72,6 +102,171 @@ tape( 'the function computes a complex quotient (base behavior)', function test(
72
102
t.end();
73
103
});
74
104
105
+
tape( 'the function computes a complex quotient (difficult cases)', function test( t ) {
106
+
var idx;
107
+
var re1;
108
+
var im1;
109
+
var re2;
110
+
var im2;
111
+
var out;
112
+
var v;
113
+
114
+
// Note: test cases extracted from Figure 6 of https://arxiv.org/pdf/1210.4539.pdf.
0 commit comments