Boost.uBlas 1.49
Linear Algebra in C++: matrices, vectors and numeric algorithms

raw.hpp

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 2002-2003
00003 //  Toon Knapen, Kresimir Fresl, Joerg Walter
00004 //
00005 //  Distributed under the Boost Software License, Version 1.0. (See
00006 //  accompanying file LICENSE_1_0.txt or copy at
00007 //  http://www.boost.org/LICENSE_1_0.txt)
00008 //
00009 //
00010 
00011 #ifndef _BOOST_UBLAS_RAW_
00012 #define _BOOST_UBLAS_RAW_
00013 
00014 namespace boost { namespace numeric { namespace ublas { namespace raw {
00015 
00016     // We need data_const() mostly due to MSVC 6.0.
00017     // But how shall we write portable code otherwise?
00018 
00019     template < typename V >
00020     BOOST_UBLAS_INLINE
00021     int size( const V &v ) ;
00022 
00023     template < typename V >
00024     BOOST_UBLAS_INLINE
00025     int size( const vector_reference<V> &v ) ;
00026 
00027     template < typename M >
00028     BOOST_UBLAS_INLINE
00029     int size1( const M &m ) ;
00030     template < typename M >
00031     BOOST_UBLAS_INLINE
00032     int size2( const M &m ) ;
00033 
00034     template < typename M >
00035     BOOST_UBLAS_INLINE
00036     int size1( const matrix_reference<M> &m ) ;
00037     template < typename M >
00038     BOOST_UBLAS_INLINE
00039     int size2( const matrix_reference<M> &m ) ;
00040 
00041     template < typename M >
00042     BOOST_UBLAS_INLINE
00043     int leading_dimension( const M &m, row_major_tag ) ;
00044     template < typename M >
00045     BOOST_UBLAS_INLINE
00046     int leading_dimension( const M &m, column_major_tag ) ;
00047     template < typename M >
00048     BOOST_UBLAS_INLINE
00049     int leading_dimension( const M &m ) ;
00050 
00051     template < typename M >
00052     BOOST_UBLAS_INLINE
00053     int leading_dimension( const matrix_reference<M> &m ) ;
00054 
00055     template < typename V >
00056     BOOST_UBLAS_INLINE
00057     int stride( const V &v ) ;
00058 
00059     template < typename V >
00060     BOOST_UBLAS_INLINE
00061     int stride( const vector_range<V> &v ) ;
00062     template < typename V >
00063     BOOST_UBLAS_INLINE
00064     int stride( const vector_slice<V> &v ) ;
00065 
00066     template < typename M >
00067     BOOST_UBLAS_INLINE
00068     int stride( const matrix_row<M> &v ) ;
00069     template < typename M >
00070     BOOST_UBLAS_INLINE
00071     int stride( const matrix_column<M> &v ) ;
00072 
00073     template < typename M >
00074     BOOST_UBLAS_INLINE
00075     int stride1( const M &m ) ;
00076     template < typename M >
00077     BOOST_UBLAS_INLINE
00078     int stride2( const M &m ) ;
00079 
00080     template < typename M >
00081     BOOST_UBLAS_INLINE
00082     int stride1( const matrix_reference<M> &m ) ;
00083     template < typename M >
00084     BOOST_UBLAS_INLINE
00085     int stride2( const matrix_reference<M> &m ) ;
00086 
00087     template < typename T, std::size_t M, std::size_t N >
00088     BOOST_UBLAS_INLINE
00089     int stride1( const c_matrix<T, M, N> &m ) ;
00090     template < typename T, std::size_t M, std::size_t N >
00091     BOOST_UBLAS_INLINE
00092     int stride2( const c_matrix<T, M, N> &m ) ;
00093 
00094     template < typename M >
00095     BOOST_UBLAS_INLINE
00096     int stride1( const matrix_range<M> &m ) ;
00097     template < typename M >
00098     BOOST_UBLAS_INLINE
00099     int stride1( const matrix_slice<M> &m ) ;
00100     template < typename M >
00101     BOOST_UBLAS_INLINE
00102     int stride2( const matrix_range<M> &m ) ;
00103     template < typename M >
00104     BOOST_UBLAS_INLINE
00105     int stride2( const matrix_slice<M> &m ) ;
00106 
00107     template < typename MV >
00108     BOOST_UBLAS_INLINE
00109     typename MV::array_type::array_type::const_pointer data( const MV &mv ) ;
00110     template < typename MV >
00111     BOOST_UBLAS_INLINE
00112     typename MV::array_type::array_type::const_pointer data_const( const MV &mv ) ;
00113     template < typename MV >
00114     BOOST_UBLAS_INLINE
00115     typename MV::array_type::pointer data( MV &mv ) ;
00116 
00117     template < typename V >
00118     BOOST_UBLAS_INLINE
00119     typename V::array_type::array_type::const_pointer data( const vector_reference<V> &v ) ;
00120     template < typename V >
00121     BOOST_UBLAS_INLINE
00122     typename V::array_type::array_type::const_pointer data_const( const vector_reference<V> &v ) ;
00123     template < typename V >
00124     BOOST_UBLAS_INLINE
00125     typename V::array_type::pointer data( vector_reference<V> &v ) ;
00126 
00127     template < typename T, std::size_t N >
00128     BOOST_UBLAS_INLINE
00129     typename c_vector<T, N>::array_type::array_type::const_pointer data( const c_vector<T, N> &v ) ;
00130     template < typename T, std::size_t N >
00131     BOOST_UBLAS_INLINE
00132     typename c_vector<T, N>::array_type::array_type::const_pointer data_const( const c_vector<T, N> &v ) ;
00133     template < typename T, std::size_t N >
00134     BOOST_UBLAS_INLINE
00135     typename c_vector<T, N>::pointer data( c_vector<T, N> &v ) ;
00136 
00137     template < typename V >
00138     BOOST_UBLAS_INLINE
00139     typename V::array_type::array_type::const_pointer data( const vector_range<V> &v ) ;
00140     template < typename V >
00141     BOOST_UBLAS_INLINE
00142     typename V::array_type::array_type::const_pointer data( const vector_slice<V> &v ) ;
00143     template < typename V >
00144     BOOST_UBLAS_INLINE
00145     typename V::array_type::array_type::const_pointer data_const( const vector_range<V> &v ) ;
00146     template < typename V >
00147     BOOST_UBLAS_INLINE
00148     typename V::array_type::array_type::const_pointer data_const( const vector_slice<V> &v ) ;
00149     template < typename V >
00150     BOOST_UBLAS_INLINE
00151     typename V::array_type::pointer data( vector_range<V> &v ) ;
00152     template < typename V >
00153     BOOST_UBLAS_INLINE
00154     typename V::array_type::pointer data( vector_slice<V> &v ) ;
00155 
00156     template < typename M >
00157     BOOST_UBLAS_INLINE
00158     typename M::array_type::array_type::const_pointer data( const matrix_reference<M> &m ) ;
00159     template < typename M >
00160     BOOST_UBLAS_INLINE
00161     typename M::array_type::array_type::const_pointer data_const( const matrix_reference<M> &m ) ;
00162     template < typename M >
00163     BOOST_UBLAS_INLINE
00164     typename M::array_type::pointer data( matrix_reference<M> &m ) ;
00165 
00166     template < typename T, std::size_t M, std::size_t N >
00167     BOOST_UBLAS_INLINE
00168     typename c_matrix<T, M, N>::array_type::array_type::const_pointer data( const c_matrix<T, M, N> &m ) ;
00169     template < typename T, std::size_t M, std::size_t N >
00170     BOOST_UBLAS_INLINE
00171     typename c_matrix<T, M, N>::array_type::array_type::const_pointer data_const( const c_matrix<T, M, N> &m ) ;
00172     template < typename T, std::size_t M, std::size_t N >
00173     BOOST_UBLAS_INLINE
00174     typename c_matrix<T, M, N>::pointer data( c_matrix<T, M, N> &m ) ;
00175 
00176     template < typename M >
00177     BOOST_UBLAS_INLINE
00178     typename M::array_type::array_type::const_pointer data( const matrix_row<M> &v ) ;
00179     template < typename M >
00180     BOOST_UBLAS_INLINE
00181     typename M::array_type::array_type::const_pointer data( const matrix_column<M> &v ) ;
00182     template < typename M >
00183     BOOST_UBLAS_INLINE
00184     typename M::array_type::array_type::const_pointer data_const( const matrix_row<M> &v ) ;
00185     template < typename M >
00186     BOOST_UBLAS_INLINE
00187     typename M::array_type::array_type::const_pointer data_const( const matrix_column<M> &v ) ;
00188     template < typename M >
00189     BOOST_UBLAS_INLINE
00190     typename M::array_type::pointer data( matrix_row<M> &v ) ;
00191     template < typename M >
00192     BOOST_UBLAS_INLINE
00193     typename M::array_type::pointer data( matrix_column<M> &v ) ;
00194 
00195     template < typename M >
00196     BOOST_UBLAS_INLINE
00197     typename M::array_type::array_type::const_pointer data( const matrix_range<M> &m ) ;
00198     template < typename M >
00199     BOOST_UBLAS_INLINE
00200     typename M::array_type::array_type::const_pointer data( const matrix_slice<M> &m ) ;
00201     template < typename M >
00202     BOOST_UBLAS_INLINE
00203     typename M::array_type::array_type::const_pointer data_const( const matrix_range<M> &m ) ;
00204     template < typename M >
00205     BOOST_UBLAS_INLINE
00206     typename M::array_type::array_type::const_pointer data_const( const matrix_slice<M> &m ) ;
00207     template < typename M >
00208     BOOST_UBLAS_INLINE
00209     typename M::array_type::pointer data( matrix_range<M> &m ) ;
00210     template < typename M >
00211     BOOST_UBLAS_INLINE
00212     typename M::array_type::pointer data( matrix_slice<M> &m ) ;
00213 
00214     template < typename MV >
00215     BOOST_UBLAS_INLINE
00216     typename MV::array_type::array_type::const_pointer base( const MV &mv ) ;
00217 
00218     template < typename MV >
00219     BOOST_UBLAS_INLINE
00220     typename MV::array_type::array_type::const_pointer base_const( const MV &mv ) ;
00221     template < typename MV >
00222     BOOST_UBLAS_INLINE
00223     typename MV::array_type::pointer base( MV &mv ) ;
00224 
00225     template < typename V >
00226     BOOST_UBLAS_INLINE
00227     typename V::array_type::array_type::const_pointer base( const vector_reference<V> &v ) ;
00228     template < typename V >
00229     BOOST_UBLAS_INLINE
00230     typename V::array_type::array_type::const_pointer base_const( const vector_reference<V> &v ) ;
00231     template < typename V >
00232     BOOST_UBLAS_INLINE
00233     typename V::array_type::pointer base( vector_reference<V> &v ) ;
00234 
00235     template < typename T, std::size_t N >
00236     BOOST_UBLAS_INLINE
00237     typename c_vector<T, N>::array_type::array_type::const_pointer base( const c_vector<T, N> &v ) ;
00238     template < typename T, std::size_t N >
00239     BOOST_UBLAS_INLINE
00240     typename c_vector<T, N>::array_type::array_type::const_pointer base_const( const c_vector<T, N> &v ) ;
00241     template < typename T, std::size_t N >
00242     BOOST_UBLAS_INLINE
00243     typename c_vector<T, N>::pointer base( c_vector<T, N> &v ) ;
00244 
00245     template < typename V >
00246     BOOST_UBLAS_INLINE
00247     typename V::array_type::array_type::const_pointer base( const vector_range<V> &v ) ;
00248     template < typename V >
00249     BOOST_UBLAS_INLINE
00250     typename V::array_type::array_type::const_pointer base( const vector_slice<V> &v ) ;
00251     template < typename V >
00252     BOOST_UBLAS_INLINE
00253     typename V::array_type::array_type::const_pointer base_const( const vector_range<V> &v ) ;
00254     template < typename V >
00255     BOOST_UBLAS_INLINE
00256     typename V::array_type::array_type::const_pointer base_const( const vector_slice<V> &v ) ;
00257     template < typename V >
00258     BOOST_UBLAS_INLINE
00259     typename V::array_type::pointer base( vector_range<V> &v ) ;
00260     template < typename V >
00261     BOOST_UBLAS_INLINE
00262     typename V::array_type::pointer base( vector_slice<V> &v ) ;
00263 
00264     template < typename M >
00265     BOOST_UBLAS_INLINE
00266     typename M::array_type::array_type::const_pointer base( const matrix_reference<M> &m ) ;
00267     template < typename M >
00268     BOOST_UBLAS_INLINE
00269     typename M::array_type::array_type::const_pointer base_const( const matrix_reference<M> &m ) ;
00270     template < typename M >
00271     BOOST_UBLAS_INLINE
00272     typename M::array_type::pointer base( matrix_reference<M> &m ) ;
00273 
00274     template < typename T, std::size_t M, std::size_t N >
00275     BOOST_UBLAS_INLINE
00276     typename c_matrix<T, M, N>::array_type::array_type::const_pointer base( const c_matrix<T, M, N> &m ) ;
00277     template < typename T, std::size_t M, std::size_t N >
00278     BOOST_UBLAS_INLINE
00279     typename c_matrix<T, M, N>::array_type::array_type::const_pointer base_const( const c_matrix<T, M, N> &m ) ;
00280     template < typename T, std::size_t M, std::size_t N >
00281     BOOST_UBLAS_INLINE
00282     typename c_matrix<T, M, N>::pointer base( c_matrix<T, M, N> &m ) ;
00283 
00284     template < typename M >
00285     BOOST_UBLAS_INLINE
00286     typename M::array_type::array_type::const_pointer base( const matrix_row<M> &v ) ;
00287     template < typename M >
00288     BOOST_UBLAS_INLINE
00289     typename M::array_type::array_type::const_pointer base( const matrix_column<M> &v ) ;
00290     template < typename M >
00291     BOOST_UBLAS_INLINE
00292     typename M::array_type::array_type::const_pointer base_const( const matrix_row<M> &v ) ;
00293     template < typename M >
00294     BOOST_UBLAS_INLINE
00295     typename M::array_type::array_type::const_pointer base_const( const matrix_column<M> &v ) ;
00296     template < typename M >
00297     BOOST_UBLAS_INLINE
00298     typename M::array_type::pointer base( matrix_row<M> &v ) ;
00299     template < typename M >
00300     BOOST_UBLAS_INLINE
00301     typename M::array_type::pointer base( matrix_column<M> &v ) ;
00302 
00303     template < typename M >
00304     BOOST_UBLAS_INLINE
00305     typename M::array_type::array_type::const_pointer base( const matrix_range<M> &m ) ;
00306     template < typename M >
00307     BOOST_UBLAS_INLINE
00308     typename M::array_type::array_type::const_pointer base( const matrix_slice<M> &m ) ;
00309     template < typename M >
00310     BOOST_UBLAS_INLINE
00311     typename M::array_type::array_type::const_pointer base_const( const matrix_range<M> &m ) ;
00312     template < typename M >
00313     BOOST_UBLAS_INLINE
00314     typename M::array_type::array_type::const_pointer base_const( const matrix_slice<M> &m ) ;
00315     template < typename M >
00316     BOOST_UBLAS_INLINE
00317     typename M::array_type::pointer base( matrix_range<M> &m ) ;
00318     template < typename M >
00319     BOOST_UBLAS_INLINE
00320     typename M::array_type::pointer base( matrix_slice<M> &m ) ;
00321 
00322     template < typename MV >
00323     BOOST_UBLAS_INLINE
00324     typename MV::size_type start( const MV &mv ) ;
00325 
00326     template < typename V >
00327     BOOST_UBLAS_INLINE
00328     typename V::size_type start( const vector_range<V> &v ) ;
00329     template < typename V >
00330     BOOST_UBLAS_INLINE
00331     typename V::size_type start( const vector_slice<V> &v ) ;
00332 
00333     template < typename M >
00334     BOOST_UBLAS_INLINE
00335     typename M::size_type start( const matrix_row<M> &v ) ;
00336     template < typename M >
00337     BOOST_UBLAS_INLINE
00338     typename M::size_type start( const matrix_column<M> &v ) ;
00339 
00340     template < typename M >
00341     BOOST_UBLAS_INLINE
00342     typename M::size_type start( const matrix_range<M> &m ) ;
00343     template < typename M >
00344     BOOST_UBLAS_INLINE
00345     typename M::size_type start( const matrix_slice<M> &m ) ;
00346 
00347 
00348 
00349     template < typename V >
00350     BOOST_UBLAS_INLINE
00351     int size( const V &v ) {
00352         return v.size() ;
00353     }
00354 
00355     template < typename V >
00356     BOOST_UBLAS_INLINE
00357     int size( const vector_reference<V> &v ) {
00358         return size( v ) ;
00359     }
00360 
00361     template < typename M >
00362     BOOST_UBLAS_INLINE
00363     int size1( const M &m ) {
00364         return m.size1() ;
00365     }
00366     template < typename M >
00367     BOOST_UBLAS_INLINE
00368     int size2( const M &m ) {
00369         return m.size2() ;
00370     }
00371 
00372     template < typename M >
00373     BOOST_UBLAS_INLINE
00374     int size1( const matrix_reference<M> &m ) {
00375         return size1( m.expression() ) ;
00376     }
00377     template < typename M >
00378     BOOST_UBLAS_INLINE
00379     int size2( const matrix_reference<M> &m ) {
00380         return size2( m.expression() ) ;
00381     }
00382 
00383     template < typename M >
00384     BOOST_UBLAS_INLINE
00385     int leading_dimension( const M &m, row_major_tag ) {
00386         return m.size2() ;
00387     }
00388     template < typename M >
00389     BOOST_UBLAS_INLINE
00390     int leading_dimension( const M &m, column_major_tag ) {
00391         return m.size1() ;
00392     }
00393     template < typename M >
00394     BOOST_UBLAS_INLINE
00395     int leading_dimension( const M &m ) {
00396         return leading_dimension( m, typename M::orientation_category() ) ;
00397     }
00398 
00399     template < typename M >
00400     BOOST_UBLAS_INLINE
00401     int leading_dimension( const matrix_reference<M> &m ) {
00402         return leading_dimension( m.expression() ) ;
00403     }
00404 
00405     template < typename V >
00406     BOOST_UBLAS_INLINE
00407     int stride( const V &v ) {
00408         return 1 ;
00409     }
00410 
00411     template < typename V >
00412     BOOST_UBLAS_INLINE
00413     int stride( const vector_range<V> &v ) {
00414         return stride( v.data() ) ;
00415     }
00416     template < typename V >
00417     BOOST_UBLAS_INLINE
00418     int stride( const vector_slice<V> &v ) {
00419         return v.stride() * stride( v.data() ) ;
00420     }
00421 
00422     template < typename M >
00423     BOOST_UBLAS_INLINE
00424     int stride( const matrix_row<M> &v ) {
00425         return stride2( v.data() ) ;
00426     }
00427     template < typename M >
00428     BOOST_UBLAS_INLINE
00429     int stride( const matrix_column<M> &v ) {
00430         return stride1( v.data() ) ;
00431     }
00432 
00433     template < typename M >
00434     BOOST_UBLAS_INLINE
00435     int stride1( const M &m ) {
00436         typedef typename M::functor_type functor_type;
00437         return functor_type::one1( m.size1(), m.size2() ) ;
00438     }
00439     template < typename M >
00440     BOOST_UBLAS_INLINE
00441     int stride2( const M &m ) {
00442         typedef typename M::functor_type functor_type;
00443         return functor_type::one2( m.size1(), m.size2() ) ;
00444     }
00445 
00446     template < typename M >
00447     BOOST_UBLAS_INLINE
00448     int stride1( const matrix_reference<M> &m ) {
00449         return stride1( m.expression() ) ;
00450     }
00451     template < typename M >
00452     BOOST_UBLAS_INLINE
00453     int stride2( const matrix_reference<M> &m ) {
00454         return stride2( m.expression() ) ;
00455     }
00456 
00457     template < typename T, std::size_t M, std::size_t N >
00458     BOOST_UBLAS_INLINE
00459     int stride1( const c_matrix<T, M, N> &m ) {
00460         return N ;
00461     }
00462     template < typename T, std::size_t M, std::size_t N >
00463     BOOST_UBLAS_INLINE
00464     int stride2( const c_matrix<T, M, N> &m ) {
00465         return 1 ;
00466     }
00467 
00468     template < typename M >
00469     BOOST_UBLAS_INLINE
00470     int stride1( const matrix_range<M> &m ) {
00471         return stride1( m.data() ) ;
00472     }
00473     template < typename M >
00474     BOOST_UBLAS_INLINE
00475     int stride1( const matrix_slice<M> &m ) {
00476         return m.stride1() * stride1( m.data() ) ;
00477     }
00478     template < typename M >
00479     BOOST_UBLAS_INLINE
00480     int stride2( const matrix_range<M> &m ) {
00481         return stride2( m.data() ) ;
00482     }
00483     template < typename M >
00484     BOOST_UBLAS_INLINE
00485     int stride2( const matrix_slice<M> &m ) {
00486         return m.stride2() * stride2( m.data() ) ;
00487     }
00488 
00489     template < typename MV >
00490     BOOST_UBLAS_INLINE
00491     typename MV::array_type::array_type::array_type::const_pointer data( const MV &mv ) {
00492         return &mv.data().begin()[0] ;
00493     }
00494     template < typename MV >
00495     BOOST_UBLAS_INLINE
00496     typename MV::array_type::array_type::const_pointer data_const( const MV &mv ) {
00497         return &mv.data().begin()[0] ;
00498     }
00499     template < typename MV >
00500     BOOST_UBLAS_INLINE
00501     typename MV::array_type::pointer data( MV &mv ) {
00502         return &mv.data().begin()[0] ;
00503     }
00504 
00505 
00506     template < typename V >
00507     BOOST_UBLAS_INLINE
00508     typename V::array_type::array_type::const_pointer data( const vector_reference<V> &v ) {
00509         return data( v.expression () ) ;
00510     }
00511     template < typename V >
00512     BOOST_UBLAS_INLINE
00513     typename V::array_type::array_type::const_pointer data_const( const vector_reference<V> &v ) {
00514         return data_const( v.expression () ) ;
00515     }
00516     template < typename V >
00517     BOOST_UBLAS_INLINE
00518     typename V::array_type::pointer data( vector_reference<V> &v ) {
00519         return data( v.expression () ) ;
00520     }
00521 
00522     template < typename T, std::size_t N >
00523     BOOST_UBLAS_INLINE
00524     typename c_vector<T, N>::array_type::array_type::const_pointer data( const c_vector<T, N> &v ) {
00525         return v.data() ;
00526     }
00527     template < typename T, std::size_t N >
00528     BOOST_UBLAS_INLINE
00529     typename c_vector<T, N>::array_type::array_type::const_pointer data_const( const c_vector<T, N> &v ) {
00530         return v.data() ;
00531     }
00532     template < typename T, std::size_t N >
00533     BOOST_UBLAS_INLINE
00534     typename c_vector<T, N>::pointer data( c_vector<T, N> &v ) {
00535         return v.data() ;
00536     }
00537 
00538     template < typename V >
00539     BOOST_UBLAS_INLINE
00540     typename V::array_type::array_type::const_pointer data( const vector_range<V> &v ) {
00541         return data( v.data() ) + v.start() * stride (v.data() ) ;
00542     }
00543     template < typename V >
00544     BOOST_UBLAS_INLINE
00545     typename V::array_type::array_type::const_pointer data( const vector_slice<V> &v ) {
00546         return data( v.data() ) + v.start() * stride (v.data() ) ;
00547     }
00548     template < typename V >
00549     BOOST_UBLAS_INLINE
00550     typename V::array_type::array_type::const_pointer data_const( const vector_range<V> &v ) {
00551         return data_const( v.data() ) + v.start() * stride (v.data() ) ;
00552     }
00553     template < typename V >
00554     BOOST_UBLAS_INLINE
00555     typename V::array_type::const_pointer data_const( const vector_slice<V> &v ) {
00556         return data_const( v.data() ) + v.start() * stride (v.data() ) ;
00557     }
00558     template < typename V >
00559     BOOST_UBLAS_INLINE
00560     typename V::array_type::pointer data( vector_range<V> &v ) {
00561         return data( v.data() ) + v.start() * stride (v.data() ) ;
00562     }
00563     template < typename V >
00564     BOOST_UBLAS_INLINE
00565     typename V::array_type::pointer data( vector_slice<V> &v ) {
00566         return data( v.data() ) + v.start() * stride (v.data() ) ;
00567     }
00568 
00569     template < typename M >
00570     BOOST_UBLAS_INLINE
00571     typename M::array_type::const_pointer data( const matrix_reference<M> &m ) {
00572         return data( m.expression () ) ;
00573     }
00574     template < typename M >
00575     BOOST_UBLAS_INLINE
00576     typename M::array_type::const_pointer data_const( const matrix_reference<M> &m ) {
00577         return data_const( m.expression () ) ;
00578     }
00579     template < typename M >
00580     BOOST_UBLAS_INLINE
00581     typename M::array_type::pointer data( matrix_reference<M> &m ) {
00582         return data( m.expression () ) ;
00583     }
00584 
00585     template < typename T, std::size_t M, std::size_t N >
00586     BOOST_UBLAS_INLINE
00587     typename c_matrix<T, M, N>::array_type::const_pointer data( const c_matrix<T, M, N> &m ) {
00588         return m.data() ;
00589     }
00590     template < typename T, std::size_t M, std::size_t N >
00591     BOOST_UBLAS_INLINE
00592     typename c_matrix<T, M, N>::array_type::const_pointer data_const( const c_matrix<T, M, N> &m ) {
00593         return m.data() ;
00594     }
00595     template < typename T, std::size_t M, std::size_t N >
00596     BOOST_UBLAS_INLINE
00597     typename c_matrix<T, M, N>::pointer data( c_matrix<T, M, N> &m ) {
00598         return m.data() ;
00599     }
00600 
00601     template < typename M >
00602     BOOST_UBLAS_INLINE
00603     typename M::array_type::const_pointer data( const matrix_row<M> &v ) {
00604         return data( v.data() ) + v.index() * stride1( v.data() ) ;
00605     }
00606     template < typename M >
00607     BOOST_UBLAS_INLINE
00608     typename M::array_type::const_pointer data( const matrix_column<M> &v ) {
00609         return data( v.data() ) + v.index() * stride2( v.data() ) ;
00610     }
00611     template < typename M >
00612     BOOST_UBLAS_INLINE
00613     typename M::array_type::const_pointer data_const( const matrix_row<M> &v ) {
00614         return data_const( v.data() ) + v.index() * stride1( v.data() ) ;
00615     }
00616     template < typename M >
00617     BOOST_UBLAS_INLINE
00618     typename M::array_type::const_pointer data_const( const matrix_column<M> &v ) {
00619         return data_const( v.data() ) + v.index() * stride2( v.data() ) ;
00620     }
00621     template < typename M >
00622     BOOST_UBLAS_INLINE
00623     typename M::array_type::pointer data( matrix_row<M> &v ) {
00624         return data( v.data() ) + v.index() * stride1( v.data() ) ;
00625     }
00626     template < typename M >
00627     BOOST_UBLAS_INLINE
00628     typename M::array_type::pointer data( matrix_column<M> &v ) {
00629         return data( v.data() ) + v.index() * stride2( v.data() ) ;
00630     }
00631 
00632     template < typename M >
00633     BOOST_UBLAS_INLINE
00634     typename M::array_type::const_pointer data( const matrix_range<M> &m ) {
00635         return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
00636     }
00637     template < typename M >
00638     BOOST_UBLAS_INLINE
00639     typename M::array_type::const_pointer data( const matrix_slice<M> &m ) {
00640         return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
00641     }
00642     template < typename M >
00643     BOOST_UBLAS_INLINE
00644     typename M::array_type::const_pointer data_const( const matrix_range<M> &m ) {
00645         return data_const( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
00646     }
00647     template < typename M >
00648     BOOST_UBLAS_INLINE
00649     typename M::array_type::const_pointer data_const( const matrix_slice<M> &m ) {
00650         return data_const( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
00651     }
00652     template < typename M >
00653     BOOST_UBLAS_INLINE
00654     typename M::array_type::pointer data( matrix_range<M> &m ) {
00655         return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
00656     }
00657     template < typename M >
00658     BOOST_UBLAS_INLINE
00659     typename M::array_type::pointer data( matrix_slice<M> &m ) {
00660         return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
00661     }
00662 
00663 
00664     template < typename MV >
00665     BOOST_UBLAS_INLINE
00666     typename MV::array_type::const_pointer base( const MV &mv ) {
00667         return &mv.data().begin()[0] ;
00668     }
00669     template < typename MV >
00670     BOOST_UBLAS_INLINE
00671     typename MV::array_type::const_pointer base_const( const MV &mv ) {
00672         return &mv.data().begin()[0] ;
00673     }
00674     template < typename MV >
00675     BOOST_UBLAS_INLINE
00676     typename MV::array_type::pointer base( MV &mv ) {
00677         return &mv.data().begin()[0] ;
00678     }
00679 
00680     template < typename V >
00681     BOOST_UBLAS_INLINE
00682     typename V::array_type::const_pointer base( const vector_reference<V> &v ) {
00683         return base( v.expression () ) ;
00684     }
00685     template < typename V >
00686     BOOST_UBLAS_INLINE
00687     typename V::array_type::const_pointer base_const( const vector_reference<V> &v ) {
00688         return base_const( v.expression () ) ;
00689     }
00690     template < typename V >
00691     BOOST_UBLAS_INLINE
00692     typename V::array_type::pointer base( vector_reference<V> &v ) {
00693         return base( v.expression () ) ;
00694     }
00695 
00696     template < typename T, std::size_t N >
00697     BOOST_UBLAS_INLINE
00698     typename c_vector<T, N>::array_type::const_pointer base( const c_vector<T, N> &v ) {
00699         return v.data() ;
00700     }
00701     template < typename T, std::size_t N >
00702     BOOST_UBLAS_INLINE
00703     typename c_vector<T, N>::array_type::const_pointer base_const( const c_vector<T, N> &v ) {
00704         return v.data() ;
00705     }
00706     template < typename T, std::size_t N >
00707     BOOST_UBLAS_INLINE
00708     typename c_vector<T, N>::pointer base( c_vector<T, N> &v ) {
00709         return v.data() ;
00710     }
00711 
00712     template < typename V >
00713     BOOST_UBLAS_INLINE
00714     typename V::array_type::const_pointer base( const vector_range<V> &v ) {
00715         return base( v.data() ) ;
00716     }
00717     template < typename V >
00718     BOOST_UBLAS_INLINE
00719     typename V::array_type::const_pointer base( const vector_slice<V> &v ) {
00720         return base( v.data() ) ;
00721     }
00722     template < typename V >
00723     BOOST_UBLAS_INLINE
00724     typename V::array_type::const_pointer base_const( const vector_range<V> &v ) {
00725         return base_const( v.data() ) ;
00726     }
00727     template < typename V >
00728     BOOST_UBLAS_INLINE
00729     typename V::array_type::const_pointer base_const( const vector_slice<V> &v ) {
00730         return base_const( v.data() ) ;
00731     }
00732     template < typename V >
00733     BOOST_UBLAS_INLINE
00734     typename V::array_type::pointer base( vector_range<V> &v ) {
00735         return base( v.data() ) ;
00736     }
00737     template < typename V >
00738     BOOST_UBLAS_INLINE
00739     typename V::array_type::pointer base( vector_slice<V> &v ) {
00740         return base( v.data() ) ;
00741     }
00742 
00743     template < typename M >
00744     BOOST_UBLAS_INLINE
00745     typename M::array_type::const_pointer base( const matrix_reference<M> &m ) {
00746         return base( m.expression () ) ;
00747     }
00748     template < typename M >
00749     BOOST_UBLAS_INLINE
00750     typename M::array_type::const_pointer base_const( const matrix_reference<M> &m ) {
00751         return base_const( m.expression () ) ;
00752     }
00753     template < typename M >
00754     BOOST_UBLAS_INLINE
00755     typename M::array_type::pointer base( matrix_reference<M> &m ) {
00756         return base( m.expression () ) ;
00757     }
00758 
00759     template < typename T, std::size_t M, std::size_t N >
00760     BOOST_UBLAS_INLINE
00761     typename c_matrix<T, M, N>::array_type::const_pointer base( const c_matrix<T, M, N> &m ) {
00762         return m.data() ;
00763     }
00764     template < typename T, std::size_t M, std::size_t N >
00765     BOOST_UBLAS_INLINE
00766     typename c_matrix<T, M, N>::array_type::const_pointer base_const( const c_matrix<T, M, N> &m ) {
00767         return m.data() ;
00768     }
00769     template < typename T, std::size_t M, std::size_t N >
00770     BOOST_UBLAS_INLINE
00771     typename c_matrix<T, M, N>::pointer base( c_matrix<T, M, N> &m ) {
00772         return m.data() ;
00773     }
00774 
00775     template < typename M >
00776     BOOST_UBLAS_INLINE
00777     typename M::array_type::const_pointer base( const matrix_row<M> &v ) {
00778         return base( v.data() ) ;
00779     }
00780     template < typename M >
00781     BOOST_UBLAS_INLINE
00782     typename M::array_type::const_pointer base( const matrix_column<M> &v ) {
00783         return base( v.data() ) ;
00784     }
00785     template < typename M >
00786     BOOST_UBLAS_INLINE
00787     typename M::array_type::const_pointer base_const( const matrix_row<M> &v ) {
00788         return base_const( v.data() ) ;
00789     }
00790     template < typename M >
00791     BOOST_UBLAS_INLINE
00792     typename M::array_type::const_pointer base_const( const matrix_column<M> &v ) {
00793         return base_const( v.data() ) ;
00794     }
00795     template < typename M >
00796     BOOST_UBLAS_INLINE
00797     typename M::array_type::pointer base( matrix_row<M> &v ) {
00798         return base( v.data() ) ;
00799     }
00800     template < typename M >
00801     BOOST_UBLAS_INLINE
00802     typename M::array_type::pointer base( matrix_column<M> &v ) {
00803         return base( v.data() ) ;
00804     }
00805 
00806     template < typename M >
00807     BOOST_UBLAS_INLINE
00808     typename M::array_type::const_pointer base( const matrix_range<M> &m ) {
00809         return base( m.data() ) ;
00810     }
00811     template < typename M >
00812     BOOST_UBLAS_INLINE
00813     typename M::array_type::const_pointer base( const matrix_slice<M> &m ) {
00814         return base( m.data() ) ;
00815     }
00816     template < typename M >
00817     BOOST_UBLAS_INLINE
00818     typename M::array_type::const_pointer base_const( const matrix_range<M> &m ) {
00819         return base_const( m.data() ) ;
00820     }
00821     template < typename M >
00822     BOOST_UBLAS_INLINE
00823     typename M::array_type::const_pointer base_const( const matrix_slice<M> &m ) {
00824         return base_const( m.data() ) ;
00825     }
00826     template < typename M >
00827     BOOST_UBLAS_INLINE
00828     typename M::array_type::pointer base( matrix_range<M> &m ) {
00829         return base( m.data() ) ;
00830     }
00831     template < typename M >
00832     BOOST_UBLAS_INLINE
00833     typename M::array_type::pointer base( matrix_slice<M> &m ) {
00834         return base( m.data() ) ;
00835     }
00836 
00837     template < typename MV >
00838     BOOST_UBLAS_INLINE
00839     typename MV::size_type start( const MV &mv ) {
00840         return 0 ;
00841     }
00842 
00843     template < typename V >
00844     BOOST_UBLAS_INLINE
00845     typename V::size_type start( const vector_range<V> &v ) {
00846         return v.start() * stride (v.data() ) ;
00847     }
00848     template < typename V >
00849     BOOST_UBLAS_INLINE
00850     typename V::size_type start( const vector_slice<V> &v ) {
00851         return v.start() * stride (v.data() ) ;
00852     }
00853 
00854     template < typename M >
00855     BOOST_UBLAS_INLINE
00856     typename M::size_type start( const matrix_row<M> &v ) {
00857         return v.index() * stride1( v.data() ) ;
00858     }
00859     template < typename M >
00860     BOOST_UBLAS_INLINE
00861     typename M::size_type start( const matrix_column<M> &v ) {
00862         return v.index() * stride2( v.data() ) ;
00863     }
00864 
00865     template < typename M >
00866     BOOST_UBLAS_INLINE
00867     typename M::size_type start( const matrix_range<M> &m ) {
00868         return m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
00869     }
00870     template < typename M >
00871     BOOST_UBLAS_INLINE
00872     typename M::size_type start( const matrix_slice<M> &m ) {
00873         return m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
00874     }
00875 
00876 }}}}
00877 
00878 #endif