1 /*
2 * Copyright (c) 2012 Picture Elements, Inc.
3 * Stephen Williams (steve@icarus.com)
4 *
5 * This source code is free software; you can redistribute it
6 * and/or modify it in source code form under the terms of the GNU
7 * General Public License as published by the Free Software
8 * Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21 # include "netparray.h"
22
23 using namespace std;
24
~netsarray_t()25 netsarray_t::~netsarray_t()
26 {
27 }
28
~netparray_t()29 netparray_t::~netparray_t()
30 {
31 }
32
33 /*
34 * The packed width of a packed array is the packed width of the
35 * element times the dimension width of the array itself.
36 */
37
packed(void) const38 bool netparray_t::packed(void) const
39 {
40 return true;
41 }
42
packed_width(void) const43 long netparray_t::packed_width(void) const
44 {
45 long cur_width = element_type()->packed_width();
46
47 for (vector<netrange_t>::const_iterator cur = static_dimensions().begin()
48 ; cur != static_dimensions().end() ; ++cur) {
49 cur_width *= cur->width();
50 }
51
52 return cur_width;
53 }
54
slice_dimensions() const55 vector<netrange_t> netparray_t::slice_dimensions() const
56 {
57 const vector<netrange_t>&packed_dims = static_dimensions();
58
59 vector<netrange_t> elem_dims = element_type()->slice_dimensions();
60
61 vector<netrange_t> res (packed_dims.size() + elem_dims.size());
62
63 for (size_t idx = 0 ; idx < packed_dims.size() ; idx += 1)
64 res[idx] = packed_dims[idx];
65 for (size_t idx = 0 ; idx < elem_dims.size() ; idx += 1)
66 res[idx+packed_dims.size()] = elem_dims[idx];
67
68 return res;
69 }
70
~netuarray_t()71 netuarray_t::~netuarray_t()
72 {
73 }
74
slice_dimensions() const75 vector<netrange_t> netuarray_t::slice_dimensions() const
76 {
77 return static_dimensions();
78 }
79