File: factory.h

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 (81 lines) | stat: -rw-r--r-- 1,814 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* $Id: factory.h 148 2005-04-19 15:12:26Z kamenik $ */
/* Copyright 2004, Ondra Kamenik */

#ifndef FACTORY_H
#define FACTORY_H 

#include "symmetry.h"
#include "int_sequence.h"
#include "twod_matrix.h"
#include "equivalence.h"
#include "rfs_tensor.h"
#include "t_container.h"

class Factory {
	void init(const Symmetry& s, const IntSequence& nvs);
	void init(int dim, int nv);
	void fillMatrix(TwoDMatrix& m) const;
public:
	double get() const;
	// this can be used with UGSTensor, FGSTensor
	template <class _Ttype>
	_Ttype* make(int r, const Symmetry& s, const IntSequence& nvs)
		{
			_Ttype* res = new _Ttype(r, TensorDimens(s, nvs));
			init(s, nvs);
			fillMatrix(*res);
			return res;
		}

	// this can be used with FFSTensor, UFSTensor, FRTensor, URTensor
	template <class _Ttype>
	_Ttype* make(int r, int nv, int dim)
		{
			_Ttype* res = new _Ttype(r, nv, dim);
			init(dim, nv);
			fillMatrix(*res);
			return res;
		}

	template <class _Ttype, class _Ctype>
	_Ctype* makeCont(int r, const IntSequence& nvs, int maxdim)
		{
			int symnum = nvs.size();
			_Ctype* res = new _Ctype(symnum);
			for (int dim = 1; dim <= maxdim; dim++) {
				if (symnum == 1) {
					// full symmetry
					Symmetry sym(dim);
					_Ttype* t = make<_Ttype>(r, sym, nvs);
					res->insert(t);
				} else {
					// general symmetry
					for (int i = 0; i <= dim; i++) {
						Symmetry sym(i, dim-i);
						_Ttype* t = make<_Ttype>(r, sym, nvs);
						res->insert(t);
					}
				}
			}
			return res;
		}

	template <class _Ttype, class _Ptype>
	_Ptype* makePoly(int r, int nv, int maxdim)
		{
			_Ptype* p = new _Ptype(r, nv);
			for (int d = 1; d <= maxdim; d++) {
				_Ttype* t = make<_Ttype>(r, nv, d);
				p->insert(t);
			}
			return p;
		}

	Vector* makeVector(int n);
};

#endif

// Local Variables:
// mode:C++
// End: