Chris@49: // Copyright (C) 2009-2010 NICTA (www.nicta.com.au) Chris@49: // Copyright (C) 2009-2010 Conrad Sanderson Chris@49: // Copyright (C) 2009-2010 Dimitrios Bouzas Chris@49: // Chris@49: // This Source Code Form is subject to the terms of the Mozilla Public Chris@49: // License, v. 2.0. If a copy of the MPL was not distributed with this Chris@49: // file, You can obtain one at http://mozilla.org/MPL/2.0/. Chris@49: Chris@49: Chris@49: //! \addtogroup fn_kron Chris@49: //! @{ Chris@49: Chris@49: Chris@49: Chris@49: //! \brief Chris@49: //! kronecker product of two matrices, Chris@49: //! with the matrices having the same element type Chris@49: template Chris@49: arma_inline Chris@49: const Glue Chris@49: kron(const Base& A, const Base& B) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: return Glue(A.get_ref(), B.get_ref()); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: //! \brief Chris@49: //! kronecker product of two matrices, Chris@49: //! with the matrices having different element types Chris@49: template Chris@49: inline Chris@49: Mat::eT> Chris@49: kron(const Base,T1>& X, const Base& Y) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: typedef typename std::complex eT1; Chris@49: Chris@49: promote_type::check(); Chris@49: Chris@49: const unwrap tmp1(X.get_ref()); Chris@49: const unwrap tmp2(Y.get_ref()); Chris@49: Chris@49: const Mat& A = tmp1.M; Chris@49: const Mat& B = tmp2.M; Chris@49: Chris@49: Mat out; Chris@49: Chris@49: glue_kron::direct_kron(out, A, B); Chris@49: Chris@49: return out; Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: //! \brief Chris@49: //! kronecker product of two matrices, Chris@49: //! with the matrices having different element types Chris@49: template Chris@49: inline Chris@49: Mat::eT> Chris@49: kron(const Base& X, const Base,T2>& Y) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: typedef typename std::complex eT2; Chris@49: Chris@49: promote_type::check(); Chris@49: Chris@49: const unwrap tmp1(X.get_ref()); Chris@49: const unwrap tmp2(Y.get_ref()); Chris@49: Chris@49: const Mat& A = tmp1.M; Chris@49: const Mat& B = tmp2.M; Chris@49: Chris@49: Mat out; Chris@49: Chris@49: glue_kron::direct_kron(out, A, B); Chris@49: Chris@49: return out; Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: //! @}