26 #include "globals.hpp"
28 #include "timezone/ztime_vector.hpp"
45 std::unique_ptr<AllocFactory>&& allocf_a=std::make_unique<FlexAllocFactory>(),
46 std::unique_ptr<AllocFactory>&& allocf_idx=std::make_unique<FlexAllocFactory>());
50 std::unique_ptr<AllocFactory>&& allocf_a=std::make_unique<FlexAllocFactory>(),
51 std::unique_ptr<AllocFactory>&& allocf_idx=std::make_unique<FlexAllocFactory>());
53 zts(std::unique_ptr<AllocFactory>&& allocf_a,
54 std::unique_ptr<AllocFactory>&& allocf_idx);
57 std::unique_ptr<AllocFactory>&& allocf_a=std::make_unique<FlexAllocFactory>(),
58 std::unique_ptr<AllocFactory>&& allocf_idx=std::make_unique<FlexAllocFactory>());
68 std::shared_ptr<Array<double>>&
getArrayPtr()
const {
return a; }
72 std::shared_ptr<Array<Global::dtime>>&
getIndexPtr()
const {
return idx; }
74 inline bool operator==(
const zts& o)
const {
75 return *idx == *o.idx && *a == *o.a;
78 inline const Vector<idx_type>& getdim()
const {
return a->getdim(); }
79 inline const idx_type getdim(idx_type d)
const {
return a->getdim(d); }
80 inline const idx_type size()
const {
return a->size(); }
81 inline const Vector<double>& getcol(idx_type i)
const {
return a->getcol(i); }
82 inline fsys::path getAllocfDirname()
const {
return a->allocf->getDirname(); }
83 inline void msync(
bool async)
const { a->msync(async); idx->msync(async); }
85 zts& append(
const char* buf,
size_t buflen,
size_t& offset);
88 Global::buflen_pair to_buffer(
size_t offset=0)
const;
90 inline zts& addprefix(
const string& prefix, idx_type d) { a->addprefix(prefix, d);
return *
this; }
92 zts& resize(idx_type d, idx_type sz, idx_type from=0);
97 template<
typename INDEX>
99 if (i.size() != a->dim.size()) {
100 throw range_error(
"incorrect number of dimensions");
106 i[0].subset(sidx, idx->getcol(0));
107 arr::idx_type dropfirst = 2;
112 template<
typename INDEX,
typename U>
119 template<
typename INDEX,
typename U>
127 zts subsetRows(idx_type from, idx_type to,
bool dummy=
false)
const;
137 zts& abind(
const zts& z, idx_type d,
const string& prefix=
"");
140 inline bool isPersistent()
const {
return a->isPersistent(); }
144 mutable std::shared_ptr<Array<double>> a;
145 mutable std::shared_ptr<Array<Global::dtime>> idx;
150 template <
typename DS,
typename DE>
156 auto dim = ts.getdim();
157 setv(dim, 0, y.
size());
160 for (
size_t i=0; i<a.ncols(); ++i) {
161 arr::align_closest<double, Global::NANF, DS, DE>
162 (ts.getIndex().getcol(0),
164 ts.getArray().getcol(i),
175 template <
typename F,
typename DS,
typename DE>
181 auto dim = ts.getArray().getdim();
182 setv(dim, 0, y.
size());
185 for (
size_t i=0; i<a.ncols(); ++i) {
186 arr::align_func<double, F, DS, DE>
187 (ts.getIndex().getcol(0),
189 ts.getArray().getcol(i),
199 template <
typename F>
200 void op(
const zts& x, zts& y)
202 for (
size_t i=0; i<y.getArray().ncols(); ++i) {
203 arr::op_zts<double, F>(x.getIndex().getcol(0), y.getIndex().getcol(0),
204 x.getArray().getcol(0), y.getArrayPtr()->getcol(i));
209 LengthMismatch(
const std::string& s) : std::invalid_argument(s) { }
212 UnorderedIndex(
const std::string& s) : std::invalid_argument(s) { }