raw.hpp 30 KB

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