comparison armadillo-3.900.4/include/armadillo_bits/op_resize_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) 2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2011 Conrad Sanderson
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
10 //! \addtogroup op_resize
11 //! @{
12
13
14
15 template<typename T1>
16 inline
17 void
18 op_resize::apply(Mat<typename T1::elem_type>& actual_out, const Op<T1,op_resize>& in)
19 {
20 arma_extra_debug_sigprint();
21
22 typedef typename T1::elem_type eT;
23
24 const uword out_n_rows = in.aux_uword_a;
25 const uword out_n_cols = in.aux_uword_b;
26
27 const unwrap<T1> tmp(in.m);
28 const Mat<eT>& A = tmp.M;
29
30 const uword A_n_rows = A.n_rows;
31 const uword A_n_cols = A.n_cols;
32
33 Mat<eT> B;
34
35 const bool alias = (&actual_out == &A);
36
37 Mat<eT>& out = alias ? B : actual_out;
38
39 out.set_size(out_n_rows, out_n_cols);
40
41 if( (out_n_rows > A_n_rows) || (out_n_cols > A_n_cols) )
42 {
43 out.zeros();
44 }
45
46 if( (out.n_elem > 0) && (A.n_elem > 0) )
47 {
48 const uword end_row = (std::min)(out_n_rows, A_n_rows) - 1;
49 const uword end_col = (std::min)(out_n_cols, A_n_cols) - 1;
50
51 out.submat(0, 0, end_row, end_col) = A.submat(0, 0, end_row, end_col);
52 }
53
54 if(alias)
55 {
56 actual_out.steal_mem(B);
57 }
58
59 }
60
61
62
63 template<typename T1>
64 inline
65 void
66 op_resize::apply(Cube<typename T1::elem_type>& actual_out, const OpCube<T1,op_resize>& in)
67 {
68 arma_extra_debug_sigprint();
69
70 typedef typename T1::elem_type eT;
71
72 const uword out_n_rows = in.aux_uword_a;
73 const uword out_n_cols = in.aux_uword_b;
74 const uword out_n_slices = in.aux_uword_c;
75
76 const unwrap_cube<T1> tmp(in.m);
77 const Cube<eT>& A = tmp.M;
78
79 const uword A_n_rows = A.n_rows;
80 const uword A_n_cols = A.n_cols;
81 const uword A_n_slices = A.n_slices;
82
83 Cube<eT> B;
84
85 const bool alias = (&actual_out == &A);
86
87 Cube<eT>& out = alias ? B : actual_out;
88
89 out.set_size(out_n_rows, out_n_cols, out_n_slices);
90
91 if( (out_n_rows > A_n_rows) || (out_n_cols > A_n_cols) || (out_n_slices > A_n_slices) )
92 {
93 out.zeros();
94 }
95
96 if( (out.n_elem > 0) && (A.n_elem > 0) )
97 {
98 const uword end_row = (std::min)(out_n_rows, A_n_rows) - 1;
99 const uword end_col = (std::min)(out_n_cols, A_n_cols) - 1;
100 const uword end_slice = (std::min)(out_n_slices, A_n_slices) - 1;
101
102 out.subcube(0, 0, 0, end_row, end_col, end_slice) = A.subcube(0, 0, 0, end_row, end_col, end_slice);
103 }
104
105 if(alias)
106 {
107 actual_out.steal_mem(B);
108 }
109
110 }
111
112
113
114 //! @}