00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 template<typename eT>
00022 inline
00023 subview<eT>::~subview()
00024 {
00025 arma_extra_debug_sigprint();
00026 }
00027
00028
00029 template<typename eT>
00030 arma_inline
00031 subview<eT>::subview(const Mat<eT>& in_m, const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2)
00032 : m(in_m)
00033 , m_ptr(0)
00034 , aux_row1(in_row1)
00035 , aux_col1(in_col1)
00036 , aux_row2(in_row2)
00037 , aux_col2(in_col2)
00038 , n_rows(1 + in_row2 - in_row1)
00039 , n_cols(1 + in_col2 - in_col1)
00040 , n_elem(n_rows*n_cols)
00041 {
00042 arma_extra_debug_sigprint();
00043 }
00044
00045
00046
00047 template<typename eT>
00048 arma_inline
00049 subview<eT>::subview(Mat<eT>& in_m, const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2)
00050 : m(in_m)
00051 , m_ptr(&in_m)
00052 , aux_row1(in_row1)
00053 , aux_col1(in_col1)
00054 , aux_row2(in_row2)
00055 , aux_col2(in_col2)
00056 , n_rows(1 + in_row2 - in_row1)
00057 , n_cols(1 + in_col2 - in_col1)
00058 , n_elem(n_rows*n_cols)
00059 {
00060 arma_extra_debug_sigprint();
00061 }
00062
00063
00064
00065 template<typename eT>
00066 inline
00067 void
00068 subview<eT>::fill(const eT val)
00069 {
00070 arma_extra_debug_sigprint();
00071
00072 for(u32 col = 0; col<n_cols; ++col)
00073 {
00074 eT* coldata = colptr(col);
00075
00076 for(u32 row = 0; row<n_rows; ++row)
00077 {
00078 coldata[row] = val;
00079 }
00080 }
00081
00082
00083 }
00084
00085
00086
00087 template<typename eT>
00088 inline
00089 void
00090 subview<eT>::operator+= (const eT val)
00091 {
00092 arma_extra_debug_sigprint();
00093
00094 for(u32 col = 0; col<n_cols; ++col)
00095 {
00096 eT* coldata = colptr(col);
00097
00098 for(u32 row = 0; row<n_rows; ++row)
00099 {
00100 coldata[row] += val;
00101 }
00102
00103 }
00104
00105 }
00106
00107
00108
00109 template<typename eT>
00110 inline
00111 void
00112 subview<eT>::operator-= (const eT val)
00113 {
00114 arma_extra_debug_sigprint();
00115
00116 for(u32 col = 0; col<n_cols; ++col)
00117 {
00118 eT* coldata = colptr(col);
00119
00120 for(u32 row = 0; row<n_rows; ++row)
00121 {
00122 coldata[row] -= val;
00123 }
00124
00125 }
00126
00127 }
00128
00129
00130
00131 template<typename eT>
00132 inline
00133 void
00134 subview<eT>::operator*= (const eT val)
00135 {
00136 arma_extra_debug_sigprint();
00137
00138 for(u32 col = 0; col<n_cols; ++col)
00139 {
00140 eT* coldata = colptr(col);
00141
00142 for(u32 row = 0; row<n_rows; ++row)
00143 {
00144 coldata[row] *= val;
00145 }
00146
00147 }
00148
00149 }
00150
00151
00152
00153 template<typename eT>
00154 inline
00155 void
00156 subview<eT>::operator/= (const eT val)
00157 {
00158 arma_extra_debug_sigprint();
00159
00160 for(u32 col = 0; col<n_cols; ++col)
00161 {
00162 eT* coldata = colptr(col);
00163
00164 for(u32 row = 0; row<n_rows; ++row)
00165 {
00166 coldata[row] /= val;
00167 }
00168
00169 }
00170
00171 }
00172
00173
00174
00175 template<typename eT>
00176 template<typename T1>
00177 inline
00178 void
00179 subview<eT>::operator_equ_mat(const Base<eT,T1>& in)
00180 {
00181 arma_extra_debug_sigprint();
00182
00183 const unwrap<T1> tmp(in.get_ref());
00184 const Mat<eT>& x = tmp.M;
00185
00186 subview<eT>& t = *this;
00187
00188 arma_debug_assert_same_size(t, x, "insert into submatrix");
00189
00190 const u32 t_n_cols = t.n_cols;
00191 const u32 t_n_rows = t.n_rows;
00192
00193 for(u32 col=0; col<t_n_cols; ++col)
00194 {
00195 syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows );
00196 }
00197 }
00198
00199
00200
00201 template<typename eT>
00202 template<typename T1>
00203 inline
00204 void
00205 subview<eT>::operator_equ_proxy(const Base<eT,T1>& in)
00206 {
00207 arma_extra_debug_sigprint();
00208
00209 const Proxy<T1> x(in.get_ref());
00210
00211 subview<eT>& t = *this;
00212
00213 arma_debug_assert_same_size(t, x, "insert into submatrix");
00214
00215 const u32 t_n_cols = t.n_cols;
00216 const u32 t_n_rows = t.n_rows;
00217
00218 for(u32 col = 0; col<t_n_cols; ++col)
00219 {
00220 eT* t_coldata = t.colptr(col);
00221
00222 for(u32 row = 0; row<t_n_rows; ++row)
00223 {
00224 t_coldata[row] = x.at(row,col);
00225 }
00226 }
00227
00228 }
00229
00230
00231
00232 template<typename eT>
00233 template<typename T1>
00234 arma_inline
00235 void
00236 subview<eT>::operator= (const Base<eT,T1>& in)
00237 {
00238 arma_extra_debug_sigprint();
00239
00240 (is_Mat<T1>::value == true) ? operator_equ_mat(in) : operator_equ_proxy(in);
00241 }
00242
00243
00244
00245 template<typename eT>
00246 template<typename T1>
00247 inline
00248 void
00249 subview<eT>::operator+= (const Base<eT,T1>& in)
00250 {
00251 arma_extra_debug_sigprint();
00252
00253 const Proxy<T1> x(in.get_ref());
00254
00255 subview<eT>& t = *this;
00256
00257 arma_debug_assert_same_size(t, x, "matrix addition");
00258
00259
00260 for(u32 col = 0; col<t.n_cols; ++col)
00261 {
00262 eT* t_coldata = t.colptr(col);
00263
00264 for(u32 row = 0; row<t.n_rows; ++row)
00265 {
00266 t_coldata[row] += x.at(row,col);
00267 }
00268 }
00269
00270 }
00271
00272
00273
00274 template<typename eT>
00275 template<typename T1>
00276 inline
00277 void
00278 subview<eT>::operator-= (const Base<eT,T1>& in)
00279 {
00280 arma_extra_debug_sigprint();
00281
00282 const Proxy<T1> x(in.get_ref());
00283
00284 subview<eT>& t = *this;
00285
00286 arma_debug_assert_same_size(t, x, "matrix subtraction");
00287
00288
00289 for(u32 col = 0; col<t.n_cols; ++col)
00290 {
00291 eT* t_coldata = t.colptr(col);
00292
00293 for(u32 row = 0; row<t.n_rows; ++row)
00294 {
00295 t_coldata[row] -= x.at(row,col);
00296 }
00297 }
00298
00299 }
00300
00301
00302
00303 template<typename eT>
00304 template<typename T1>
00305 inline
00306 void
00307 subview<eT>::operator%= (const Base<eT,T1>& in)
00308 {
00309 arma_extra_debug_sigprint();
00310
00311 const Proxy<T1> x(in.get_ref());
00312
00313 subview<eT>& t = *this;
00314
00315 arma_debug_assert_same_size(t, x, "matrix schur product");
00316
00317
00318 for(u32 col = 0; col<t.n_cols; ++col)
00319 {
00320 eT* t_coldata = t.colptr(col);
00321
00322 for(u32 row = 0; row<t.n_rows; ++row)
00323 {
00324 t_coldata[row] *= x.at(row,col);
00325 }
00326 }
00327
00328 }
00329
00330
00331
00332 template<typename eT>
00333 template<typename T1>
00334 inline
00335 void
00336 subview<eT>::operator/= (const Base<eT,T1>& in)
00337 {
00338 arma_extra_debug_sigprint();
00339
00340 const Proxy<T1> x(in.get_ref());
00341
00342 subview<eT>& t = *this;
00343
00344 arma_debug_assert_same_size(t, x, "element-wise matrix division");
00345
00346
00347 for(u32 col = 0; col<t.n_cols; ++col)
00348 {
00349 eT* t_coldata = t.colptr(col);
00350
00351 for(u32 row = 0; row<t.n_rows; ++row)
00352 {
00353 t_coldata[row] /= x.at(row,col);
00354 }
00355 }
00356
00357 }
00358
00359
00360
00361
00362 template<typename eT>
00363 inline
00364 void
00365 subview<eT>::operator= (const subview<eT>& x_in)
00366 {
00367 arma_extra_debug_sigprint();
00368
00369 const bool overlap = check_overlap(x_in);
00370
00371 Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
00372 const subview<eT>* tmp_subview = overlap ? new subview<eT>(*tmp_mat, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0;
00373 const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
00374
00375 subview<eT>& t = *this;
00376
00377 arma_debug_assert_same_size(t, x, "insert into submatrix");
00378
00379 const u32 t_n_cols = t.n_cols;
00380 const u32 t_n_rows = t.n_rows;
00381
00382 for(u32 col = 0; col<t_n_cols; ++col)
00383 {
00384 syslib::copy_elem( t.colptr(col), x.colptr(col), t_n_rows );
00385 }
00386
00387 if(overlap)
00388 {
00389 delete tmp_subview;
00390 delete tmp_mat;
00391 }
00392
00393 }
00394
00395
00396
00397 template<typename eT>
00398 inline
00399 void
00400 subview<eT>::operator+= (const subview<eT>& x_in)
00401 {
00402 arma_extra_debug_sigprint();
00403
00404 const bool overlap = check_overlap(x_in);
00405
00406 Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
00407 const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0;
00408 const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
00409
00410
00411 subview<eT>& t = *this;
00412
00413 arma_debug_assert_same_size(t, x, "matrix addition");
00414
00415
00416 for(u32 col = 0; col<t.n_cols; ++col)
00417 {
00418 eT* t_coldata = t.colptr(col);
00419 const eT* x_coldata = x.colptr(col);
00420
00421 for(u32 row = 0; row<t.n_rows; ++row)
00422 {
00423 t_coldata[row] += x_coldata[row];
00424 }
00425
00426 }
00427
00428 }
00429
00430
00431
00432 template<typename eT>
00433 inline
00434 void
00435 subview<eT>::operator-= (const subview<eT>& x_in)
00436 {
00437 arma_extra_debug_sigprint();
00438
00439 const bool overlap = check_overlap(x_in);
00440
00441 Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
00442 const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0;
00443 const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
00444
00445 subview<eT>& t = *this;
00446
00447 arma_debug_assert_same_size(t, x, "matrix subtraction");
00448
00449
00450 for(u32 col = 0; col<t.n_cols; ++col)
00451 {
00452 eT* t_coldata = t.colptr(col);
00453 const eT* x_coldata = x.colptr(col);
00454
00455 for(u32 row = 0; row<t.n_rows; ++row)
00456 {
00457 t_coldata[row] -= x_coldata[row];
00458 }
00459 }
00460
00461 if(overlap)
00462 {
00463 delete tmp_subview;
00464 delete tmp_mat;
00465 }
00466
00467 }
00468
00469
00470
00471 template<typename eT>
00472 inline
00473 void
00474 subview<eT>::operator%= (const subview& x_in)
00475 {
00476 arma_extra_debug_sigprint();
00477
00478 const bool overlap = check_overlap(x_in);
00479
00480 Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
00481 const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0;
00482 const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
00483
00484 subview<eT>& t = *this;
00485
00486 arma_debug_assert_same_size(t, x, "matrix schur product");
00487
00488
00489 for(u32 col = 0; col<t.n_cols; ++col)
00490 {
00491 eT* t_coldata = t.colptr(col);
00492 const eT* x_coldata = x.colptr(col);
00493
00494 for(u32 row = 0; row<t.n_rows; ++row)
00495 {
00496 t_coldata[row] *= x_coldata[row];
00497 }
00498 }
00499
00500 if(overlap)
00501 {
00502 delete tmp_subview;
00503 delete tmp_mat;
00504 }
00505
00506 }
00507
00508
00509
00510 template<typename eT>
00511 inline
00512 void
00513 subview<eT>::operator/= (const subview& x_in)
00514 {
00515 arma_extra_debug_sigprint();
00516
00517 const bool overlap = check_overlap(x_in);
00518
00519 Mat<eT>* tmp_mat = overlap ? new Mat<eT>(x_in.m) : 0;
00520 const subview<eT>* tmp_subview = overlap ? new subview(*tmp_mat, x_in.aux_row1, x_in.aux_col1, x_in.aux_row2, x_in.aux_col2) : 0;
00521 const subview<eT>& x = overlap ? (*tmp_subview) : x_in;
00522
00523 subview<eT>& t = *this;
00524
00525 arma_debug_assert_same_size(t, x, "element-wise matrix division");
00526
00527
00528 for(u32 col = 0; col<t.n_cols; ++col)
00529 {
00530 eT* t_coldata = t.colptr(col);
00531 const eT* x_coldata = x.colptr(col);
00532
00533 for(u32 row = 0; row<t.n_rows; ++row)
00534 {
00535 t_coldata[row] /= x_coldata[row];
00536 }
00537 }
00538
00539 if(overlap)
00540 {
00541 delete tmp_subview;
00542 delete tmp_mat;
00543 }
00544
00545 }
00546
00547
00548
00549 template<typename eT>
00550 inline
00551 void
00552 subview<eT>::zeros()
00553 {
00554 arma_extra_debug_sigprint();
00555
00556 subview<eT>& t = *this;
00557
00558 for(u32 col = 0; col<t.n_cols; ++col)
00559 {
00560 eT* t_coldata = t.colptr(col);
00561
00562 for(u32 row = 0; row<t.n_rows; ++row)
00563 {
00564 t_coldata[row] = eT(0);
00565 }
00566
00567 }
00568
00569 }
00570
00571
00572
00573 template<typename eT>
00574 arma_inline
00575 eT&
00576 subview<eT>::operator[](const u32 i)
00577 {
00578 arma_check( (m_ptr == 0), "subview::operator[]: matrix is read-only");
00579
00580 const u32 in_col = i / n_rows;
00581 const u32 in_row = i % n_rows;
00582
00583 const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00584 return access::rw( (*m_ptr).mem[index] );
00585 }
00586
00587
00588
00589 template<typename eT>
00590 arma_inline
00591 eT
00592 subview<eT>::operator[](const u32 i) const
00593 {
00594 const u32 in_col = i / n_rows;
00595 const u32 in_row = i % n_rows;
00596
00597 const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00598 return m.mem[index];
00599 }
00600
00601
00602
00603 template<typename eT>
00604 arma_inline
00605 eT&
00606 subview<eT>::operator()(const u32 i)
00607 {
00608 arma_check( (m_ptr == 0), "subview::operator(): matrix is read-only");
00609 arma_debug_check( (i >= n_elem), "subview::operator(): index out of bounds");
00610
00611 const u32 in_col = i / n_rows;
00612 const u32 in_row = i % n_rows;
00613
00614 const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00615 return access::rw( (*m_ptr).mem[index] );
00616 }
00617
00618
00619
00620 template<typename eT>
00621 arma_inline
00622 eT
00623 subview<eT>::operator()(const u32 i) const
00624 {
00625 arma_debug_check( (i >= n_elem), "subview::operator(): index out of bounds");
00626
00627 const u32 in_col = i / n_rows;
00628 const u32 in_row = i % n_rows;
00629
00630 const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00631 return m.mem[index];
00632 }
00633
00634
00635
00636 template<typename eT>
00637 arma_inline
00638 eT&
00639 subview<eT>::operator()(const u32 in_row, const u32 in_col)
00640 {
00641 arma_check( (m_ptr == 0), "subview::operator(): matrix is read-only");
00642 arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::operator(): index out of bounds");
00643
00644 const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00645 return access::rw( (*m_ptr).mem[index] );
00646 }
00647
00648
00649
00650 template<typename eT>
00651 arma_inline
00652 eT
00653 subview<eT>::operator()(const u32 in_row, const u32 in_col) const
00654 {
00655 arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "subview::operator(): index out of bounds");
00656
00657 const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00658 return m.mem[index];
00659 }
00660
00661
00662
00663 template<typename eT>
00664 arma_inline
00665 eT&
00666 subview<eT>::at(const u32 in_row, const u32 in_col)
00667 {
00668 arma_check( (m_ptr == 0), "subview::at(): matrix is read-only");
00669
00670 const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00671 return access::rw( (*m_ptr).mem[index] );
00672 }
00673
00674
00675
00676 template<typename eT>
00677 arma_inline
00678 eT
00679 subview<eT>::at(const u32 in_row, const u32 in_col) const
00680 {
00681 const u32 index = (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
00682 return m.mem[index];
00683 }
00684
00685
00686
00687 template<typename eT>
00688 arma_inline
00689 eT*
00690 subview<eT>::colptr(const u32 in_col)
00691 {
00692 arma_check( (m_ptr == 0), "subview::colptr(): matrix is read-only");
00693
00694 return & access::rw((*m_ptr).mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ]);
00695 }
00696
00697
00698
00699 template<typename eT>
00700 arma_inline
00701 const eT*
00702 subview<eT>::colptr(const u32 in_col) const
00703 {
00704 return & m.mem[ (in_col + aux_col1)*m.n_rows + aux_row1 ];
00705 }
00706
00707
00708
00709 template<typename eT>
00710 inline
00711 bool
00712 subview<eT>::check_overlap(const subview<eT>& x) const
00713 {
00714 const subview<eT>& t = *this;
00715
00716 if(&t.m != &x.m)
00717 {
00718 return false;
00719 }
00720 else
00721 {
00722 const bool row_overlap =
00723 (
00724 ( (x.aux_row1 >= t.aux_row1) && (x.aux_row1 <= t.aux_row2) )
00725 ||
00726 ( (x.aux_row2 >= t.aux_row1) && (x.aux_row2 <= t.aux_row2) )
00727 );
00728
00729 const bool col_overlap =
00730 (
00731 ( (x.aux_col1 >= t.aux_col1) && (x.aux_col1 <= t.aux_col2) )
00732 ||
00733 ( (x.aux_col2 >= t.aux_col1) && (x.aux_col2 <= t.aux_col2) )
00734 );
00735
00736
00737 return (row_overlap & col_overlap);
00738 }
00739 }
00740
00741
00742
00743 template<typename eT>
00744 inline
00745 bool
00746 subview<eT>::is_vec() const
00747 {
00748 return ( (n_rows == 1) || (n_cols == 1) );
00749 }
00750
00751
00752
00753
00754 template<typename eT>
00755 inline
00756 void
00757 subview<eT>::extract(Mat<eT>& actual_out, const subview<eT>& in)
00758 {
00759 arma_extra_debug_sigprint();
00760
00761
00762 const bool alias = (&actual_out == &in.m);
00763
00764 Mat<eT>* tmp = (alias) ? new Mat<eT> : 0;
00765 Mat<eT>& out = (alias) ? (*tmp) : actual_out;
00766
00767
00768
00769 const u32 n_rows = in.n_rows;
00770 const u32 n_cols = in.n_cols;
00771
00772 out.set_size(n_rows, n_cols);
00773
00774 arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d in.m.n_rows = %d in.m.n_cols = %d") % out.n_rows % out.n_cols % in.m.n_rows % in.m.n_cols );
00775
00776
00777 if(in.is_vec() == true)
00778 {
00779 if(n_cols == 1)
00780 {
00781 arma_extra_debug_print("subview::extract(): copying col (going across rows)");
00782
00783 eT* out_mem = out.memptr();
00784 const eT* in_coldata = in.colptr(0);
00785
00786 for(u32 row=0; row<n_rows; ++row)
00787 {
00788 out_mem[row] = in_coldata[row];
00789 }
00790 }
00791 else
00792 {
00793 arma_extra_debug_print("subview::extract(): copying row (going across columns)");
00794
00795 const Mat<eT>& X = in.m;
00796
00797 eT* out_mem = out.memptr();
00798 const u32 row = in.aux_row1;
00799 const u32 start_col = in.aux_col1;
00800
00801 for(u32 i=0; i<n_cols; ++i)
00802 {
00803 out_mem[i] = X.at(row, i+start_col);
00804 }
00805 }
00806 }
00807 else
00808 {
00809 arma_extra_debug_print("subview::extract(): general submatrix");
00810
00811 for(u32 col = 0; col<n_cols; ++col)
00812 {
00813 syslib::copy_elem( out.colptr(col), in.colptr(col), n_rows );
00814 }
00815 }
00816
00817
00818 if(alias)
00819 {
00820 actual_out = out;
00821 delete tmp;
00822 }
00823
00824 }
00825
00826
00827
00828
00829 template<typename eT>
00830 inline
00831 void
00832 subview<eT>::plus_inplace(Mat<eT>& out, const subview<eT>& in)
00833 {
00834 arma_extra_debug_sigprint();
00835
00836 arma_debug_assert_same_size(out, in, "matrix addition");
00837
00838 const u32 n_rows = out.n_rows;
00839 const u32 n_cols = out.n_cols;
00840
00841 for(u32 col = 0; col<n_cols; ++col)
00842 {
00843 eT* out_coldata = out.colptr(col);
00844 const eT* in_coldata = in.colptr(col);
00845
00846 for(u32 row = 0; row<n_rows; ++row)
00847 {
00848 out_coldata[row] += in_coldata[row];
00849 }
00850 }
00851 }
00852
00853
00854
00855
00856 template<typename eT>
00857 inline
00858 void
00859 subview<eT>::minus_inplace(Mat<eT>& out, const subview<eT>& in)
00860 {
00861 arma_extra_debug_sigprint();
00862
00863 arma_debug_assert_same_size(out, in, "matrix subtraction");
00864
00865 const u32 n_rows = out.n_rows;
00866 const u32 n_cols = out.n_cols;
00867
00868 for(u32 col = 0; col<n_cols; ++col)
00869 {
00870 eT* out_coldata = out.colptr(col);
00871 const eT* in_coldata = in.colptr(col);
00872
00873 for(u32 row = 0; row<n_rows; ++row)
00874 {
00875 out_coldata[row] -= in_coldata[row];
00876 }
00877 }
00878 }
00879
00880
00881
00882
00883 template<typename eT>
00884 inline
00885 void
00886 subview<eT>::schur_inplace(Mat<eT>& out, const subview<eT>& in)
00887 {
00888 arma_extra_debug_sigprint();
00889
00890 arma_debug_assert_same_size(out, in, "matrix schur product");
00891
00892 const u32 n_rows = out.n_rows;
00893 const u32 n_cols = out.n_cols;
00894
00895 for(u32 col = 0; col<n_cols; ++col)
00896 {
00897 eT* out_coldata = out.colptr(col);
00898 const eT* in_coldata = in.colptr(col);
00899
00900 for(u32 row = 0; row<n_rows; ++row)
00901 {
00902 out_coldata[row] *= in_coldata[row];
00903 }
00904 }
00905 }
00906
00907
00908
00909
00910 template<typename eT>
00911 inline
00912 void
00913 subview<eT>::div_inplace(Mat<eT>& out, const subview<eT>& in)
00914 {
00915 arma_extra_debug_sigprint();
00916
00917 arma_debug_assert_same_size(out, in, "element-wise matrix division");
00918
00919 const u32 n_rows = out.n_rows;
00920 const u32 n_cols = out.n_cols;
00921
00922 for(u32 col = 0; col<n_cols; ++col)
00923 {
00924 eT* out_coldata = out.colptr(col);
00925 const eT* in_coldata = in.colptr(col);
00926
00927 for(u32 row = 0; row<n_rows; ++row)
00928 {
00929 out_coldata[row] /= in_coldata[row];
00930 }
00931 }
00932 }
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942 template<typename eT>
00943 arma_inline
00944 subview_col<eT>::subview_col(const Mat<eT>& in_m, const u32 in_col)
00945 : subview<eT>(in_m, 0, in_col, in_m.n_rows-1, in_col)
00946 {
00947 arma_extra_debug_sigprint();
00948 }
00949
00950
00951
00952 template<typename eT>
00953 arma_inline
00954 subview_col<eT>::subview_col(Mat<eT>& in_m, const u32 in_col)
00955 : subview<eT>(in_m, 0, in_col, in_m.n_rows-1, in_col)
00956 {
00957 arma_extra_debug_sigprint();
00958 }
00959
00960
00961
00962 template<typename eT>
00963 arma_inline
00964 subview_col<eT>::subview_col(const Mat<eT>& in_m, const u32 in_col, const u32 in_row1, const u32 in_row2)
00965 : subview<eT>(in_m, in_row1, in_col, in_row2, in_col)
00966 {
00967 arma_extra_debug_sigprint();
00968 }
00969
00970
00971
00972 template<typename eT>
00973 arma_inline
00974 subview_col<eT>::subview_col(Mat<eT>& in_m, const u32 in_col, const u32 in_row1, const u32 in_row2)
00975 : subview<eT>(in_m, in_row1, in_col, in_row2, in_col)
00976 {
00977 arma_extra_debug_sigprint();
00978 }
00979
00980
00981
00982 template<typename eT>
00983 inline
00984 void
00985 subview_col<eT>::operator=(const subview<eT>& X)
00986 {
00987 arma_extra_debug_sigprint();
00988
00989 subview<eT>::operator=(X);
00990 arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
00991 }
00992
00993
00994
00995 template<typename eT>
00996 inline
00997 void
00998 subview_col<eT>::operator=(const subview_col<eT>& X)
00999 {
01000 arma_extra_debug_sigprint();
01001
01002 subview<eT>::operator=(X);
01003 arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
01004 }
01005
01006
01007
01008 template<typename eT>
01009 template<typename T1>
01010 inline
01011 void
01012 subview_col<eT>::operator=(const Base<eT,T1>& X)
01013 {
01014 arma_extra_debug_sigprint();
01015
01016 subview<eT>::operator=(X);
01017 arma_debug_check( (subview<eT>::n_cols > 1), "subview_col(): incompatible dimensions" );
01018 }
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029 template<typename eT>
01030 arma_inline
01031 subview_row<eT>::subview_row(const Mat<eT>& in_m, const u32 in_row)
01032 : subview<eT>(in_m, in_row, 0, in_row, in_m.n_cols-1)
01033 {
01034 arma_extra_debug_sigprint();
01035 }
01036
01037
01038
01039 template<typename eT>
01040 arma_inline
01041 subview_row<eT>::subview_row(Mat<eT>& in_m, const u32 in_row)
01042 : subview<eT>(in_m, in_row, 0, in_row, in_m.n_cols-1)
01043 {
01044 arma_extra_debug_sigprint();
01045 }
01046
01047
01048
01049 template<typename eT>
01050 arma_inline
01051 subview_row<eT>::subview_row(const Mat<eT>& in_m, const u32 in_row, const u32 in_col1, const u32 in_col2)
01052 : subview<eT>(in_m, in_row, in_col1, in_row, in_col2)
01053 {
01054 arma_extra_debug_sigprint();
01055 }
01056
01057
01058
01059 template<typename eT>
01060 arma_inline
01061 subview_row<eT>::subview_row(Mat<eT>& in_m, const u32 in_row, const u32 in_col1, const u32 in_col2)
01062 : subview<eT>(in_m, in_row, in_col1, in_row, in_col2)
01063 {
01064 arma_extra_debug_sigprint();
01065 }
01066
01067
01068
01069 template<typename eT>
01070 inline
01071 void
01072 subview_row<eT>::operator=(const subview<eT>& X)
01073 {
01074 arma_extra_debug_sigprint();
01075
01076 subview<eT>::operator=(X);
01077 arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
01078 }
01079
01080
01081
01082 template<typename eT>
01083 inline
01084 void
01085 subview_row<eT>::operator=(const subview_row<eT>& X)
01086 {
01087 arma_extra_debug_sigprint();
01088
01089 subview<eT>::operator=(X);
01090 arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
01091 }
01092
01093
01094
01095 template<typename eT>
01096 template<typename T1>
01097 inline
01098 void
01099 subview_row<eT>::operator=(const Base<eT,T1>& X)
01100 {
01101 arma_extra_debug_sigprint();
01102
01103 subview<eT>::operator=(X);
01104 arma_debug_check( (subview<eT>::n_rows > 1), "subview_row(): incompatible dimensions" );
01105 }
01106
01107
01108
01109