File: fine_container.cweb

package info (click to toggle)
dynare 4.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 40,640 kB
  • sloc: fortran: 82,231; cpp: 72,734; ansic: 28,874; pascal: 13,241; sh: 4,300; objc: 3,281; yacc: 2,833; makefile: 1,288; lex: 1,162; python: 162; lisp: 54; xml: 8
file content (41 lines) | stat: -rw-r--r-- 935 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@q $Id: fine_container.cweb 1833 2008-05-18 20:22:39Z kamenik $ @>
@q Copyright 2005, Ondra Kamenik @>

@ Start of {\tt stack\_container.cpp} file.

@c
#include "fine_container.h"

#include <cmath>

@<|SizeRefinement| constructor code@>;

@ Here we construct the vector of new sizes of containers (before
|nc|) and copy all remaining sizes behind |nc|.

@<|SizeRefinement| constructor code@>=
SizeRefinement::SizeRefinement(const IntSequence& s, int nc, int max)
{
	new_nc = 0;
	for (int i = 0; i < nc; i++) {
		int nr = s[i]/max;
		if (s[i] % max != 0)
			nr++;
		int ss = (nr>0) ? (int)round(((double)s[i])/nr) : 0;
		for (int j = 0; j < nr - 1; j++) {
			rsizes.push_back(ss);
			ind_map.push_back(i);
			new_nc++;
		}
		rsizes.push_back(s[i]-(nr-1)*ss);
		ind_map.push_back(i);
		new_nc++;
	}

	for (int i = nc; i < s.size(); i++) {
		rsizes.push_back(s[i]);
		ind_map.push_back(i);
	}
}

@ End of {\tt stack\_container.cpp} file.