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

Add assignment operator to DimNameProxy#339

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
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Remove duplicated code
  • Loading branch information
Florian Plaza Oñate committedAug 14, 2015
commit268a5c5ba11c7f15dd9104a82ee6aaa0bc050707
20 changes: 10 additions & 10 deletionsinst/include/Rcpp/vector/DimNameProxy.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,18 +34,17 @@ namespace internal{
data_(other.data_), dim_(other.dim_) {}

inline DimNameProxy& operator=(SEXP other) {
SEXPdim = Rf_getAttrib(data_, R_DimSymbol);
if (INTEGER(dim)[dim_] != Rf_length(other)) {
SEXPdims = Rf_getAttrib(data_, R_DimSymbol);
if (INTEGER(dims)[dim_] != Rf_length(other)) {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This does the trick

if (Rf_length(other) !=0 && INTEGER(dims)[dim_] != Rf_length(other))

but it looks a bit dirty.

std::stringstream s;
s << "dimension extent is '"
<< INTEGER(dim)[dim_]
<< INTEGER(dims)[dim_]
<< "' while length of names is '"
<< Rf_length(other)
<< "'";
stop(s.str());
}
SEXP dimnames = Rf_getAttrib(data_, R_DimNamesSymbol);
SEXP dims = Rf_getAttrib(data_, R_DimSymbol);
if (Rf_isNull(dimnames)) {
Shield<SEXP> new_dimnames(Rf_allocVector(VECSXP, Rf_length(dims)));
SET_VECTOR_ELT(new_dimnames, dim_, other);
Expand All@@ -55,20 +54,20 @@ namespace internal{
}
return *this;
}


inline DimNameProxy& operator=(const DimNameProxy& other) {
SEXPdim = Rf_getAttrib(data_, R_DimSymbol);
if (INTEGER(dim)[dim_] != INTEGER(dim)[other.dim_]) {
inline DimNameProxy& operator=(const DimNameProxy& other) {
SEXPdims = Rf_getAttrib(data_, R_DimSymbol);
if (INTEGER(dims)[dim_] != INTEGER(dims)[other.dim_]) {
std::stringstream s;
s << "dimension extent is '"
<< INTEGER(dim)[dim_]
<< INTEGER(dims)[dim_]
<< "' while length of names is '"
<< INTEGER(dim)[other.dim_]
<< INTEGER(dims)[other.dim_]
<< "'";
stop(s.str());
}
SEXP dimnames = Rf_getAttrib(data_, R_DimNamesSymbol);
SEXP dims = Rf_getAttrib(data_, R_DimSymbol);
SEXP other_dimnames = SEXP(other);
if (Rf_isNull(dimnames)) {
Shield<SEXP> new_dimnames(Rf_allocVector(VECSXP, Rf_length(dims)));
Expand All@@ -79,6 +78,7 @@ namespace internal{
}
return *this;
}



inline operator SEXP() const {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp