| fn_as_scalar.hpp | | fn_as_scalar.hpp | |
|
| // Copyright (C) 2010 NICTA (www.nicta.com.au) | | // Copyright (C) 2010-2011 NICTA (www.nicta.com.au) | |
| // Copyright (C) 2010 Conrad Sanderson | | // Copyright (C) 2010-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 296 | | skipping to change at line 296 | |
| else | | else | |
| { | | { | |
| return val * op_dotext::direct_rowvec_diagmat_colvec(A.mem, B, C.mem); | | return val * op_dotext::direct_rowvec_diagmat_colvec(A.mem, B, C.mem); | |
| } | | } | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| arma_inline | | arma_inline | |
| arma_warn_unused | | arma_warn_unused | |
| typename T1::elem_type | | typename T1::elem_type | |
|
| as_scalar(const Glue<T1, T2, glue_times>& X) | | as_scalar(const Glue<T1, T2, glue_times>& X, const typename arma_not_cx<typ
ename T1::elem_type>::result* junk = 0) | |
| { | | { | |
| arma_extra_debug_sigprint(); | | arma_extra_debug_sigprint(); | |
|
| | | arma_ignore(junk); | |
| | | | |
| if(is_glue_times_diag<T1>::value == false) | | if(is_glue_times_diag<T1>::value == false) | |
| { | | { | |
| const s32 N_mat = 1 + depth_lhs< glue_times, Glue<T1,T2,glue_times> >::
num; | | const s32 N_mat = 1 + depth_lhs< glue_times, Glue<T1,T2,glue_times> >::
num; | |
| | | | |
| arma_extra_debug_print(arma_boost::format("N_mat = %d") % N_mat); | | arma_extra_debug_print(arma_boost::format("N_mat = %d") % N_mat); | |
| | | | |
| return as_scalar_redirect<N_mat>::apply(X); | | return as_scalar_redirect<N_mat>::apply(X); | |
| } | | } | |
| else | | else | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 4 lines changed or added | |
|
| glue_times_meat.hpp | | glue_times_meat.hpp | |
| | | | |
| skipping to change at line 35 | | skipping to change at line 35 | |
| | | | |
| const partial_unwrap_check<T1> tmp1(X.A, out); | | const partial_unwrap_check<T1> tmp1(X.A, out); | |
| const partial_unwrap_check<T2> tmp2(X.B, out); | | const partial_unwrap_check<T2> tmp2(X.B, out); | |
| | | | |
| const Mat<eT>& A = tmp1.M; | | const Mat<eT>& A = tmp1.M; | |
| const Mat<eT>& B = tmp2.M; | | const Mat<eT>& B = tmp2.M; | |
| | | | |
| const bool do_trans_A = tmp1.do_trans; | | const bool do_trans_A = tmp1.do_trans; | |
| const bool do_trans_B = tmp2.do_trans; | | const bool do_trans_B = tmp2.do_trans; | |
| | | | |
|
| const bool use_alpha = tmp1.do_times | tmp2.do_times; | | const bool use_alpha = tmp1.do_times || tmp2.do_times; | |
| const eT alpha = use_alpha ? (tmp1.val * tmp2.val) : eT(0); | | const eT alpha = use_alpha ? (tmp1.val * tmp2.val) : eT(0); | |
| | | | |
| glue_times::apply(out, A, B, alpha, do_trans_A, do_trans_B, use_alpha); | | glue_times::apply(out, A, B, alpha, do_trans_A, do_trans_B, use_alpha); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2, typename T3> | | template<typename T1, typename T2, typename T3> | |
| inline | | inline | |
| void | | void | |
| glue_times_redirect<3>::apply(Mat<typename T1::elem_type>& out, const Glue<
Glue<T1,T2,glue_times>, T3, glue_times>& X) | | glue_times_redirect<3>::apply(Mat<typename T1::elem_type>& out, const Glue<
Glue<T1,T2,glue_times>, T3, glue_times>& X) | |
| { | | { | |
| | | | |
| skipping to change at line 65 | | skipping to change at line 65 | |
| const partial_unwrap_check<T3> tmp3(X.B, out); | | const partial_unwrap_check<T3> tmp3(X.B, out); | |
| | | | |
| const Mat<eT>& A = tmp1.M; | | const Mat<eT>& A = tmp1.M; | |
| const Mat<eT>& B = tmp2.M; | | const Mat<eT>& B = tmp2.M; | |
| const Mat<eT>& C = tmp3.M; | | const Mat<eT>& C = tmp3.M; | |
| | | | |
| const bool do_trans_A = tmp1.do_trans; | | const bool do_trans_A = tmp1.do_trans; | |
| const bool do_trans_B = tmp2.do_trans; | | const bool do_trans_B = tmp2.do_trans; | |
| const bool do_trans_C = tmp3.do_trans; | | const bool do_trans_C = tmp3.do_trans; | |
| | | | |
|
| const bool use_alpha = tmp1.do_times | tmp2.do_times | tmp3.do_times; | | const bool use_alpha = tmp1.do_times || tmp2.do_times || tmp3.do_times; | |
| const eT alpha = use_alpha ? (tmp1.val * tmp2.val * tmp3.val) : eT(
0); | | const eT alpha = use_alpha ? (tmp1.val * tmp2.val * tmp3.val) : eT(
0); | |
| | | | |
| glue_times::apply(out, A, B, C, alpha, do_trans_A, do_trans_B, do_trans_C
, use_alpha); | | glue_times::apply(out, A, B, C, alpha, do_trans_A, do_trans_B, do_trans_C
, use_alpha); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2, typename T3, typename T4> | | template<typename T1, typename T2, typename T3, typename T4> | |
| inline | | inline | |
| void | | void | |
| glue_times_redirect<4>::apply(Mat<typename T1::elem_type>& out, const Glue<
Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X) | | glue_times_redirect<4>::apply(Mat<typename T1::elem_type>& out, const Glue<
Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X) | |
| { | | { | |
| | | | |
| skipping to change at line 98 | | skipping to change at line 98 | |
| const Mat<eT>& A = tmp1.M; | | const Mat<eT>& A = tmp1.M; | |
| const Mat<eT>& B = tmp2.M; | | const Mat<eT>& B = tmp2.M; | |
| const Mat<eT>& C = tmp3.M; | | const Mat<eT>& C = tmp3.M; | |
| const Mat<eT>& D = tmp4.M; | | const Mat<eT>& D = tmp4.M; | |
| | | | |
| const bool do_trans_A = tmp1.do_trans; | | const bool do_trans_A = tmp1.do_trans; | |
| const bool do_trans_B = tmp2.do_trans; | | const bool do_trans_B = tmp2.do_trans; | |
| const bool do_trans_C = tmp3.do_trans; | | const bool do_trans_C = tmp3.do_trans; | |
| const bool do_trans_D = tmp4.do_trans; | | const bool do_trans_D = tmp4.do_trans; | |
| | | | |
|
| const bool use_alpha = tmp1.do_times | tmp2.do_times | tmp3.do_times | tm
p4.do_times; | | const bool use_alpha = tmp1.do_times || tmp2.do_times || tmp3.do_times ||
tmp4.do_times; | |
| const eT alpha = use_alpha ? (tmp1.val * tmp2.val * tmp3.val * tmp4
.val) : eT(0); | | const eT alpha = use_alpha ? (tmp1.val * tmp2.val * tmp3.val * tmp4
.val) : eT(0); | |
| | | | |
| glue_times::apply(out, A, B, C, D, alpha, do_trans_A, do_trans_B, do_tran
s_C, do_trans_D, use_alpha); | | glue_times::apply(out, A, B, C, D, alpha, do_trans_A, do_trans_B, do_tran
s_C, do_trans_D, use_alpha); | |
| } | | } | |
| | | | |
| template<typename T1, typename T2> | | template<typename T1, typename T2> | |
| inline | | inline | |
| void | | void | |
| glue_times::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_t
imes>& X) | | glue_times::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_t
imes>& X) | |
| { | | { | |
| | | | |
| skipping to change at line 183 | | skipping to change at line 183 | |
| | | | |
| const partial_unwrap_check<T1> tmp1(X.A, out); | | const partial_unwrap_check<T1> tmp1(X.A, out); | |
| const partial_unwrap_check<T2> tmp2(X.B, out); | | const partial_unwrap_check<T2> tmp2(X.B, out); | |
| | | | |
| const Mat<eT>& A = tmp1.M; | | const Mat<eT>& A = tmp1.M; | |
| const Mat<eT>& B = tmp2.M; | | const Mat<eT>& B = tmp2.M; | |
| const eT alpha = tmp1.val * tmp2.val * ( (sign > s32(0)) ? eT(1) :
eT(-1) ); | | const eT alpha = tmp1.val * tmp2.val * ( (sign > s32(0)) ? eT(1) :
eT(-1) ); | |
| | | | |
| const bool do_trans_A = tmp1.do_trans; | | const bool do_trans_A = tmp1.do_trans; | |
| const bool do_trans_B = tmp2.do_trans; | | const bool do_trans_B = tmp2.do_trans; | |
|
| const bool use_alpha = tmp1.do_times | tmp2.do_times | (sign < s32(0)); | | const bool use_alpha = tmp1.do_times || tmp2.do_times || (sign < s32(0))
; | |
| | | | |
| arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multipli
cation"); | | arma_debug_assert_mul_size(A, B, do_trans_A, do_trans_B, "matrix multipli
cation"); | |
| | | | |
| const u32 result_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; | | const u32 result_n_rows = (do_trans_A == false) ? A.n_rows : A.n_cols; | |
| const u32 result_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; | | const u32 result_n_cols = (do_trans_B == false) ? B.n_cols : B.n_rows; | |
| | | | |
| arma_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result_n_col
s, "addition"); | | arma_assert_same_size(out.n_rows, out.n_cols, result_n_rows, result_n_col
s, "addition"); | |
| | | | |
| if(out.n_elem > 0) | | if(out.n_elem > 0) | |
| { | | { | |
| | | | |
End of changes. 4 change blocks. |
| 4 lines changed or deleted | | 4 lines changed or added | |
|
| op_diagmat_meat.hpp | | op_diagmat_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 69 | | skipping to change at line 69 | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| // generate a diagonal matrix out of a matrix | | // generate a diagonal matrix out of a matrix | |
| | | | |
| arma_debug_check( (A.is_square() == false), "diagmat(): given matrix is
not square" ); | | arma_debug_check( (A.is_square() == false), "diagmat(): given matrix is
not square" ); | |
| | | | |
| const u32 N = A.n_rows; | | const u32 N = A.n_rows; | |
| | | | |
|
| out.zeros(N,N); | | if(&out != &A) | |
| | | { | |
| | | // no aliasing | |
| | | | |
| | | out.zeros(N,N); | |
| | | | |
|
| for(u32 i=0; i<N; ++i) | | for(u32 i=0; i<N; ++i) | |
| | | { | |
| | | out.at(i,i) = A.at(i,i); | |
| | | } | |
| | | } | |
| | | else | |
| { | | { | |
|
| out.at(i,i) = A.at(i,i); | | // aliasing | |
| | | | |
| | | for(u32 i=0; i<N; ++i) | |
| | | { | |
| | | eT* colptr = out.colptr(i); | |
| | | | |
| | | // clear above the diagonal | |
| | | arrayops::inplace_set(colptr, eT(0), i); | |
| | | | |
| | | // clear below the diagonal | |
| | | arrayops::inplace_set(colptr+(i+1), eT(0), N-1-i); | |
| | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| //! @} | | //! @} | |
| | | | |
End of changes. 4 change blocks. |
| 5 lines changed or deleted | | 25 lines changed or added | |
|
| op_symmat_meat.hpp | | op_symmat_meat.hpp | |
| | | | |
| skipping to change at line 87 | | skipping to change at line 87 | |
| for(u32 row=0; row < col; ++row) | | for(u32 row=0; row < col; ++row) | |
| { | | { | |
| out.at(col,row) = coldata[row]; | | out.at(col,row) = coldata[row]; | |
| } | | } | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| // reflect elements across the diagonal from lower triangle to upper tr
iangle | | // reflect elements across the diagonal from lower triangle to upper tr
iangle | |
| | | | |
|
| for(u32 col=0; col < (N-1); ++col) | | for(u32 col=0; col < N; ++col) | |
| { | | { | |
| const eT* coldata = out.colptr(col); | | const eT* coldata = out.colptr(col); | |
| | | | |
| for(u32 row=(col+1); row < N; ++row) | | for(u32 row=(col+1); row < N; ++row) | |
| { | | { | |
| out.at(col,row) = coldata[row]; | | out.at(col,row) = coldata[row]; | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 170 | | skipping to change at line 170 | |
| for(u32 row=0; row < col; ++row) | | for(u32 row=0; row < col; ++row) | |
| { | | { | |
| out.at(col,row) = std::conj(coldata[row]); | | out.at(col,row) = std::conj(coldata[row]); | |
| } | | } | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| // reflect elements across the diagonal from lower triangle to upper tr
iangle | | // reflect elements across the diagonal from lower triangle to upper tr
iangle | |
| | | | |
|
| for(u32 col=0; col < (N-1); ++col) | | for(u32 col=0; col < N; ++col) | |
| { | | { | |
| const eT* coldata = out.colptr(col); | | const eT* coldata = out.colptr(col); | |
| | | | |
| for(u32 row=(col+1); row < N; ++row) | | for(u32 row=(col+1); row < N; ++row) | |
| { | | { | |
| out.at(col,row) = std::conj(coldata[row]); | | out.at(col,row) = std::conj(coldata[row]); | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|