Le 05/10/10 11:16, Christian Gunning a écrit :
Sorry for slow reply.

Or perhaps use the "_" thing :

ret( i, _ ) = ...

Is there documentation on _?

No.

It is used in a few places :

Function rnorm( "rnorm" ) ;
rnorm( 10, _["mean"] = 2.0 ) ;

Language call( "rnorm", _["sd"] = 3.0 ) ;

List::create(
  _["foo"] = 3,
  _["bar"] = "bla" ) ;

Or perhaps have this syntax :

ret.row(i) = ...

We aleardy have row member function that returns a Row object, but it
currently does not have a operator=, that could be taken care of.

This sounds good.
I'll look at this in the next week or 2.

Two questions about how this might extend -

1.  Would this allow for an analogous member function along the
following lines, or is "Rows" too much of a stretch?

typedef MatrixRows<RTYPE>  Rows ;
inline Rows row( NumericVector i ){ return Row( *this, i ) ; }

and

Class MatrixRows :
     ...
     private:
         MatrixRow&  row ;
         NumericVector index ;

I'm not sure. What would you then do with a "Rows" object ?

2. For an Array class, does a chained assignment like
ret.slice(i).row(j) = ... sound sensible?

That implies that Array is only 3D. This surely is most of the cases, but I don't want to impose the restriction.

Chaining might be possible, with some work.

best,
xian

The next logical extension of matrix/array indexing beyond boolean
would be to allow NumericVectors in each of the index positions.  At
this point, though, there's an explosion of over-loaded functions - a
3D Num myArray(x, y, z) gives 27 separate functions for x,y,z chosen
from {bool, int, NumericVector}, plus NumericMatrix and NumericVector.
  Here's where an indexer class starts to make sense - unified
constructors, along with clear dimensionality of the indexer and
simple checks of dimensional conformance between indexer and indexed.

Sure.

As a side-note, I just spent some time with arma, and was sad to find
that arma_mat.insert_rows(atrow, rowvec) extends arma_mat, with no
apparent way to do row/col-level in-place replacement. So, at least
we're not whipping a dead horse.

Can you point me to the relevant NumericMatrix(i,j) indexer code?

Look for the "offset" member functions in
https://r-forge.r-project.org/scm/viewvc.php/pkg/Rcpp/inst/include/Rcpp/vector/Vector.h?view=markup&revision=2031&root=rcpp

This is what is used by operator()(int,int) in Matrix.h:
https://r-forge.r-project.org/scm/viewvc.php/pkg/Rcpp/inst/include/Rcpp/vector/Matrix.h?view=markup&revision=1907&root=rcpp


thanks much,
Christian


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/cCmbgg : Rcpp 0.8.6
|- http://bit.ly/bzoWrs : Rcpp svn revision 2000
`- http://bit.ly/b8VNE2 : Rcpp at LondonR, oct 5th


_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to