Chris@49: // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) Chris@49: // Copyright (C) 2010-2013 Conrad Sanderson 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: Chris@49: //! \addtogroup glue_toeplitz Chris@49: //! @{ Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: inline Chris@49: void Chris@49: glue_toeplitz::apply(Mat& out, const Glue& in) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: const unwrap_check tmp1(in.A, out); Chris@49: const unwrap_check tmp2(in.B, out); Chris@49: Chris@49: const Mat& A = tmp1.M; Chris@49: const Mat& B = tmp2.M; Chris@49: Chris@49: arma_debug_check Chris@49: ( Chris@49: ( ((A.is_vec() == false) && (A.is_empty() == false)) || ((B.is_vec() == false) && (B.is_empty() == false)) ), Chris@49: "toeplitz(): given object is not a vector" Chris@49: ); Chris@49: Chris@49: const uword A_N = A.n_elem; Chris@49: const uword B_N = B.n_elem; Chris@49: Chris@49: const eT* A_mem = A.memptr(); Chris@49: const eT* B_mem = B.memptr(); Chris@49: Chris@49: out.set_size(A_N, B_N); Chris@49: Chris@49: if( out.is_empty() ) { return; } Chris@49: Chris@49: for(uword col=0; col < B_N; ++col) Chris@49: { Chris@49: eT* col_mem = out.colptr(col); Chris@49: Chris@49: uword i = 0; Chris@49: for(uword row=col; row < A_N; ++row, ++i) { col_mem[row] = A_mem[i]; } Chris@49: } Chris@49: Chris@49: for(uword row=0; row < A_N; ++row) Chris@49: { Chris@49: uword i = 1; Chris@49: for(uword col=(row+1); col < B_N; ++col, ++i) { out.at(row,col) = B_mem[i]; } Chris@49: } Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: //! @}