annotate armadillo-3.900.4/include/armadillo_bits/glue_toeplitz_meat.hpp @ 84:55a047986812 tip

Update library URI so as not to be document-local
author Chris Cannam
date Wed, 22 Apr 2020 14:21:57 +0100
parents 1ec0e2823891
children
rev   line source
Chris@49 1 // Copyright (C) 2010-2013 NICTA (www.nicta.com.au)
Chris@49 2 // Copyright (C) 2010-2013 Conrad Sanderson
Chris@49 3 //
Chris@49 4 // This Source Code Form is subject to the terms of the Mozilla Public
Chris@49 5 // License, v. 2.0. If a copy of the MPL was not distributed with this
Chris@49 6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
Chris@49 7
Chris@49 8
Chris@49 9
Chris@49 10 //! \addtogroup glue_toeplitz
Chris@49 11 //! @{
Chris@49 12
Chris@49 13
Chris@49 14
Chris@49 15 template<typename T1, typename T2>
Chris@49 16 inline
Chris@49 17 void
Chris@49 18 glue_toeplitz::apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_toeplitz>& in)
Chris@49 19 {
Chris@49 20 arma_extra_debug_sigprint();
Chris@49 21
Chris@49 22 typedef typename T1::elem_type eT;
Chris@49 23
Chris@49 24 const unwrap_check<T1> tmp1(in.A, out);
Chris@49 25 const unwrap_check<T2> tmp2(in.B, out);
Chris@49 26
Chris@49 27 const Mat<eT>& A = tmp1.M;
Chris@49 28 const Mat<eT>& B = tmp2.M;
Chris@49 29
Chris@49 30 arma_debug_check
Chris@49 31 (
Chris@49 32 ( ((A.is_vec() == false) && (A.is_empty() == false)) || ((B.is_vec() == false) && (B.is_empty() == false)) ),
Chris@49 33 "toeplitz(): given object is not a vector"
Chris@49 34 );
Chris@49 35
Chris@49 36 const uword A_N = A.n_elem;
Chris@49 37 const uword B_N = B.n_elem;
Chris@49 38
Chris@49 39 const eT* A_mem = A.memptr();
Chris@49 40 const eT* B_mem = B.memptr();
Chris@49 41
Chris@49 42 out.set_size(A_N, B_N);
Chris@49 43
Chris@49 44 if( out.is_empty() ) { return; }
Chris@49 45
Chris@49 46 for(uword col=0; col < B_N; ++col)
Chris@49 47 {
Chris@49 48 eT* col_mem = out.colptr(col);
Chris@49 49
Chris@49 50 uword i = 0;
Chris@49 51 for(uword row=col; row < A_N; ++row, ++i) { col_mem[row] = A_mem[i]; }
Chris@49 52 }
Chris@49 53
Chris@49 54 for(uword row=0; row < A_N; ++row)
Chris@49 55 {
Chris@49 56 uword i = 1;
Chris@49 57 for(uword col=(row+1); col < B_N; ++col, ++i) { out.at(row,col) = B_mem[i]; }
Chris@49 58 }
Chris@49 59 }
Chris@49 60
Chris@49 61
Chris@49 62
Chris@49 63 //! @}