CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
test_numbers.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __test_numbers_h__
13#define __test_numbers_h__
14
15#include <fstream>
16#include "base/base.h"
17
18namespace CNORXZ
19{
20 namespace Test
21 {
23 class Numbers
24 {
25 private:
26 static Vector<Double> sCont;
27 static void init()
28 {
29 std::fstream f(TEST_NUMBER_FILE, f.in); // text file with simple format: size\nnum0\nnum1\n...
30 CXZ_ASSERT(f.is_open(), "test number file '" << TEST_NUMBER_FILE << "'not found");
31 SizeT nsize;
32 f >> nsize;
33 sCont.resize(nsize);
34 for(SizeT i = 0; i != nsize; ++i){
35 f >> sCont[i];
36 }
37 CXZ_ASSERT(f.good(), "error while reading test number file '" << TEST_NUMBER_FILE << "'");
38 f.close();
39 }
40
41 public:
42
43 static auto begin()
44 {
45 if(sCont.size() == 0) init();
46 return sCont.cbegin();
47 }
48
49 static auto end()
50 {
51 if(sCont.size() == 0) init();
52 return sCont.cend();
53 }
54
55 static auto get(SizeT pos, SizeT size)
56 {
57 auto b = begin()+pos;
58 auto e = b+size;
59 CXZ_ASSERT(e <= end(), "requested test numbers out of range");
60 return Vector<Double>(b,e);
61 }
62 };
64 }
65}
66
67#endif
#define CXZ_ASSERT(statement, errmsg)
Definition assert.h:40
basic headers