File: factory.h

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 (92 lines) | stat: -rw-r--r-- 2,020 bytes parent folder | download
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
82
83
84
85
86
87
88
89
90
91
92
/* $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: