annotate armadillo-2.4.4/include/armadillo_bits/fn_kron.hpp @ 5:79b343f3e4b8

In thi version the problem of letters assigned to each segment has been solved.
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 13:48:13 +0100
parents 8b6102e2a9b0
children
rev   line source
max@0 1 // Copyright (C) 2009-2010 NICTA (www.nicta.com.au)
max@0 2 // Copyright (C) 2009-2010 Conrad Sanderson
max@0 3 // Copyright (C) 2009-2010 Dimitrios Bouzas
max@0 4 //
max@0 5 // This file is part of the Armadillo C++ library.
max@0 6 // It is provided without any warranty of fitness
max@0 7 // for any purpose. You can redistribute this file
max@0 8 // and/or modify it under the terms of the GNU
max@0 9 // Lesser General Public License (LGPL) as published
max@0 10 // by the Free Software Foundation, either version 3
max@0 11 // of the License or (at your option) any later version.
max@0 12 // (see http://www.opensource.org/licenses for more info)
max@0 13
max@0 14
max@0 15 //! \addtogroup fn_kron
max@0 16 //! @{
max@0 17
max@0 18
max@0 19
max@0 20 //! \brief
max@0 21 //! kronecker product of two matrices,
max@0 22 //! with the matrices having the same element type
max@0 23 template<typename T1, typename T2>
max@0 24 arma_inline
max@0 25 const Glue<T1,T2,glue_kron>
max@0 26 kron(const Base<typename T1::elem_type,T1>& A, const Base<typename T1::elem_type,T2>& B)
max@0 27 {
max@0 28 arma_extra_debug_sigprint();
max@0 29
max@0 30 return Glue<T1, T2, glue_kron>(A.get_ref(), B.get_ref());
max@0 31 }
max@0 32
max@0 33
max@0 34
max@0 35 //! \brief
max@0 36 //! kronecker product of two matrices,
max@0 37 //! with the matrices having different element types
max@0 38 template<typename T, typename T1, typename T2>
max@0 39 inline
max@0 40 Mat<typename eT_promoter<T1,T2>::eT>
max@0 41 kron(const Base<std::complex<T>,T1>& X, const Base<T,T2>& Y)
max@0 42 {
max@0 43 arma_extra_debug_sigprint();
max@0 44
max@0 45 typedef typename std::complex<T> eT1;
max@0 46
max@0 47 promote_type<eT1,T>::check();
max@0 48
max@0 49 const unwrap<T1> tmp1(X.get_ref());
max@0 50 const unwrap<T2> tmp2(Y.get_ref());
max@0 51
max@0 52 const Mat<eT1>& A = tmp1.M;
max@0 53 const Mat<T >& B = tmp2.M;
max@0 54
max@0 55 Mat<eT1> out;
max@0 56
max@0 57 glue_kron::direct_kron(out, A, B);
max@0 58
max@0 59 return out;
max@0 60 }
max@0 61
max@0 62
max@0 63
max@0 64 //! \brief
max@0 65 //! kronecker product of two matrices,
max@0 66 //! with the matrices having different element types
max@0 67 template<typename T, typename T1, typename T2>
max@0 68 inline
max@0 69 Mat<typename eT_promoter<T1,T2>::eT>
max@0 70 kron(const Base<T,T1>& X, const Base<std::complex<T>,T2>& Y)
max@0 71 {
max@0 72 arma_extra_debug_sigprint();
max@0 73
max@0 74 typedef typename std::complex<T> eT2;
max@0 75
max@0 76 promote_type<T,eT2>::check();
max@0 77
max@0 78 const unwrap<T1> tmp1(X.get_ref());
max@0 79 const unwrap<T2> tmp2(Y.get_ref());
max@0 80
max@0 81 const Mat<T >& A = tmp1.M;
max@0 82 const Mat<eT2>& B = tmp2.M;
max@0 83
max@0 84 Mat<eT2> out;
max@0 85
max@0 86 glue_kron::direct_kron(out, A, B);
max@0 87
max@0 88 return out;
max@0 89 }
max@0 90
max@0 91
max@0 92
max@0 93 //! @}