Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for upper_tri and lower_tri with unit tests (closes #641) #642

Merged
merged 2 commits into from
Jan 31, 2017

Conversation

nathan-russell
Copy link
Contributor

With these changes,

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
LogicalMatrix UpperTri(NumericMatrix x, bool diag = false) {
    return upper_tri(x, diag);
}

// [[Rcpp::export]]
LogicalMatrix LowerTri(NumericMatrix x, bool diag = false) {
    return lower_tri(x, diag);
}

/*** R

x <- matrix(1:4, 4, 5)

all.equal(UpperTri(x), upper.tri(x))
# [1] TRUE

all.equal(UpperTri(x, TRUE), upper.tri(x, TRUE))
# [1] TRUE

all.equal(LowerTri(x), lower.tri(x))
# [1] TRUE

all.equal(LowerTri(x, TRUE), lower.tri(x, TRUE))
# [1] TRUE

*/

Copy link
Member

@eddelbuettel eddelbuettel left a comment

Choose a reason for hiding this comment

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

Looks good to me at a first glance.

@@ -1,8 +1,9 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for catching that here. Slowly changing them myself whenever I see one in a file I use.

//
// lower_tri.h: Rcpp R/C++ interface class library -- lower.tri
//
// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
Copy link
Member

Choose a reason for hiding this comment

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

I think one usually separates the years, so that would be 2010 - 2016 if the next one 2017 - ... No biggie.

@eddelbuettel eddelbuettel merged commit d05d9c6 into RcppCore:master Jan 31, 2017
@nathan-russell nathan-russell deleted the bugfix/upper-lower-tri branch April 23, 2017 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants