Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00017
00018
00019
00022 template<typename eT>
00023 inline
00024 void
00025 glue_kron::direct_kron(Mat<eT>& out, const Mat<eT>& A, const Mat<eT>& B)
00026 {
00027 arma_extra_debug_sigprint();
00028
00029 const uword A_rows = A.n_rows;
00030 const uword A_cols = A.n_cols;
00031 const uword B_rows = B.n_rows;
00032 const uword B_cols = B.n_cols;
00033
00034 out.set_size(A_rows*B_rows, A_cols*B_cols);
00035
00036 for(uword i = 0; i < A_rows; i++)
00037 {
00038 for(uword j = 0; j < A_cols; j++)
00039 {
00040 out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i,j) * B;
00041 }
00042 }
00043 }
00044
00045
00046
00050 template<typename T>
00051 inline
00052 void
00053 glue_kron::direct_kron(Mat< std::complex<T> >& out, const Mat< std::complex<T> >& A, const Mat<T>& B)
00054 {
00055 arma_extra_debug_sigprint();
00056
00057 typedef typename std::complex<T> eT;
00058
00059 const uword A_rows = A.n_rows;
00060 const uword A_cols = A.n_cols;
00061 const uword B_rows = B.n_rows;
00062 const uword B_cols = B.n_cols;
00063
00064 out.set_size(A_rows*B_rows, A_cols*B_cols);
00065
00066 Mat<eT> tmp_B = conv_to< Mat<eT> >::from(B);
00067
00068 for(uword i = 0; i < A_rows; i++)
00069 {
00070 for(uword j = 0; j < A_cols; j++)
00071 {
00072 out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i,j) * tmp_B;
00073 }
00074 }
00075 }
00076
00077
00078
00082 template<typename T>
00083 inline
00084 void
00085 glue_kron::direct_kron(Mat< std::complex<T> >& out, const Mat<T>& A, const Mat< std::complex<T> >& B)
00086 {
00087 arma_extra_debug_sigprint();
00088
00089 const uword A_rows = A.n_rows;
00090 const uword A_cols = A.n_cols;
00091 const uword B_rows = B.n_rows;
00092 const uword B_cols = B.n_cols;
00093
00094 out.set_size(A_rows*B_rows, A_cols*B_cols);
00095
00096 for(uword i = 0; i < A_rows; i++)
00097 {
00098 for(uword j = 0; j < A_cols; j++)
00099 {
00100 out.submat(i*B_rows, j*B_cols, (i+1)*B_rows-1, (j+1)*B_cols-1) = A(i,j) * B;
00101 }
00102 }
00103 }
00104
00105
00106
00109 template<typename T1, typename T2>
00110 inline
00111 void
00112 glue_kron::apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_kron>& X)
00113 {
00114 arma_extra_debug_sigprint();
00115
00116 typedef typename T1::elem_type eT;
00117
00118 const unwrap_check<T1> A_tmp(X.A, out);
00119 const unwrap_check<T2> B_tmp(X.B, out);
00120
00121 const Mat<eT>& A = A_tmp.M;
00122 const Mat<eT>& B = B_tmp.M;
00123
00124 glue_kron::direct_kron(out, A, B);
00125 }
00126
00127
00128