1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | inline mxd::t m_diagonal(mxd::t _m,vxd::t _entries){ for(z::t i(0) ; i < _m.cols() ; ++i){ mxd::b tl = _m.block(i, i , 1 , 1 ); mxd::b tr = _m.block(i , i + 1 , 1 , _m.cols() - (i + 1) ); mxd::b bl = _m.block(i + 1 , i , _m.rows() - (i + 1) , 1 ); mxd::b br = _m.block(i + 1 , i + 1 , _m.rows() - (i + 1) , _m.cols() - (i + 1) ); co(tl,"tl"); co(tr,"tr"); co(bl,"bl"); co(br,"br"); tl << _entries(i); tr.setZero(); bl.setZero(); } return _m; } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | tl = 1 tr = 2 3 4 5 bl = 6 1 6 1 br = 7 8 9 10 2 3 4 5 7 8 9 10 2 3 4 5 tl = 7 tr = 8 9 10 bl = 2 7 2 br = 3 4 5 8 9 10 3 4 5 tl = 3 tr = 4 5 bl = 8 3 br = 9 10 4 5 tl = 9 tr = 10 bl = 4 br = 5 tl = 5 tr = bl = br = output = 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 5 | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | inline mxd::t m_lower(mxd::t _m){ for(z::t i(0) ; i < _m.cols() ; ++i){ mxd::b tl = _m.block(i, i , 1 , 1 ); mxd::b tr = _m.block(i , i + 1 , 1 , _m.cols() - (i + 1) ); mxd::b bl = _m.block(i + 1 , i , _m.rows() - (i + 1) , 1 ); mxd::b br = _m.block(i + 1 , i + 1 , _m.rows() - (i + 1) , _m.cols() - (i + 1) ); co(tl,"tl"); co(tr,"tr"); co(bl,"bl"); co(br,"br"); tl << 1; tr.setZero(); } return _m; } inline mxd::t m_upper(mxd::t _m){ for(z::t i(0) ; i < _m.cols() ; ++i){ mxd::b tl = _m.block(i, i , 1 , 1 ); mxd::b tr = _m.block(i , i + 1 , 1 , _m.cols() - (i + 1) ); mxd::b bl = _m.block(i + 1 , i , _m.rows() - (i + 1) , 1 ); mxd::b br = _m.block(i + 1 , i + 1 , _m.rows() - (i + 1) , _m.cols() - (i + 1) ); co(tl,"tl"); co(tr,"tr"); co(bl,"bl"); co(br,"br"); tl << 1; bl.setZero(); } return _m; } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | inline mxd::t m_transpose(mxd::t _m){ mxd::t m_(_m.cols(), _m.rows()); m_.setZero(); for(z::t i(0) ; i < _m.cols() ; ++i){ mxd::b col = _m.block(0, i ,_m.rows(),1 ); mxd::b rows = m_.block(i, 0, 1, _m.cols()); for(z::t x(0) ; x < _m.cols() ; ++x){ rows.col(x) = col.row(x); } co(col, "col"); co(rows, "rows"); } return m_; } | cs |