| subview_cube_meat.hpp | | subview_cube_meat.hpp | |
|
| // Copyright (C) 2008-2013 Conrad Sanderson | | // Copyright (C) 2008-2014 Conrad Sanderson | |
| // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2014 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup subview_cube | | //! \addtogroup subview_cube | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| | | | |
| skipping to change at line 486 | | skipping to change at line 486 | |
| const Mat<eT>& x = tmp.M; | | const Mat<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
| const uword t_n_rows = t.n_rows; | | const uword t_n_rows = t.n_rows; | |
| const uword t_n_cols = t.n_cols; | | const uword t_n_cols = t.n_cols; | |
| const uword t_n_slices = t.n_slices; | | const uword t_n_slices = t.n_slices; | |
| | | | |
| const uword x_n_rows = x.n_rows; | | const uword x_n_rows = x.n_rows; | |
| const uword x_n_cols = x.n_cols; | | const uword x_n_cols = x.n_cols; | |
| | | | |
|
| | | if( ((x_n_rows == 1) || (x_n_cols == 1)) && (t_n_rows == 1) && (t_n_cols | |
| | | == 1) && (x.n_elem == t_n_slices) ) | |
| | | { | |
| | | Cube<eT>& Q = const_cast< Cube<eT>& >(t.m); | |
| | | | |
| | | const uword t_aux_row1 = t.aux_row1; | |
| | | const uword t_aux_col1 = t.aux_col1; | |
| | | const uword t_aux_slice1 = t.aux_slice1; | |
| | | | |
| | | const eT* x_mem = x.memptr(); | |
| | | | |
| | | uword i,j; | |
| | | for(i=0, j=1; j < t_n_slices; i+=2, j+=2) | |
| | | { | |
| | | const eT tmp_i = x_mem[i]; | |
| | | const eT tmp_j = x_mem[j]; | |
| | | | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + i) = tmp_i; | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + j) = tmp_j; | |
| | | } | |
| | | | |
| | | if(i < t_n_slices) | |
| | | { | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + i) = x_mem[i]; | |
| | | } | |
| | | } | |
| | | else | |
| if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1)
) | | if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1)
) | |
| { | | { | |
| // interpret the matrix as a cube with one slice | | // interpret the matrix as a cube with one slice | |
| | | | |
| for(uword col = 0; col < t_n_cols; ++col) | | for(uword col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::copy( t.slice_colptr(0, col), x.colptr(col), t_n_rows ); | | arrayops::copy( t.slice_colptr(0, col), x.colptr(col), t_n_rows ); | |
| } | | } | |
| } | | } | |
| else | | else | |
| | | | |
| skipping to change at line 563 | | skipping to change at line 589 | |
| const Mat<eT>& x = tmp.M; | | const Mat<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
| const uword t_n_rows = t.n_rows; | | const uword t_n_rows = t.n_rows; | |
| const uword t_n_cols = t.n_cols; | | const uword t_n_cols = t.n_cols; | |
| const uword t_n_slices = t.n_slices; | | const uword t_n_slices = t.n_slices; | |
| | | | |
| const uword x_n_rows = x.n_rows; | | const uword x_n_rows = x.n_rows; | |
| const uword x_n_cols = x.n_cols; | | const uword x_n_cols = x.n_cols; | |
| | | | |
|
| | | if( ((x_n_rows == 1) || (x_n_cols == 1)) && (t_n_rows == 1) && (t_n_cols | |
| | | == 1) && (x.n_elem == t_n_slices) ) | |
| | | { | |
| | | Cube<eT>& Q = const_cast< Cube<eT>& >(t.m); | |
| | | | |
| | | const uword t_aux_row1 = t.aux_row1; | |
| | | const uword t_aux_col1 = t.aux_col1; | |
| | | const uword t_aux_slice1 = t.aux_slice1; | |
| | | | |
| | | const eT* x_mem = x.memptr(); | |
| | | | |
| | | uword i,j; | |
| | | for(i=0, j=1; j < t_n_slices; i+=2, j+=2) | |
| | | { | |
| | | const eT tmp_i = x_mem[i]; | |
| | | const eT tmp_j = x_mem[j]; | |
| | | | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + i) += tmp_i; | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + j) += tmp_j; | |
| | | } | |
| | | | |
| | | if(i < t_n_slices) | |
| | | { | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + i) += x_mem[i]; | |
| | | } | |
| | | } | |
| | | else | |
| if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1)
) | | if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1)
) | |
| { | | { | |
| for(uword col = 0; col < t_n_cols; ++col) | | for(uword col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_plus( t.slice_colptr(0, col), x.colptr(col), t_n_ro
ws ); | | arrayops::inplace_plus( t.slice_colptr(0, col), x.colptr(col), t_n_ro
ws ); | |
| } | | } | |
| } | | } | |
| else | | else | |
| if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols)
) | | if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols)
) | |
| { | | { | |
| | | | |
| skipping to change at line 638 | | skipping to change at line 690 | |
| const Mat<eT>& x = tmp.M; | | const Mat<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
| const uword t_n_rows = t.n_rows; | | const uword t_n_rows = t.n_rows; | |
| const uword t_n_cols = t.n_cols; | | const uword t_n_cols = t.n_cols; | |
| const uword t_n_slices = t.n_slices; | | const uword t_n_slices = t.n_slices; | |
| | | | |
| const uword x_n_rows = x.n_rows; | | const uword x_n_rows = x.n_rows; | |
| const uword x_n_cols = x.n_cols; | | const uword x_n_cols = x.n_cols; | |
| | | | |
|
| | | if( ((x_n_rows == 1) || (x_n_cols == 1)) && (t_n_rows == 1) && (t_n_cols | |
| | | == 1) && (x.n_elem == t_n_slices) ) | |
| | | { | |
| | | Cube<eT>& Q = const_cast< Cube<eT>& >(t.m); | |
| | | | |
| | | const uword t_aux_row1 = t.aux_row1; | |
| | | const uword t_aux_col1 = t.aux_col1; | |
| | | const uword t_aux_slice1 = t.aux_slice1; | |
| | | | |
| | | const eT* x_mem = x.memptr(); | |
| | | | |
| | | uword i,j; | |
| | | for(i=0, j=1; j < t_n_slices; i+=2, j+=2) | |
| | | { | |
| | | const eT tmp_i = x_mem[i]; | |
| | | const eT tmp_j = x_mem[j]; | |
| | | | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + i) -= tmp_i; | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + j) -= tmp_j; | |
| | | } | |
| | | | |
| | | if(i < t_n_slices) | |
| | | { | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + i) -= x_mem[i]; | |
| | | } | |
| | | } | |
| | | else | |
| if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1)
) | | if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1)
) | |
| { | | { | |
| for(uword col = 0; col < t_n_cols; ++col) | | for(uword col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_minus( t.slice_colptr(0, col), x.colptr(col), t_n_r
ows ); | | arrayops::inplace_minus( t.slice_colptr(0, col), x.colptr(col), t_n_r
ows ); | |
| } | | } | |
| } | | } | |
| else | | else | |
| if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols)
) | | if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols)
) | |
| { | | { | |
| | | | |
| skipping to change at line 713 | | skipping to change at line 791 | |
| const Mat<eT>& x = tmp.M; | | const Mat<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
| const uword t_n_rows = t.n_rows; | | const uword t_n_rows = t.n_rows; | |
| const uword t_n_cols = t.n_cols; | | const uword t_n_cols = t.n_cols; | |
| const uword t_n_slices = t.n_slices; | | const uword t_n_slices = t.n_slices; | |
| | | | |
| const uword x_n_rows = x.n_rows; | | const uword x_n_rows = x.n_rows; | |
| const uword x_n_cols = x.n_cols; | | const uword x_n_cols = x.n_cols; | |
| | | | |
|
| | | if( ((x_n_rows == 1) || (x_n_cols == 1)) && (t_n_rows == 1) && (t_n_cols | |
| | | == 1) && (x.n_elem == t_n_slices) ) | |
| | | { | |
| | | Cube<eT>& Q = const_cast< Cube<eT>& >(t.m); | |
| | | | |
| | | const uword t_aux_row1 = t.aux_row1; | |
| | | const uword t_aux_col1 = t.aux_col1; | |
| | | const uword t_aux_slice1 = t.aux_slice1; | |
| | | | |
| | | const eT* x_mem = x.memptr(); | |
| | | | |
| | | uword i,j; | |
| | | for(i=0, j=1; j < t_n_slices; i+=2, j+=2) | |
| | | { | |
| | | const eT tmp_i = x_mem[i]; | |
| | | const eT tmp_j = x_mem[j]; | |
| | | | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + i) *= tmp_i; | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + j) *= tmp_j; | |
| | | } | |
| | | | |
| | | if(i < t_n_slices) | |
| | | { | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + i) *= x_mem[i]; | |
| | | } | |
| | | } | |
| | | else | |
| if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1)
) | | if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1)
) | |
| { | | { | |
| for(uword col = 0; col < t_n_cols; ++col) | | for(uword col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_mul( t.slice_colptr(0, col), x.colptr(col), t_n_row
s ); | | arrayops::inplace_mul( t.slice_colptr(0, col), x.colptr(col), t_n_row
s ); | |
| } | | } | |
| } | | } | |
| else | | else | |
| if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols)
) | | if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols)
) | |
| { | | { | |
| | | | |
| skipping to change at line 788 | | skipping to change at line 892 | |
| const Mat<eT>& x = tmp.M; | | const Mat<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
| const uword t_n_rows = t.n_rows; | | const uword t_n_rows = t.n_rows; | |
| const uword t_n_cols = t.n_cols; | | const uword t_n_cols = t.n_cols; | |
| const uword t_n_slices = t.n_slices; | | const uword t_n_slices = t.n_slices; | |
| | | | |
| const uword x_n_rows = x.n_rows; | | const uword x_n_rows = x.n_rows; | |
| const uword x_n_cols = x.n_cols; | | const uword x_n_cols = x.n_cols; | |
| | | | |
|
| | | if( ((x_n_rows == 1) || (x_n_cols == 1)) && (t_n_rows == 1) && (t_n_cols | |
| | | == 1) && (x.n_elem == t_n_slices) ) | |
| | | { | |
| | | Cube<eT>& Q = const_cast< Cube<eT>& >(t.m); | |
| | | | |
| | | const uword t_aux_row1 = t.aux_row1; | |
| | | const uword t_aux_col1 = t.aux_col1; | |
| | | const uword t_aux_slice1 = t.aux_slice1; | |
| | | | |
| | | const eT* x_mem = x.memptr(); | |
| | | | |
| | | uword i,j; | |
| | | for(i=0, j=1; j < t_n_slices; i+=2, j+=2) | |
| | | { | |
| | | const eT tmp_i = x_mem[i]; | |
| | | const eT tmp_j = x_mem[j]; | |
| | | | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + i) /= tmp_i; | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + j) /= tmp_j; | |
| | | } | |
| | | | |
| | | if(i < t_n_slices) | |
| | | { | |
| | | Q.at(t_aux_row1, t_aux_col1, t_aux_slice1 + i) /= x_mem[i]; | |
| | | } | |
| | | } | |
| | | else | |
| if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1)
) | | if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1)
) | |
| { | | { | |
| for(uword col = 0; col < t_n_cols; ++col) | | for(uword col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_div( t.slice_colptr(0, col), x.colptr(col), t_n_row
s ); | | arrayops::inplace_div( t.slice_colptr(0, col), x.colptr(col), t_n_row
s ); | |
| } | | } | |
| } | | } | |
| else | | else | |
| if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols)
) | | if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols)
) | |
| { | | { | |
| | | | |
End of changes. 6 change blocks. |
| 2 lines changed or deleted | | 137 lines changed or added | |
|