File: fine_container.cweb

package info (click to toggle)
dynare 4.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 49,408 kB
  • sloc: cpp: 84,998; ansic: 29,058; pascal: 13,843; sh: 4,833; objc: 4,236; yacc: 3,622; makefile: 2,278; lex: 1,541; python: 236; lisp: 69; 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.