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

Feature/issue383 -- closes #383 #397

Merged
merged 11 commits into from
Nov 12, 2015
Merged

Feature/issue383 -- closes #383 #397

merged 11 commits into from
Nov 12, 2015

Conversation

eddelbuettel
Copy link
Member

this should close #383:

  • works on square and non-square integer and real matrices
  • deals with dimnames
  • will add one for strings as well, not sure I can be bothered for complex

@eddelbuettel
Copy link
Member Author

Bump to @jjallaire @kevinushey -- please take a look when time permits.

This is an addition of three free functions (along with tests), and changes no interface.

@jjallaire
Copy link
Member

LGTM however I don't know enough about the internals to fully provide the green light. @kevinushey ?

s[i] = x[j];
}

// there must be a simpler, more C++-ish way for this ...
Copy link
Contributor

Choose a reason for hiding this comment

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

You could do something like this:

SEXP oldDimNames = Rf_getAttrib(x, R_DimNamesSymbol);
if (!Rf_isNull(oldDimNames)) {
    Shield<SEXP> newDimNames(Rf_allocVector(VECSXP, 2));
    SET_VECTOR_ELT(newDimNames, 0, VECTOR_ELT(oldDimNames, 1));
    SET_VECTOR_ELT(newDimNames, 1, VECTOR_ELT(oldDimNames, 0));
    Rf_setAttrib(r, R_DimNamesSymbol, newDimNames);
}

Marginally cleaner?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice. Anything that avoid PROTECT and UNPROTECT has my vote :)

Copy link
Member Author

Choose a reason for hiding this comment

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

That's been committed.

@kevinushey
Copy link
Contributor

This is fine as-is but made some comments that might help clean up (code duplication, Shield<SEXP>)

@eddelbuettel
Copy link
Member Author

Very helpful -- thanks for he comments, Kevin. Will revise once more.

@eddelbuettel
Copy link
Member Author

Bump. @kevinushey if you can take another quick look...

@kevinushey
Copy link
Contributor

Looks good to me!

eddelbuettel added a commit that referenced this pull request Nov 12, 2015
@eddelbuettel eddelbuettel merged commit 28d099d into master Nov 12, 2015
@eddelbuettel eddelbuettel deleted the feature/issue383 branch November 13, 2015 00:40
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.

matrix transpose
3 participants