| op_htrans_meat.hpp | | op_htrans_meat.hpp | |
|
| // Copyright (C) 2008-2014 Conrad Sanderson | | // Copyright (C) 2008-2015 Conrad Sanderson | |
| // Copyright (C) 2008-2014 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2015 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2012 Ryan Curtin | | // Copyright (C) 2012 Ryan Curtin | |
| // | | // | |
| // 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 op_htrans | | //! \addtogroup op_htrans | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| | | | |
| skipping to change at line 52 | | skipping to change at line 52 | |
| const eT* A_mem = A.memptr(); | | const eT* A_mem = A.memptr(); | |
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| | | | |
| for(uword i=0; i < n_elem; ++i) | | for(uword i=0; i < n_elem; ++i) | |
| { | | { | |
| out_mem[i] = std::conj(A_mem[i]); | | out_mem[i] = std::conj(A_mem[i]); | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| const uword out_n_rows = out.n_rows; | | eT* outptr = out.memptr(); | |
| | | | |
|
| const eT* colptr = A.memptr(); | | for(uword k=0; k < A_n_rows; ++k) | |
| | | | |
| for(uword k=0; k < A_n_cols; ++k) | | | |
| { | | { | |
|
| eT* outptr = &(out.at(k,0)); | | const eT* Aptr = &(A.at(k,0)); | |
| | | | |
|
| for(uword j=0; j < A_n_rows; ++j) | | for(uword j=0; j < A_n_cols; ++j) | |
| { | | { | |
|
| (*outptr) = std::conj(*colptr); | | (*outptr) = std::conj(*Aptr); | |
| | | | |
|
| colptr++; | | Aptr += A_n_rows; | |
| outptr += out_n_rows; | | outptr++; | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| arma_hot | | arma_hot | |
| arma_inline | | arma_inline | |
| void | | void | |
| op_htrans::apply_mat_inplace(Mat<eT>& out, const typename arma_not_cx<eT>::
result* junk) | | op_htrans::apply_mat_inplace(Mat<eT>& out, const typename arma_not_cx<eT>::
result* junk) | |
| | | | |
| skipping to change at line 223 | | skipping to change at line 221 | |
| | | | |
| out.steal_mem(out2); | | out.steal_mem(out2); | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| if(is_alias == false) | | if(is_alias == false) | |
| { | | { | |
| out.set_size(n_cols, n_rows); | | out.set_size(n_cols, n_rows); | |
| | | | |
|
| const uword out_n_rows = out.n_rows; | | eT* outptr = out.memptr(); | |
| | | | |
|
| for(uword k=0; k < n_cols; ++k) | | for(uword k=0; k < n_rows; ++k) | |
| { | | { | |
|
| eT* outptr = &(out.at(k,0)); | | for(uword j=0; j < n_cols; ++j) | |
| | | | |
| for(uword i=0; i < n_rows; ++i) | | | |
| { | | { | |
|
| (*outptr) = std::conj(P.at(i,k)); | | (*outptr) = std::conj(P.at(k,j)); | |
| | | | |
|
| outptr += out_n_rows; | | outptr++; | |
| } | | } | |
| } | | } | |
| } | | } | |
| else // aliasing | | else // aliasing | |
| { | | { | |
| Mat<eT> out2(n_cols, n_rows); | | Mat<eT> out2(n_cols, n_rows); | |
| | | | |
|
| const uword out2_n_rows = out2.n_rows; | | eT* out2ptr = out2.memptr(); | |
| | | | |
|
| for(uword k=0; k < n_cols; ++k) | | for(uword k=0; k < n_rows; ++k) | |
| { | | { | |
|
| eT* out2ptr = &(out2.at(k,0)); | | for(uword j=0; j < n_cols; ++j) | |
| | | | |
| for(uword i=0; i < n_rows; ++i) | | | |
| { | | { | |
|
| (*out2ptr) = std::conj(P.at(i,k)); | | (*out2ptr) = std::conj(P.at(k,j)); | |
| | | | |
|
| out2ptr += out2_n_rows; | | out2ptr++; | |
| } | | } | |
| } | | } | |
| | | | |
| out.steal_mem(out2); | | out.steal_mem(out2); | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| | | | |
| skipping to change at line 333 | | skipping to change at line 327 | |
| const eT* A_mem = A.memptr(); | | const eT* A_mem = A.memptr(); | |
| eT* out_mem = out.memptr(); | | eT* out_mem = out.memptr(); | |
| | | | |
| for(uword i=0; i < n_elem; ++i) | | for(uword i=0; i < n_elem; ++i) | |
| { | | { | |
| out_mem[i] = val * std::conj(A_mem[i]); | | out_mem[i] = val * std::conj(A_mem[i]); | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| const uword out_n_rows = out.n_rows; | | eT* outptr = out.memptr(); | |
| | | | |
|
| const eT* colptr = A.memptr(); | | for(uword k=0; k < A_n_rows; ++k) | |
| | | | |
| for(uword k=0; k < A_n_cols; ++k) | | | |
| { | | { | |
|
| eT* outptr = &(out.at(k,0)); | | const eT* Aptr = &(A.at(k,0)); | |
| | | | |
|
| for(uword j=0; j < A_n_rows; ++j) | | for(uword j=0; j < A_n_cols; ++j) | |
| { | | { | |
|
| (*outptr) = val * std::conj(*colptr); | | (*outptr) = val * std::conj(*Aptr); | |
| | | | |
|
| colptr++; | | Aptr += A_n_rows; | |
| outptr += out_n_rows; | | outptr++; | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| op_htrans2::apply(Mat<eT>& out, const Mat<eT>& A, const eT val) | | op_htrans2::apply(Mat<eT>& out, const Mat<eT>& A, const eT val) | |
| | | | |
| skipping to change at line 470 | | skipping to change at line 462 | |
| | | | |
| out.steal_mem(out2); | | out.steal_mem(out2); | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| if(is_alias == false) | | if(is_alias == false) | |
| { | | { | |
| out.set_size(n_cols, n_rows); | | out.set_size(n_cols, n_rows); | |
| | | | |
|
| const uword out_n_rows = out.n_rows; | | eT* outptr = out.memptr(); | |
| | | | |
|
| for(uword k=0; k < n_cols; ++k) | | for(uword k=0; k < n_rows; ++k) | |
| { | | { | |
|
| eT* outptr = &(out.at(k,0)); | | for(uword j=0; j < n_cols; ++j) | |
| | | | |
| for(uword i=0; i < n_rows; ++i) | | | |
| { | | { | |
|
| (*outptr) = val * std::conj(P.at(i,k)); | | (*outptr) = val * std::conj(P.at(k,j)); | |
| | | | |
|
| outptr += out_n_rows; | | outptr++; | |
| } | | } | |
| } | | } | |
| } | | } | |
| else // aliasing | | else // aliasing | |
| { | | { | |
| Mat<eT> out2(n_cols, n_rows); | | Mat<eT> out2(n_cols, n_rows); | |
| | | | |
|
| const uword out2_n_rows = out2.n_rows; | | eT* out2ptr = out2.memptr(); | |
| | | | |
|
| for(uword k=0; k < n_cols; ++k) | | for(uword k=0; k < n_rows; ++k) | |
| { | | { | |
|
| eT* out2ptr = &(out2.at(k,0)); | | for(uword j=0; j < n_cols; ++j) | |
| | | | |
| for(uword i=0; i < n_rows; ++i) | | | |
| { | | { | |
|
| (*out2ptr) = val * std::conj(P.at(i,k)); | | (*out2ptr) = val * std::conj(P.at(k,j)); | |
| | | | |
|
| out2ptr += out2_n_rows; | | out2ptr++; | |
| } | | } | |
| } | | } | |
| | | | |
| out.steal_mem(out2); | | out.steal_mem(out2); | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| | | | |
End of changes. 33 change blocks. |
| 48 lines changed or deleted | | 36 lines changed or added | |
|
| op_strans_meat.hpp | | op_strans_meat.hpp | |
|
| // Copyright (C) 2008-2014 Conrad Sanderson | | // Copyright (C) 2008-2015 Conrad Sanderson | |
| // Copyright (C) 2008-2014 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2015 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2012 Ryan Curtin | | // Copyright (C) 2012 Ryan Curtin | |
| // | | // | |
| // 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 op_strans | | //! \addtogroup op_strans | |
| //! @{ | | //! @{ | |
| | | | |
| //! for tiny square matrices (size <= 4x4) | | //! for tiny square matrices (size <= 4x4) | |
| | | | |
| skipping to change at line 112 | | skipping to change at line 112 | |
| arrayops::copy( out.memptr(), A.memptr(), A.n_elem ); | | arrayops::copy( out.memptr(), A.memptr(), A.n_elem ); | |
| } | | } | |
| else | | else | |
| { | | { | |
| if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) ) | | if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) ) | |
| { | | { | |
| op_strans::apply_mat_noalias_tinysq(out, A); | | op_strans::apply_mat_noalias_tinysq(out, A); | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| const uword out_n_rows = out.n_rows; | | eT* outptr = out.memptr(); | |
| | | | |
|
| const eT* colptr = A.memptr(); | | for(uword k=0; k < A_n_rows; ++k) | |
| | | | |
| for(uword k=0; k < A_n_cols; ++k) | | | |
| { | | { | |
|
| eT* outptr = &(out.at(k,0)); | | const eT* Aptr = &(A.at(k,0)); | |
| | | | |
| uword j; | | uword j; | |
|
| for(j=1; j < A_n_rows; j+=2) | | for(j=1; j < A_n_cols; j+=2) | |
| { | | { | |
|
| const eT tmp_i = (*colptr); colptr++; | | const eT tmp_i = (*Aptr); Aptr += A_n_rows; | |
| const eT tmp_j = (*colptr); colptr++; | | const eT tmp_j = (*Aptr); Aptr += A_n_rows; | |
| | | | |
|
| (*outptr) = tmp_i; outptr += out_n_rows; | | (*outptr) = tmp_i; outptr++; | |
| (*outptr) = tmp_j; outptr += out_n_rows; | | (*outptr) = tmp_j; outptr++; | |
| } | | } | |
| | | | |
|
| const uword i = j-1; | | if((j-1) < A_n_cols) | |
| | | | |
| if(i < A_n_rows) | | | |
| { | | { | |
|
| (*outptr) = (*colptr); colptr++; | | (*outptr) = (*Aptr); outptr++;; | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| | | | |
| skipping to change at line 295 | | skipping to change at line 291 | |
| | | | |
| out.steal_mem(out2); | | out.steal_mem(out2); | |
| } | | } | |
| } | | } | |
| else // general matrix transpose | | else // general matrix transpose | |
| { | | { | |
| if(is_alias == false) | | if(is_alias == false) | |
| { | | { | |
| out.set_size(n_cols, n_rows); | | out.set_size(n_cols, n_rows); | |
| | | | |
|
| const uword out_n_rows = out.n_rows; | | eT* outptr = out.memptr(); | |
| | | | |
|
| for(uword k=0; k < n_cols; ++k) | | for(uword k=0; k < n_rows; ++k) | |
| { | | { | |
|
| eT* outptr = &(out.at(k,0)); | | | |
| | | | |
| uword j; | | uword j; | |
|
| for(j=1; j < n_rows; j+=2) | | for(j=1; j < n_cols; j+=2) | |
| { | | { | |
| const uword i = j-1; | | const uword i = j-1; | |
| | | | |
|
| const eT tmp_i = P.at(i,k); | | const eT tmp_i = P.at(k,i); | |
| const eT tmp_j = P.at(j,k); | | const eT tmp_j = P.at(k,j); | |
| | | | |
|
| (*outptr) = tmp_i; outptr += out_n_rows; | | (*outptr) = tmp_i; outptr++; | |
| (*outptr) = tmp_j; outptr += out_n_rows; | | (*outptr) = tmp_j; outptr++; | |
| } | | } | |
| | | | |
| const uword i = j-1; | | const uword i = j-1; | |
| | | | |
|
| if(i < n_rows) | | if(i < n_cols) | |
| { | | { | |
|
| (*outptr) = P.at(i,k); | | (*outptr) = P.at(k,i); outptr++; | |
| } | | } | |
| } | | } | |
| } | | } | |
| else // aliasing | | else // aliasing | |
| { | | { | |
| Mat<eT> out2(n_cols, n_rows); | | Mat<eT> out2(n_cols, n_rows); | |
| | | | |
|
| const uword out2_n_rows = out2.n_rows; | | eT* out2ptr = out2.memptr(); | |
| | | | |
|
| for(uword k=0; k < n_cols; ++k) | | for(uword k=0; k < n_rows; ++k) | |
| { | | { | |
|
| eT* out2ptr = &(out2.at(k,0)); | | | |
| | | | |
| uword j; | | uword j; | |
|
| for(j=1; j < n_rows; j+=2) | | for(j=1; j < n_cols; j+=2) | |
| { | | { | |
| const uword i = j-1; | | const uword i = j-1; | |
| | | | |
|
| const eT tmp_i = P.at(i,k); | | const eT tmp_i = P.at(k,i); | |
| const eT tmp_j = P.at(j,k); | | const eT tmp_j = P.at(k,j); | |
| | | | |
|
| (*out2ptr) = tmp_i; out2ptr += out2_n_rows; | | (*out2ptr) = tmp_i; out2ptr++; | |
| (*out2ptr) = tmp_j; out2ptr += out2_n_rows; | | (*out2ptr) = tmp_j; out2ptr++; | |
| } | | } | |
| | | | |
| const uword i = j-1; | | const uword i = j-1; | |
| | | | |
|
| if(i < n_rows) | | if(i < n_cols) | |
| { | | { | |
|
| (*out2ptr) = P.at(i,k); | | (*out2ptr) = P.at(k,i); out2ptr++; | |
| } | | } | |
| } | | } | |
| | | | |
| out.steal_mem(out2); | | out.steal_mem(out2); | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| | | | |
| skipping to change at line 488 | | skipping to change at line 480 | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) ) | | if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) ) | |
| { | | { | |
| op_strans2::apply_noalias_tinysq(out, A, val); | | op_strans2::apply_noalias_tinysq(out, A, val); | |
| } | | } | |
| else | | else | |
| { | | { | |
|
| const uword out_n_rows = out.n_rows; | | eT* outptr = out.memptr(); | |
| | | | |
|
| const eT* colptr = A.memptr(); | | for(uword k=0; k < A_n_rows; ++k) | |
| | | | |
| for(uword k=0; k < A_n_cols; ++k) | | | |
| { | | { | |
|
| eT* outptr = &(out.at(k,0)); | | const eT* Aptr = &(A.at(k,0)); | |
| | | | |
| uword j; | | uword j; | |
|
| for(j=1; j < A_n_rows; j+=2) | | for(j=1; j < A_n_cols; j+=2) | |
| { | | { | |
|
| const eT tmp_i = (*colptr); colptr++; | | const eT tmp_i = (*Aptr); Aptr += A_n_rows; | |
| const eT tmp_j = (*colptr); colptr++; | | const eT tmp_j = (*Aptr); Aptr += A_n_rows; | |
| | | | |
|
| (*outptr) = val * tmp_i; outptr += out_n_rows; | | (*outptr) = val * tmp_i; outptr++; | |
| (*outptr) = val * tmp_j; outptr += out_n_rows; | | (*outptr) = val * tmp_j; outptr++; | |
| } | | } | |
| | | | |
|
| const uword i = j-1; | | if((j-1) < A_n_cols) | |
| | | | |
| if(i < A_n_rows) | | | |
| { | | { | |
|
| (*outptr) = val * (*colptr); colptr++; | | (*outptr) = val * (*Aptr); outptr++;; | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eT, typename TA> | | template<typename eT, typename TA> | |
| arma_hot | | arma_hot | |
| inline | | inline | |
| void | | void | |
| | | | |
| skipping to change at line 659 | | skipping to change at line 647 | |
| | | | |
| out.steal_mem(out2); | | out.steal_mem(out2); | |
| } | | } | |
| } | | } | |
| else // general matrix transpose | | else // general matrix transpose | |
| { | | { | |
| if(is_alias == false) | | if(is_alias == false) | |
| { | | { | |
| out.set_size(n_cols, n_rows); | | out.set_size(n_cols, n_rows); | |
| | | | |
|
| const uword out_n_rows = out.n_rows; | | eT* outptr = out.memptr(); | |
| | | | |
|
| for(uword k=0; k < n_cols; ++k) | | for(uword k=0; k < n_rows; ++k) | |
| { | | { | |
|
| eT* outptr = &(out.at(k,0)); | | | |
| | | | |
| uword j; | | uword j; | |
|
| for(j=1; j < n_rows; j+=2) | | for(j=1; j < n_cols; j+=2) | |
| { | | { | |
| const uword i = j-1; | | const uword i = j-1; | |
| | | | |
|
| const eT tmp_i = P.at(i,k); | | const eT tmp_i = P.at(k,i); | |
| const eT tmp_j = P.at(j,k); | | const eT tmp_j = P.at(k,j); | |
| | | | |
|
| (*outptr) = val * tmp_i; outptr += out_n_rows; | | (*outptr) = val * tmp_i; outptr++; | |
| (*outptr) = val * tmp_j; outptr += out_n_rows; | | (*outptr) = val * tmp_j; outptr++; | |
| } | | } | |
| | | | |
| const uword i = j-1; | | const uword i = j-1; | |
| | | | |
|
| if(i < n_rows) | | if(i < n_cols) | |
| { | | { | |
|
| (*outptr) = val * P.at(i,k); | | (*outptr) = val * P.at(k,i); outptr++; | |
| } | | } | |
| } | | } | |
| } | | } | |
| else // aliasing | | else // aliasing | |
| { | | { | |
| Mat<eT> out2(n_cols, n_rows); | | Mat<eT> out2(n_cols, n_rows); | |
| | | | |
|
| const uword out2_n_rows = out2.n_rows; | | eT* out2ptr = out2.memptr(); | |
| | | | |
|
| for(uword k=0; k < n_cols; ++k) | | for(uword k=0; k < n_rows; ++k) | |
| { | | { | |
|
| eT* out2ptr = &(out2.at(k,0)); | | | |
| | | | |
| uword j; | | uword j; | |
|
| for(j=1; j < n_rows; j+=2) | | for(j=1; j < n_cols; j+=2) | |
| { | | { | |
| const uword i = j-1; | | const uword i = j-1; | |
| | | | |
|
| const eT tmp_i = P.at(i,k); | | const eT tmp_i = P.at(k,i); | |
| const eT tmp_j = P.at(j,k); | | const eT tmp_j = P.at(k,j); | |
| | | | |
|
| (*out2ptr) = val * tmp_i; out2ptr += out2_n_rows; | | (*out2ptr) = val * tmp_i; out2ptr++; | |
| (*out2ptr) = val * tmp_j; out2ptr += out2_n_rows; | | (*out2ptr) = val * tmp_j; out2ptr++; | |
| } | | } | |
| | | | |
| const uword i = j-1; | | const uword i = j-1; | |
| | | | |
|
| if(i < n_rows) | | if(i < n_cols) | |
| { | | { | |
|
| (*out2ptr) = val * P.at(i,k); | | (*out2ptr) = val * P.at(k,i); out2ptr++; | |
| } | | } | |
| } | | } | |
| | | | |
| out.steal_mem(out2); | | out.steal_mem(out2); | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 49 change blocks. |
| 74 lines changed or deleted | | 58 lines changed or added | |
|