Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 template<typename T1, typename T2>
00024 inline
00025 void
00026 glue_toeplitz::apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_toeplitz>& in)
00027 {
00028 arma_extra_debug_sigprint();
00029
00030 typedef typename T1::elem_type eT;
00031
00032 if( ((void*)(&in.A)) == ((void*)(&in.B)) )
00033 {
00034 arma_extra_debug_print("glue_toeplitz::apply(): one argument version");
00035
00036 const unwrap_check<T1> tmp(in.A, out);
00037 const Mat<eT>& A = tmp.M;
00038
00039 arma_debug_check( (A.is_vec() == false), "toeplitz(): input argument must be a vector" );
00040
00041 const u32 N = A.n_elem;
00042 const eT* A_mem = A.memptr();
00043
00044 out.set_size(N,N);
00045
00046 for(u32 col=0; col<N; ++col)
00047 {
00048 eT* col_mem = out.colptr(col);
00049
00050 u32 i;
00051
00052 i = col;
00053 for(u32 row=0; row<col; ++row, --i)
00054 {
00055 col_mem[row] = A_mem[i];
00056 }
00057
00058 i = 0;
00059 for(u32 row=col; row<N; ++row, ++i)
00060 {
00061 col_mem[row] = A_mem[i];
00062 }
00063 }
00064 }
00065 else
00066 {
00067 arma_extra_debug_print("glue_toeplitz::apply(): two argument version");
00068
00069 const unwrap_check<T1> tmp1(in.A, out);
00070 const unwrap_check<T2> tmp2(in.B, out);
00071
00072 const Mat<eT>& A = tmp1.M;
00073 const Mat<eT>& B = tmp2.M;
00074
00075 arma_debug_check( ( (A.is_vec() == false) || (B.is_vec() == false) ), "toeplitz(): input arguments must be vectors" );
00076
00077 const u32 A_N = A.n_elem;
00078 const u32 B_N = B.n_elem;
00079
00080 const eT* A_mem = A.memptr();
00081 const eT* B_mem = B.memptr();
00082
00083 out.set_size(A_N, B_N);
00084
00085 for(u32 col=0; col<B_N; ++col)
00086 {
00087 eT* col_mem = out.colptr(col);
00088
00089 u32 i = 0;
00090 for(u32 row=col; row<A_N; ++row, ++i)
00091 {
00092 col_mem[row] = A_mem[i];
00093 }
00094 }
00095
00096 for(u32 row=0; row<A_N; ++row)
00097 {
00098 u32 i = 1;
00099 for(u32 col=(row+1); col<B_N; ++col, ++i)
00100 {
00101 out.at(row,col) = B_mem[i];
00102 }
00103 }
00104
00105 }
00106
00107
00108 }
00109
00110
00111
00112