| Mat_meat.hpp | | Mat_meat.hpp | |
|
| // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2008-2010 Conrad Sanderson | | // Copyright (C) 2008-2011 Conrad Sanderson | |
| // | | // | |
| // This file is part of the Armadillo C++ library. | | // This file is part of the Armadillo C++ library. | |
| // It is provided without any warranty of fitness | | // It is provided without any warranty of fitness | |
| // for any purpose. You can redistribute this file | | // for any purpose. You can redistribute this file | |
| // and/or modify it under the terms of the GNU | | // and/or modify it under the terms of the GNU | |
| // Lesser General Public License (LGPL) as published | | // Lesser General Public License (LGPL) as published | |
| // by the Free Software Foundation, either version 3 | | // by the Free Software Foundation, either version 3 | |
| // of the License or (at your option) any later version. | | // of the License or (at your option) any later version. | |
| // (see http://www.opensource.org/licenses for more info) | | // (see http://www.opensource.org/licenses for more info) | |
| | | | |
| | | | |
| skipping to change at line 24 | | skipping to change at line 24 | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Mat<eT>::~Mat() | | Mat<eT>::~Mat() | |
| { | | { | |
| arma_extra_debug_sigprint_this(this); | | arma_extra_debug_sigprint_this(this); | |
| | | | |
| if(mem_state == 0) | | if(mem_state == 0) | |
| { | | { | |
|
| if(n_elem > Mat_prealloc::mem_n_elem) | | if(n_elem > arma_config::mat_prealloc) | |
| { | | { | |
| delete [] mem; | | delete [] mem; | |
| } | | } | |
| } | | } | |
| | | | |
| if(arma_config::debug == true) | | if(arma_config::debug == true) | |
| { | | { | |
| // try to expose buggy user code that accesses deleted objects | | // try to expose buggy user code that accesses deleted objects | |
| access::rw(n_rows) = 0; | | access::rw(n_rows) = 0; | |
| access::rw(n_cols) = 0; | | access::rw(n_cols) = 0; | |
| | | | |
| skipping to change at line 126 | | skipping to change at line 126 | |
| else | | else | |
| { | | { | |
| arma_debug_check | | arma_debug_check | |
| ( | | ( | |
| (t_mem_state == 2), | | (t_mem_state == 2), | |
| "Mat::init(): requested size is not compatible with the size of aux
iliary memory" | | "Mat::init(): requested size is not compatible with the size of aux
iliary memory" | |
| ); | | ); | |
| | | | |
| if(t_mem_state == 0) | | if(t_mem_state == 0) | |
| { | | { | |
|
| if(old_n_elem > Mat_prealloc::mem_n_elem ) | | if(old_n_elem > arma_config::mat_prealloc) | |
| { | | { | |
| arma_extra_debug_print("Mat::init(): freeing memory"); | | arma_extra_debug_print("Mat::init(): freeing memory"); | |
| | | | |
| delete [] mem; | | delete [] mem; | |
| } | | } | |
| } | | } | |
| | | | |
|
| if(new_n_elem <= Mat_prealloc::mem_n_elem ) | | if(new_n_elem <= arma_config::mat_prealloc) | |
| { | | { | |
| access::rw(mem) = mem_local; | | access::rw(mem) = mem_local; | |
| } | | } | |
| else | | else | |
| { | | { | |
| arma_extra_debug_print("Mat::init(): allocating memory"); | | arma_extra_debug_print("Mat::init(): allocating memory"); | |
| | | | |
| access::rw(mem) = new(std::nothrow) eT[new_n_elem]; | | access::rw(mem) = new(std::nothrow) eT[new_n_elem]; | |
| | | | |
| arma_check( (mem == 0), "Mat::init(): out of memory" ); | | arma_check( (mem == 0), "Mat::init(): out of memory" ); | |
| | | | |
| skipping to change at line 419 | | skipping to change at line 419 | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| Mat<eT>::init(const Mat<eT>& x) | | Mat<eT>::init(const Mat<eT>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| if(this != &x) | | if(this != &x) | |
| { | | { | |
| init(x.n_rows, x.n_cols); | | init(x.n_rows, x.n_cols); | |
|
| syslib::copy_elem( memptr(), x.mem, x.n_elem ); | | arrayops::copy( memptr(), x.mem, x.n_elem ); | |
| } | | } | |
| } | | } | |
| | | | |
| //! for constructing a complex matrix out of two non-complex matrices | | //! for constructing a complex matrix out of two non-complex matrices | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| void | | void | |
| Mat<eT>::init | | Mat<eT>::init | |
| ( | | ( | |
| | | | |
| skipping to change at line 501 | | skipping to change at line 501 | |
| { | | { | |
| layout_ok = true; | | layout_ok = true; | |
| } | | } | |
| | | | |
| if( (t_vec_state == 2) && ( x_n_rows <= 1) ) | | if( (t_vec_state == 2) && ( x_n_rows <= 1) ) | |
| { | | { | |
| layout_ok = true; | | layout_ok = true; | |
| } | | } | |
| } | | } | |
| | | | |
|
| if( (x_mem_state == 0) && (x_n_elem > Mat_prealloc::mem_n_elem) && (lay
out_ok == true) ) | | if( (x_mem_state == 0) && (x_n_elem > arma_config::mat_prealloc) && (la
yout_ok == true) ) | |
| { | | { | |
| reset(); | | reset(); | |
| | | | |
| access::rw(n_rows) = x_n_rows; | | access::rw(n_rows) = x_n_rows; | |
| access::rw(n_cols) = x_n_cols; | | access::rw(n_cols) = x_n_cols; | |
| access::rw(n_elem) = x_n_elem; | | access::rw(n_elem) = x_n_elem; | |
| access::rw(mem) = x.mem; | | access::rw(mem) = x.mem; | |
| | | | |
| access::rw(x.n_rows) = 0; | | access::rw(x.n_rows) = 0; | |
| access::rw(x.n_cols) = 0; | | access::rw(x.n_cols) = 0; | |
| | | | |
| skipping to change at line 543 | | skipping to change at line 543 | |
| , vec_state( 0 ) | | , vec_state( 0 ) | |
| , mem_state(copy_aux_mem ? 0 : ( strict ? 2 : 1 ) ) | | , mem_state(copy_aux_mem ? 0 : ( strict ? 2 : 1 ) ) | |
| , mem (copy_aux_mem ? mem : aux_mem ) | | , mem (copy_aux_mem ? mem : aux_mem ) | |
| { | | { | |
| arma_extra_debug_sigprint_this(this); | | arma_extra_debug_sigprint_this(this); | |
| | | | |
| if(copy_aux_mem == true) | | if(copy_aux_mem == true) | |
| { | | { | |
| init(aux_n_rows, aux_n_cols); | | init(aux_n_rows, aux_n_cols); | |
| | | | |
|
| syslib::copy_elem( memptr(), aux_mem, n_elem ); | | arrayops::copy( memptr(), aux_mem, n_elem ); | |
| } | | } | |
| } | | } | |
| | | | |
| //! construct a matrix from a given auxiliary read-only array of eTs. | | //! construct a matrix from a given auxiliary read-only array of eTs. | |
| //! the array is copied. | | //! the array is copied. | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Mat<eT>::Mat(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols) | | Mat<eT>::Mat(const eT* aux_mem, const u32 aux_n_rows, const u32 aux_n_cols) | |
| : n_rows(0) | | : n_rows(0) | |
| , n_cols(0) | | , n_cols(0) | |
| , n_elem(0) | | , n_elem(0) | |
| , vec_state(0) | | , vec_state(0) | |
| , mem_state(0) | | , mem_state(0) | |
| //, mem(0) | | //, mem(0) | |
| , mem(mem) | | , mem(mem) | |
| { | | { | |
| arma_extra_debug_sigprint_this(this); | | arma_extra_debug_sigprint_this(this); | |
| | | | |
| init(aux_n_rows, aux_n_cols); | | init(aux_n_rows, aux_n_cols); | |
| | | | |
|
| syslib::copy_elem( memptr(), aux_mem, n_elem ); | | arrayops::copy( memptr(), aux_mem, n_elem ); | |
| } | | } | |
| | | | |
| //! DANGEROUS! Construct a temporary matrix, using auxiliary memory. | | //! DANGEROUS! Construct a temporary matrix, using auxiliary memory. | |
| //! This constructor is NOT intended for usage by user code. | | //! This constructor is NOT intended for usage by user code. | |
| //! Its sole purpose is to be used by the Cube class. | | //! Its sole purpose is to be used by the Cube class. | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| Mat<eT>::Mat(const char junk, const eT* aux_mem, const u32 aux_n_rows, cons
t u32 aux_n_cols) | | Mat<eT>::Mat(const char junk, const eT* aux_mem, const u32 aux_n_rows, cons
t u32 aux_n_cols) | |
| : n_rows (aux_n_rows ) | | : n_rows (aux_n_rows ) | |
| | | | |
| skipping to change at line 3953 | | skipping to change at line 3953 | |
| { | | { | |
| arma_extra_debug_sigprint_this(this); | | arma_extra_debug_sigprint_this(this); | |
| | | | |
| if(fixed_n_elem > 0) | | if(fixed_n_elem > 0) | |
| { | | { | |
| access::rw(Mat<eT>::n_rows) = fixed_n_rows; | | access::rw(Mat<eT>::n_rows) = fixed_n_rows; | |
| access::rw(Mat<eT>::n_cols) = fixed_n_cols; | | access::rw(Mat<eT>::n_cols) = fixed_n_cols; | |
| access::rw(Mat<eT>::n_elem) = fixed_n_elem; | | access::rw(Mat<eT>::n_elem) = fixed_n_elem; | |
| access::rw(Mat<eT>::vec_state) = 0; | | access::rw(Mat<eT>::vec_state) = 0; | |
| access::rw(Mat<eT>::mem_state) = 3; | | access::rw(Mat<eT>::mem_state) = 3; | |
|
| access::rw(Mat<eT>::mem) = (fixed_n_elem > Mat_prealloc::mem_n_el
em) ? mem_local_extra : mem_local; | | access::rw(Mat<eT>::mem) = (fixed_n_elem > arma_config::mat_preal
loc) ? mem_local_extra : mem_local; | |
| } | | } | |
| else | | else | |
| { | | { | |
| access::rw(Mat<eT>::n_rows) = 0; | | access::rw(Mat<eT>::n_rows) = 0; | |
| access::rw(Mat<eT>::n_cols) = 0; | | access::rw(Mat<eT>::n_cols) = 0; | |
| access::rw(Mat<eT>::n_elem) = 0; | | access::rw(Mat<eT>::n_elem) = 0; | |
| access::rw(Mat<eT>::vec_state) = 0; | | access::rw(Mat<eT>::vec_state) = 0; | |
| access::rw(Mat<eT>::mem_state) = 3; | | access::rw(Mat<eT>::mem_state) = 3; | |
| access::rw(Mat<eT>::mem) = 0; | | access::rw(Mat<eT>::mem) = 0; | |
| } | | } | |
| | | | |
End of changes. 9 change blocks. |
| 10 lines changed or deleted | | 10 lines changed or added | |
|
| arrayops_proto.hpp | | arrayops_proto.hpp | |
|
| // Copyright (C) 2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2011 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2010 Conrad Sanderson | | // Copyright (C) 2011 Conrad Sanderson | |
| // | | // | |
| // This file is part of the Armadillo C++ library. | | // This file is part of the Armadillo C++ library. | |
| // It is provided without any warranty of fitness | | // It is provided without any warranty of fitness | |
| // for any purpose. You can redistribute this file | | // for any purpose. You can redistribute this file | |
| // and/or modify it under the terms of the GNU | | // and/or modify it under the terms of the GNU | |
| // Lesser General Public License (LGPL) as published | | // Lesser General Public License (LGPL) as published | |
| // by the Free Software Foundation, either version 3 | | // by the Free Software Foundation, either version 3 | |
| // of the License or (at your option) any later version. | | // of the License or (at your option) any later version. | |
| // (see http://www.opensource.org/licenses for more info) | | // (see http://www.opensource.org/licenses for more info) | |
| | | | |
| //! \addtogroup arrayops | | //! \addtogroup arrayops | |
| //! @{ | | //! @{ | |
| | | | |
| class arrayops | | class arrayops | |
| { | | { | |
| public: | | public: | |
| | | | |
| template<typename eT> | | template<typename eT> | |
|
| arma_hot | | arma_hot inline static void | |
| inline | | copy(eT* dest, const eT* src, const u32 n_elem); | |
| static | | | |
| void | | | |
| inplace_plus(eT* dest, const eT* src, const u32 n_elem) | | | |
| { | | | |
| u32 i,j; | | | |
| | | | |
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| dest[i] += src[i]; | | | |
| dest[j] += src[j]; | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| dest[i] += src[i]; | | | |
| } | | | |
| } | | | |
| | | | |
| template<typename eT> | | | |
| arma_hot | | | |
| inline | | | |
| static | | | |
| void | | | |
| inplace_minus(eT* dest, const eT* src, const u32 n_elem) | | | |
| { | | | |
| u32 i,j; | | | |
| | | | |
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| dest[i] -= src[i]; | | | |
| dest[j] -= src[j]; | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| dest[i] -= src[i]; | | | |
| } | | | |
| } | | | |
| | | | |
| template<typename eT> | | | |
| arma_hot | | | |
| inline | | | |
| static | | | |
| void | | | |
| inplace_mul(eT* dest, const eT* src, const u32 n_elem) | | | |
| { | | | |
| u32 i,j; | | | |
| | | | |
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| dest[i] *= src[i]; | | | |
| dest[j] *= src[j]; | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| dest[i] *= src[i]; | | | |
| } | | | |
| } | | | |
| | | | |
| template<typename eT> | | | |
| arma_hot | | | |
| inline | | | |
| static | | | |
| void | | | |
| inplace_div(eT* dest, const eT* src, const u32 n_elem) | | | |
| { | | | |
| u32 i,j; | | | |
| | | | |
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| dest[i] /= src[i]; | | | |
| dest[j] /= src[j]; | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| dest[i] /= src[i]; | | | |
| } | | | |
| } | | | |
| | | | |
| template<typename eT> | | | |
| arma_hot | | | |
| inline | | | |
| static | | | |
| void | | | |
| inplace_set(eT* dest, const eT val, const u32 n_elem) | | | |
| { | | | |
| u32 i,j; | | | |
| | | | |
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| dest[i] = val; | | | |
| dest[j] = val; | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| dest[i] = val; | | | |
| } | | | |
| } | | | |
| | | | |
| template<typename eT> | | | |
| arma_hot | | | |
| inline | | | |
| static | | | |
| void | | | |
| inplace_plus(eT* dest, const eT val, const u32 n_elem) | | | |
| { | | | |
| u32 i,j; | | | |
| | | | |
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| dest[i] += val; | | | |
| dest[j] += val; | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| dest[i] += val; | | | |
| } | | | |
| } | | | |
| | | | |
| template<typename eT> | | | |
| arma_hot | | | |
| inline | | | |
| static | | | |
| void | | | |
| inplace_minus(eT* dest, const eT val, const u32 n_elem) | | | |
| { | | | |
| u32 i,j; | | | |
| | | | |
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| dest[i] -= val; | | | |
| dest[j] -= val; | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| dest[i] -= val; | | | |
| } | | | |
| } | | | |
| | | | |
| template<typename eT> | | | |
| arma_hot | | | |
| inline | | | |
| static | | | |
| void | | | |
| inplace_mul(eT* dest, const eT val, const u32 n_elem) | | | |
| { | | | |
| u32 i,j; | | | |
| | | | |
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| dest[i] *= val; | | | |
| dest[j] *= val; | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| dest[i] *= val; | | | |
| } | | | |
| } | | | |
| | | | |
| template<typename eT> | | | |
| arma_hot | | | |
| inline | | | |
| static | | | |
| void | | | |
| inplace_div(eT* dest, const eT val, const u32 n_elem) | | | |
| { | | | |
| u32 i,j; | | | |
| | | | |
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| dest[i] /= val; | | | |
| dest[j] /= val; | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| dest[i] /= val; | | | |
| } | | | |
| } | | | |
| | | | |
| template<typename eT> | | | |
| arma_hot | | | |
| arma_pure | | | |
| inline | | | |
| static | | | |
| eT | | | |
| accumulate(const eT* src, const u32 n_elem) | | | |
| { | | | |
| u32 i,j; | | | |
| | | | |
| eT acc1 = eT(0); | | | |
| eT acc2 = eT(0); | | | |
| | | | |
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| acc1 += src[i]; | | | |
| acc2 += src[j]; | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| acc1 += src[i]; | | | |
| } | | | |
| | | | |
| return acc1 + acc2; | | | |
| } | | | |
| | | | |
| template<typename eT> | | | |
| arma_hot | | | |
| arma_pure | | | |
| inline | | | |
| static | | | |
| typename get_pod_type<eT>::result | | | |
| norm_1(const eT* src, const u32 n_elem) | | | |
| { | | | |
| typedef typename get_pod_type<eT>::result T; | | | |
| | | | |
|
| T acc = T(0); | | // | |
| | | // array = convert(array) | |
| | | | |
|
| u32 i,j; | | template<typename out_eT, typename in_eT> | |
| | | arma_hot arma_inline static void | |
| | | convert_cx_scalar(out_eT& out, const in_eT& in, const typename arma_not_ | |
| | | cx<out_eT>::result* junk1 = 0, const typename arma_not_cx< in_eT>::result* | |
| | | junk2 = 0); | |
| | | | |
|
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | template<typename out_eT, typename in_T> | |
| { | | arma_hot arma_inline static void | |
| acc += std::abs(src[i]); | | convert_cx_scalar(out_eT& out, const std::complex<in_T>& in, const typena | |
| acc += std::abs(src[j]); | | me arma_not_cx<out_eT>::result* junk = 0); | |
| } | | | |
| | | | |
|
| if(i < n_elem) | | template<typename out_T, typename in_T> | |
| { | | arma_hot arma_inline static void | |
| acc += std::abs(src[i]); | | convert_cx_scalar(std::complex<out_T>& out, const std::complex< in_T>& in | |
| } | | ); | |
| | | | |
|
| return acc; | | template<typename out_eT, typename in_eT> | |
| } | | arma_hot inline static void | |
| | | convert(out_eT* dest, const in_eT* src, const u32 n_elem); | |
| template<typename eT> | | | |
| arma_hot | | | |
| arma_pure | | | |
| inline | | | |
| static | | | |
| eT | | | |
| norm_2(const eT* src, const u32 n_elem, const typename arma_not_cx<eT>::r | | | |
| esult* junk = 0) | | | |
| { | | | |
| eT acc = eT(0); | | | |
| | | | |
| u32 i,j; | | | |
| | | | |
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| const eT tmp_i = src[i]; | | | |
| const eT tmp_j = src[j]; | | | |
| | | | |
| acc += tmp_i * tmp_i; | | | |
| acc += tmp_j * tmp_j; | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| const eT tmp_i = src[i]; | | | |
| | | | |
|
| acc += tmp_i * tmp_i; | | template<typename out_eT, typename in_eT> | |
| } | | arma_hot inline static void | |
| | | convert_cx(out_eT* dest, const in_eT* src, const u32 n_elem); | |
| | | | |
|
| return std::sqrt(acc); | | // | |
| } | | // array op= array | |
| | | | |
|
| template<typename T> | | template<typename eT> | |
| arma_hot | | arma_hot inline static | |
| arma_pure | | void | |
| inline | | inplace_plus(eT* dest, const eT* src, const u32 n_elem); | |
| static | | | |
| T | | | |
| norm_2(const std::complex<T>* src, const u32 n_elem) | | | |
| { | | | |
| T acc = T(0); | | | |
| | | | |
|
| u32 i,j; | | template<typename eT> | |
| | | arma_hot inline static | |
| | | void | |
| | | inplace_minus(eT* dest, const eT* src, const u32 n_elem); | |
| | | | |
|
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | template<typename eT> | |
| { | | arma_hot inline static | |
| const T tmp_i = std::abs(src[i]); | | void | |
| const T tmp_j = std::abs(src[j]); | | inplace_mul(eT* dest, const eT* src, const u32 n_elem); | |
| | | | |
|
| acc += tmp_i * tmp_i; | | template<typename eT> | |
| acc += tmp_j * tmp_j; | | arma_hot inline static | |
| } | | void | |
| | | inplace_div(eT* dest, const eT* src, const u32 n_elem); | |
| | | | |
|
| if(i < n_elem) | | // | |
| { | | // array op= scalar | |
| const T tmp_i = std::abs(src[i]); | | | |
| | | | |
|
| acc += tmp_i * tmp_i; | | template<typename eT> | |
| } | | arma_hot inline static | |
| | | void | |
| | | inplace_set(eT* dest, const eT val, const u32 n_elem); | |
| | | | |
|
| return std::sqrt(acc); | | template<typename eT> | |
| } | | arma_hot inline static | |
| | | void | |
| | | inplace_plus(eT* dest, const eT val, const u32 n_elem); | |
| | | | |
| template<typename eT> | | template<typename eT> | |
|
| arma_hot | | arma_hot inline static | |
| arma_pure | | void | |
| inline | | inplace_minus(eT* dest, const eT val, const u32 n_elem); | |
| static | | | |
| typename get_pod_type<eT>::result | | | |
| norm_k(const eT* src, const u32 n_elem, const int k) | | | |
| { | | | |
| typedef typename get_pod_type<eT>::result T; | | | |
| | | | |
|
| T acc = T(0); | | template<typename eT> | |
| | | arma_hot inline static void | |
| | | inplace_mul(eT* dest, const eT val, const u32 n_elem); | |
| | | | |
|
| u32 i,j; | | template<typename eT> | |
| | | arma_hot inline static | |
| | | void | |
| | | inplace_div(eT* dest, const eT val, const u32 n_elem); | |
| | | | |
|
| for(i=0, j=1; j<n_elem; i+=2, j+=2) | | // | |
| { | | // scalar = op(array) | |
| acc += std::pow(std::abs(src[i]), k); | | | |
| acc += std::pow(std::abs(src[j]), k); | | | |
| } | | | |
| | | | |
|
| if(i < n_elem) | | template<typename eT> | |
| { | | arma_hot arma_pure inline static | |
| acc += std::pow(std::abs(src[i]), k); | | eT | |
| } | | accumulate(const eT* src, const u32 n_elem); | |
| | | | |
|
| return std::pow(acc, T(1)/T(k)); | | template<typename eT> | |
| } | | arma_hot arma_pure inline static | |
| | | eT | |
| | | product(const eT* src, const u32 n_elem); | |
| | | | |
| template<typename eT> | | template<typename eT> | |
|
| arma_hot | | arma_hot arma_pure inline static | |
| arma_pure | | | |
| inline | | | |
| static | | | |
| typename get_pod_type<eT>::result | | typename get_pod_type<eT>::result | |
|
| norm_max(const eT* src, const u32 n_elem) | | norm_1(const eT* src, const u32 n_elem); | |
| { | | | |
| typedef typename get_pod_type<eT>::result T; | | | |
| | | | |
| T max_val = std::abs(src[0]); | | | |
| | | | |
| u32 i,j; | | | |
| | | | |
| for(i=1, j=2; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| const T tmp_i = std::abs(src[i]); | | | |
| const T tmp_j = std::abs(src[j]); | | | |
| | | | |
| if(max_val < tmp_i) { max_val = tmp_i; } | | | |
| if(max_val < tmp_j) { max_val = tmp_j; } | | | |
| } | | | |
| | | | |
| if(i < n_elem) | | | |
| { | | | |
| const T tmp_i = std::abs(src[i]); | | | |
| | | | |
|
| if(max_val < tmp_i) { max_val = tmp_i; } | | template<typename eT> | |
| } | | arma_hot arma_pure inline static | |
| | | eT | |
| | | norm_2(const eT* src, const u32 n_elem, const typename arma_not_cx<eT>::r | |
| | | esult* junk = 0); | |
| | | | |
|
| return max_val; | | template<typename T> | |
| } | | arma_hot arma_pure inline static | |
| | | T | |
| | | norm_2(const std::complex<T>* src, const u32 n_elem); | |
| | | | |
| template<typename eT> | | template<typename eT> | |
|
| arma_hot | | arma_hot arma_pure inline static | |
| arma_pure | | | |
| inline | | | |
| static | | | |
| typename get_pod_type<eT>::result | | typename get_pod_type<eT>::result | |
|
| norm_min(const eT* src, const u32 n_elem) | | norm_k(const eT* src, const u32 n_elem, const int k); | |
| { | | | |
| typedef typename get_pod_type<eT>::result T; | | | |
| | | | |
| T min_val = std::abs(src[0]); | | | |
| | | | |
| u32 i,j; | | | |
| | | | |
| for(i=1, j=2; j<n_elem; i+=2, j+=2) | | | |
| { | | | |
| const T tmp_i = std::abs(src[i]); | | | |
| const T tmp_j = std::abs(src[j]); | | | |
| | | | |
|
| if(min_val > tmp_i) { min_val = tmp_i; } | | template<typename eT> | |
| if(min_val > tmp_j) { min_val = tmp_j; } | | arma_hot arma_pure inline static | |
| } | | typename get_pod_type<eT>::result | |
| | | norm_max(const eT* src, const u32 n_elem); | |
| if(i < n_elem) | | | |
| { | | | |
| const T tmp_i = std::abs(src[i]); | | | |
| | | | |
| if(min_val > tmp_i) { min_val = tmp_i; } | | | |
| } | | | |
| | | | |
|
| return min_val; | | template<typename eT> | |
| } | | arma_hot arma_pure inline static | |
| | | typename get_pod_type<eT>::result | |
| | | norm_min(const eT* src, const u32 n_elem); | |
| | | | |
| }; | | }; | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 30 change blocks. |
| 370 lines changed or deleted | | 94 lines changed or added | |
|
| auxlib_meat.hpp | | auxlib_meat.hpp | |
|
| // Copyright (C) 2008-2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2008-2010 Conrad Sanderson | | // Copyright (C) 2008-2011 Conrad Sanderson | |
| // Copyright (C) 2009 Edmund Highcock | | // Copyright (C) 2009 Edmund Highcock | |
| // | | // | |
| // This file is part of the Armadillo C++ library. | | // This file is part of the Armadillo C++ library. | |
| // It is provided without any warranty of fitness | | // It is provided without any warranty of fitness | |
| // for any purpose. You can redistribute this file | | // for any purpose. You can redistribute this file | |
| // and/or modify it under the terms of the GNU | | // and/or modify it under the terms of the GNU | |
| // Lesser General Public License (LGPL) as published | | // Lesser General Public License (LGPL) as published | |
| // by the Free Software Foundation, either version 3 | | // by the Free Software Foundation, either version 3 | |
| // of the License or (at your option) any later version. | | // of the License or (at your option) any later version. | |
| // (see http://www.opensource.org/licenses for more info) | | // (see http://www.opensource.org/licenses for more info) | |
| | | | |
| skipping to change at line 1369 | | skipping to change at line 1369 | |
| if(info == 0) | | if(info == 0) | |
| { | | { | |
| work_len = static_cast<blas_int>(access::tmp_real(work[0])); | | work_len = static_cast<blas_int>(access::tmp_real(work[0])); | |
| work.set_size(work_len); | | work.set_size(work_len); | |
| } | | } | |
| | | | |
| lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor
k_len, &info); | | lapack::geqrf(&m, &n, R.memptr(), &m, tau.memptr(), work.memptr(), &wor
k_len, &info); | |
| | | | |
| Q.set_size(R_n_rows, R_n_rows); | | Q.set_size(R_n_rows, R_n_rows); | |
| | | | |
|
| syslib::copy_elem( Q.memptr(), R.memptr(), (std::min)(Q.n_elem, R.n_ele
m) ); | | arrayops::copy( Q.memptr(), R.memptr(), (std::min)(Q.n_elem, R.n_elem)
); | |
| | | | |
| // | | // | |
| // construct R | | // construct R | |
| | | | |
| for(u32 col=0; col < R_n_cols; ++col) | | for(u32 col=0; col < R_n_cols; ++col) | |
| { | | { | |
| for(u32 row=(col+1); row < R_n_rows; ++row) | | for(u32 row=(col+1); row < R_n_rows; ++row) | |
| { | | { | |
| R.at(row,col) = eT(0); | | R.at(row,col) = eT(0); | |
| } | | } | |
| | | | |
| skipping to change at line 1816 | | skipping to change at line 1816 | |
| arma_ignore(S); | | arma_ignore(S); | |
| arma_ignore(V); | | arma_ignore(V); | |
| arma_ignore(X); | | arma_ignore(X); | |
| arma_stop("svd(): need LAPACK"); | | arma_stop("svd(): need LAPACK"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| } | | } | |
| | | | |
|
| //! Solve a system of linear equations | | //! Solve a system of linear equations. | |
| //! Assumes that A.n_rows = A.n_cols | | //! Assumes that A.n_rows = A.n_cols and B.n_rows = A.n_rows | |
| //! and B.n_rows = A.n_rows | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| bool | | bool | |
|
| auxlib::solve(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B) | | auxlib::solve(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| if(A.is_empty() || B.is_empty()) | | if(A.is_empty() || B.is_empty()) | |
| { | | { | |
| out.reset(); | | out.reset(); | |
| return false; | | return false; | |
| } | | } | |
| | | | |
| #if defined(ARMA_USE_LAPACK) | | #if defined(ARMA_USE_LAPACK) | |
| { | | { | |
| blas_int n = A.n_rows; | | blas_int n = A.n_rows; | |
| blas_int lda = A.n_rows; | | blas_int lda = A.n_rows; | |
| blas_int ldb = A.n_rows; | | blas_int ldb = A.n_rows; | |
| blas_int nrhs = B.n_cols; | | blas_int nrhs = B.n_cols; | |
| blas_int info; | | blas_int info; | |
| | | | |
| podarray<blas_int> ipiv(n); | | podarray<blas_int> ipiv(n); | |
| | | | |
| out = B; | | out = B; | |
|
| Mat<eT> A_copy = A; | | | |
| | | | |
|
| lapack::gesv<eT>(&n, &nrhs, A_copy.memptr(), &lda, ipiv.memptr(), out.m
emptr(), &ldb, &info); | | lapack::gesv<eT>(&n, &nrhs, A.memptr(), &lda, ipiv.memptr(), out.memptr
(), &ldb, &info); | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(out); | | arma_ignore(out); | |
| arma_ignore(A); | | arma_ignore(A); | |
| arma_ignore(B); | | arma_ignore(B); | |
| arma_stop("solve(): need LAPACK"); | | arma_stop("solve(): need LAPACK"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| //! Solve an over-determined system. | | //! Solve an over-determined system. | |
|
| //! Assumes that A.n_rows > A.n_cols | | //! Assumes that A.n_rows > A.n_cols and B.n_rows = A.n_rows | |
| //! and B.n_rows = A.n_rows | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| bool | | bool | |
|
| auxlib::solve_od(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B) | | auxlib::solve_od(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| if(A.is_empty() || B.is_empty()) | | if(A.is_empty() || B.is_empty()) | |
| { | | { | |
| out.reset(); | | out.reset(); | |
| return false; | | return false; | |
| } | | } | |
| | | | |
| #if defined(ARMA_USE_LAPACK) | | #if defined(ARMA_USE_LAPACK) | |
| | | | |
| skipping to change at line 1888 | | skipping to change at line 1885 | |
| char trans = 'N'; | | char trans = 'N'; | |
| | | | |
| blas_int m = A.n_rows; | | blas_int m = A.n_rows; | |
| blas_int n = A.n_cols; | | blas_int n = A.n_cols; | |
| blas_int lda = A.n_rows; | | blas_int lda = A.n_rows; | |
| blas_int ldb = A.n_rows; | | blas_int ldb = A.n_rows; | |
| blas_int nrhs = B.n_cols; | | blas_int nrhs = B.n_cols; | |
| blas_int lwork = n + (std::max)(n, nrhs); | | blas_int lwork = n + (std::max)(n, nrhs); | |
| blas_int info; | | blas_int info; | |
| | | | |
|
| Mat<eT> A_copy = A; | | Mat<eT> tmp = B; | |
| Mat<eT> tmp = B; | | | |
| | | | |
| podarray<eT> work(lwork); | | podarray<eT> work(lwork); | |
| | | | |
| arma_extra_debug_print("lapack::gels()"); | | arma_extra_debug_print("lapack::gels()"); | |
| | | | |
|
| // NOTE: | | // NOTE: the dgels() function in the lapack library supplied by ATLAS 3 | |
| // the dgels() function in the lapack library supplied by ATLAS 3.6 | | .6 seems to have problems | |
| // seems to have problems | | | |
| | | | |
| lapack::gels<eT> | | lapack::gels<eT> | |
| ( | | ( | |
| &trans, &m, &n, &nrhs, | | &trans, &m, &n, &nrhs, | |
|
| A_copy.memptr(), &lda, | | A.memptr(), &lda, | |
| tmp.memptr(), &ldb, | | tmp.memptr(), &ldb, | |
| work.memptr(), &lwork, | | work.memptr(), &lwork, | |
| &info | | &info | |
| ); | | ); | |
| | | | |
| arma_extra_debug_print("lapack::gels() -- finished"); | | arma_extra_debug_print("lapack::gels() -- finished"); | |
| | | | |
| out.set_size(A.n_cols, B.n_cols); | | out.set_size(A.n_cols, B.n_cols); | |
| | | | |
| for(u32 col=0; col<B.n_cols; ++col) | | for(u32 col=0; col<B.n_cols; ++col) | |
| { | | { | |
|
| syslib::copy_elem( out.colptr(col), tmp.colptr(col), A.n_cols ); | | arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); | |
| } | | } | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(out); | | arma_ignore(out); | |
| arma_ignore(A); | | arma_ignore(A); | |
| arma_ignore(B); | | arma_ignore(B); | |
|
| arma_stop("auxlib::solve_od(): need LAPACK"); | | arma_stop("solve(): need LAPACK"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| //! Solve an under-determined system. | | //! Solve an under-determined system. | |
|
| //! Assumes that A.n_rows < A.n_cols | | //! Assumes that A.n_rows < A.n_cols and B.n_rows = A.n_rows | |
| //! and B.n_rows = A.n_rows | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| bool | | bool | |
|
| auxlib::solve_ud(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B) | | auxlib::solve_ud(Mat<eT>& out, Mat<eT>& A, const Mat<eT>& B) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| if(A.is_empty() || B.is_empty()) | | if(A.is_empty() || B.is_empty()) | |
| { | | { | |
| out.reset(); | | out.reset(); | |
| return false; | | return false; | |
| } | | } | |
| | | | |
| #if defined(ARMA_USE_LAPACK) | | #if defined(ARMA_USE_LAPACK) | |
| | | | |
| skipping to change at line 1958 | | skipping to change at line 1951 | |
| char trans = 'N'; | | char trans = 'N'; | |
| | | | |
| blas_int m = A.n_rows; | | blas_int m = A.n_rows; | |
| blas_int n = A.n_cols; | | blas_int n = A.n_cols; | |
| blas_int lda = A.n_rows; | | blas_int lda = A.n_rows; | |
| blas_int ldb = A.n_cols; | | blas_int ldb = A.n_cols; | |
| blas_int nrhs = B.n_cols; | | blas_int nrhs = B.n_cols; | |
| blas_int lwork = m + (std::max)(m,nrhs); | | blas_int lwork = m + (std::max)(m,nrhs); | |
| blas_int info; | | blas_int info; | |
| | | | |
|
| Mat<eT> A_copy = A; | | | |
| | | | |
| Mat<eT> tmp; | | Mat<eT> tmp; | |
| tmp.zeros(A.n_cols, B.n_cols); | | tmp.zeros(A.n_cols, B.n_cols); | |
| | | | |
| for(u32 col=0; col<B.n_cols; ++col) | | for(u32 col=0; col<B.n_cols; ++col) | |
| { | | { | |
| eT* tmp_colmem = tmp.colptr(col); | | eT* tmp_colmem = tmp.colptr(col); | |
| | | | |
|
| syslib::copy_elem( tmp_colmem, B.colptr(col), B.n_rows ); | | arrayops::copy( tmp_colmem, B.colptr(col), B.n_rows ); | |
| | | | |
| for(u32 row=B.n_rows; row<A.n_cols; ++row) | | for(u32 row=B.n_rows; row<A.n_cols; ++row) | |
| { | | { | |
| tmp_colmem[row] = eT(0); | | tmp_colmem[row] = eT(0); | |
| } | | } | |
| } | | } | |
| | | | |
| podarray<eT> work(lwork); | | podarray<eT> work(lwork); | |
| | | | |
| arma_extra_debug_print("lapack::gels()"); | | arma_extra_debug_print("lapack::gels()"); | |
| | | | |
|
| // NOTE: | | // NOTE: the dgels() function in the lapack library supplied by ATLAS 3 | |
| // the dgels() function in the lapack library supplied by ATLAS 3.6 | | .6 seems to have problems | |
| // seems to have problems | | | |
| | | | |
| lapack::gels<eT> | | lapack::gels<eT> | |
| ( | | ( | |
| &trans, &m, &n, &nrhs, | | &trans, &m, &n, &nrhs, | |
|
| A_copy.memptr(), &lda, | | A.memptr(), &lda, | |
| tmp.memptr(), &ldb, | | tmp.memptr(), &ldb, | |
| work.memptr(), &lwork, | | work.memptr(), &lwork, | |
| &info | | &info | |
| ); | | ); | |
| | | | |
| arma_extra_debug_print("lapack::gels() -- finished"); | | arma_extra_debug_print("lapack::gels() -- finished"); | |
| | | | |
| out.set_size(A.n_cols, B.n_cols); | | out.set_size(A.n_cols, B.n_cols); | |
| | | | |
| for(u32 col=0; col<B.n_cols; ++col) | | for(u32 col=0; col<B.n_cols; ++col) | |
| { | | { | |
|
| syslib::copy_elem( out.colptr(col), tmp.colptr(col), A.n_cols ); | | arrayops::copy( out.colptr(col), tmp.colptr(col), A.n_cols ); | |
| } | | } | |
| | | | |
| return (info == 0); | | return (info == 0); | |
| } | | } | |
| #else | | #else | |
| { | | { | |
| arma_ignore(out); | | arma_ignore(out); | |
| arma_ignore(A); | | arma_ignore(A); | |
| arma_ignore(B); | | arma_ignore(B); | |
|
| arma_stop("auxlib::solve_ud(): need LAPACK"); | | arma_stop("solve(): need LAPACK"); | |
| return false; | | return false; | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| // | | // | |
| // solve_tr | | // solve_tr | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| | | | |
End of changes. 21 change blocks. |
| 32 lines changed or deleted | | 23 lines changed or added | |
|
| fn_conv_to.hpp | | fn_conv_to.hpp | |
| | | | |
| skipping to change at line 75 | | skipping to change at line 75 | |
| | | | |
| arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply(
); | | arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply(
); | |
| | | | |
| const unwrap<T1> tmp(in.get_ref()); | | const unwrap<T1> tmp(in.get_ref()); | |
| const Mat<in_eT>& X = tmp.M; | | const Mat<in_eT>& X = tmp.M; | |
| | | | |
| arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have
exactly one element" ); | | arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have
exactly one element" ); | |
| | | | |
| out_eT out; | | out_eT out; | |
| | | | |
|
| syslib::convert_cx_scalar(out, X.mem[0]); | | arrayops::convert_cx_scalar(out, X.mem[0]); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT, typename T1> | | template<typename in_eT, typename T1> | |
| inline | | inline | |
| out_eT | | out_eT | |
| conv_to<out_eT>::from(const BaseCube<in_eT, T1>& in, const typename arma_no
t_cx<in_eT>::result* junk) | | conv_to<out_eT>::from(const BaseCube<in_eT, T1>& in, const typename arma_no
t_cx<in_eT>::result* junk) | |
| { | | { | |
| | | | |
| skipping to change at line 119 | | skipping to change at line 119 | |
| | | | |
| arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply(
); | | arma_type_check< is_supported_elem_type<out_eT>::value == false >::apply(
); | |
| | | | |
| const unwrap_cube<T1> tmp(in.get_ref()); | | const unwrap_cube<T1> tmp(in.get_ref()); | |
| const Cube<in_eT>& X = tmp.M; | | const Cube<in_eT>& X = tmp.M; | |
| | | | |
| arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have
exactly one element" ); | | arma_debug_check( (X.n_elem != 1), "conv_to(): given object doesn't have
exactly one element" ); | |
| | | | |
| out_eT out; | | out_eT out; | |
| | | | |
|
| syslib::convert_cx_scalar(out, X.mem[0]); | | arrayops::convert_cx_scalar(out, X.mem[0]); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| //! conversion to Armadillo matrices from Armadillo Base objects, | | //! conversion to Armadillo matrices from Armadillo Base objects, | |
| //! as well as from std::vector, itpp::Mat and itpp::Vec | | //! as well as from std::vector, itpp::Mat and itpp::Vec | |
| template<typename out_eT> | | template<typename out_eT> | |
| class conv_to< Mat<out_eT> > | | class conv_to< Mat<out_eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| skipping to change at line 171 | | skipping to change at line 171 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap<T1> tmp(in.get_ref()); | | const unwrap<T1> tmp(in.get_ref()); | |
| const Mat<in_eT>& X = tmp.M; | | const Mat<in_eT>& X = tmp.M; | |
| | | | |
| Mat<out_eT> out(X.n_rows, X.n_cols); | | Mat<out_eT> out(X.n_rows, X.n_cols); | |
| | | | |
|
| syslib::copy_and_convert_elem( out.memptr(), X.memptr(), out.n_elem ); | | arrayops::convert( out.memptr(), X.memptr(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT, typename T1> | | template<typename in_eT, typename T1> | |
| inline | | inline | |
| Mat<out_eT> | | Mat<out_eT> | |
| conv_to< Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma
_cx_only<in_eT>::result* junk) | | conv_to< Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma
_cx_only<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap<T1> tmp(in.get_ref()); | | const unwrap<T1> tmp(in.get_ref()); | |
| const Mat<in_eT>& X = tmp.M; | | const Mat<in_eT>& X = tmp.M; | |
| | | | |
| Mat<out_eT> out(X.n_rows, X.n_cols); | | Mat<out_eT> out(X.n_rows, X.n_cols); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out.memptr(), X.memptr(), out.n_elem ); | | arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Mat<out_eT> | | Mat<out_eT> | |
| conv_to< Mat<out_eT> >::from(const std::vector<in_eT>& in, const typename a
rma_not_cx<in_eT>::result* junk) | | conv_to< Mat<out_eT> >::from(const std::vector<in_eT>& in, const typename a
rma_not_cx<in_eT>::result* junk) | |
| { | | { | |
| | | | |
| skipping to change at line 251 | | skipping to change at line 251 | |
| typename Mat<out_eT>::iterator out_end = out.end(); | | typename Mat<out_eT>::iterator out_end = out.end(); | |
| | | | |
| typename std::vector<in_eT>::const_iterator in_it; | | typename std::vector<in_eT>::const_iterator in_it; | |
| typename Mat<out_eT>::iterator out_it; | | typename Mat<out_eT>::iterator out_it; | |
| | | | |
| for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it !=
out_end); ++in_it, ++out_it) | | for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it !=
out_end); ++in_it, ++out_it) | |
| { | | { | |
| out_eT& out_elem = (*out_it); | | out_eT& out_elem = (*out_it); | |
| const in_eT& in_elem = (*in_it); | | const in_eT& in_elem = (*in_it); | |
| | | | |
|
| syslib::convert_cx_scalar(out_elem, in_elem); | | arrayops::convert_cx_scalar(out_elem, in_elem); | |
| } | | } | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Mat<out_eT> | | Mat<out_eT> | |
| conv_to< Mat<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | | conv_to< Mat<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| Mat<out_eT> out(in.rows(), in.cols()); | | Mat<out_eT> out(in.rows(), in.cols()); | |
| | | | |
|
| syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Mat<out_eT> | | Mat<out_eT> | |
| conv_to< Mat<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | | conv_to< Mat<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| Mat<out_eT> out(in.rows(), in.cols()); | | Mat<out_eT> out(in.rows(), in.cols()); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert_cx( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Mat<out_eT> | | Mat<out_eT> | |
| conv_to< Mat<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | | conv_to< Mat<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| Mat<out_eT> out(in.length(), 1); | | Mat<out_eT> out(in.length(), 1); | |
| | | | |
|
| syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Mat<out_eT> | | Mat<out_eT> | |
| conv_to< Mat<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | | conv_to< Mat<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| Mat<out_eT> out(in.length(), 1); | | Mat<out_eT> out(in.length(), 1); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert_cx( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| //! conversion to Armadillo row vectors from Armadillo Base objects, | | //! conversion to Armadillo row vectors from Armadillo Base objects, | |
| //! as well as from std::vector, itpp::Mat and itpp::Vec | | //! as well as from std::vector, itpp::Mat and itpp::Vec | |
| template<typename out_eT> | | template<typename out_eT> | |
| class conv_to< Row<out_eT> > | | class conv_to< Row<out_eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| skipping to change at line 374 | | skipping to change at line 374 | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap<T1> tmp(in.get_ref()); | | const unwrap<T1> tmp(in.get_ref()); | |
| const Mat<in_eT>& X = tmp.M; | | const Mat<in_eT>& X = tmp.M; | |
| | | | |
| arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" ); | | arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" ); | |
| | | | |
| Row<out_eT> out(X.n_elem); | | Row<out_eT> out(X.n_elem); | |
| | | | |
|
| syslib::copy_and_convert_elem( out.memptr(), X.memptr(), out.n_elem ); | | arrayops::convert( out.memptr(), X.memptr(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT, typename T1> | | template<typename in_eT, typename T1> | |
| inline | | inline | |
| Row<out_eT> | | Row<out_eT> | |
| conv_to< Row<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma
_cx_only<in_eT>::result* junk) | | conv_to< Row<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma
_cx_only<in_eT>::result* junk) | |
| { | | { | |
| | | | |
| skipping to change at line 396 | | skipping to change at line 396 | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap<T1> tmp(in.get_ref()); | | const unwrap<T1> tmp(in.get_ref()); | |
| const Mat<in_eT>& X = tmp.M; | | const Mat<in_eT>& X = tmp.M; | |
| | | | |
| arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" ); | | arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" ); | |
| | | | |
| Row<out_eT> out(X.n_rows, X.n_cols); | | Row<out_eT> out(X.n_rows, X.n_cols); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out.memptr(), X.memptr(), out.n_elem ); | | arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Row<out_eT> | | Row<out_eT> | |
| conv_to< Row<out_eT> >::from(const std::vector<in_eT>& in, const typename a
rma_not_cx<in_eT>::result* junk) | | conv_to< Row<out_eT> >::from(const std::vector<in_eT>& in, const typename a
rma_not_cx<in_eT>::result* junk) | |
| { | | { | |
| | | | |
| skipping to change at line 456 | | skipping to change at line 456 | |
| typename Col<out_eT>::iterator out_end = out.end(); | | typename Col<out_eT>::iterator out_end = out.end(); | |
| | | | |
| typename std::vector<in_eT>::const_iterator in_it; | | typename std::vector<in_eT>::const_iterator in_it; | |
| typename Col<out_eT>::iterator out_it; | | typename Col<out_eT>::iterator out_it; | |
| | | | |
| for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it !=
out_end); ++in_it, ++out_it) | | for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it !=
out_end); ++in_it, ++out_it) | |
| { | | { | |
| out_eT& out_elem = (*out_it); | | out_eT& out_elem = (*out_it); | |
| const in_eT& in_elem = (*in_it); | | const in_eT& in_elem = (*in_it); | |
| | | | |
|
| syslib::convert_cx_scalar(out_elem, in_elem); | | arrayops::convert_cx_scalar(out_elem, in_elem); | |
| } | | } | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Row<out_eT> | | Row<out_eT> | |
| conv_to< Row<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | | conv_to< Row<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | |
| | | | |
| skipping to change at line 478 | | skipping to change at line 478 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) ); | | const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) ); | |
| | | | |
| arma_debug_check( (is_vec == false), "conv_to(): given object can't be in
terpreted as a vector" ); | | arma_debug_check( (is_vec == false), "conv_to(): given object can't be in
terpreted as a vector" ); | |
| | | | |
| Row<out_eT> out(in.rows() * in.cols()); | | Row<out_eT> out(in.rows() * in.cols()); | |
| | | | |
|
| syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Row<out_eT> | | Row<out_eT> | |
| conv_to< Row<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | | conv_to< Row<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) ); | | const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) ); | |
| | | | |
| Row<out_eT> out(in.rows() * in.cols()); | | Row<out_eT> out(in.rows() * in.cols()); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert_cx( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Row<out_eT> | | Row<out_eT> | |
| conv_to< Row<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | | conv_to< Row<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| Row<out_eT> out(in.length()); | | Row<out_eT> out(in.length()); | |
| | | | |
|
| syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Row<out_eT> | | Row<out_eT> | |
| conv_to< Row<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | | conv_to< Row<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| Row<out_eT> out(in.length()); | | Row<out_eT> out(in.length()); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert_cx( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| //! conversion to Armadillo column vectors from Armadillo Base objects, | | //! conversion to Armadillo column vectors from Armadillo Base objects, | |
| //! as well as from std::vector, itpp::Mat and itpp::Vec | | //! as well as from std::vector, itpp::Mat and itpp::Vec | |
| template<typename out_eT> | | template<typename out_eT> | |
| class conv_to< Col<out_eT> > | | class conv_to< Col<out_eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| skipping to change at line 585 | | skipping to change at line 585 | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap<T1> tmp(in.get_ref()); | | const unwrap<T1> tmp(in.get_ref()); | |
| const Mat<in_eT>& X = tmp.M; | | const Mat<in_eT>& X = tmp.M; | |
| | | | |
| arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" ); | | arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" ); | |
| | | | |
| Col<out_eT> out(X.n_elem); | | Col<out_eT> out(X.n_elem); | |
| | | | |
|
| syslib::copy_and_convert_elem( out.memptr(), X.memptr(), out.n_elem ); | | arrayops::convert( out.memptr(), X.memptr(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT, typename T1> | | template<typename in_eT, typename T1> | |
| inline | | inline | |
| Col<out_eT> | | Col<out_eT> | |
| conv_to< Col<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma
_cx_only<in_eT>::result* junk) | | conv_to< Col<out_eT> >::from(const Base<in_eT, T1>& in, const typename arma
_cx_only<in_eT>::result* junk) | |
| { | | { | |
| | | | |
| skipping to change at line 607 | | skipping to change at line 607 | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap<T1> tmp(in.get_ref()); | | const unwrap<T1> tmp(in.get_ref()); | |
| const Mat<in_eT>& X = tmp.M; | | const Mat<in_eT>& X = tmp.M; | |
| | | | |
| arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" ); | | arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" ); | |
| | | | |
| Col<out_eT> out(X.n_rows, X.n_cols); | | Col<out_eT> out(X.n_rows, X.n_cols); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out.memptr(), X.memptr(), out.n_elem ); | | arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Col<out_eT> | | Col<out_eT> | |
| conv_to< Col<out_eT> >::from(const std::vector<in_eT>& in, const typename a
rma_not_cx<in_eT>::result* junk) | | conv_to< Col<out_eT> >::from(const std::vector<in_eT>& in, const typename a
rma_not_cx<in_eT>::result* junk) | |
| { | | { | |
| | | | |
| skipping to change at line 667 | | skipping to change at line 667 | |
| typename Col<out_eT>::iterator out_end = out.end(); | | typename Col<out_eT>::iterator out_end = out.end(); | |
| | | | |
| typename std::vector<in_eT>::const_iterator in_it; | | typename std::vector<in_eT>::const_iterator in_it; | |
| typename Col<out_eT>::iterator out_it; | | typename Col<out_eT>::iterator out_it; | |
| | | | |
| for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it !=
out_end); ++in_it, ++out_it) | | for(in_it = in_begin, out_it = out_begin; (in_it != in_end) && (out_it !=
out_end); ++in_it, ++out_it) | |
| { | | { | |
| out_eT& out_elem = (*out_it); | | out_eT& out_elem = (*out_it); | |
| const in_eT& in_elem = (*in_it); | | const in_eT& in_elem = (*in_it); | |
| | | | |
|
| syslib::convert_cx_scalar(out_elem, in_elem); | | arrayops::convert_cx_scalar(out_elem, in_elem); | |
| } | | } | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Col<out_eT> | | Col<out_eT> | |
| conv_to< Col<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | | conv_to< Col<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | |
| | | | |
| skipping to change at line 689 | | skipping to change at line 689 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) ); | | const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) ); | |
| | | | |
| arma_debug_check( (is_vec == false), "conv_to(): given object can't be in
terpreted as a vector" ); | | arma_debug_check( (is_vec == false), "conv_to(): given object can't be in
terpreted as a vector" ); | |
| | | | |
| Col<out_eT> out(in.rows() * in.cols()); | | Col<out_eT> out(in.rows() * in.cols()); | |
| | | | |
|
| syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Col<out_eT> | | Col<out_eT> | |
| conv_to< Col<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | | conv_to< Col<out_eT> >::from(const itpp::Mat<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) ); | | const bool is_vec = ( (in.rows() == 1) || (in.cols() == 1) ); | |
| | | | |
| Col<out_eT> out(in.rows() * in.cols()); | | Col<out_eT> out(in.rows() * in.cols()); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert_cx( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Col<out_eT> | | Col<out_eT> | |
| conv_to< Col<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | | conv_to< Col<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_not_cx<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| Col<out_eT> out( in.length() ); | | Col<out_eT> out( in.length() ); | |
| | | | |
|
| syslib::copy_and_convert_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT> | | template<typename in_eT> | |
| inline | | inline | |
| Col<out_eT> | | Col<out_eT> | |
| conv_to< Col<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | | conv_to< Col<out_eT> >::from(const itpp::Vec<in_eT>& in, const typename arm
a_cx_only<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| Col<out_eT> out( in.length() ); | | Col<out_eT> out( in.length() ); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out.memptr(), in._data(), out.n_elem ); | | arrayops::convert_cx( out.memptr(), in._data(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| //! conversion to Armadillo cubes from Armadillo BaseCube objects | | //! conversion to Armadillo cubes from Armadillo BaseCube objects | |
| template<typename out_eT> | | template<typename out_eT> | |
| class conv_to< Cube<out_eT> > | | class conv_to< Cube<out_eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| | | | |
| skipping to change at line 775 | | skipping to change at line 775 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap_cube<T1> tmp( in.get_ref() ); | | const unwrap_cube<T1> tmp( in.get_ref() ); | |
| const Cube<in_eT>& X = tmp.M; | | const Cube<in_eT>& X = tmp.M; | |
| | | | |
| Cube<out_eT> out(X.n_rows, X.n_cols, X.n_slices); | | Cube<out_eT> out(X.n_rows, X.n_cols, X.n_slices); | |
| | | | |
|
| syslib::copy_and_convert_elem( out.memptr(), X.memptr(), out.n_elem ); | | arrayops::convert( out.memptr(), X.memptr(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT, typename T1> | | template<typename in_eT, typename T1> | |
| inline | | inline | |
| Cube<out_eT> | | Cube<out_eT> | |
| conv_to< Cube<out_eT> >::from(const BaseCube<in_eT, T1>& in, const typename
arma_cx_only<in_eT>::result* junk) | | conv_to< Cube<out_eT> >::from(const BaseCube<in_eT, T1>& in, const typename
arma_cx_only<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap_cube<T1> tmp( in.get_ref() ); | | const unwrap_cube<T1> tmp( in.get_ref() ); | |
| const Cube<in_eT>& X = tmp.M; | | const Cube<in_eT>& X = tmp.M; | |
| | | | |
| Cube<out_eT> out(X.n_rows, X.n_cols, X.n_slices); | | Cube<out_eT> out(X.n_rows, X.n_cols, X.n_slices); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out.memptr(), X.memptr(), out.n_elem ); | | arrayops::convert_cx( out.memptr(), X.memptr(), out.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| //! conversion to std::vector from Armadillo Base objects | | //! conversion to std::vector from Armadillo Base objects | |
| template<typename out_eT> | | template<typename out_eT> | |
| class conv_to< std::vector<out_eT> > | | class conv_to< std::vector<out_eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| | | | |
| skipping to change at line 878 | | skipping to change at line 878 | |
| typename std::vector<out_eT>::iterator out_end = out.end(); | | typename std::vector<out_eT>::iterator out_end = out.end(); | |
| | | | |
| typename Mat<in_eT>::const_iterator X_it; | | typename Mat<in_eT>::const_iterator X_it; | |
| typename std::vector<out_eT>::iterator out_it; | | typename std::vector<out_eT>::iterator out_it; | |
| | | | |
| for(X_it = X_begin, out_it = out_begin; (X_it != X_end) && (out_it != out
_end); ++X_it, ++out_it) | | for(X_it = X_begin, out_it = out_begin; (X_it != X_end) && (out_it != out
_end); ++X_it, ++out_it) | |
| { | | { | |
| out_eT& out_elem = (*out_it); | | out_eT& out_elem = (*out_it); | |
| const in_eT& X_elem = (*X_it); | | const in_eT& X_elem = (*X_it); | |
| | | | |
|
| syslib::convert_cx_scalar(out_elem, X_elem); | | arrayops::convert_cx_scalar(out_elem, X_elem); | |
| } | | } | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| //! conversion to itpp::Mat from Armadillo Base objects | | //! conversion to itpp::Mat from Armadillo Base objects | |
| template<typename out_eT> | | template<typename out_eT> | |
| class conv_to< itpp::Mat<out_eT> > | | class conv_to< itpp::Mat<out_eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| skipping to change at line 912 | | skipping to change at line 912 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap<T1> tmp( in.get_ref() ); | | const unwrap<T1> tmp( in.get_ref() ); | |
| const Mat<in_eT>& X = tmp.M; | | const Mat<in_eT>& X = tmp.M; | |
| | | | |
| itpp::Mat<out_eT> out(X.n_rows, X.n_cols); | | itpp::Mat<out_eT> out(X.n_rows, X.n_cols); | |
| | | | |
|
| syslib::copy_and_convert_elem( out._data(), X.memptr(), X.n_elem ); | | arrayops::convert( out._data(), X.memptr(), X.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT, typename T1> | | template<typename in_eT, typename T1> | |
| inline | | inline | |
| itpp::Mat<out_eT> | | itpp::Mat<out_eT> | |
| conv_to< itpp::Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typenam
e arma_cx_only<in_eT>::result* junk) | | conv_to< itpp::Mat<out_eT> >::from(const Base<in_eT, T1>& in, const typenam
e arma_cx_only<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap<T1> tmp( in.get_ref() ); | | const unwrap<T1> tmp( in.get_ref() ); | |
| const Mat<in_eT>& X = tmp.M; | | const Mat<in_eT>& X = tmp.M; | |
| | | | |
| itpp::Mat<out_eT> out(X.n_rows, X.n_cols); | | itpp::Mat<out_eT> out(X.n_rows, X.n_cols); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out._data(), X.memptr(), X.n_elem ); | | arrayops::convert_cx( out._data(), X.memptr(), X.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| //! conversion to itpp::Vec from Armadillo Base objects | | //! conversion to itpp::Vec from Armadillo Base objects | |
| template<typename out_eT> | | template<typename out_eT> | |
| class conv_to< itpp::Vec<out_eT> > | | class conv_to< itpp::Vec<out_eT> > | |
| { | | { | |
| public: | | public: | |
| | | | |
| | | | |
| skipping to change at line 967 | | skipping to change at line 967 | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap<T1> tmp( in.get_ref() ); | | const unwrap<T1> tmp( in.get_ref() ); | |
| const Mat<in_eT>& X = tmp.M; | | const Mat<in_eT>& X = tmp.M; | |
| | | | |
| arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" ); | | arma_debug_check( (X.is_vec() == false), "conv_to(): given object can't b
e interpreted as a vector" ); | |
| | | | |
| itpp::Vec<out_eT> out(X.n_elem); | | itpp::Vec<out_eT> out(X.n_elem); | |
| | | | |
|
| syslib::copy_and_convert_elem( out._data(), X.memptr(), X.n_elem ); | | arrayops::convert( out._data(), X.memptr(), X.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| template<typename out_eT> | | template<typename out_eT> | |
| template<typename in_eT, typename T1> | | template<typename in_eT, typename T1> | |
| inline | | inline | |
| itpp::Vec<out_eT> | | itpp::Vec<out_eT> | |
| conv_to< itpp::Vec<out_eT> >::from(const Base<in_eT, T1>& in, const typenam
e arma_cx_only<in_eT>::result* junk) | | conv_to< itpp::Vec<out_eT> >::from(const Base<in_eT, T1>& in, const typenam
e arma_cx_only<in_eT>::result* junk) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| arma_ignore(junk); | | arma_ignore(junk); | |
| | | | |
| const unwrap<T1> tmp( in.get_ref() ); | | const unwrap<T1> tmp( in.get_ref() ); | |
| const Mat<in_eT>& X = tmp.M; | | const Mat<in_eT>& X = tmp.M; | |
| | | | |
| itpp::Vec<out_eT> out(X.n_elem); | | itpp::Vec<out_eT> out(X.n_elem); | |
| | | | |
|
| syslib::copy_and_convert_cx_elem( out._data(), X.memptr(), X.n_elem ); | | arrayops::convert_cx( out._data(), X.memptr(), X.n_elem ); | |
| | | | |
| return out; | | return out; | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 30 change blocks. |
| 30 lines changed or deleted | | 30 lines changed or added | |
|
| subview_cube_meat.hpp | | subview_cube_meat.hpp | |
| | | | |
| skipping to change at line 184 | | skipping to change at line 184 | |
| arma_debug_assert_same_size(t, x, "copy into subcube"); | | arma_debug_assert_same_size(t, x, "copy into subcube"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_n_slices = t.n_slices; | | const u32 t_n_slices = t.n_slices; | |
| | | | |
| for(u32 slice = 0; slice < t_n_slices; ++slice) | | for(u32 slice = 0; slice < t_n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
|
| syslib::copy_elem( t.slice_colptr(slice,col), x.slice_colptr(slice,co
l), t_n_rows ); | | arrayops::copy( t.slice_colptr(slice,col), x.slice_colptr(slice,col),
t_n_rows ); | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
| subview_cube<eT>::operator+= (const BaseCube<eT,T1>& in) | | subview_cube<eT>::operator+= (const BaseCube<eT,T1>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const unwrap_cube<T1> tmp(in.get_ref()); | | const unwrap_cube<T1> tmp(in.get_ref()); | |
| | | | |
| const Cube<eT>& x = tmp.M; | | const Cube<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "cube addition"); | | arma_debug_assert_same_size(t, x, "addition"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_n_slices = t.n_slices; | | const u32 t_n_slices = t.n_slices; | |
| | | | |
| for(u32 slice = 0; slice < t_n_slices; ++slice) | | for(u32 slice = 0; slice < t_n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(sli
ce,col), t_n_rows ); | | arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(sli
ce,col), t_n_rows ); | |
| | | | |
| skipping to change at line 230 | | skipping to change at line 230 | |
| void | | void | |
| subview_cube<eT>::operator-= (const BaseCube<eT,T1>& in) | | subview_cube<eT>::operator-= (const BaseCube<eT,T1>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const unwrap_cube<T1> tmp(in.get_ref()); | | const unwrap_cube<T1> tmp(in.get_ref()); | |
| | | | |
| const Cube<eT>& x = tmp.M; | | const Cube<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "cube subtraction"); | | arma_debug_assert_same_size(t, x, "subtraction"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_n_slices = t.n_slices; | | const u32 t_n_slices = t.n_slices; | |
| | | | |
| for(u32 slice = 0; slice < t_n_slices; ++slice) | | for(u32 slice = 0; slice < t_n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(sl
ice,col), t_n_rows ); | | arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(sl
ice,col), t_n_rows ); | |
| | | | |
| skipping to change at line 258 | | skipping to change at line 258 | |
| void | | void | |
| subview_cube<eT>::operator%= (const BaseCube<eT,T1>& in) | | subview_cube<eT>::operator%= (const BaseCube<eT,T1>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const unwrap_cube<T1> tmp(in.get_ref()); | | const unwrap_cube<T1> tmp(in.get_ref()); | |
| | | | |
| const Cube<eT>& x = tmp.M; | | const Cube<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "cube schur product"); | | arma_debug_assert_same_size(t, x, "element-wise multiplication"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_n_slices = t.n_slices; | | const u32 t_n_slices = t.n_slices; | |
| | | | |
| for(u32 slice = 0; slice < t_n_slices; ++slice) | | for(u32 slice = 0; slice < t_n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slic
e,col), t_n_rows ); | | arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slic
e,col), t_n_rows ); | |
| | | | |
| skipping to change at line 286 | | skipping to change at line 286 | |
| void | | void | |
| subview_cube<eT>::operator/= (const BaseCube<eT,T1>& in) | | subview_cube<eT>::operator/= (const BaseCube<eT,T1>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const unwrap_cube<T1> tmp(in.get_ref()); | | const unwrap_cube<T1> tmp(in.get_ref()); | |
| | | | |
| const Cube<eT>& x = tmp.M; | | const Cube<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "element-wise cube division"); | | arma_debug_assert_same_size(t, x, "element-wise division"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_n_slices = t.n_slices; | | const u32 t_n_slices = t.n_slices; | |
| | | | |
| for(u32 slice = 0; slice < t_n_slices; ++slice) | | for(u32 slice = 0; slice < t_n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slic
e,col), t_n_rows ); | | arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slic
e,col), t_n_rows ); | |
| | | | |
| skipping to change at line 327 | | skipping to change at line 327 | |
| arma_debug_assert_same_size(t, x, "copy into subcube"); | | arma_debug_assert_same_size(t, x, "copy into subcube"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_n_slices = t.n_slices; | | const u32 t_n_slices = t.n_slices; | |
| | | | |
| for(u32 slice = 0; slice < t_n_slices; ++slice) | | for(u32 slice = 0; slice < t_n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
|
| syslib::copy_elem( t.slice_colptr(slice,col), x.slice_colptr(slice,co
l), t_n_rows ); | | arrayops::copy( t.slice_colptr(slice,col), x.slice_colptr(slice,col),
t_n_rows ); | |
| } | | } | |
| } | | } | |
| | | | |
| if(overlap) | | if(overlap) | |
| { | | { | |
| delete tmp_subview_cube; | | delete tmp_subview_cube; | |
| delete tmp_cube; | | delete tmp_cube; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| skipping to change at line 354 | | skipping to change at line 354 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const bool overlap = check_overlap(x_in); | | const bool overlap = check_overlap(x_in); | |
| | | | |
| Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m)
: 0; | | Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m)
: 0; | |
| const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>
(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x
_in.aux_col2, x_in.aux_slice2) : 0; | | const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>
(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x
_in.aux_col2, x_in.aux_slice2) : 0; | |
| const subview_cube<eT>& x = overlap ? (*tmp_subview_cube)
: x_in; | | const subview_cube<eT>& x = overlap ? (*tmp_subview_cube)
: x_in; | |
| | | | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "cube addition"); | | arma_debug_assert_same_size(t, x, "addition"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_n_slices = t.n_slices; | | const u32 t_n_slices = t.n_slices; | |
| | | | |
| for(u32 slice = 0; slice < t_n_slices; ++slice) | | for(u32 slice = 0; slice < t_n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(sli
ce,col), t_n_rows ); | | arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(sli
ce,col), t_n_rows ); | |
| | | | |
| skipping to change at line 391 | | skipping to change at line 391 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const bool overlap = check_overlap(x_in); | | const bool overlap = check_overlap(x_in); | |
| | | | |
| Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m)
: 0; | | Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m)
: 0; | |
| const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>
(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x
_in.aux_col2, x_in.aux_slice2) : 0; | | const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>
(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x
_in.aux_col2, x_in.aux_slice2) : 0; | |
| const subview_cube<eT>& x = overlap ? (*tmp_subview_cube)
: x_in; | | const subview_cube<eT>& x = overlap ? (*tmp_subview_cube)
: x_in; | |
| | | | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "cube subtraction"); | | arma_debug_assert_same_size(t, x, "subtraction"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_n_slices = t.n_slices; | | const u32 t_n_slices = t.n_slices; | |
| | | | |
| for(u32 slice = 0; slice < t_n_slices; ++slice) | | for(u32 slice = 0; slice < t_n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(sl
ice,col), t_n_rows ); | | arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(sl
ice,col), t_n_rows ); | |
| | | | |
| skipping to change at line 428 | | skipping to change at line 428 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const bool overlap = check_overlap(x_in); | | const bool overlap = check_overlap(x_in); | |
| | | | |
| Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m)
: 0; | | Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m)
: 0; | |
| const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>
(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x
_in.aux_col2, x_in.aux_slice2) : 0; | | const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>
(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x
_in.aux_col2, x_in.aux_slice2) : 0; | |
| const subview_cube<eT>& x = overlap ? (*tmp_subview_cube)
: x_in; | | const subview_cube<eT>& x = overlap ? (*tmp_subview_cube)
: x_in; | |
| | | | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "element-wise cube multiplication"); | | arma_debug_assert_same_size(t, x, "element-wise multiplication"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_n_slices = t.n_slices; | | const u32 t_n_slices = t.n_slices; | |
| | | | |
| for(u32 slice = 0; slice < t_n_slices; ++slice) | | for(u32 slice = 0; slice < t_n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slic
e,col), t_n_rows ); | | arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slic
e,col), t_n_rows ); | |
| | | | |
| skipping to change at line 465 | | skipping to change at line 465 | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const bool overlap = check_overlap(x_in); | | const bool overlap = check_overlap(x_in); | |
| | | | |
| Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m)
: 0; | | Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m)
: 0; | |
| const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>
(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x
_in.aux_col2, x_in.aux_slice2) : 0; | | const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>
(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.aux_row2, x
_in.aux_col2, x_in.aux_slice2) : 0; | |
| const subview_cube<eT>& x = overlap ? (*tmp_subview_cube)
: x_in; | | const subview_cube<eT>& x = overlap ? (*tmp_subview_cube)
: x_in; | |
| | | | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "element-wise cube division"); | | arma_debug_assert_same_size(t, x, "element-wise division"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_n_slices = t.n_slices; | | const u32 t_n_slices = t.n_slices; | |
| | | | |
| for(u32 slice = 0; slice < t_n_slices; ++slice) | | for(u32 slice = 0; slice < t_n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slic
e,col), t_n_rows ); | | arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slic
e,col), t_n_rows ); | |
| | | | |
| skipping to change at line 508 | | skipping to change at line 508 | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
| arma_debug_assert_same_size(t, x, "copy into subcube"); | | arma_debug_assert_same_size(t, x, "copy into subcube"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_aux_slice1 = t.aux_slice1; | | const u32 t_aux_slice1 = t.aux_slice1; | |
| | | | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
|
| syslib:copy_elem( t.slice_colptr(t_aux_slice1, col), x.colptr(col), t_n
_rows ); | | arrayops::copy( t.slice_colptr(t_aux_slice1, col), x.colptr(col), t_n_r
ows ); | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| template<typename T1> | | template<typename T1> | |
| inline | | inline | |
| void | | void | |
| subview_cube<eT>::operator+= (const Base<eT,T1>& in) | | subview_cube<eT>::operator+= (const Base<eT,T1>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const unwrap<T1> tmp(in.get_ref()); | | const unwrap<T1> tmp(in.get_ref()); | |
| | | | |
| const Mat<eT>& x = tmp.M; | | const Mat<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "cube addition"); | | arma_debug_assert_same_size(t, x, "addition"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_aux_slice1 = t.aux_slice1; | | const u32 t_aux_slice1 = t.aux_slice1; | |
| | | | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_plus( t.slice_colptr(t_aux_slice1, col), x.colptr(col
), t_n_rows ); | | arrayops::inplace_plus( t.slice_colptr(t_aux_slice1, col), x.colptr(col
), t_n_rows ); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 550 | | skipping to change at line 550 | |
| void | | void | |
| subview_cube<eT>::operator-= (const Base<eT,T1>& in) | | subview_cube<eT>::operator-= (const Base<eT,T1>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const unwrap<T1> tmp(in.get_ref()); | | const unwrap<T1> tmp(in.get_ref()); | |
| | | | |
| const Mat<eT>& x = tmp.M; | | const Mat<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "cube subtraction"); | | arma_debug_assert_same_size(t, x, "subtraction"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_aux_slice1 = t.aux_slice1; | | const u32 t_aux_slice1 = t.aux_slice1; | |
| | | | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_minus( t.slice_colptr(t_aux_slice1, col), x.colptr(co
l), t_n_rows ); | | arrayops::inplace_minus( t.slice_colptr(t_aux_slice1, col), x.colptr(co
l), t_n_rows ); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 575 | | skipping to change at line 575 | |
| void | | void | |
| subview_cube<eT>::operator%= (const Base<eT,T1>& in) | | subview_cube<eT>::operator%= (const Base<eT,T1>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const unwrap<T1> tmp(in.get_ref()); | | const unwrap<T1> tmp(in.get_ref()); | |
| | | | |
| const Mat<eT>& x = tmp.M; | | const Mat<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "cube schur product"); | | arma_debug_assert_same_size(t, x, "element-wise multiplication"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_aux_slice1 = t.aux_slice1; | | const u32 t_aux_slice1 = t.aux_slice1; | |
| | | | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_mul( t.slice_colptr(t_aux_slice1, col), x.colptr(col)
, t_n_rows ); | | arrayops::inplace_mul( t.slice_colptr(t_aux_slice1, col), x.colptr(col)
, t_n_rows ); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 600 | | skipping to change at line 600 | |
| void | | void | |
| subview_cube<eT>::operator/= (const Base<eT,T1>& in) | | subview_cube<eT>::operator/= (const Base<eT,T1>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const unwrap<T1> tmp(in.get_ref()); | | const unwrap<T1> tmp(in.get_ref()); | |
| | | | |
| const Mat<eT>& x = tmp.M; | | const Mat<eT>& x = tmp.M; | |
| subview_cube<eT>& t = *this; | | subview_cube<eT>& t = *this; | |
| | | | |
|
| arma_debug_assert_same_size(t, x, "element-wise cube division"); | | arma_debug_assert_same_size(t, x, "element-wise division"); | |
| | | | |
| const u32 t_n_rows = t.n_rows; | | const u32 t_n_rows = t.n_rows; | |
| const u32 t_n_cols = t.n_cols; | | const u32 t_n_cols = t.n_cols; | |
| const u32 t_aux_slice1 = t.aux_slice1; | | const u32 t_aux_slice1 = t.aux_slice1; | |
| | | | |
| for(u32 col = 0; col < t_n_cols; ++col) | | for(u32 col = 0; col < t_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_div( t.slice_colptr(t_aux_slice1, col), x.colptr(col)
, t_n_rows ); | | arrayops::inplace_div( t.slice_colptr(t_aux_slice1, col), x.colptr(col)
, t_n_rows ); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 865 | | skipping to change at line 865 | |
| const u32 n_slices = in.n_slices; | | const u32 n_slices = in.n_slices; | |
| | | | |
| out.set_size(n_rows, n_cols, n_slices); | | out.set_size(n_rows, n_cols, n_slices); | |
| | | | |
| arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols =
%d out.n_slices = %d in.m.n_rows = %d in.m.n_cols = %d in.m.n_sl
ices = %d") % out.n_rows % out.n_cols % out.n_slices % in.m.n_rows % in.m.n
_cols % in.m.n_slices); | | arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols =
%d out.n_slices = %d in.m.n_rows = %d in.m.n_cols = %d in.m.n_sl
ices = %d") % out.n_rows % out.n_cols % out.n_slices % in.m.n_rows % in.m.n
_cols % in.m.n_slices); | |
| | | | |
| for(u32 slice = 0; slice < n_slices; ++slice) | | for(u32 slice = 0; slice < n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col < n_cols; ++col) | | for(u32 col = 0; col < n_cols; ++col) | |
| { | | { | |
|
| syslib::copy_elem( out.slice_colptr(slice,col), in.slice_colptr(slice
,col), n_rows ); | | arrayops::copy( out.slice_colptr(slice,col), in.slice_colptr(slice,co
l), n_rows ); | |
| } | | } | |
| } | | } | |
| | | | |
| if(alias) | | if(alias) | |
| { | | { | |
| actual_out = out; | | actual_out = out; | |
| delete tmp; | | delete tmp; | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| skipping to change at line 895 | | skipping to change at line 895 | |
| arma_debug_check( (in.n_slices != 1), "subview_cube::extract(): given sub
cube doesn't have exactly one slice" ); | | arma_debug_check( (in.n_slices != 1), "subview_cube::extract(): given sub
cube doesn't have exactly one slice" ); | |
| | | | |
| const u32 n_rows = in.n_rows; | | const u32 n_rows = in.n_rows; | |
| const u32 n_cols = in.n_cols; | | const u32 n_cols = in.n_cols; | |
| const u32 aux_slice1 = in.aux_slice1; | | const u32 aux_slice1 = in.aux_slice1; | |
| | | | |
| out.set_size(n_rows, n_cols); | | out.set_size(n_rows, n_cols); | |
| | | | |
| for(u32 col = 0; col < n_cols; ++col) | | for(u32 col = 0; col < n_cols; ++col) | |
| { | | { | |
|
| syslib::copy_elem( out.colptr(col), in.slice_colptr(aux_slice1, col), n
_rows ); | | arrayops::copy( out.colptr(col), in.slice_colptr(aux_slice1, col), n_ro
ws ); | |
| } | | } | |
| } | | } | |
| | | | |
| //! cube X += Y.subcube(...) | | //! cube X += Y.subcube(...) | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| subview_cube<eT>::plus_inplace(Cube<eT>& out, const subview_cube<eT>& in) | | subview_cube<eT>::plus_inplace(Cube<eT>& out, const subview_cube<eT>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_assert_same_size(out, in, "cube addition"); | | arma_debug_assert_same_size(out, in, "addition"); | |
| | | | |
| const u32 n_rows = out.n_rows; | | const u32 n_rows = out.n_rows; | |
| const u32 n_cols = out.n_cols; | | const u32 n_cols = out.n_cols; | |
| const u32 n_slices = out.n_slices; | | const u32 n_slices = out.n_slices; | |
| | | | |
| for(u32 slice = 0; slice<n_slices; ++slice) | | for(u32 slice = 0; slice<n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col<n_cols; ++col) | | for(u32 col = 0; col<n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_plus( out.slice_colptr(slice,col), in.slice_colptr(
slice,col), n_rows ); | | arrayops::inplace_plus( out.slice_colptr(slice,col), in.slice_colptr(
slice,col), n_rows ); | |
| | | | |
| skipping to change at line 930 | | skipping to change at line 930 | |
| } | | } | |
| | | | |
| //! cube X -= Y.subcube(...) | | //! cube X -= Y.subcube(...) | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| subview_cube<eT>::minus_inplace(Cube<eT>& out, const subview_cube<eT>& in) | | subview_cube<eT>::minus_inplace(Cube<eT>& out, const subview_cube<eT>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_assert_same_size(out, in, "cube subtraction"); | | arma_debug_assert_same_size(out, in, "subtraction"); | |
| | | | |
| const u32 n_rows = out.n_rows; | | const u32 n_rows = out.n_rows; | |
| const u32 n_cols = out.n_cols; | | const u32 n_cols = out.n_cols; | |
| const u32 n_slices = out.n_slices; | | const u32 n_slices = out.n_slices; | |
| | | | |
| for(u32 slice = 0; slice<n_slices; ++slice) | | for(u32 slice = 0; slice<n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col<n_cols; ++col) | | for(u32 col = 0; col<n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_minus( out.slice_colptr(slice,col), in.slice_colptr
(slice,col), n_rows ); | | arrayops::inplace_minus( out.slice_colptr(slice,col), in.slice_colptr
(slice,col), n_rows ); | |
| | | | |
| skipping to change at line 953 | | skipping to change at line 953 | |
| } | | } | |
| | | | |
| //! cube X %= Y.subcube(...) | | //! cube X %= Y.subcube(...) | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| subview_cube<eT>::schur_inplace(Cube<eT>& out, const subview_cube<eT>& in) | | subview_cube<eT>::schur_inplace(Cube<eT>& out, const subview_cube<eT>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_assert_same_size(out, in, "cube schur product"); | | arma_debug_assert_same_size(out, in, "element-wise multiplication"); | |
| | | | |
| const u32 n_rows = out.n_rows; | | const u32 n_rows = out.n_rows; | |
| const u32 n_cols = out.n_cols; | | const u32 n_cols = out.n_cols; | |
| const u32 n_slices = out.n_slices; | | const u32 n_slices = out.n_slices; | |
| | | | |
| for(u32 slice = 0; slice<n_slices; ++slice) | | for(u32 slice = 0; slice<n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col<n_cols; ++col) | | for(u32 col = 0; col<n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_mul( out.slice_colptr(slice,col), in.slice_colptr(s
lice,col), n_rows ); | | arrayops::inplace_mul( out.slice_colptr(slice,col), in.slice_colptr(s
lice,col), n_rows ); | |
| | | | |
| skipping to change at line 976 | | skipping to change at line 976 | |
| } | | } | |
| | | | |
| //! cube X /= Y.subcube(...) | | //! cube X /= Y.subcube(...) | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| subview_cube<eT>::div_inplace(Cube<eT>& out, const subview_cube<eT>& in) | | subview_cube<eT>::div_inplace(Cube<eT>& out, const subview_cube<eT>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_assert_same_size(out, in, "element-wise cube division"); | | arma_debug_assert_same_size(out, in, "element-wise division"); | |
| | | | |
| const u32 n_rows = out.n_rows; | | const u32 n_rows = out.n_rows; | |
| const u32 n_cols = out.n_cols; | | const u32 n_cols = out.n_cols; | |
| const u32 n_slices = out.n_slices; | | const u32 n_slices = out.n_slices; | |
| | | | |
| for(u32 slice = 0; slice<n_slices; ++slice) | | for(u32 slice = 0; slice<n_slices; ++slice) | |
| { | | { | |
| for(u32 col = 0; col<n_cols; ++col) | | for(u32 col = 0; col<n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_div( out.slice_colptr(slice,col), in.slice_colptr(s
lice,col), n_rows ); | | arrayops::inplace_div( out.slice_colptr(slice,col), in.slice_colptr(s
lice,col), n_rows ); | |
| | | | |
| skipping to change at line 999 | | skipping to change at line 999 | |
| } | | } | |
| | | | |
| //! mat X += Y.subcube(...) | | //! mat X += Y.subcube(...) | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| subview_cube<eT>::plus_inplace(Mat<eT>& out, const subview_cube<eT>& in) | | subview_cube<eT>::plus_inplace(Mat<eT>& out, const subview_cube<eT>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_assert_same_size(out, in, "matrix addition"); | | arma_debug_assert_same_size(out, in, "addition"); | |
| | | | |
| const u32 in_n_rows = in.n_rows; | | const u32 in_n_rows = in.n_rows; | |
| const u32 in_n_cols = in.n_cols; | | const u32 in_n_cols = in.n_cols; | |
| const u32 in_aux_slice1 = in.aux_slice1; | | const u32 in_aux_slice1 = in.aux_slice1; | |
| | | | |
| for(u32 col = 0; col < in_n_cols; ++col) | | for(u32 col = 0; col < in_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_plus( out.colptr(col), in.slice_colptr(in_aux_slice1,
col), in_n_rows ); | | arrayops::inplace_plus( out.colptr(col), in.slice_colptr(in_aux_slice1,
col), in_n_rows ); | |
| } | | } | |
| } | | } | |
| | | | |
| //! mat X -= Y.subcube(...) | | //! mat X -= Y.subcube(...) | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| subview_cube<eT>::minus_inplace(Mat<eT>& out, const subview_cube<eT>& in) | | subview_cube<eT>::minus_inplace(Mat<eT>& out, const subview_cube<eT>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_assert_same_size(out, in, "matrix subtraction"); | | arma_debug_assert_same_size(out, in, "subtraction"); | |
| | | | |
| const u32 in_n_rows = in.n_rows; | | const u32 in_n_rows = in.n_rows; | |
| const u32 in_n_cols = in.n_cols; | | const u32 in_n_cols = in.n_cols; | |
| const u32 in_aux_slice1 = in.aux_slice1; | | const u32 in_aux_slice1 = in.aux_slice1; | |
| | | | |
| for(u32 col = 0; col < in_n_cols; ++col) | | for(u32 col = 0; col < in_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_minus( out.colptr(col), in.slice_colptr(in_aux_slice1
, col), in_n_rows ); | | arrayops::inplace_minus( out.colptr(col), in.slice_colptr(in_aux_slice1
, col), in_n_rows ); | |
| } | | } | |
| } | | } | |
| | | | |
| //! mat X %= Y.subcube(...) | | //! mat X %= Y.subcube(...) | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| subview_cube<eT>::schur_inplace(Mat<eT>& out, const subview_cube<eT>& in) | | subview_cube<eT>::schur_inplace(Mat<eT>& out, const subview_cube<eT>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_assert_same_size(out, in, "matrix schur product"); | | arma_debug_assert_same_size(out, in, "element-wise multiplication"); | |
| | | | |
| const u32 in_n_rows = in.n_rows; | | const u32 in_n_rows = in.n_rows; | |
| const u32 in_n_cols = in.n_cols; | | const u32 in_n_cols = in.n_cols; | |
| const u32 in_aux_slice1 = in.aux_slice1; | | const u32 in_aux_slice1 = in.aux_slice1; | |
| | | | |
| for(u32 col = 0; col < in_n_cols; ++col) | | for(u32 col = 0; col < in_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_mul( out.colptr(col), in.slice_colptr(in_aux_slice1,
col), in_n_rows ); | | arrayops::inplace_mul( out.colptr(col), in.slice_colptr(in_aux_slice1,
col), in_n_rows ); | |
| } | | } | |
| } | | } | |
| | | | |
| //! mat X /= Y.subcube(...) | | //! mat X /= Y.subcube(...) | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| void | | void | |
| subview_cube<eT>::div_inplace(Mat<eT>& out, const subview_cube<eT>& in) | | subview_cube<eT>::div_inplace(Mat<eT>& out, const subview_cube<eT>& in) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_assert_same_size(out, in, "matrix element-wise division"); | | arma_debug_assert_same_size(out, in, "element-wise division"); | |
| | | | |
| const u32 in_n_rows = in.n_rows; | | const u32 in_n_rows = in.n_rows; | |
| const u32 in_n_cols = in.n_cols; | | const u32 in_n_cols = in.n_cols; | |
| const u32 in_aux_slice1 = in.aux_slice1; | | const u32 in_aux_slice1 = in.aux_slice1; | |
| | | | |
| for(u32 col = 0; col < in_n_cols; ++col) | | for(u32 col = 0; col < in_n_cols; ++col) | |
| { | | { | |
| arrayops::inplace_div( out.colptr(col), in.slice_colptr(in_aux_slice1,
col), in_n_rows ); | | arrayops::inplace_div( out.colptr(col), in.slice_colptr(in_aux_slice1,
col), in_n_rows ); | |
| } | | } | |
| } | | } | |
| | | | |
End of changes. 25 change blocks. |
| 25 lines changed or deleted | | 25 lines changed or added | |
|