Skip to content

Conversation

@ShraddheyaS
Copy link
Contributor

@ShraddheyaS ShraddheyaS commented Jul 23, 2018

Resolves #101.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

  • Read, understood, and followed the contributing guidelines, including the relevant style guides.
  • Read and understand the Code of Conduct.
  • Read and understood the licensing terms.
  • Searched for existing issues and pull requests before submitting this pull request.
  • Filed an issue (or an issue already existed) prior to submitting this pull request.
  • Rebased onto latest develop.
  • Submitted against develop branch.

Description

What is the purpose of this pull request?

This pull request:

  • Adds the feature of the negation of complex numbers

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Yes.

  • The last 2 checkboxes are not ticked because I am putting in this PR against the feature/complex-negate branch.

@stdlib-js/reviewers

@kgryte kgryte changed the title Completed all the TODO's Add support for negating a complex number Jul 23, 2018
@kgryte kgryte added Feature Issue or pull request for adding a new feature. Math Issue or pull request specific to math functionality. labels Jul 23, 2018
Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShraddheyaS Thanks for working on this! Main questions center around positive and negative zeros. Once these are resolved, this PR should be ready for acceptance.


v = cnegate( 0.0, 0.0 );
// returns [ TODO, TODO ]
// returns [ 0.0, 0.0 ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? Why not negative zeros?

* var out = new Array( 2 );
* var v = cnegate( out, 0.0, 0.0 );
* // returns [ TODO, TODO ]
* // returns [ 0.0, 0.0 ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not negative zeros?

*
* v = cnegate( 0.0, 0.0 );
* // returns [ TODO, TODO ]
* // returns [ 0.0, 0.0 ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not negative zeros?

* @example
* var v = cnegate( 0.0, 0.0 );
* // returns [ TODO, TODO ]
* // returns [ 0.0, 0.0 ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not negative zeros?

t.deepEqual( actual, expected, 'returns expected value' );

actual = cnegate( 0.0, 0.0 );
expected = [ 0.0, 0.0 ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is a bit more nuanced, as one needs to test for negative/positive zeros. Ideally, we would have tests for both.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this test is actually already taken care of in the tests starting at L118 and L125. Feel free to modify this test with, say, two negative numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thank you for pointing it out. I saw the isPositiveZero and isNegativeZero tests now. I have changed these tests in the latest commit.


actual = cnegate( 0.0, 0.0 );
expected = [ -0.0, -0.0 ];
t.deepEqual( actual, expected, 'returns expected value' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, deepEqual does not check for sign equality when comparing zeros. Hence, the following test passes

actual = cnegate( 0.0, 0.0 );
expected = [ 0.0, 0.0 ];
t.deepEqual( actual, expected, 'returns expected value' );

even if it shouldn't. Unfortunately, one cannot use deepEqual, but, instead, one must manually check individual array elements. In this case, that entails checking for value and sign equality. This has already been done, in later tests. So having tests here which test function signed zero behavior is not necessary. Perhaps, better might be to just test other values, perhaps with a different sign combination. For example,

actual = cnegate( -1.0, -1.0 );
expected = [ 1.0, 1.0 ];
t.deepEqual( actual, expected, 'returns expected value' );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I realized the redundancy and changed the tests.

Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShraddheyaS Looks good! Will merge once the canary build passes.

@kgryte kgryte merged commit 53d50f1 into stdlib-js:feature/complex-negate Jul 23, 2018
kgryte added a commit that referenced this pull request Jul 23, 2018
* Add pkg scaffold
* Fix pkg path
* Add support for negating a complex number (#193)
* Completed all the TODO's
* Fixed the minus zero results
* Edited the redundant tests which are being checked later
@ShraddheyaS ShraddheyaS deleted the feature/complex-negate branch July 23, 2018 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Issue or pull request for adding a new feature. Math Issue or pull request specific to math functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants