aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/vect.cc
blob: e38ed745a8d272bc91a49d23f8243524b9c3fb42 (plain)
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
#include <cassert>
#include <iostream>

#include "cctk.h"

#include "defs.hh"

#include "vect.hh"

using namespace std;



// Input
template<class T,int D>
void vect<T,D>::input (istream& is) {
  skipws (is);
  consume (is, '[');
  for (int d=0; d<D; ++d) {
    is >> (*this)[d];
    assert (is.good());
    if (d<D-1) {
      skipws (is);
      consume (is, ',');
    }
  }
  skipws (is);
  consume (is, ']');
}



// Output
template<class T,int D>
void vect<T,D>::output (ostream& os) const {
  os << "[";
  for (int d=0; d<D; ++d) {
    os << (*this)[d];
    if (d<D-1) os << ",";
  }
  os << "]";
}



// Specialise some constructors for lower dimensions
// These functions are declared, but must not be used.

template<> vect<int,0>::vect (const int& x, const int& y) { assert(0); }
template<> vect<int,1>::vect (const int& x, const int& y) { assert(0); }
template<> vect<int,3>::vect (const int& x, const int& y) { assert(0); }
template<> vect<int,4>::vect (const int& x, const int& y) { assert(0); }

template<> vect<int,0>::vect (const int& x, const int& y, const int& z) { assert(0); }
template<> vect<int,1>::vect (const int& x, const int& y, const int& z) { assert(0); }
template<> vect<int,2>::vect (const int& x, const int& y, const int& z) { assert(0); }
template<> vect<int,4>::vect (const int& x, const int& y, const int& z) { assert(0); }

template<> vect<int,0>::vect (const int& x, const int& y, const int& z, const int& t) { assert(0); }
template<> vect<int,1>::vect (const int& x, const int& y, const int& z, const int& t) { assert(0); }
template<> vect<int,2>::vect (const int& x, const int& y, const int& z, const int& t) { assert(0); }
template<> vect<int,3>::vect (const int& x, const int& y, const int& z, const int& t) { assert(0); }



// Note: We need all dimensions all the time.
template class vect<int,0>;
template class vect<int,1>;
template class vect<int,2>;
template class vect<int,3>;
template class vect<int,4>;

template void vect<CCTK_REAL,dim>::input (istream& is);
template void vect<vect<bool,2>,dim>::input (istream& is);
template void vect<vect<bool,dim>,2>::input (istream& is);

template void vect<bool,2>::output (ostream& os) const;
template void vect<bool,dim>::output (ostream& os) const;
template void vect<CCTK_REAL,2>::output (ostream& os) const;
template void vect<CCTK_REAL,dim>::output (ostream& os) const;
template void vect<vect<bool,2>,dim>::output (ostream& os) const;
template void vect<vect<int,2>,dim>::output (ostream& os) const;
template void vect<vect<bool,dim>,2>::output (ostream& os) const;
template void vect<vect<int,dim>,2>::output (ostream& os) const;