@@ -27,114 +27,114 @@ namespace Rcpp{
2727 template <int RTYPE, template <class > class StoragePolicy >
2828 Matrix<RTYPE, StoragePolicy>::Matrix(SEXP x) : VECTOR( r_cast<RTYPE>( x ) ), nrows( VECTOR::dims()[0 ] ) {}
2929
30- template <int RTYPE>
31- Matrix<RTYPE>::Matrix( const Dimension& dims) : VECTOR( Rf_allocMatrix( RTYPE, dims[0 ], dims[1 ] ) ), nrows(dims[0 ]) {
30+ template <int RTYPE, template < class > class StoragePolicy >
31+ Matrix<RTYPE,StoragePolicy >::Matrix( const Dimension& dims) : VECTOR( Rf_allocMatrix( RTYPE, dims[0 ], dims[1 ] ) ), nrows(dims[0 ]) {
3232 if ( dims.size () != 2 ) throw not_compatible (" not a matrix" ) ;
3333 VECTOR::init () ;
3434 }
3535
36- template <int RTYPE>
37- Matrix<RTYPE>::Matrix( const int & nrows_, const int & ncols) :
36+ template <int RTYPE, template < class > class StoragePolicy >
37+ Matrix<RTYPE,StoragePolicy >::Matrix( const int & nrows_, const int & ncols) :
3838 VECTOR ( Dimension( nrows_, ncols ) ),
3939 nrows(nrows_)
4040 {}
4141
42- template <int RTYPE>
42+ template <int RTYPE, template < class > class StoragePolicy >
4343 template <typename Iterator>
44- Matrix<RTYPE>::Matrix( const int & nrows_, const int & ncols, Iterator start ) :
44+ Matrix<RTYPE,StoragePolicy >::Matrix( const int & nrows_, const int & ncols, Iterator start ) :
4545 VECTOR ( start, start + (nrows_*ncols) ),
4646 nrows(nrows_)
4747 {
4848 VECTOR::attr ( " dim" ) = Dimension ( nrows, ncols ) ;
4949 }
5050
51- template <int RTYPE>
52- Matrix<RTYPE>::Matrix( const int & n) : VECTOR( Dimension( n, n ) ), nrows(n) {}
51+ template <int RTYPE, template < class > class StoragePolicy >
52+ Matrix<RTYPE,StoragePolicy >::Matrix( const int & n) : VECTOR( Dimension( n, n ) ), nrows(n) {}
5353
54- template <int RTYPE>
55- Matrix<RTYPE>::Matrix( const Matrix& other) : VECTOR( other.asSexp () ), nrows(other.nrows) {}
54+ template <int RTYPE, template < class > class StoragePolicy >
55+ Matrix<RTYPE,StoragePolicy >::Matrix( const Matrix& other) : VECTOR( other.get__ () ), nrows(other.nrows) {}
5656
57- template <int RTYPE>
57+ template <int RTYPE, template < class > class StoragePolicy >
5858 template <bool NA, typename MAT>
59- Matrix<RTYPE>::Matrix( const MatrixBase<RTYPE,NA,MAT>& other ) : VECTOR( Rf_allocMatrix( RTYPE, other.nrow(), other.ncol() ) ), nrows(other.nrow()) {
59+ Matrix<RTYPE,StoragePolicy >::Matrix( const MatrixBase<RTYPE,NA,MAT>& other ) : VECTOR( Rf_allocMatrix( RTYPE, other.nrow(), other.ncol() ) ), nrows(other.nrow()) {
6060 import_matrix_expression<NA,MAT>( other, nrows, ncol () ) ;
6161 }
6262
63- template <int RTYPE>
64- Matrix<RTYPE>& Matrix<RTYPE>::operator =(const Matrix& other) {
65- SEXP x = other. asSexp () ;
63+ template <int RTYPE, template < class > class StoragePolicy >
64+ Matrix<RTYPE, StoragePolicy >& Matrix<RTYPE,StoragePolicy >::operator =(const Matrix& other) {
65+ SEXP x = VECTOR::get__ () ;
6666 if ( ! ::Rf_isMatrix (x) ) not_compatible (" not a matrix" ) ;
6767 VECTOR::set_sexp ( x ) ;
6868 nrows = other.nrows ;
6969 return *this ;
7070 }
7171
72- template <int RTYPE>
72+ template <int RTYPE, template < class > class StoragePolicy >
7373 template <typename U>
74- void Matrix<RTYPE>::fill_diag( const U& u){
74+ void Matrix<RTYPE,StoragePolicy >::fill_diag( const U& u){
7575 fill_diag__dispatch ( typename traits::is_trivial<RTYPE>::type (), u ) ;
7676 }
7777
78- template <int RTYPE>
78+ template <int RTYPE, template < class > class StoragePolicy >
7979 template <typename U>
80- Matrix<RTYPE> Matrix<RTYPE>::diag( int size, const U& diag_value ){
80+ Matrix<RTYPE,StoragePolicy > Matrix<RTYPE,StoragePolicy >::diag( int size, const U& diag_value ){
8181 Matrix res (size,size) ;
8282 res.fill_diag ( diag_value ) ;
8383 return res ;
8484 }
8585
86- template <int RTYPE>
87- inline typename Matrix<RTYPE>::Proxy Matrix<RTYPE>::operator []( int i ){
86+ template <int RTYPE, template < class > class StoragePolicy >
87+ inline typename Matrix<RTYPE,StoragePolicy >::Proxy Matrix<RTYPE,StoragePolicy >::operator []( int i ){
8888 return static_cast < Vector<RTYPE>* >( this )->operator []( i ) ;
8989 }
9090
91- template <int RTYPE>
92- inline typename Matrix<RTYPE>::const_Proxy Matrix<RTYPE>::operator []( int i ) const {
91+ template <int RTYPE, template < class > class StoragePolicy >
92+ inline typename Matrix<RTYPE,StoragePolicy >::const_Proxy Matrix<RTYPE,StoragePolicy >::operator []( int i ) const {
9393 return static_cast < const Vector<RTYPE>* >( this )->operator []( i ) ;
9494 }
9595
96- template <int RTYPE>
97- inline typename Matrix<RTYPE>::Proxy Matrix<RTYPE>::operator ()( const size_t & i, const size_t & j) {
96+ template <int RTYPE, template < class > class StoragePolicy >
97+ inline typename Matrix<RTYPE,StoragePolicy >::Proxy Matrix<RTYPE,StoragePolicy >::operator ()( const size_t & i, const size_t & j) {
9898 return static_cast < Vector<RTYPE>* >( this )->operator []( offset ( i, j ) ) ;
9999 }
100100
101- template <int RTYPE>
102- inline typename Matrix<RTYPE>::const_Proxy Matrix<RTYPE>::operator ()( const size_t & i, const size_t & j) const {
101+ template <int RTYPE, template < class > class StoragePolicy >
102+ inline typename Matrix<RTYPE,StoragePolicy >::const_Proxy Matrix<RTYPE,StoragePolicy >::operator ()( const size_t & i, const size_t & j) const {
103103 return static_cast < const Vector<RTYPE>* >( this )->operator []( offset ( i, j ) ) ;
104104 }
105105
106- template <int RTYPE>
107- inline typename Matrix<RTYPE>::Row Matrix<RTYPE>::operator ()( int i, internal::NamedPlaceHolder ){
106+ template <int RTYPE, template < class > class StoragePolicy >
107+ inline typename Matrix<RTYPE,StoragePolicy >::Row Matrix<RTYPE,StoragePolicy >::operator ()( int i, internal::NamedPlaceHolder ){
108108 return Row ( *this , i ) ;
109109 }
110110
111- template <int RTYPE>
112- inline typename Matrix<RTYPE>::Column Matrix<RTYPE>::operator ()( internal::NamedPlaceHolder, int i ){
111+ template <int RTYPE, template < class > class StoragePolicy >
112+ inline typename Matrix<RTYPE,StoragePolicy >::Column Matrix<RTYPE,StoragePolicy >::operator ()( internal::NamedPlaceHolder, int i ){
113113 return Column ( *this , i ) ;
114114 }
115115
116- template <int RTYPE>
117- inline typename Matrix<RTYPE>::Column Matrix<RTYPE>::operator ()( internal::NamedPlaceHolder, int i ) const {
116+ template <int RTYPE, template < class > class StoragePolicy >
117+ inline typename Matrix<RTYPE,StoragePolicy >::Column Matrix<RTYPE,StoragePolicy >::operator ()( internal::NamedPlaceHolder, int i ) const {
118118 return Column ( *this , i ) ;
119119 }
120120
121- template <int RTYPE>
122- inline typename Matrix<RTYPE>::Sub Matrix<RTYPE>::operator ()( const Range& row_range, const Range& col_range){
121+ template <int RTYPE, template < class > class StoragePolicy >
122+ inline typename Matrix<RTYPE,StoragePolicy >::Sub Matrix<RTYPE,StoragePolicy >::operator ()( const Range& row_range, const Range& col_range){
123123 return Sub ( const_cast <Matrix&>(*this ), row_range, col_range ) ;
124124 }
125- template <int RTYPE>
126- inline typename Matrix<RTYPE>::Sub Matrix<RTYPE>::operator ()( internal::NamedPlaceHolder, const Range& col_range){
125+ template <int RTYPE, template < class > class StoragePolicy >
126+ inline typename Matrix<RTYPE,StoragePolicy >::Sub Matrix<RTYPE,StoragePolicy >::operator ()( internal::NamedPlaceHolder, const Range& col_range){
127127 return Sub ( const_cast <Matrix&>(*this ), Range (0 ,nrow ()-1 ) , col_range ) ;
128128 }
129129
130- template <int RTYPE>
131- inline typename Matrix<RTYPE>::Sub Matrix<RTYPE>::operator ()( const Range& row_range, internal::NamedPlaceHolder ){
130+ template <int RTYPE, template < class > class StoragePolicy >
131+ inline typename Matrix<RTYPE,StoragePolicy >::Sub Matrix<RTYPE,StoragePolicy >::operator ()( const Range& row_range, internal::NamedPlaceHolder ){
132132 return Sub ( const_cast <Matrix&>(*this ), row_range, Range (0 ,ncol ()-1 ) ) ;
133133 }
134134
135- template <int RTYPE>
135+ template <int RTYPE, template < class > class StoragePolicy >
136136 template <typename U>
137- void Matrix<RTYPE>::fill_diag__dispatch( traits::false_type, const U& u){
137+ void Matrix<RTYPE,StoragePolicy >::fill_diag__dispatch( traits::false_type, const U& u){
138138 Shield<SEXP> elem ( converter_type::get ( u ) ) ;
139139 int n = Matrix::ncol () ;
140140 int offset = n +1 ;
@@ -145,9 +145,9 @@ namespace Rcpp{
145145 }
146146 }
147147
148- template <int RTYPE>
148+ template <int RTYPE, template < class > class StoragePolicy >
149149 template <typename U>
150- void Matrix<RTYPE>::fill_diag__dispatch( traits::true_type, const U& u){
150+ void Matrix<RTYPE,StoragePolicy >::fill_diag__dispatch( traits::true_type, const U& u){
151151 stored_type elem = converter_type::get ( u ) ;
152152 int n = Matrix::ncol () ;
153153 int offset = n + 1 ;
@@ -158,9 +158,9 @@ namespace Rcpp{
158158 }
159159 }
160160
161- template <int RTYPE>
161+ template <int RTYPE, template < class > class StoragePolicy >
162162 template <bool NA, typename MAT>
163- void Matrix<RTYPE>::import_matrix_expression( const MatrixBase<RTYPE,NA,MAT>& other, int nr, int nc ){
163+ void Matrix<RTYPE,StoragePolicy >::import_matrix_expression( const MatrixBase<RTYPE,NA,MAT>& other, int nr, int nc ){
164164 iterator start = VECTOR::begin () ;
165165 for ( int j=0 ; j<nc; j++){
166166 for ( int i=0 ; i<nr; i++, ++start){
0 commit comments