Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

row/col-Sums/Means and unit tests - for #549#551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
eddelbuettel merged 2 commits intoRcppCore:masterfromnathan-russell:master
Sep 5, 2016

Conversation

@nathan-russell
Copy link
Contributor

As discussed in#549, this commit adds Sugar functions forrowSums,colSums,rowMeans, andcolMeans, along with unit tests.

@eddelbuettel
Copy link
Member

That looks like it is really nice work, once again. Thank so much!

nathan-russell and kevinushey reacted with thumbs up emoji

}


inline void incr(double& lhs, double rhs) {
Copy link
Contributor

@kevinusheykevinusheySep 5, 2016
edited
Loading

Choose a reason for hiding this comment

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

Minor style quip, but I think it's a preferable to receive arguments that will be mutated by pointer, rather than by reference -- it makes it more obvious at the call site whether a passed-in parameter might be mutated. For example,

do_something(x);

versus

do_something(&x);

In the first case, I think the expectation most would have is thatdo_something(x) will not mutatex, whereby it's more obvious that mutation might happen withdo_something(&x).

The main downside is the fact that pointers can beNULL while references can't, but I think the clarity in code makes up for that. I'll let others weigh on whether that change is worth making.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with Kevin, especially in the case where by local idiom there is no
possibility of the pointer being NULL (which BTW would already be true if
you can pass a reference there).

On Sun, Sep 4, 2016 at 9:38 PM, Kevin Usheynotifications@github.com
wrote:

In inst/include/Rcpp/sugar/functions/rowSums.h
#551 (comment):

+}
+
+inline bool check_na(Rboolean x) {

  • return x == NA_LOGICAL;
    +}

+inline bool check_na(SEXP x) {

  • return x == NA_STRING;
    +}

+inline bool check_na(Rcomplex x) {

  • return ISNAN(x.r) || ISNAN(x.i);
    +}

+inline void incr(double& lhs, double rhs) {

Minor style issue, but I think it's a preferable to receive arguments that
will be mutated by pointer, rather than by reference -- it makes it more
obvious at the call site whether a passed-in parameter might be mutated.
For example,

do_something(x);

versus

do_something(&x);

In the first case, I think the expectation most would have is that
do_something(x) will not mutate x, whereby it's more obvious that
mutation might happen with do_something(&x).

The main downside is the fact that pointers can be NULL while references
can't, but I think the clarity in code makes up for that. I'll let others
weigh on whether that change is worth making.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/RcppCore/Rcpp/pull/551/files/e92b69626da0e6f08f105e01e2f1ff63988da193#r77463324,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGXx1FKiNKUquAVcJPoK1VR4pXRlPxMks5qm3KrgaJpZM4J0m43
.

@eddelbuettel
Copy link
Member

No strong feelings on pointers (clearer as@kevinushey says) versus references (bettern 'modern' C++ ?).

};

ROW_SUMS_IMPL_KEEPNA(LGLSXP)
ROW_SUMS_IMPL_KEEPNA(INTSXP)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same#undef here?

@kevinushey
Copy link
Contributor

Barring some very minor stylistic suggestions, LGTM!

eddelbuettel reacted with thumbs up emoji

@eddelbuettel
Copy link
Member

Thanks@kevinushey . We'll see if@nathan-russell has time for a revision, else we can probably take it as is.

@nathan-russell
Copy link
ContributorAuthor

Those are reasonable suggestions; thanks for reviewing everyone.

@eddelbuetteleddelbuettel merged commitf75ff3b intoRcppCore:masterSep 5, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@nathan-russell@eddelbuettel@kevinushey@jjallaire

[8]ページ先頭

©2009-2025 Movatter.jp