source: NonGTP/Boost/boost/numeric/ublas/detail/raw.hpp @ 857

Revision 857, 30.8 KB checked in by igarcia, 18 years ago (diff)
Line 
1//
2//  Copyright (c) 2002-2003
3//  Toon Knapen, Kresimir Fresl, Joerg Walter
4//
5//  Permission to use, copy, modify, distribute and sell this software
6//  and its documentation for any purpose is hereby granted without fee,
7//  provided that the above copyright notice appear in all copies and
8//  that both that copyright notice and this permission notice appear
9//  in supporting documentation.  The authors make no representations
10//  about the suitability of this software for any purpose.
11//  It is provided "as is" without express or implied warranty.
12//
13//
14
15#ifndef _BOOST_UBLAS_RAW_
16#define _BOOST_UBLAS_RAW_
17
18namespace boost { namespace numeric { namespace ublas { namespace raw {
19
20    // We need data_const() mostly due to MSVC 6.0.
21    // But how shall we write portable code otherwise?
22
23    template < typename V >
24    BOOST_UBLAS_INLINE
25    int size( const V &v ) ;
26
27    template < typename V >
28    BOOST_UBLAS_INLINE
29    int size( const vector_reference<V> &v ) ;
30
31    template < typename M >
32    BOOST_UBLAS_INLINE
33    int size1( const M &m ) ;
34    template < typename M >
35    BOOST_UBLAS_INLINE
36    int size2( const M &m ) ;
37
38    template < typename M >
39    BOOST_UBLAS_INLINE
40    int size1( const matrix_reference<M> &m ) ;
41    template < typename M >
42    BOOST_UBLAS_INLINE
43    int size2( const matrix_reference<M> &m ) ;
44
45    template < typename M >
46    BOOST_UBLAS_INLINE
47    int leading_dimension( const M &m, row_major_tag ) ;
48    template < typename M >
49    BOOST_UBLAS_INLINE
50    int leading_dimension( const M &m, column_major_tag ) ;
51    template < typename M >
52    BOOST_UBLAS_INLINE
53    int leading_dimension( const M &m ) ;
54
55    template < typename M >
56    BOOST_UBLAS_INLINE
57    int leading_dimension( const matrix_reference<M> &m ) ;
58
59    template < typename V >
60    BOOST_UBLAS_INLINE
61    int stride( const V &v ) ;
62
63    template < typename V >
64    BOOST_UBLAS_INLINE
65    int stride( const vector_range<V> &v ) ;
66    template < typename V >
67    BOOST_UBLAS_INLINE
68    int stride( const vector_slice<V> &v ) ;
69
70    template < typename M >
71    BOOST_UBLAS_INLINE
72    int stride( const matrix_row<M> &v ) ;
73    template < typename M >
74    BOOST_UBLAS_INLINE
75    int stride( const matrix_column<M> &v ) ;
76
77    template < typename M >
78    BOOST_UBLAS_INLINE
79    int stride1( const M &m ) ;
80    template < typename M >
81    BOOST_UBLAS_INLINE
82    int stride2( const M &m ) ;
83
84    template < typename M >
85    BOOST_UBLAS_INLINE
86    int stride1( const matrix_reference<M> &m ) ;
87    template < typename M >
88    BOOST_UBLAS_INLINE
89    int stride2( const matrix_reference<M> &m ) ;
90
91    template < typename T, std::size_t M, std::size_t N >
92    BOOST_UBLAS_INLINE
93    int stride1( const c_matrix<T, M, N> &m ) ;
94    template < typename T, std::size_t M, std::size_t N >
95    BOOST_UBLAS_INLINE
96    int stride2( const c_matrix<T, M, N> &m ) ;
97
98    template < typename M >
99    BOOST_UBLAS_INLINE
100    int stride1( const matrix_range<M> &m ) ;
101    template < typename M >
102    BOOST_UBLAS_INLINE
103    int stride1( const matrix_slice<M> &m ) ;
104    template < typename M >
105    BOOST_UBLAS_INLINE
106    int stride2( const matrix_range<M> &m ) ;
107    template < typename M >
108    BOOST_UBLAS_INLINE
109    int stride2( const matrix_slice<M> &m ) ;
110
111    template < typename MV >
112    BOOST_UBLAS_INLINE
113    typename MV::array_type::array_type::const_pointer data( const MV &mv ) ;
114    template < typename MV >
115    BOOST_UBLAS_INLINE
116    typename MV::array_type::array_type::const_pointer data_const( const MV &mv ) ;
117    template < typename MV >
118    BOOST_UBLAS_INLINE
119    typename MV::array_type::pointer data( MV &mv ) ;
120
121    template < typename V >
122    BOOST_UBLAS_INLINE
123    typename V::array_type::array_type::const_pointer data( const vector_reference<V> &v ) ;
124    template < typename V >
125    BOOST_UBLAS_INLINE
126    typename V::array_type::array_type::const_pointer data_const( const vector_reference<V> &v ) ;
127    template < typename V >
128    BOOST_UBLAS_INLINE
129    typename V::array_type::pointer data( vector_reference<V> &v ) ;
130
131    template < typename T, std::size_t N >
132    BOOST_UBLAS_INLINE
133    typename c_vector<T, N>::array_type::array_type::const_pointer data( const c_vector<T, N> &v ) ;
134    template < typename T, std::size_t N >
135    BOOST_UBLAS_INLINE
136    typename c_vector<T, N>::array_type::array_type::const_pointer data_const( const c_vector<T, N> &v ) ;
137    template < typename T, std::size_t N >
138    BOOST_UBLAS_INLINE
139    typename c_vector<T, N>::pointer data( c_vector<T, N> &v ) ;
140
141    template < typename V >
142    BOOST_UBLAS_INLINE
143    typename V::array_type::array_type::const_pointer data( const vector_range<V> &v ) ;
144    template < typename V >
145    BOOST_UBLAS_INLINE
146    typename V::array_type::array_type::const_pointer data( const vector_slice<V> &v ) ;
147    template < typename V >
148    BOOST_UBLAS_INLINE
149    typename V::array_type::array_type::const_pointer data_const( const vector_range<V> &v ) ;
150    template < typename V >
151    BOOST_UBLAS_INLINE
152    typename V::array_type::array_type::const_pointer data_const( const vector_slice<V> &v ) ;
153    template < typename V >
154    BOOST_UBLAS_INLINE
155    typename V::array_type::pointer data( vector_range<V> &v ) ;
156    template < typename V >
157    BOOST_UBLAS_INLINE
158    typename V::array_type::pointer data( vector_slice<V> &v ) ;
159
160    template < typename M >
161    BOOST_UBLAS_INLINE
162    typename M::array_type::array_type::const_pointer data( const matrix_reference<M> &m ) ;
163    template < typename M >
164    BOOST_UBLAS_INLINE
165    typename M::array_type::array_type::const_pointer data_const( const matrix_reference<M> &m ) ;
166    template < typename M >
167    BOOST_UBLAS_INLINE
168    typename M::array_type::pointer data( matrix_reference<M> &m ) ;
169
170    template < typename T, std::size_t M, std::size_t N >
171    BOOST_UBLAS_INLINE
172    typename c_matrix<T, M, N>::array_type::array_type::const_pointer data( const c_matrix<T, M, N> &m ) ;
173    template < typename T, std::size_t M, std::size_t N >
174    BOOST_UBLAS_INLINE
175    typename c_matrix<T, M, N>::array_type::array_type::const_pointer data_const( const c_matrix<T, M, N> &m ) ;
176    template < typename T, std::size_t M, std::size_t N >
177    BOOST_UBLAS_INLINE
178    typename c_matrix<T, M, N>::pointer data( c_matrix<T, M, N> &m ) ;
179
180    template < typename M >
181    BOOST_UBLAS_INLINE
182    typename M::array_type::array_type::const_pointer data( const matrix_row<M> &v ) ;
183    template < typename M >
184    BOOST_UBLAS_INLINE
185    typename M::array_type::array_type::const_pointer data( const matrix_column<M> &v ) ;
186    template < typename M >
187    BOOST_UBLAS_INLINE
188    typename M::array_type::array_type::const_pointer data_const( const matrix_row<M> &v ) ;
189    template < typename M >
190    BOOST_UBLAS_INLINE
191    typename M::array_type::array_type::const_pointer data_const( const matrix_column<M> &v ) ;
192    template < typename M >
193    BOOST_UBLAS_INLINE
194    typename M::array_type::pointer data( matrix_row<M> &v ) ;
195    template < typename M >
196    BOOST_UBLAS_INLINE
197    typename M::array_type::pointer data( matrix_column<M> &v ) ;
198
199    template < typename M >
200    BOOST_UBLAS_INLINE
201    typename M::array_type::array_type::const_pointer data( const matrix_range<M> &m ) ;
202    template < typename M >
203    BOOST_UBLAS_INLINE
204    typename M::array_type::array_type::const_pointer data( const matrix_slice<M> &m ) ;
205    template < typename M >
206    BOOST_UBLAS_INLINE
207    typename M::array_type::array_type::const_pointer data_const( const matrix_range<M> &m ) ;
208    template < typename M >
209    BOOST_UBLAS_INLINE
210    typename M::array_type::array_type::const_pointer data_const( const matrix_slice<M> &m ) ;
211    template < typename M >
212    BOOST_UBLAS_INLINE
213    typename M::array_type::pointer data( matrix_range<M> &m ) ;
214    template < typename M >
215    BOOST_UBLAS_INLINE
216    typename M::array_type::pointer data( matrix_slice<M> &m ) ;
217
218    template < typename MV >
219    BOOST_UBLAS_INLINE
220    typename MV::array_type::array_type::const_pointer base( const MV &mv ) ;
221
222    template < typename MV >
223    BOOST_UBLAS_INLINE
224    typename MV::array_type::array_type::const_pointer base_const( const MV &mv ) ;
225    template < typename MV >
226    BOOST_UBLAS_INLINE
227    typename MV::array_type::pointer base( MV &mv ) ;
228
229    template < typename V >
230    BOOST_UBLAS_INLINE
231    typename V::array_type::array_type::const_pointer base( const vector_reference<V> &v ) ;
232    template < typename V >
233    BOOST_UBLAS_INLINE
234    typename V::array_type::array_type::const_pointer base_const( const vector_reference<V> &v ) ;
235    template < typename V >
236    BOOST_UBLAS_INLINE
237    typename V::array_type::pointer base( vector_reference<V> &v ) ;
238
239    template < typename T, std::size_t N >
240    BOOST_UBLAS_INLINE
241    typename c_vector<T, N>::array_type::array_type::const_pointer base( const c_vector<T, N> &v ) ;
242    template < typename T, std::size_t N >
243    BOOST_UBLAS_INLINE
244    typename c_vector<T, N>::array_type::array_type::const_pointer base_const( const c_vector<T, N> &v ) ;
245    template < typename T, std::size_t N >
246    BOOST_UBLAS_INLINE
247    typename c_vector<T, N>::pointer base( c_vector<T, N> &v ) ;
248
249    template < typename V >
250    BOOST_UBLAS_INLINE
251    typename V::array_type::array_type::const_pointer base( const vector_range<V> &v ) ;
252    template < typename V >
253    BOOST_UBLAS_INLINE
254    typename V::array_type::array_type::const_pointer base( const vector_slice<V> &v ) ;
255    template < typename V >
256    BOOST_UBLAS_INLINE
257    typename V::array_type::array_type::const_pointer base_const( const vector_range<V> &v ) ;
258    template < typename V >
259    BOOST_UBLAS_INLINE
260    typename V::array_type::array_type::const_pointer base_const( const vector_slice<V> &v ) ;
261    template < typename V >
262    BOOST_UBLAS_INLINE
263    typename V::array_type::pointer base( vector_range<V> &v ) ;
264    template < typename V >
265    BOOST_UBLAS_INLINE
266    typename V::array_type::pointer base( vector_slice<V> &v ) ;
267
268    template < typename M >
269    BOOST_UBLAS_INLINE
270    typename M::array_type::array_type::const_pointer base( const matrix_reference<M> &m ) ;
271    template < typename M >
272    BOOST_UBLAS_INLINE
273    typename M::array_type::array_type::const_pointer base_const( const matrix_reference<M> &m ) ;
274    template < typename M >
275    BOOST_UBLAS_INLINE
276    typename M::array_type::pointer base( matrix_reference<M> &m ) ;
277
278    template < typename T, std::size_t M, std::size_t N >
279    BOOST_UBLAS_INLINE
280    typename c_matrix<T, M, N>::array_type::array_type::const_pointer base( const c_matrix<T, M, N> &m ) ;
281    template < typename T, std::size_t M, std::size_t N >
282    BOOST_UBLAS_INLINE
283    typename c_matrix<T, M, N>::array_type::array_type::const_pointer base_const( const c_matrix<T, M, N> &m ) ;
284    template < typename T, std::size_t M, std::size_t N >
285    BOOST_UBLAS_INLINE
286    typename c_matrix<T, M, N>::pointer base( c_matrix<T, M, N> &m ) ;
287
288    template < typename M >
289    BOOST_UBLAS_INLINE
290    typename M::array_type::array_type::const_pointer base( const matrix_row<M> &v ) ;
291    template < typename M >
292    BOOST_UBLAS_INLINE
293    typename M::array_type::array_type::const_pointer base( const matrix_column<M> &v ) ;
294    template < typename M >
295    BOOST_UBLAS_INLINE
296    typename M::array_type::array_type::const_pointer base_const( const matrix_row<M> &v ) ;
297    template < typename M >
298    BOOST_UBLAS_INLINE
299    typename M::array_type::array_type::const_pointer base_const( const matrix_column<M> &v ) ;
300    template < typename M >
301    BOOST_UBLAS_INLINE
302    typename M::array_type::pointer base( matrix_row<M> &v ) ;
303    template < typename M >
304    BOOST_UBLAS_INLINE
305    typename M::array_type::pointer base( matrix_column<M> &v ) ;
306
307    template < typename M >
308    BOOST_UBLAS_INLINE
309    typename M::array_type::array_type::const_pointer base( const matrix_range<M> &m ) ;
310    template < typename M >
311    BOOST_UBLAS_INLINE
312    typename M::array_type::array_type::const_pointer base( const matrix_slice<M> &m ) ;
313    template < typename M >
314    BOOST_UBLAS_INLINE
315    typename M::array_type::array_type::const_pointer base_const( const matrix_range<M> &m ) ;
316    template < typename M >
317    BOOST_UBLAS_INLINE
318    typename M::array_type::array_type::const_pointer base_const( const matrix_slice<M> &m ) ;
319    template < typename M >
320    BOOST_UBLAS_INLINE
321    typename M::array_type::pointer base( matrix_range<M> &m ) ;
322    template < typename M >
323    BOOST_UBLAS_INLINE
324    typename M::array_type::pointer base( matrix_slice<M> &m ) ;
325
326    template < typename MV >
327    BOOST_UBLAS_INLINE
328    typename MV::size_type start( const MV &mv ) ;
329
330    template < typename V >
331    BOOST_UBLAS_INLINE
332    typename V::size_type start( const vector_range<V> &v ) ;
333    template < typename V >
334    BOOST_UBLAS_INLINE
335    typename V::size_type start( const vector_slice<V> &v ) ;
336
337    template < typename M >
338    BOOST_UBLAS_INLINE
339    typename M::size_type start( const matrix_row<M> &v ) ;
340    template < typename M >
341    BOOST_UBLAS_INLINE
342    typename M::size_type start( const matrix_column<M> &v ) ;
343
344    template < typename M >
345    BOOST_UBLAS_INLINE
346    typename M::size_type start( const matrix_range<M> &m ) ;
347    template < typename M >
348    BOOST_UBLAS_INLINE
349    typename M::size_type start( const matrix_slice<M> &m ) ;
350
351
352
353    template < typename V >
354    BOOST_UBLAS_INLINE
355    int size( const V &v ) {
356        return v.size() ;
357    }
358
359    template < typename V >
360    BOOST_UBLAS_INLINE
361    int size( const vector_reference<V> &v ) {
362        return size( v ) ;
363    }
364
365    template < typename M >
366    BOOST_UBLAS_INLINE
367    int size1( const M &m ) {
368        return m.size1() ;
369    }
370    template < typename M >
371    BOOST_UBLAS_INLINE
372    int size2( const M &m ) {
373        return m.size2() ;
374    }
375
376    template < typename M >
377    BOOST_UBLAS_INLINE
378    int size1( const matrix_reference<M> &m ) {
379        return size1( m.expression() ) ;
380    }
381    template < typename M >
382    BOOST_UBLAS_INLINE
383    int size2( const matrix_reference<M> &m ) {
384        return size2( m.expression() ) ;
385    }
386
387    template < typename M >
388    BOOST_UBLAS_INLINE
389    int leading_dimension( const M &m, row_major_tag ) {
390        return m.size2() ;
391    }
392    template < typename M >
393    BOOST_UBLAS_INLINE
394    int leading_dimension( const M &m, column_major_tag ) {
395        return m.size1() ;
396    }
397    template < typename M >
398    BOOST_UBLAS_INLINE
399    int leading_dimension( const M &m ) {
400        return leading_dimension( m, typename M::orientation_category() ) ;
401    }
402
403    template < typename M >
404    BOOST_UBLAS_INLINE
405    int leading_dimension( const matrix_reference<M> &m ) {
406        return leading_dimension( m.expression() ) ;
407    }
408
409    template < typename V >
410    BOOST_UBLAS_INLINE
411    int stride( const V &v ) {
412        return 1 ;
413    }
414
415    template < typename V >
416    BOOST_UBLAS_INLINE
417    int stride( const vector_range<V> &v ) {
418        return stride( v.data() ) ;
419    }
420    template < typename V >
421    BOOST_UBLAS_INLINE
422    int stride( const vector_slice<V> &v ) {
423        return v.stride() * stride( v.data() ) ;
424    }
425
426    template < typename M >
427    BOOST_UBLAS_INLINE
428    int stride( const matrix_row<M> &v ) {
429        return stride2( v.data() ) ;
430    }
431    template < typename M >
432    BOOST_UBLAS_INLINE
433    int stride( const matrix_column<M> &v ) {
434        return stride1( v.data() ) ;
435    }
436
437    template < typename M >
438    BOOST_UBLAS_INLINE
439    int stride1( const M &m ) {
440        typedef typename M::functor_type functor_type;
441        return functor_type::one1( m.size1(), m.size2() ) ;
442    }
443    template < typename M >
444    BOOST_UBLAS_INLINE
445    int stride2( const M &m ) {
446        typedef typename M::functor_type functor_type;
447        return functor_type::one2( m.size1(), m.size2() ) ;
448    }
449
450    template < typename M >
451    BOOST_UBLAS_INLINE
452    int stride1( const matrix_reference<M> &m ) {
453        return stride1( m.expression() ) ;
454    }
455    template < typename M >
456    BOOST_UBLAS_INLINE
457    int stride2( const matrix_reference<M> &m ) {
458        return stride2( m.expression() ) ;
459    }
460
461    template < typename T, std::size_t M, std::size_t N >
462    BOOST_UBLAS_INLINE
463    int stride1( const c_matrix<T, M, N> &m ) {
464        return N ;
465    }
466    template < typename T, std::size_t M, std::size_t N >
467    BOOST_UBLAS_INLINE
468    int stride2( const c_matrix<T, M, N> &m ) {
469        return 1 ;
470    }
471
472    template < typename M >
473    BOOST_UBLAS_INLINE
474    int stride1( const matrix_range<M> &m ) {
475        return stride1( m.data() ) ;
476    }
477    template < typename M >
478    BOOST_UBLAS_INLINE
479    int stride1( const matrix_slice<M> &m ) {
480        return m.stride1() * stride1( m.data() ) ;
481    }
482    template < typename M >
483    BOOST_UBLAS_INLINE
484    int stride2( const matrix_range<M> &m ) {
485        return stride2( m.data() ) ;
486    }
487    template < typename M >
488    BOOST_UBLAS_INLINE
489    int stride2( const matrix_slice<M> &m ) {
490        return m.stride2() * stride2( m.data() ) ;
491    }
492
493    template < typename MV >
494    BOOST_UBLAS_INLINE
495    typename MV::array_type::array_type::array_type::const_pointer data( const MV &mv ) {
496        return &mv.data().begin()[0] ;
497    }
498    template < typename MV >
499    BOOST_UBLAS_INLINE
500    typename MV::array_type::array_type::const_pointer data_const( const MV &mv ) {
501        return &mv.data().begin()[0] ;
502    }
503    template < typename MV >
504    BOOST_UBLAS_INLINE
505    typename MV::array_type::pointer data( MV &mv ) {
506        return &mv.data().begin()[0] ;
507    }
508
509
510    template < typename V >
511    BOOST_UBLAS_INLINE
512    typename V::array_type::array_type::const_pointer data( const vector_reference<V> &v ) {
513        return data( v.expression () ) ;
514    }
515    template < typename V >
516    BOOST_UBLAS_INLINE
517    typename V::array_type::array_type::const_pointer data_const( const vector_reference<V> &v ) {
518        return data_const( v.expression () ) ;
519    }
520    template < typename V >
521    BOOST_UBLAS_INLINE
522    typename V::array_type::pointer data( vector_reference<V> &v ) {
523        return data( v.expression () ) ;
524    }
525
526    template < typename T, std::size_t N >
527    BOOST_UBLAS_INLINE
528    typename c_vector<T, N>::array_type::array_type::const_pointer data( const c_vector<T, N> &v ) {
529        return v.data() ;
530    }
531    template < typename T, std::size_t N >
532    BOOST_UBLAS_INLINE
533    typename c_vector<T, N>::array_type::array_type::const_pointer data_const( const c_vector<T, N> &v ) {
534        return v.data() ;
535    }
536    template < typename T, std::size_t N >
537    BOOST_UBLAS_INLINE
538    typename c_vector<T, N>::pointer data( c_vector<T, N> &v ) {
539        return v.data() ;
540    }
541
542    template < typename V >
543    BOOST_UBLAS_INLINE
544    typename V::array_type::array_type::const_pointer data( const vector_range<V> &v ) {
545        return data( v.data() ) + v.start() * stride (v.data() ) ;
546    }
547    template < typename V >
548    BOOST_UBLAS_INLINE
549    typename V::array_type::array_type::const_pointer data( const vector_slice<V> &v ) {
550        return data( v.data() ) + v.start() * stride (v.data() ) ;
551    }
552    template < typename V >
553    BOOST_UBLAS_INLINE
554    typename V::array_type::array_type::const_pointer data_const( const vector_range<V> &v ) {
555        return data_const( v.data() ) + v.start() * stride (v.data() ) ;
556    }
557    template < typename V >
558    BOOST_UBLAS_INLINE
559    typename V::array_type::const_pointer data_const( const vector_slice<V> &v ) {
560        return data_const( v.data() ) + v.start() * stride (v.data() ) ;
561    }
562    template < typename V >
563    BOOST_UBLAS_INLINE
564    typename V::array_type::pointer data( vector_range<V> &v ) {
565        return data( v.data() ) + v.start() * stride (v.data() ) ;
566    }
567    template < typename V >
568    BOOST_UBLAS_INLINE
569    typename V::array_type::pointer data( vector_slice<V> &v ) {
570        return data( v.data() ) + v.start() * stride (v.data() ) ;
571    }
572
573    template < typename M >
574    BOOST_UBLAS_INLINE
575    typename M::array_type::const_pointer data( const matrix_reference<M> &m ) {
576        return data( m.expression () ) ;
577    }
578    template < typename M >
579    BOOST_UBLAS_INLINE
580    typename M::array_type::const_pointer data_const( const matrix_reference<M> &m ) {
581        return data_const( m.expression () ) ;
582    }
583    template < typename M >
584    BOOST_UBLAS_INLINE
585    typename M::array_type::pointer data( matrix_reference<M> &m ) {
586        return data( m.expression () ) ;
587    }
588
589    template < typename T, std::size_t M, std::size_t N >
590    BOOST_UBLAS_INLINE
591    typename c_matrix<T, M, N>::array_type::const_pointer data( const c_matrix<T, M, N> &m ) {
592        return m.data() ;
593    }
594    template < typename T, std::size_t M, std::size_t N >
595    BOOST_UBLAS_INLINE
596    typename c_matrix<T, M, N>::array_type::const_pointer data_const( const c_matrix<T, M, N> &m ) {
597        return m.data() ;
598    }
599    template < typename T, std::size_t M, std::size_t N >
600    BOOST_UBLAS_INLINE
601    typename c_matrix<T, M, N>::pointer data( c_matrix<T, M, N> &m ) {
602        return m.data() ;
603    }
604
605    template < typename M >
606    BOOST_UBLAS_INLINE
607    typename M::array_type::const_pointer data( const matrix_row<M> &v ) {
608        return data( v.data() ) + v.index() * stride1( v.data() ) ;
609    }
610    template < typename M >
611    BOOST_UBLAS_INLINE
612    typename M::array_type::const_pointer data( const matrix_column<M> &v ) {
613        return data( v.data() ) + v.index() * stride2( v.data() ) ;
614    }
615    template < typename M >
616    BOOST_UBLAS_INLINE
617    typename M::array_type::const_pointer data_const( const matrix_row<M> &v ) {
618        return data_const( v.data() ) + v.index() * stride1( v.data() ) ;
619    }
620    template < typename M >
621    BOOST_UBLAS_INLINE
622    typename M::array_type::const_pointer data_const( const matrix_column<M> &v ) {
623        return data_const( v.data() ) + v.index() * stride2( v.data() ) ;
624    }
625    template < typename M >
626    BOOST_UBLAS_INLINE
627    typename M::array_type::pointer data( matrix_row<M> &v ) {
628        return data( v.data() ) + v.index() * stride1( v.data() ) ;
629    }
630    template < typename M >
631    BOOST_UBLAS_INLINE
632    typename M::array_type::pointer data( matrix_column<M> &v ) {
633        return data( v.data() ) + v.index() * stride2( v.data() ) ;
634    }
635
636    template < typename M >
637    BOOST_UBLAS_INLINE
638    typename M::array_type::const_pointer data( const matrix_range<M> &m ) {
639        return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
640    }
641    template < typename M >
642    BOOST_UBLAS_INLINE
643    typename M::array_type::const_pointer data( const matrix_slice<M> &m ) {
644        return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
645    }
646    template < typename M >
647    BOOST_UBLAS_INLINE
648    typename M::array_type::const_pointer data_const( const matrix_range<M> &m ) {
649        return data_const( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
650    }
651    template < typename M >
652    BOOST_UBLAS_INLINE
653    typename M::array_type::const_pointer data_const( const matrix_slice<M> &m ) {
654        return data_const( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
655    }
656    template < typename M >
657    BOOST_UBLAS_INLINE
658    typename M::array_type::pointer data( matrix_range<M> &m ) {
659        return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
660    }
661    template < typename M >
662    BOOST_UBLAS_INLINE
663    typename M::array_type::pointer data( matrix_slice<M> &m ) {
664        return data( m.data() ) + m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
665    }
666
667
668    template < typename MV >
669    BOOST_UBLAS_INLINE
670    typename MV::array_type::const_pointer base( const MV &mv ) {
671        return &mv.data().begin()[0] ;
672    }
673    template < typename MV >
674    BOOST_UBLAS_INLINE
675    typename MV::array_type::const_pointer base_const( const MV &mv ) {
676        return &mv.data().begin()[0] ;
677    }
678    template < typename MV >
679    BOOST_UBLAS_INLINE
680    typename MV::array_type::pointer base( MV &mv ) {
681        return &mv.data().begin()[0] ;
682    }
683
684    template < typename V >
685    BOOST_UBLAS_INLINE
686    typename V::array_type::const_pointer base( const vector_reference<V> &v ) {
687        return base( v.expression () ) ;
688    }
689    template < typename V >
690    BOOST_UBLAS_INLINE
691    typename V::array_type::const_pointer base_const( const vector_reference<V> &v ) {
692        return base_const( v.expression () ) ;
693    }
694    template < typename V >
695    BOOST_UBLAS_INLINE
696    typename V::array_type::pointer base( vector_reference<V> &v ) {
697        return base( v.expression () ) ;
698    }
699
700    template < typename T, std::size_t N >
701    BOOST_UBLAS_INLINE
702    typename c_vector<T, N>::array_type::const_pointer base( const c_vector<T, N> &v ) {
703        return v.data() ;
704    }
705    template < typename T, std::size_t N >
706    BOOST_UBLAS_INLINE
707    typename c_vector<T, N>::array_type::const_pointer base_const( const c_vector<T, N> &v ) {
708        return v.data() ;
709    }
710    template < typename T, std::size_t N >
711    BOOST_UBLAS_INLINE
712    typename c_vector<T, N>::pointer base( c_vector<T, N> &v ) {
713        return v.data() ;
714    }
715
716    template < typename V >
717    BOOST_UBLAS_INLINE
718    typename V::array_type::const_pointer base( const vector_range<V> &v ) {
719        return base( v.data() ) ;
720    }
721    template < typename V >
722    BOOST_UBLAS_INLINE
723    typename V::array_type::const_pointer base( const vector_slice<V> &v ) {
724        return base( v.data() ) ;
725    }
726    template < typename V >
727    BOOST_UBLAS_INLINE
728    typename V::array_type::const_pointer base_const( const vector_range<V> &v ) {
729        return base_const( v.data() ) ;
730    }
731    template < typename V >
732    BOOST_UBLAS_INLINE
733    typename V::array_type::const_pointer base_const( const vector_slice<V> &v ) {
734        return base_const( v.data() ) ;
735    }
736    template < typename V >
737    BOOST_UBLAS_INLINE
738    typename V::array_type::pointer base( vector_range<V> &v ) {
739        return base( v.data() ) ;
740    }
741    template < typename V >
742    BOOST_UBLAS_INLINE
743    typename V::array_type::pointer base( vector_slice<V> &v ) {
744        return base( v.data() ) ;
745    }
746
747    template < typename M >
748    BOOST_UBLAS_INLINE
749    typename M::array_type::const_pointer base( const matrix_reference<M> &m ) {
750        return base( m.expression () ) ;
751    }
752    template < typename M >
753    BOOST_UBLAS_INLINE
754    typename M::array_type::const_pointer base_const( const matrix_reference<M> &m ) {
755        return base_const( m.expression () ) ;
756    }
757    template < typename M >
758    BOOST_UBLAS_INLINE
759    typename M::array_type::pointer base( matrix_reference<M> &m ) {
760        return base( m.expression () ) ;
761    }
762
763    template < typename T, std::size_t M, std::size_t N >
764    BOOST_UBLAS_INLINE
765    typename c_matrix<T, M, N>::array_type::const_pointer base( const c_matrix<T, M, N> &m ) {
766        return m.data() ;
767    }
768    template < typename T, std::size_t M, std::size_t N >
769    BOOST_UBLAS_INLINE
770    typename c_matrix<T, M, N>::array_type::const_pointer base_const( const c_matrix<T, M, N> &m ) {
771        return m.data() ;
772    }
773    template < typename T, std::size_t M, std::size_t N >
774    BOOST_UBLAS_INLINE
775    typename c_matrix<T, M, N>::pointer base( c_matrix<T, M, N> &m ) {
776        return m.data() ;
777    }
778
779    template < typename M >
780    BOOST_UBLAS_INLINE
781    typename M::array_type::const_pointer base( const matrix_row<M> &v ) {
782        return base( v.data() ) ;
783    }
784    template < typename M >
785    BOOST_UBLAS_INLINE
786    typename M::array_type::const_pointer base( const matrix_column<M> &v ) {
787        return base( v.data() ) ;
788    }
789    template < typename M >
790    BOOST_UBLAS_INLINE
791    typename M::array_type::const_pointer base_const( const matrix_row<M> &v ) {
792        return base_const( v.data() ) ;
793    }
794    template < typename M >
795    BOOST_UBLAS_INLINE
796    typename M::array_type::const_pointer base_const( const matrix_column<M> &v ) {
797        return base_const( v.data() ) ;
798    }
799    template < typename M >
800    BOOST_UBLAS_INLINE
801    typename M::array_type::pointer base( matrix_row<M> &v ) {
802        return base( v.data() ) ;
803    }
804    template < typename M >
805    BOOST_UBLAS_INLINE
806    typename M::array_type::pointer base( matrix_column<M> &v ) {
807        return base( v.data() ) ;
808    }
809
810    template < typename M >
811    BOOST_UBLAS_INLINE
812    typename M::array_type::const_pointer base( const matrix_range<M> &m ) {
813        return base( m.data() ) ;
814    }
815    template < typename M >
816    BOOST_UBLAS_INLINE
817    typename M::array_type::const_pointer base( const matrix_slice<M> &m ) {
818        return base( m.data() ) ;
819    }
820    template < typename M >
821    BOOST_UBLAS_INLINE
822    typename M::array_type::const_pointer base_const( const matrix_range<M> &m ) {
823        return base_const( m.data() ) ;
824    }
825    template < typename M >
826    BOOST_UBLAS_INLINE
827    typename M::array_type::const_pointer base_const( const matrix_slice<M> &m ) {
828        return base_const( m.data() ) ;
829    }
830    template < typename M >
831    BOOST_UBLAS_INLINE
832    typename M::array_type::pointer base( matrix_range<M> &m ) {
833        return base( m.data() ) ;
834    }
835    template < typename M >
836    BOOST_UBLAS_INLINE
837    typename M::array_type::pointer base( matrix_slice<M> &m ) {
838        return base( m.data() ) ;
839    }
840
841    template < typename MV >
842    BOOST_UBLAS_INLINE
843    typename MV::size_type start( const MV &mv ) {
844        return 0 ;
845    }
846
847    template < typename V >
848    BOOST_UBLAS_INLINE
849    typename V::size_type start( const vector_range<V> &v ) {
850        return v.start() * stride (v.data() ) ;
851    }
852    template < typename V >
853    BOOST_UBLAS_INLINE
854    typename V::size_type start( const vector_slice<V> &v ) {
855        return v.start() * stride (v.data() ) ;
856    }
857
858    template < typename M >
859    BOOST_UBLAS_INLINE
860    typename M::size_type start( const matrix_row<M> &v ) {
861        return v.index() * stride1( v.data() ) ;
862    }
863    template < typename M >
864    BOOST_UBLAS_INLINE
865    typename M::size_type start( const matrix_column<M> &v ) {
866        return v.index() * stride2( v.data() ) ;
867    }
868
869    template < typename M >
870    BOOST_UBLAS_INLINE
871    typename M::size_type start( const matrix_range<M> &m ) {
872        return m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
873    }
874    template < typename M >
875    BOOST_UBLAS_INLINE
876    typename M::size_type start( const matrix_slice<M> &m ) {
877        return m.start1() * stride1( m.data () ) + m.start2() * stride2( m.data () ) ;
878    }
879
880}}}}
881
882#endif
Note: See TracBrowser for help on using the repository browser.