Fix for non-symmetric matrix diagonal fill (Closes #619) #622

Merged
merged 1 commit into from Dec 31, 2016

Projects

None yet

3 participants

@coatless
Contributor

Fix for the non-symmetric case of the diagonal fill.

Adds unit tests to the diagonal fill feature as well.

Per discussion in #619, this PR moves the matrix diagonal fill away from using an iterator solution to using the matrix subset operator.

@codecov-io

Current coverage is 76.47% (diff: 100%)

Merging #622 into master will not change coverage

@@             master       #622   diff @@
==========================================
  Files            68         68          
  Lines          4004       4004          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           3062       3062          
  Misses          942        942          
  Partials          0          0          

Powered by Codecov. Last update 2883ef3...8aa14aa

+
+ R_xlen_t bounds = ( Matrix::nrow() < Matrix::ncol() ) ?
+ Matrix::nrow() : Matrix::ncol();
+
@eddelbuettel
eddelbuettel Dec 31, 2016 Member

I was just squinting at this (and mostly wondering if I had written it on one line) when I realized that

 R_xlen_t bounds = std::min( Matrix::nrow(), Matrix::ncol() );

is probably even easier :) (Subjec to testing in whether stdLLmin() likes the R type etc pp)

@eddelbuettel
eddelbuettel Dec 31, 2016 Member

I guess one could argue that the ternary operator may be lighter-weight that a function call (which, I bet, ends up inlined). I use that operator a fair amount for alternates too. It just seemed more compact...

@eddelbuettel eddelbuettel merged commit 8e5a3e8 into RcppCore:master Dec 31, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment