mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
Fixed offset bug.
This commit is contained in:
parent
13d1ad7a6a
commit
c2917dca52
@ -42,7 +42,7 @@ function _nthComplexRoots(a, root) {
|
||||
if (root % 1 !== 0) throw new Error('Root must be an integer');
|
||||
if (a === 0 || a.abs() === 0) return [complex(0)];
|
||||
var aIsNumeric = typeof(a) === 'number';
|
||||
var offset = 0;
|
||||
var offset;
|
||||
// determine the offset (argument of a)/(pi/2)
|
||||
if (aIsNumeric || a.re === 0 || a.im === 0) {
|
||||
if (aIsNumeric) {
|
||||
|
||||
@ -21,6 +21,17 @@ describe('nthRoots', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the correct answer for Complex values', function() {
|
||||
var roots = nthRoots(complex(3, 4), 2);
|
||||
var roots1 = [
|
||||
{ re: 2, im: 1 },
|
||||
{ re: -2.0000000000000004, im: -0.9999999999999999}
|
||||
];
|
||||
roots.forEach(function (value, index, array) {
|
||||
assert.deepEqual(value, roots1[index]);
|
||||
});
|
||||
});
|
||||
|
||||
var twos = [
|
||||
complex(2, 0),
|
||||
complex(0, 2),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user