00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef GEN_MATRIX_CLASS_H
00032 #define GEN_MATRIX_CLASS_H
00033
00034 #include "DenseLinAlgPack_DVectorClass.hpp"
00035 #include "DenseLinAlgPack_DMatrixAssign.hpp"
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 namespace DenseLinAlgPack {
00046
00047 class DMatrix;
00048
00049
00050
00051
00052
00053
00054
00055
00057
00058
00059
00060
00061
00062
00063 class DMatrixSlice {
00064 public:
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 typedef DenseLinAlgPack::value_type value_type;
00080 typedef DenseLinAlgPack::size_type size_type;
00081 typedef ptrdiff_t difference_type;
00082 typedef value_type& reference;
00083 typedef const value_type& const_reference;
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00099
00100
00101
00102
00103 DMatrixSlice();
00104
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 DMatrixSlice( value_type* ptr, size_type size
00141 , size_type max_rows, size_type rows, size_type cols );
00142
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 DMatrixSlice( DMatrixSlice& gms, const Range1D& I
00159 , const Range1D& J );
00160
00161
00162
00164
00165
00166
00167
00168 void bind( DMatrixSlice gms );
00169
00170
00171
00172
00174 size_type rows() const;
00176 size_type cols() const;
00177
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 EOverLap overlap(const DMatrixSlice& gms) const;
00189
00190
00191
00192
00193
00194
00196 reference operator()(size_type i, size_type j);
00198 const_reference operator()(size_type i, size_type j) const;
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00212 DVectorSlice row(size_type i);
00214 const DVectorSlice row(size_type i) const;
00216 DVectorSlice col(size_type j);
00218 const DVectorSlice col(size_type j) const;
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 DVectorSlice diag(difference_type k = 0);
00233 const DVectorSlice diag(difference_type k = 0) const;
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250 DMatrixSlice operator()(const Range1D& I, const Range1D& J);
00252 const DMatrixSlice operator()(const Range1D& I, const Range1D& J) const;
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 DMatrixSlice operator()(size_type i1, size_type i2, size_type j1
00268 , size_type j2);
00270 const DMatrixSlice operator()(size_type i1, size_type i2, size_type j1
00271 , size_type j2) const;
00273 DMatrixSlice* operator&() {
00274 return this;
00275 }
00277 const DMatrixSlice* operator&() const {
00278 return this;
00279 }
00281 DMatrixSlice& operator()();
00283 const DMatrixSlice& operator()() const;
00284
00285
00286
00287
00288
00289
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300 DMatrixSlice& operator=(value_type alpha);
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316 DMatrixSlice& operator=(const DMatrixSlice& gms_rhs);
00317
00318
00319
00320
00321
00322
00323
00325 size_type max_rows() const;
00327
00328
00329
00330 value_type* col_ptr(size_type j);
00332 const value_type* col_ptr(size_type j) const;
00333
00334
00335
00336 private:
00337 value_type *ptr_;
00338 size_type max_rows_,
00339 rows_,
00340 cols_;
00341
00342
00343 void validate_row_subscript(size_type i) const;
00344
00345 void validate_col_subscript(size_type j) const;
00346
00347 void validate_setup(size_type size) const;
00348
00349
00350 DVectorSlice p_diag(difference_type k) const;
00351
00352 };
00353
00355
00356
00357
00358
00359 class DMatrix {
00360 public:
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376 typedef DenseLinAlgPack::value_type value_type;
00377 typedef DenseLinAlgPack::size_type size_type;
00378 typedef ptrdiff_t difference_type;
00379 typedef value_type& reference;
00380 typedef const value_type& const_reference;
00381 typedef std::valarray<value_type> valarray;
00382
00383
00384
00385
00386
00387
00388
00389
00390
00392 DMatrix();
00394 explicit DMatrix(size_type rows, size_type cols);
00396
00397
00398
00399
00400
00401
00402 explicit DMatrix(value_type val, size_type rows, size_type cols);
00404
00405
00406
00407
00408
00409
00410 explicit DMatrix(const value_type* p, size_type rows, size_type cols);
00412
00413
00414
00415
00416
00417
00418 DMatrix(const DMatrixSlice& gms);
00419
00420
00421
00422
00423
00424
00426 void resize(size_type rows, size_type cols, value_type val = value_type());
00427
00429 void free();
00430
00432 size_type rows() const;
00433
00435 size_type cols() const;
00436
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447 EOverLap overlap(const DMatrixSlice& gms) const;
00448
00449
00450
00451
00452
00453
00455 reference operator()(size_type i, size_type j);
00456
00458 const_reference operator()(size_type i, size_type j) const;
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00472 DVectorSlice row(size_type i);
00473
00475 const DVectorSlice row(size_type i) const;
00476
00478 DVectorSlice col(size_type j);
00479
00481 const DVectorSlice col(size_type j) const;
00482
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495 DVectorSlice diag(difference_type k = 0);
00496
00498 const DVectorSlice diag(difference_type k = 0) const;
00499
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516 DMatrixSlice operator()(const Range1D& I, const Range1D& J);
00517
00519 const DMatrixSlice operator()(const Range1D& I, const Range1D& J) const;
00520
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535 DMatrixSlice operator()(size_type i1, size_type i2, size_type j1
00536 , size_type j2);
00537
00539 const DMatrixSlice operator()(size_type i1, size_type i2, size_type j1
00540 , size_type j2) const;
00541
00543 DMatrixSlice operator()();
00544
00546 const DMatrixSlice operator()() const;
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00559 operator DMatrixSlice();
00561 operator const DMatrixSlice() const;
00562
00563
00564
00565
00566
00567
00569
00570
00571
00572
00573
00574
00575
00576
00577 DMatrix& operator=(value_type rhs);
00579
00580
00581
00582
00583
00584
00585
00586 DMatrix& operator=(const DMatrixSlice& gms_rhs);
00588 DMatrix& operator=(const DMatrix& rhs);
00589
00590
00591
00592
00593
00594
00595
00597 size_type max_rows() const;
00599
00600
00601
00602 value_type* col_ptr(size_type j);
00604 const value_type* col_ptr(size_type j) const;
00605
00606
00607
00608 private:
00609 std::valarray<value_type> v_;
00610 size_type rows_;
00611
00612
00613 void validate_row_subscript(size_type i) const;
00614
00615 void validate_col_subscript(size_type j) const;
00616
00617
00618 DVectorSlice p_diag(difference_type k) const;
00619
00620 };
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633 inline
00635
00636
00637
00638
00639
00640
00641
00642
00643
00645 void assert_gms_sizes(const DMatrixSlice& gms1, BLAS_Cpp::Transp trans1, const DMatrixSlice& gms2
00646 , BLAS_Cpp::Transp trans2);
00647
00648 inline
00650 void assert_gms_square(const DMatrixSlice& gms) {
00651 #ifdef LINALGPACK_CHECK_SLICE_SETUP
00652 if(gms.rows() != gms.cols())
00653 throw std::length_error("Matrix must be square");
00654 #endif
00655 }
00656
00657 inline
00659
00660
00661
00662
00663
00664
00665
00666
00667 void assert_gms_lhs(const DMatrixSlice& gms_lhs, size_type rows, size_type cols
00668 , BLAS_Cpp::Transp trans_rhs = BLAS_Cpp::no_trans)
00669 {
00670 if(trans_rhs == BLAS_Cpp::trans) std::swap(rows,cols);
00671 if(gms_lhs.rows() == rows && gms_lhs.cols() == cols) return;
00672
00673 throw std::length_error("assert_gms_lhs(...): lhs DMatrixSlice dim does not match rhs dim");
00674 }
00675
00676
00677
00678
00679 inline
00681 DVectorSlice row(DMatrixSlice& gms, BLAS_Cpp::Transp trans, size_type i) {
00682 return (trans == BLAS_Cpp::no_trans) ? gms.row(i) : gms.col(i);
00683 }
00684
00685 inline
00687 DVectorSlice col(DMatrixSlice& gms, BLAS_Cpp::Transp trans, size_type j) {
00688 return (trans == BLAS_Cpp::no_trans) ? gms.col(j) : gms.row(j);
00689 }
00690
00691 inline
00693 const DVectorSlice row(const DMatrixSlice& gms, BLAS_Cpp::Transp trans, size_type i) {
00694 return (trans == BLAS_Cpp::no_trans) ? gms.row(i) : gms.col(i);
00695 }
00696
00697 inline
00699 const DVectorSlice col(const DMatrixSlice& gms, BLAS_Cpp::Transp trans, size_type j) {
00700 return (trans == BLAS_Cpp::no_trans) ? gms.col(j) : gms.row(j);
00701 }
00702
00703 inline
00705 DVectorSlice row(DMatrix& gm, BLAS_Cpp::Transp trans, size_type i) {
00706 return (trans == BLAS_Cpp::no_trans) ? gm.row(i) : gm.col(i);
00707 }
00708
00709 inline
00711 DVectorSlice col(DMatrix& gm, BLAS_Cpp::Transp trans, size_type j) {
00712 return (trans == BLAS_Cpp::no_trans) ? gm.col(j) : gm.row(j);
00713 }
00714
00715 inline
00717 const DVectorSlice row(const DMatrix& gm, BLAS_Cpp::Transp trans, size_type i) {
00718 return (trans == BLAS_Cpp::no_trans) ? gm.row(i) : gm.col(i);
00719 }
00720
00721 inline
00723 const DVectorSlice col(const DMatrix& gm, BLAS_Cpp::Transp trans, size_type j) {
00724 return (trans == BLAS_Cpp::no_trans) ? gm.col(j) : gm.row(j);
00725 }
00726
00727
00728
00729 inline
00731 void resize_gm_lhs(DMatrix* gm_rhs, size_type rows, size_type cols
00732 , BLAS_Cpp::Transp trans_rhs)
00733 {
00734 if(trans_rhs == BLAS_Cpp::trans) std::swap(rows,cols);
00735 gm_rhs->resize(rows,cols);
00736 }
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753 #ifndef LINALGPACK_CHECK_RANGE
00754 inline
00755 void DMatrixSlice::validate_row_subscript(size_type i) const
00756 {}
00757 #endif
00758
00759 #ifndef LINALGPACK_CHECK_RANGE
00760 inline
00761 void DMatrixSlice::validate_col_subscript(size_type j) const
00762 {}
00763 #endif
00764
00765 #ifndef LINALGPACK_CHECK_SLICE_SETUP
00766 inline
00767 void DMatrixSlice::validate_setup(size_type size) const
00768 {}
00769 #endif
00770
00771
00772
00773 inline
00774 DMatrixSlice::DMatrixSlice()
00775 : ptr_(0), max_rows_(0), rows_(0), cols_(0)
00776 {}
00777
00778 inline
00779 DMatrixSlice::DMatrixSlice( value_type* ptr, size_type size
00780 , size_type max_rows, size_type rows, size_type cols )
00781 : ptr_(ptr), max_rows_(max_rows), rows_(rows), cols_(cols)
00782 {
00783 validate_setup(size);
00784 }
00785
00786 inline
00787 DMatrixSlice::DMatrixSlice( DMatrixSlice& gms, const Range1D& I
00788 , const Range1D& J)
00789 : ptr_( gms.col_ptr(1) + (I.lbound() - 1) + (J.lbound() - 1) * gms.max_rows() )
00790 , max_rows_(gms.max_rows())
00791 , rows_(I.size())
00792 , cols_(J.size())
00793 {
00794 gms.validate_row_subscript(I.ubound());
00795 gms.validate_col_subscript(J.ubound());
00796 }
00797
00798 inline
00799 void DMatrixSlice::bind(DMatrixSlice gms) {
00800 ptr_ = gms.ptr_;
00801 max_rows_ = gms.max_rows_;
00802 rows_ = gms.rows_;
00803 cols_ = gms.cols_;
00804 }
00805
00806
00807
00808 inline
00809 DMatrixSlice::size_type DMatrixSlice::rows() const {
00810 return rows_;
00811 }
00812
00813 inline
00814 DMatrixSlice::size_type DMatrixSlice::cols() const {
00815 return cols_;
00816 }
00817
00818
00819
00820
00821
00822 inline
00823 DMatrixSlice::reference DMatrixSlice::operator()(size_type i, size_type j)
00824 {
00825 validate_row_subscript(i);
00826 validate_col_subscript(j);
00827 return ptr_[(i-1) + (j-1) * max_rows_];
00828 }
00829
00830 inline
00831 DMatrixSlice::const_reference DMatrixSlice::operator()(size_type i, size_type j) const
00832 {
00833 validate_row_subscript(i);
00834 validate_col_subscript(j);
00835 return ptr_[(i-1) + (j-1) * max_rows_];
00836 }
00837
00838
00839
00840 inline
00841 DVectorSlice DMatrixSlice::row(size_type i) {
00842 validate_row_subscript(i);
00843 return DVectorSlice( ptr_ + (i-1), cols(), max_rows() );
00844 }
00845
00846 inline
00847 const DVectorSlice DMatrixSlice::row(size_type i) const {
00848 validate_row_subscript(i);
00849 return DVectorSlice( const_cast<value_type*>(ptr_) + (i-1), cols(), max_rows() );
00850 }
00851
00852 inline
00853 DVectorSlice DMatrixSlice::col(size_type j) {
00854 validate_col_subscript(j);
00855 return DVectorSlice( ptr_ + (j-1)*max_rows(), rows(), 1 );
00856 }
00857
00858 inline
00859 const DVectorSlice DMatrixSlice::col(size_type j) const {
00860 validate_col_subscript(j);
00861 return DVectorSlice( const_cast<value_type*>(ptr_) + (j-1)*max_rows(), rows(), 1 );
00862 }
00863
00864 inline
00865 DVectorSlice DMatrixSlice::diag(difference_type k) {
00866 return p_diag(k);
00867 }
00868
00869 inline
00870 const DVectorSlice DMatrixSlice::diag(difference_type k) const {
00871 return p_diag(k);
00872 }
00873
00874 inline
00875 DMatrixSlice DMatrixSlice::operator()(const Range1D& I, const Range1D& J) {
00876 return DMatrixSlice(*this, RangePack::full_range(I, 1, rows()), RangePack::full_range(J,1,cols()));
00877 }
00878
00879 inline
00880 const DMatrixSlice DMatrixSlice::operator()(const Range1D& I, const Range1D& J) const {
00881 return DMatrixSlice( const_cast<DMatrixSlice&>(*this)
00882 , RangePack::full_range(I, 1, rows()), RangePack::full_range(J,1,cols()) );
00883 }
00884
00885 inline
00886 DMatrixSlice DMatrixSlice::operator()(size_type i1, size_type i2, size_type j1
00887 , size_type j2)
00888 {
00889 return DMatrixSlice(*this, Range1D(i1,i2), Range1D(j1,j2));
00890 }
00891
00892 inline
00893 const DMatrixSlice DMatrixSlice::operator()(size_type i1, size_type i2, size_type j1
00894 , size_type j2) const
00895 {
00896 return DMatrixSlice( const_cast<DMatrixSlice&>(*this), Range1D(i1,i2)
00897 , Range1D(j1,j2) );
00898 }
00899
00900 inline
00901 DMatrixSlice& DMatrixSlice::operator()() {
00902 return *this;
00903 }
00904
00905 inline
00906 const DMatrixSlice& DMatrixSlice::operator()() const {
00907 return *this;
00908 }
00909
00910
00911
00912 inline
00913 DMatrixSlice& DMatrixSlice::operator=(value_type alpha) {
00914 assign(this, alpha);
00915 return *this;
00916 }
00917
00918 inline
00919 DMatrixSlice& DMatrixSlice::operator=(const DMatrixSlice& rhs) {
00920 assign(this, rhs, BLAS_Cpp::no_trans);
00921 return *this;
00922 }
00923
00924
00925
00926 inline
00927 DMatrixSlice::size_type DMatrixSlice::max_rows() const
00928 { return max_rows_; }
00929
00930 inline
00931 DMatrixSlice::value_type* DMatrixSlice::col_ptr(size_type j) {
00932 if( ptr_ )
00933 validate_col_subscript(j);
00934 return ptr_ + (j-1) * max_rows();
00935 }
00936
00937 inline
00938 const DMatrixSlice::value_type* DMatrixSlice::col_ptr(size_type j) const {
00939 if( ptr_ )
00940 validate_col_subscript(j);
00941 return ptr_ + (j-1) * max_rows();
00942 }
00943
00944
00945
00946
00947
00948
00949 #ifndef LINALGPACK_CHECK_RANGE
00950 inline
00951 void DMatrix::validate_row_subscript(size_type i) const
00952 {}
00953 #endif
00954
00955 #ifndef LINALGPACK_CHECK_RANGE
00956 inline
00957 void DMatrix::validate_col_subscript(size_type j) const
00958 {}
00959 #endif
00960
00961
00962
00963 inline
00964 DMatrix::DMatrix() : v_(), rows_(0)
00965 {}
00966
00967 inline
00968 DMatrix::DMatrix(size_type rows, size_type cols)
00969 : v_(rows*cols), rows_(rows)
00970 {}
00971
00972 inline
00973 DMatrix::DMatrix(value_type val, size_type rows, size_type cols)
00974 : v_(val,rows*cols), rows_(rows)
00975 {}
00976
00977 inline
00978 DMatrix::DMatrix(const value_type* p, size_type rows, size_type cols)
00979 : v_(rows*cols), rows_(rows)
00980 {
00981
00982
00983
00984 std::copy( p, p + rows*cols, &v_[0] );
00985 }
00986
00987 inline
00988 DMatrix::DMatrix(const DMatrixSlice& gms)
00989 : v_(gms.rows() * gms.cols()), rows_(gms.rows())
00990 {
00991 assign(this, gms, BLAS_Cpp::no_trans);
00992 }
00993
00994
00995
00996 inline
00997 void DMatrix::resize(size_type rows, size_type cols, value_type val)
00998 {
00999 v_.resize(rows*cols,val);
01000 v_ = val;
01001 rows_ = rows;
01002 }
01003
01004 inline
01005 void DMatrix::free() {
01006 v_.resize(0);
01007 rows_ = 0;
01008 }
01009
01010
01011
01012 inline
01013 DMatrix::size_type DMatrix::rows() const {
01014 return rows_;
01015 }
01016
01017 inline
01018 DMatrix::size_type DMatrix::cols() const {
01019 return rows_ > 0 ? v_.size() / rows_ : 0;
01020 }
01021
01022
01023
01024 inline
01025 DMatrix::reference DMatrix::operator()(size_type i, size_type j)
01026 {
01027 validate_row_subscript(i); validate_col_subscript(j);
01028 return v_[(i-1) + (j-1) * rows_];
01029 }
01030
01031 inline
01032 DMatrix::const_reference DMatrix::operator()(size_type i, size_type j) const
01033 {
01034 validate_row_subscript(i); validate_col_subscript(j);
01035 return (const_cast<std::valarray<value_type>&>(v_))[(i-1) + (j-1) * rows_];
01036 }
01037
01038
01039
01040 inline
01041 DVectorSlice DMatrix::row(size_type i)
01042 {
01043 validate_row_subscript(i);
01044 return DVectorSlice( col_ptr(1) + (i-1), cols(), rows() );
01045 }
01046
01047 inline
01048 const DVectorSlice DMatrix::row(size_type i) const
01049 {
01050 validate_row_subscript(i);
01051 return DVectorSlice( const_cast<value_type*>(col_ptr(1)) + (i-1), cols(), rows() );
01052 }
01053
01054 inline
01055 DVectorSlice DMatrix::col(size_type j)
01056 {
01057 validate_col_subscript(j);
01058 return DVectorSlice( col_ptr(1) + (j-1) * rows(), rows(), 1 );
01059 }
01060
01061 inline
01062 const DVectorSlice DMatrix::col(size_type j) const
01063 {
01064 validate_col_subscript(j);
01065 return DVectorSlice( const_cast<value_type*>(col_ptr(1)) + (j-1) * rows(), rows(), 1 ) ;
01066 }
01067
01068 inline
01069 DVectorSlice DMatrix::diag(difference_type k)
01070 {
01071 return p_diag(k);
01072 }
01073
01074 inline
01075 const DVectorSlice DMatrix::diag(difference_type k) const
01076 {
01077 return p_diag(k);
01078 }
01079
01080 inline
01081 DMatrixSlice DMatrix::operator()(const Range1D& I, const Range1D& J)
01082 {
01083 Range1D Ix = RangePack::full_range(I,1,rows()), Jx = RangePack::full_range(J,1,cols());
01084 return DMatrixSlice( col_ptr(1) + (Ix.lbound() - 1) + (Jx.lbound() - 1) * rows()
01085 , max_rows() * cols(), max_rows(), Ix.size(), Jx.size() );
01086 }
01087
01088 inline
01089 const DMatrixSlice DMatrix::operator()(const Range1D& I, const Range1D& J) const
01090 {
01091 Range1D Ix = RangePack::full_range(I,1,rows()), Jx = RangePack::full_range(J,1,cols());
01092 return DMatrixSlice( const_cast<value_type*>(col_ptr(1)) + (Ix.lbound() - 1) + (Jx.lbound() - 1) * rows()
01093 , max_rows() * cols(), max_rows(), Ix.size(), Jx.size() );
01094 }
01095
01096 inline
01097 DMatrixSlice DMatrix::operator()(size_type i1, size_type i2, size_type j1
01098 , size_type j2)
01099 {
01100 return DMatrixSlice( col_ptr(1) + (i1 - 1) + (j1 - 1) * rows()
01101 , max_rows() * cols(), max_rows(), i2 - i1 + 1, j2 - j1 + 1 );
01102 }
01103
01104 inline
01105 const DMatrixSlice DMatrix::operator()(size_type i1, size_type i2, size_type j1
01106 , size_type j2) const
01107 {
01108 return DMatrixSlice( const_cast<value_type*>(col_ptr(1)) + (i1 - 1) + (j1 - 1) * rows()
01109 , max_rows() * cols(), max_rows(), i2 - i1 + 1, j2 - j1 + 1 );
01110 }
01111
01112 inline
01113 DMatrixSlice DMatrix::operator()()
01114 {
01115 return DMatrixSlice( col_ptr(1), max_rows() * cols(), max_rows(), rows(), cols() );
01116 }
01117
01118 inline
01119 const DMatrixSlice DMatrix::operator()() const
01120 {
01121 return DMatrixSlice( const_cast<value_type*>(col_ptr(1)), max_rows() * cols(), max_rows()
01122 , rows(), cols() );
01123 }
01124
01125
01126
01127 inline
01128 DMatrix::operator DMatrixSlice() {
01129 return (*this)();
01130 }
01131
01132 inline
01133 DMatrix::operator const DMatrixSlice() const
01134 {
01135 return (*this)();
01136 }
01137
01138
01139
01140 inline
01141 DMatrix& DMatrix::operator=(value_type alpha)
01142 {
01143 assign(this, alpha);
01144 return *this;
01145 }
01146
01147 inline
01148 DMatrix& DMatrix::operator=(const DMatrix& rhs)
01149 {
01150 assign(this, rhs, BLAS_Cpp::no_trans);
01151 return *this;
01152 }
01153
01154 inline
01155 DMatrix& DMatrix::operator=(const DMatrixSlice& rhs)
01156 {
01157 assign(this, rhs, BLAS_Cpp::no_trans);
01158 return *this;
01159 }
01160
01161
01162
01163 inline
01164 DMatrix::size_type DMatrix::max_rows() const
01165 { return rows_; }
01166
01167 inline
01168 DMatrix::value_type* DMatrix::col_ptr(size_type j)
01169 {
01170 if( v_.size() ) {
01171 validate_col_subscript(j);
01172 return &v_[ (j-1) * max_rows() ];
01173 }
01174 else {
01175 return 0;
01176 }
01177 }
01178
01179 inline
01180 const DMatrix::value_type* DMatrix::col_ptr(size_type j) const
01181 {
01182 if( v_.size() ) {
01183 validate_col_subscript(j);
01184 return &const_cast<valarray&>(v_)[ (j-1) * max_rows() ];
01185 }
01186 else {
01187 return 0;
01188 }
01189 }
01190
01191 }
01192
01193 #endif // GEN_MATRIX_CLASS_H