| SpMat_meat.hpp | | SpMat_meat.hpp | |
| | | | |
| skipping to change at line 526 | | skipping to change at line 526 | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| const SpMat<eT>& | | const SpMat<eT>& | |
| SpMat<eT>::operator+=(const SpMat<eT>& x) | | SpMat<eT>::operator+=(const SpMat<eT>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_assert_same_size(n_rows, n_cols, x.n_rows, x.n_cols, "addition | | SpMat<eT> out; | |
| "); | | out = (*this) + x; | |
| | | steal_mem(out); | |
| // Iterate over nonzero values of other matrix. | | | |
| for (const_iterator it = x.begin(); it != x.end(); it++) | | | |
| { | | | |
| get_value(it.row(), it.col()) += *it; | | | |
| } | | | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| const SpMat<eT>& | | const SpMat<eT>& | |
| SpMat<eT>::operator-=(const SpMat<eT>& x) | | SpMat<eT>::operator-=(const SpMat<eT>& x) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_assert_same_size(n_rows, n_cols, x.n_rows, x.n_cols, "subtract | | SpMat<eT> out; | |
| ion"); | | out = (*this) - x; | |
| | | steal_mem(out); | |
| // Iterate over nonzero values of other matrix. | | | |
| for (const_iterator it = x.begin(); it != x.end(); it++) | | | |
| { | | | |
| get_value(it.row(), it.col()) -= *it; | | | |
| } | | | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| const SpMat<eT>& | | const SpMat<eT>& | |
| SpMat<eT>::operator*=(const SpMat<eT>& y) | | SpMat<eT>::operator*=(const SpMat<eT>& y) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
|
| arma_debug_assert_mul_size(n_rows, n_cols, y.n_rows, y.n_cols, "matrix mu | | | |
| ltiplication"); | | | |
| | | | |
| SpMat<eT> z; | | SpMat<eT> z; | |
| z = (*this) * y; | | z = (*this) * y; | |
| steal_mem(z); | | steal_mem(z); | |
| | | | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| // This is in-place element-wise matrix multiplication. | | // This is in-place element-wise matrix multiplication. | |
| template<typename eT> | | template<typename eT> | |
| inline | | inline | |
| | | | |
End of changes. 3 change blocks. |
| 19 lines changed or deleted | | 6 lines changed or added | |
|
| fn_dot.hpp | | fn_dot.hpp | |
| | | | |
| skipping to change at line 18 | | skipping to change at line 18 | |
| | | | |
| //! \addtogroup fn_dot | | //! \addtogroup fn_dot | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_inline | | arma_inline | |
| arma_warn_unused | | arma_warn_unused | |
| typename | | typename | |
| enable_if2 | | enable_if2 | |
| < | | < | |
|
| is_arma_type<T1>::value && is_arma_type<T2>::value && is_same_type<typena
me T1::elem_type, typename T2::elem_type>::value, | | is_arma_type<T1>::value && is_arma_type<T2>::value && is_same_type<typena
me T1::elem_type, typename T2::elem_type>::yes, | |
| typename T1::elem_type | | typename T1::elem_type | |
| >::result | | >::result | |
| dot | | dot | |
| ( | | ( | |
| const T1& A, | | const T1& A, | |
| const T2& B | | const T2& B | |
| ) | | ) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return op_dot::apply(A,B); | | return op_dot::apply(A,B); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
|
| | | inline | |
| | | arma_warn_unused | |
| | | typename | |
| | | enable_if2 | |
| | | < | |
| | | is_arma_type<T1>::value && is_arma_type<T2>::value && is_same_type<typena | |
| | | me T1::elem_type, typename T2::elem_type>::no, | |
| | | typename promote_type<typename T1::elem_type, typename T2::elem_type>::re | |
| | | sult | |
| | | >::result | |
| | | dot | |
| | | ( | |
| | | const T1& A, | |
| | | const T2& B | |
| | | ) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | return op_dot_mixed::apply(A,B); | |
| | | } | |
| | | | |
| | | template<typename T1, typename T2> | |
| arma_inline | | arma_inline | |
| arma_warn_unused | | arma_warn_unused | |
| typename | | typename | |
| enable_if2 | | enable_if2 | |
| < | | < | |
| is_arma_type<T1>::value && is_arma_type<T2>::value && is_same_type<typena
me T1::elem_type, typename T2::elem_type>::value, | | is_arma_type<T1>::value && is_arma_type<T2>::value && is_same_type<typena
me T1::elem_type, typename T2::elem_type>::value, | |
| typename T1::elem_type | | typename T1::elem_type | |
| >::result | | >::result | |
| norm_dot | | norm_dot | |
| ( | | ( | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 23 lines changed or added | |
|
| fn_eig.hpp | | fn_eig.hpp | |
|
| // Copyright (C) 2008-2012 Conrad Sanderson | | // Copyright (C) 2008-2013 Conrad Sanderson | |
| // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | | // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2009 Edmund Highcock | | // Copyright (C) 2009 Edmund Highcock | |
| // Copyright (C) 2011 Stanislav Funiak | | // Copyright (C) 2011 Stanislav Funiak | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup fn_eig | | //! \addtogroup fn_eig | |
| //! @{ | | //! @{ | |
| | | | |
| | | | |
| skipping to change at line 309 | | skipping to change at line 309 | |
| if(status == false) | | if(status == false) | |
| { | | { | |
| eigval.reset(); | | eigval.reset(); | |
| eigvec.reset(); | | eigvec.reset(); | |
| arma_bad("eig_gen(): failed to converge", false); | | arma_bad("eig_gen(): failed to converge", false); | |
| } | | } | |
| | | | |
| return status; | | return status; | |
| } | | } | |
| | | | |
|
| | | template<typename eT, typename T1> | |
| | | inline | |
| | | bool | |
| | | eig_gen | |
| | | ( | |
| | | Col< std::complex<eT> >& eigval, | |
| | | Mat< std::complex<eT> >& eigvec, | |
| | | const Base<eT, T1>& X, | |
| | | const char* side = "right", | |
| | | const typename arma_blas_type_only<typename T1::elem_type>::result* junk | |
| | | = 0 | |
| | | ) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | arma_ignore(junk); | |
| | | | |
| | | return eig_gen(eigval, eigvec, X, side[0]); | |
| | | } | |
| | | | |
| | | template<typename T, typename T1> | |
| | | inline | |
| | | bool | |
| | | eig_gen | |
| | | ( | |
| | | Col<std::complex<T> >& eigval, | |
| | | Mat<std::complex<T> >& eigvec, | |
| | | const Base<std::complex<T>, T1>& X, | |
| | | const char* side = "right", | |
| | | const typename arma_blas_type_only<typename T1::elem_type>::result* junk | |
| | | = 0 | |
| | | ) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | arma_ignore(junk); | |
| | | | |
| | | return eig_gen(eigval, eigvec, X, side[0]); | |
| | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 40 lines changed or added | |
|
| fn_join.hpp | | fn_join.hpp | |
|
| // Copyright (C) 2010 Conrad Sanderson | | // Copyright (C) 2010-2013 Conrad Sanderson | |
| // Copyright (C) 2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup fn_join | | //! \addtogroup fn_join | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| | | | |
| skipping to change at line 24 | | skipping to change at line 24 | |
| join_cols(const Base<typename T1::elem_type,T1>& A, const Base<typename T1:
:elem_type,T2>& B) | | join_cols(const Base<typename T1::elem_type,T1>& A, const Base<typename T1:
:elem_type,T2>& B) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Glue<T1, T2, glue_join>(A.get_ref(), B.get_ref(), 0); | | return Glue<T1, T2, glue_join>(A.get_ref(), B.get_ref(), 0); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| const Glue<T1, T2, glue_join> | | const Glue<T1, T2, glue_join> | |
|
| | | join_vert(const Base<typename T1::elem_type,T1>& A, const Base<typename T1: | |
| | | :elem_type,T2>& B) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | return Glue<T1, T2, glue_join>(A.get_ref(), B.get_ref(), 0); | |
| | | } | |
| | | | |
| | | template<typename T1, typename T2> | |
| | | inline | |
| | | const Glue<T1, T2, glue_join> | |
| join_rows(const Base<typename T1::elem_type,T1>& A, const Base<typename T1:
:elem_type,T2>& B) | | join_rows(const Base<typename T1::elem_type,T1>& A, const Base<typename T1:
:elem_type,T2>& B) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return Glue<T1, T2, glue_join>(A.get_ref(), B.get_ref(), 1); | | return Glue<T1, T2, glue_join>(A.get_ref(), B.get_ref(), 1); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
|
| | | const Glue<T1, T2, glue_join> | |
| | | join_horiz(const Base<typename T1::elem_type,T1>& A, const Base<typename T1 | |
| | | ::elem_type,T2>& B) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| | | return Glue<T1, T2, glue_join>(A.get_ref(), B.get_ref(), 1); | |
| | | } | |
| | | | |
| | | template<typename T1, typename T2> | |
| | | inline | |
| const GlueCube<T1, T2, glue_join> | | const GlueCube<T1, T2, glue_join> | |
| join_slices(const BaseCube<typename T1::elem_type,T1>& A, const BaseCube<ty
pename T1::elem_type,T2>& B) | | join_slices(const BaseCube<typename T1::elem_type,T1>& A, const BaseCube<ty
pename T1::elem_type,T2>& B) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| return GlueCube<T1, T2, glue_join>(A.get_ref(), B.get_ref()); | | return GlueCube<T1, T2, glue_join>(A.get_ref(), B.get_ref()); | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 3 change blocks. |
| 2 lines changed or deleted | | 24 lines changed or added | |
|
| glue_join_bones.hpp | | glue_join_bones.hpp | |
|
| // Copyright (C) 2010 Conrad Sanderson | | // Copyright (C) 2010-2013 Conrad Sanderson | |
| // Copyright (C) 2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup glue_join | | //! \addtogroup glue_join | |
| //! @{ | | //! @{ | |
| | | | |
| class glue_join | | class glue_join | |
| { | | { | |
| public: | | public: | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
T2,glue_join>& X); | | inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,
T2,glue_join>& X); | |
| | | | |
|
| | | template<typename eT> | |
| | | inline static void apply_noalias(Mat<eT>& out, const Mat<eT>& A, const Ma | |
| | | t<eT>& B, const uword join_type); | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline static void apply(Cube<typename T1::elem_type>& out, const GlueCub
e<T1,T2,glue_join>& X); | | inline static void apply(Cube<typename T1::elem_type>& out, const GlueCub
e<T1,T2,glue_join>& X); | |
| }; | | }; | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 6 lines changed or added | |
|
| glue_join_meat.hpp | | glue_join_meat.hpp | |
|
| // Copyright (C) 2008-2011 Conrad Sanderson | | // Copyright (C) 2010-2013 Conrad Sanderson | |
| // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) | | // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup glue_join | | //! \addtogroup glue_join | |
| //! @{ | | //! @{ | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| void | | void | |
| glue_join::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_jo
in>& X) | | glue_join::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_jo
in>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| | | const uword join_type = X.aux_uword; | |
| | | | |
| const unwrap<T1> A_tmp(X.A); | | const unwrap<T1> A_tmp(X.A); | |
| const unwrap<T2> B_tmp(X.B); | | const unwrap<T2> B_tmp(X.B); | |
| | | | |
| const Mat<eT>& A = A_tmp.M; | | const Mat<eT>& A = A_tmp.M; | |
| const Mat<eT>& B = B_tmp.M; | | const Mat<eT>& B = B_tmp.M; | |
| | | | |
|
| | | if( (&out != &A) && (&out != &B) ) | |
| | | { | |
| | | glue_join::apply_noalias(out, A, B, join_type); | |
| | | } | |
| | | else | |
| | | { | |
| | | Mat<eT> tmp; | |
| | | | |
| | | glue_join::apply_noalias(tmp, A, B, join_type); | |
| | | | |
| | | out.steal_mem(tmp); | |
| | | } | |
| | | } | |
| | | | |
| | | template<typename eT> | |
| | | inline | |
| | | void | |
| | | glue_join::apply_noalias(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B, | |
| | | const uword join_type) | |
| | | { | |
| | | arma_extra_debug_sigprint(); | |
| | | | |
| const uword A_n_rows = A.n_rows; | | const uword A_n_rows = A.n_rows; | |
| const uword A_n_cols = A.n_cols; | | const uword A_n_cols = A.n_cols; | |
| | | | |
| const uword B_n_rows = B.n_rows; | | const uword B_n_rows = B.n_rows; | |
| const uword B_n_cols = B.n_cols; | | const uword B_n_cols = B.n_cols; | |
| | | | |
|
| const uword join_type = X.aux_uword; | | | |
| | | | |
| if(join_type == 0) | | if(join_type == 0) | |
| { | | { | |
| arma_debug_check | | arma_debug_check | |
| ( | | ( | |
| ( (A_n_cols != B_n_cols) && ( (A_n_rows > 0) || (A_n_cols > 0) ) && (
(B_n_rows > 0) || (B_n_cols > 0) ) ), | | ( (A_n_cols != B_n_cols) && ( (A_n_rows > 0) || (A_n_cols > 0) ) && (
(B_n_rows > 0) || (B_n_cols > 0) ) ), | |
|
| "join_cols(): number of columns must be the same" | | "join_cols() / join_vert(): number of columns must be the same" | |
| ); | | ); | |
| } | | } | |
| else | | else | |
| { | | { | |
| arma_debug_check | | arma_debug_check | |
| ( | | ( | |
| ( (A_n_rows != B.n_rows) && ( (A_n_rows > 0) || (A_n_cols > 0) ) && (
(B_n_rows > 0) || (B_n_cols > 0) ) ), | | ( (A_n_rows != B.n_rows) && ( (A_n_rows > 0) || (A_n_cols > 0) ) && (
(B_n_rows > 0) || (B_n_cols > 0) ) ), | |
|
| "join_rows(): number of rows must be the same" | | "join_rows() / join_horiz(): number of rows must be the same" | |
| ); | | ); | |
| } | | } | |
| | | | |
|
| if( (&out != &A) && (&out != &B) ) | | if(join_type == 0) // join columns (i.e. result matrix has more rows) | |
| { | | { | |
|
| if(join_type == 0) // join columns (i.e. result matrix has more rows) | | out.set_size( A_n_rows + B_n_rows, (std::max)(A_n_cols, B_n_cols) ); | |
| { | | | |
| out.set_size( A_n_rows + B_n_rows, (std::max)(A_n_cols, B_n_cols) ); | | | |
| | | | |
|
| if( out.n_elem > 0 ) | | if( out.n_elem > 0 ) | |
| | | { | |
| | | if(A.is_empty() == false) | |
| { | | { | |
|
| if(A.is_empty() == false) | | out.submat(0, 0, A_n_rows-1, out.n_cols-1) = A; | |
| { | | | |
| out.submat(0, 0, A_n_rows-1, out.n_cols-1) = A; | | | |
| } | | | |
| | | | |
| if(B.is_empty() == false) | | | |
| { | | | |
| out.submat(A_n_rows, 0, out.n_rows-1, out.n_cols-1) = B; | | | |
| } | | | |
| } | | } | |
|
| } | | | |
| else // join rows (i.e. result matrix has more columns) | | | |
| { | | | |
| out.set_size( (std::max)(A_n_rows, B_n_rows), A_n_cols + B_n_cols ); | | | |
| | | | |
|
| if( out.n_elem > 0 ) | | if(B.is_empty() == false) | |
| { | | { | |
|
| if(A.is_empty() == false) | | out.submat(A_n_rows, 0, out.n_rows-1, out.n_cols-1) = B; | |
| { | | | |
| out.submat(0, 0, out.n_rows-1, A.n_cols-1) = A; | | | |
| } | | | |
| | | | |
| if(B.is_empty() == false) | | | |
| { | | | |
| out.submat(0, A_n_cols, out.n_rows-1, out.n_cols-1) = B; | | | |
| } | | | |
| } | | } | |
| } | | } | |
| } | | } | |
|
| else // we have aliasing | | else // join rows (i.e. result matrix has more columns) | |
| { | | { | |
|
| Mat<eT> C; | | out.set_size( (std::max)(A_n_rows, B_n_rows), A_n_cols + B_n_cols ); | |
| | | | |
|
| if(join_type == 0) | | if( out.n_elem > 0 ) | |
| { | | { | |
|
| C.set_size( A_n_rows + B_n_rows, (std::max)(A_n_cols, B_n_cols) ); | | if(A.is_empty() == false) | |
| | | | |
| if( C.n_elem > 0 ) | | | |
| { | | { | |
|
| if(A.is_empty() == false) | | out.submat(0, 0, out.n_rows-1, A.n_cols-1) = A; | |
| { | | | |
| C.submat(0, 0, A_n_rows-1, C.n_cols-1) = A; | | | |
| } | | | |
| | | | |
| if(B.is_empty() == false) | | | |
| { | | | |
| C.submat(A_n_rows, 0, C.n_rows-1, C.n_cols-1) = B; | | | |
| } | | | |
| } | | } | |
|
| } | | | |
| else | | | |
| { | | | |
| C.set_size( (std::max)(A_n_rows, B_n_rows), A_n_cols + B_n_cols ); | | | |
| | | | |
|
| if( C.n_elem > 0 ) | | if(B.is_empty() == false) | |
| { | | { | |
|
| if(A.is_empty() == false) | | out.submat(0, A_n_cols, out.n_rows-1, out.n_cols-1) = B; | |
| { | | | |
| C.submat(0, 0, C.n_rows-1, A_n_cols-1) = A; | | | |
| } | | | |
| | | | |
| if(B.is_empty() == false) | | | |
| { | | | |
| C.submat(0, A_n_cols, C.n_rows-1, C.n_cols-1) = B; | | | |
| } | | | |
| } | | } | |
| } | | } | |
|
| | | | |
| out.steal_mem(C); | | | |
| } | | } | |
|
| | | | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| void | | void | |
| glue_join::apply(Cube<typename T1::elem_type>& out, const GlueCube<T1,T2,gl
ue_join>& X) | | glue_join::apply(Cube<typename T1::elem_type>& out, const GlueCube<T1,T2,gl
ue_join>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
End of changes. 23 change blocks. |
| 66 lines changed or deleted | | 43 lines changed or added | |
|
| glue_kron_meat.hpp | | glue_kron_meat.hpp | |
|
| // Copyright (C) 2009-2010 Conrad Sanderson | | // Copyright (C) 2009-2013 Conrad Sanderson | |
| // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2009-2013 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2009-2010 Dimitrios Bouzas | | // Copyright (C) 2009-2010 Dimitrios Bouzas | |
| // | | // | |
| // This Source Code Form is subject to the terms of the Mozilla Public | | // This Source Code Form is subject to the terms of the Mozilla Public | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this | | // License, v. 2.0. If a copy of the MPL was not distributed with this | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | | // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
| | | | |
| //! \addtogroup glue_kron | | //! \addtogroup glue_kron | |
| //! @{ | | //! @{ | |
| | | | |
| //! \brief | | //! \brief | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const uword A_rows = A.n_rows; | | const uword A_rows = A.n_rows; | |
| const uword A_cols = A.n_cols; | | const uword A_cols = A.n_cols; | |
| const uword B_rows = B.n_rows; | | const uword B_rows = B.n_rows; | |
| const uword B_cols = B.n_cols; | | const uword B_cols = B.n_cols; | |
| | | | |
| out.set_size(A_rows*B_rows, A_cols*B_cols); | | out.set_size(A_rows*B_rows, A_cols*B_cols); | |
| | | | |
|
| for(uword i = 0; i < A_rows; i++) | | for(uword j = 0; j < A_cols; j++) | |
| { | | { | |
|
| for(uword j = 0; j < A_cols; j++) | | for(uword i = 0; i < A_rows; i++) | |
| { | | { | |
|
| out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i,
j) * B; | | out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A.at
(i,j) * B; | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| //! \brief | | //! \brief | |
| //! different types of input matrices | | //! different types of input matrices | |
| //! A -> complex, B -> basic element type | | //! A -> complex, B -> basic element type | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
| void | | void | |
| | | | |
| skipping to change at line 58 | | skipping to change at line 58 | |
| | | | |
| const uword A_rows = A.n_rows; | | const uword A_rows = A.n_rows; | |
| const uword A_cols = A.n_cols; | | const uword A_cols = A.n_cols; | |
| const uword B_rows = B.n_rows; | | const uword B_rows = B.n_rows; | |
| const uword B_cols = B.n_cols; | | const uword B_cols = B.n_cols; | |
| | | | |
| out.set_size(A_rows*B_rows, A_cols*B_cols); | | out.set_size(A_rows*B_rows, A_cols*B_cols); | |
| | | | |
| Mat<eT> tmp_B = conv_to< Mat<eT> >::from(B); | | Mat<eT> tmp_B = conv_to< Mat<eT> >::from(B); | |
| | | | |
|
| for(uword i = 0; i < A_rows; i++) | | for(uword j = 0; j < A_cols; j++) | |
| { | | { | |
|
| for(uword j = 0; j < A_cols; j++) | | for(uword i = 0; i < A_rows; i++) | |
| { | | { | |
|
| out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i,
j) * tmp_B; | | out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A.at
(i,j) * tmp_B; | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| //! \brief | | //! \brief | |
| //! different types of input matrices | | //! different types of input matrices | |
| //! A -> basic element type, B -> complex | | //! A -> basic element type, B -> complex | |
| template<typename T> | | template<typename T> | |
| inline | | inline | |
| void | | void | |
| | | | |
| skipping to change at line 84 | | skipping to change at line 84 | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| const uword A_rows = A.n_rows; | | const uword A_rows = A.n_rows; | |
| const uword A_cols = A.n_cols; | | const uword A_cols = A.n_cols; | |
| const uword B_rows = B.n_rows; | | const uword B_rows = B.n_rows; | |
| const uword B_cols = B.n_cols; | | const uword B_cols = B.n_cols; | |
| | | | |
| out.set_size(A_rows*B_rows, A_cols*B_cols); | | out.set_size(A_rows*B_rows, A_cols*B_cols); | |
| | | | |
|
| for(uword i = 0; i < A_rows; i++) | | for(uword j = 0; j < A_cols; j++) | |
| { | | { | |
|
| for(uword j = 0; j < A_cols; j++) | | for(uword i = 0; i < A_rows; i++) | |
| { | | { | |
|
| out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i,
j) * B; | | out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A.at
(i,j) * B; | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| //! \brief | | //! \brief | |
| //! apply Kronecker product for two objects with same element type | | //! apply Kronecker product for two objects with same element type | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| void | | void | |
| glue_kron::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_kr
on>& X) | | glue_kron::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_kr
on>& X) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
| | | | |
| typedef typename T1::elem_type eT; | | typedef typename T1::elem_type eT; | |
| | | | |
|
| const unwrap_check<T1> A_tmp(X.A, out); | | const unwrap<T1> A_tmp(X.A); | |
| const unwrap_check<T2> B_tmp(X.B, out); | | const unwrap<T2> B_tmp(X.B); | |
| | | | |
| const Mat<eT>& A = A_tmp.M; | | const Mat<eT>& A = A_tmp.M; | |
| const Mat<eT>& B = B_tmp.M; | | const Mat<eT>& B = B_tmp.M; | |
| | | | |
|
| glue_kron::direct_kron(out, A, B); | | if( (&out != &A) && (&out != &B) ) | |
| | | { | |
| | | glue_kron::direct_kron(out, A, B); | |
| | | } | |
| | | else | |
| | | { | |
| | | Mat<eT> tmp; | |
| | | | |
| | | glue_kron::direct_kron(tmp, A, B); | |
| | | | |
| | | out.steal_mem(tmp); | |
| | | } | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 12 change blocks. |
| 14 lines changed or deleted | | 25 lines changed or added | |
|
| glue_times_bones.hpp | | glue_times_bones.hpp | |
| | | | |
| skipping to change at line 84 | | skipping to change at line 84 | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const
Glue<T1,T2,glue_times>& X); | | arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const
Glue<T1,T2,glue_times>& X); | |
| | | | |
| template<typename T1> | | template<typename T1> | |
| arma_hot inline static void apply_inplace(Mat<typename T1::elem_type>& ou
t, const T1& X); | | arma_hot inline static void apply_inplace(Mat<typename T1::elem_type>& ou
t, const T1& X); | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_hot inline static void apply_inplace_plus(Mat<typename T1::elem_type
>& out, const Glue<T1, T2, glue_times>& X, const sword sign); | | arma_hot inline static void apply_inplace_plus(Mat<typename T1::elem_type
>& out, const Glue<T1, T2, glue_times>& X, const sword sign); | |
| | | | |
|
| template<typename eT1, typename eT2> | | | |
| inline static void apply_mixed(Mat<typename promote_type<eT1,eT2>::result | | | |
| >& out, const Mat<eT1>& X, const Mat<eT2>& Y); | | | |
| | | | |
| // | | // | |
| | | | |
| template<typename eT, const bool do_trans_A, const bool do_trans_B, typen
ame TA, typename TB> | | template<typename eT, const bool do_trans_A, const bool do_trans_B, typen
ame TA, typename TB> | |
| arma_inline static uword mul_storage_cost(const TA& A, const TB& B); | | arma_inline static uword mul_storage_cost(const TA& A, const TB& B); | |
| | | | |
| template<typename eT, const bool do_trans_A, const bool do_trans_B, const
bool do_scalar_times, typename TA, typename TB> | | template<typename eT, const bool do_trans_A, const bool do_trans_B, const
bool do_scalar_times, typename TA, typename TB> | |
| arma_hot inline static void apply(Mat<eT>& out, const TA& A, const TB& B,
const eT val); | | arma_hot inline static void apply(Mat<eT>& out, const TA& A, const TB& B,
const eT val); | |
| | | | |
| template<typename eT, const bool do_trans_A, const bool do_trans_B, const
bool do_trans_C, const bool do_scalar_times, typename TA, typename TB, typ
ename TC> | | template<typename eT, const bool do_trans_A, const bool do_trans_B, const
bool do_trans_C, const bool do_scalar_times, typename TA, typename TB, typ
ename TC> | |
| arma_hot inline static void apply(Mat<eT>& out, const TA& A, const TB& B,
const TC& C, const eT val); | | arma_hot inline static void apply(Mat<eT>& out, const TA& A, const TB& B,
const TC& C, const eT val); | |
| | | | |
End of changes. 1 change blocks. |
| 4 lines changed or deleted | | 0 lines changed or added | |
|