Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/op_toeplitz_meat.hpp @ 49:1ec0e2823891
Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author | Chris Cannam |
---|---|
date | Thu, 13 Jun 2013 10:25:24 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
48:69251e11a913 | 49:1ec0e2823891 |
---|---|
1 // Copyright (C) 2013 Conrad Sanderson | |
2 // Copyright (C) 2013 NICTA (www.nicta.com.au) | |
3 // | |
4 // This Source Code Form is subject to the terms of the Mozilla Public | |
5 // License, v. 2.0. If a copy of the MPL was not distributed with this | |
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
7 | |
8 | |
9 //! \addtogroup op_toeplitz | |
10 //! @{ | |
11 | |
12 | |
13 | |
14 template<typename T1> | |
15 inline | |
16 void | |
17 op_toeplitz::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_toeplitz>& in) | |
18 { | |
19 arma_extra_debug_sigprint(); | |
20 | |
21 typedef typename T1::elem_type eT; | |
22 | |
23 const unwrap_check<T1> tmp(in.m, out); | |
24 const Mat<eT>& X = tmp.M; | |
25 | |
26 arma_debug_check( ((X.is_vec() == false) && (X.is_empty() == false)), "toeplitz(): given object is not a vector" ); | |
27 | |
28 const uword N = X.n_elem; | |
29 const eT* X_mem = X.memptr(); | |
30 | |
31 out.set_size(N,N); | |
32 | |
33 for(uword col=0; col < N; ++col) | |
34 { | |
35 eT* col_mem = out.colptr(col); | |
36 | |
37 uword i; | |
38 | |
39 i = col; | |
40 for(uword row=0; row < col; ++row, --i) { col_mem[row] = X_mem[i]; } | |
41 | |
42 i = 0; | |
43 for(uword row=col; row < N; ++row, ++i) { col_mem[row] = X_mem[i]; } | |
44 } | |
45 } | |
46 | |
47 | |
48 | |
49 template<typename T1> | |
50 inline | |
51 void | |
52 op_toeplitz_c::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_toeplitz_c>& in) | |
53 { | |
54 arma_extra_debug_sigprint(); | |
55 | |
56 typedef typename T1::elem_type eT; | |
57 | |
58 const unwrap_check<T1> tmp(in.m, out); | |
59 const Mat<eT>& X = tmp.M; | |
60 | |
61 arma_debug_check( ((X.is_vec() == false) && (X.is_empty() == false)), "circ_toeplitz(): given object is not a vector" ); | |
62 | |
63 const uword N = X.n_elem; | |
64 const eT* X_mem = X.memptr(); | |
65 | |
66 out.set_size(N,N); | |
67 | |
68 if(X.is_rowvec() == true) | |
69 { | |
70 for(uword row=0; row < N; ++row) | |
71 { | |
72 uword i; | |
73 | |
74 i = row; | |
75 for(uword col=0; col < row; ++col, --i) { out.at(row,col) = X_mem[N-i]; } | |
76 | |
77 i = 0; | |
78 for(uword col=row; col < N; ++col, ++i) { out.at(row,col) = X_mem[i]; } | |
79 } | |
80 } | |
81 else | |
82 { | |
83 for(uword col=0; col < N; ++col) | |
84 { | |
85 eT* col_mem = out.colptr(col); | |
86 | |
87 uword i; | |
88 | |
89 i = col; | |
90 for(uword row=0; row < col; ++row, --i) { col_mem[row] = X_mem[N-i]; } | |
91 | |
92 i = 0; | |
93 for(uword row=col; row < N; ++row, ++i) { col_mem[row] = X_mem[i]; } | |
94 } | |
95 } | |
96 } | |
97 | |
98 | |
99 | |
100 //! @} |