39 #define TOON_ALIGN8 __attribute__ ((aligned(8))) 51 typedef Precision* PointerType;
52 typedef const Precision* ConstPointerType;
53 typedef Precision& ReferenceType;
54 typedef const Precision& ConstReferenceType;
58 template<
int Size,
class Precision,
bool heap>
class StackOrHeap;
60 template<
int Size,
class Precision>
class StackOrHeap<Size,Precision,0>
65 debug_initialize(my_data, Size);
67 Precision my_data[Size];
75 debug_initialize(my_data, Size);
77 double my_data[Size] TOON_ALIGN8 ;
81 template<
int Size,
class Precision>
class StackOrHeap<Size, Precision, 1>
85 :my_data(
new Precision[Size])
87 debug_initialize(my_data, Size);
99 :my_data(
new Precision[Size])
101 for(
int i=0; i < Size; i++)
102 my_data[i] = from.my_data[i];
130 template<
class Precision2,
int Size2>
133 static_assert(Size == Size2,
"Wrong number of elements to initialize static vector");
134 for(
int j=0; j < Size; j++)
149 Precision *get_data_ptr()
154 const Precision *get_data_ptr()
const 166 const Precision *data()
const 171 void try_destructive_resize(
int)
174 template<
class Op>
void try_destructive_resize(
const Operator<Op>&)
189 std::copy(i.begin(), i.end(), my_data);
193 :my_data(
new Precision[v.my_size]), my_size(v.my_size)
195 for(
int i=0; i < my_size; i++)
196 my_data[i] = v.my_data[i];
199 VectorAlloc(VectorAlloc&& from) noexcept
200 : my_data(from.my_data), my_size(from.my_size)
206 :my_data(
new Precision[s]), my_size(s)
208 debug_initialize(my_data, my_size);
213 : my_data(
new Precision[op.size()]), my_size(op.size())
215 debug_initialize(my_data, my_size);
226 Precision *get_data_ptr()
231 const Precision *get_data_ptr()
const 236 void swap(VectorAlloc& v)
239 std::swap(my_data, v.my_data);
249 const Precision *data()
const 254 void try_destructive_resize(
int)
257 template<
class Op>
void try_destructive_resize(
const Operator<Op>&)
269 std::vector<Precision> numbers;
285 debug_initialize(data(), size());
292 debug_initialize(data(), size());
296 return numbers.size();
299 Precision *get_data_ptr()
304 const Precision *get_data_ptr()
const 311 numbers.swap(s.numbers);
320 const Precision* data()
const {
327 template<
int S>
struct SFINAE_dummy{
typedef void type;};
341 try_destructive_resize(op.size());
346 void try_destructive_resize(
const Op&)
349 void try_destructive_resize(
int newsize)
351 numbers.resize(newsize);
352 debug_initialize(data(), newsize);
359 int old_size = size();
362 debug_initialize(data()+old_size, s-old_size);
371 template<
int S,
class Precision,
class PtrType=Precision*,
class ConstPtrType=const Precision*,
class RefType=Precision&,
class ConstRefType=const Precision&>
struct VectorSlice 379 const PtrType my_data;
395 ConstPtrType data()
const 400 void try_destructive_resize(
int)
403 template<
class Op>
void try_destructive_resize(
const Operator<Op>&)
407 typedef PtrType PointerType;
408 typedef ConstPtrType ConstPointerType;
409 typedef RefType ReferenceType;
410 typedef ConstRefType ConstReferenceType;
417 template<
class Precision,
class PtrType,
class ConstPtrType,
class RefType,
class ConstRefType>
struct VectorSlice<Dynamic, Precision, PtrType, ConstPtrType, RefType, ConstRefType>
419 const PtrType my_data;
423 :my_data(d), my_size(s)
440 ConstPtrType data()
const 445 void try_destructive_resize(
int)
448 template<
class Op>
void try_destructive_resize(
const Operator<Op>&)
452 typedef PtrType PointerType;
453 typedef ConstPtrType ConstPointerType;
454 typedef RefType ReferenceType;
455 typedef ConstRefType ConstReferenceType;
516 template<
typename Op>
542 template<
typename Op>
551 template<
int R,
int C,
class Precision,
bool FullyStatic=(R>=0 && C>=0)>
564 int num_rows()
const {
568 int num_cols()
const {
574 Precision* get_data_ptr()
579 const Precision* get_data_ptr()
const 586 template<
int R,
int C,
class Precision>
struct MatrixAlloc<R, C, Precision, false>
590 Precision*
const my_data;
599 my_data(
new Precision[num_rows()*num_cols()]) {
600 const int size=num_rows()*num_cols();
601 for(
int i=0; i < size; i++) {
602 my_data[i] = m.my_data[i];
609 my_data(
new Precision[num_rows()*num_cols()])
611 debug_initialize(my_data, num_rows()*num_cols());
617 my_data(
new Precision[num_rows()*num_cols()])
619 debug_initialize(my_data, num_rows()*num_cols());
626 Precision* get_data_ptr()
631 const Precision* get_data_ptr()
const 642 Precision*
const my_data;
Definition: allocator.hh:528
Definition: allocator.hh:58
Pretty generic SFINAE introspection generator.
Definition: vec_test.cc:21
Definition: allocator.hh:699
Definition: allocator.hh:49
VectorAlloc(int)
Construction from a size (required by damic vectors, ignored otherwise).
Definition: allocator.hh:128
Definition: allocator.hh:715
const int my_size
The size.
Definition: allocator.hh:491
RowSizeHolder(int i)
Construct from an int to provide a run time size if necessary.
Definition: allocator.hh:507
VectorAlloc()
Default constructor (only for statically sized vectors)
Definition: allocator.hh:125
Definition: operators.hh:119
int num_rows() const
Return the number of rows.
Definition: allocator.hh:520
SizeHolder(int)
Construct from an int and discard it.
Definition: allocator.hh:472
int num_cols() const
Return the number of columns.
Definition: allocator.hh:546
int size() const
Simply return the statcally known size.
Definition: allocator.hh:475
ColSizeHolder(int i)
Construct from an int to provide a run time size if necessary.
Definition: allocator.hh:533
int size() const
Return the size of the vector.
Definition: allocator.hh:143
VectorAlloc(const Operator< Op > &)
Construction from an Operator. See Operator::size().
Definition: allocator.hh:140
RowSizeHolder(const Operator< Op > &op)
Construct from an Operator, taking the size from the operator.
Definition: allocator.hh:517
ColSizeHolder(const Operator< Op > &op)
Construct from an Operator, taking the size from the operator.
Definition: allocator.hh:543
Definition: size_mismatch.hh:103
Definition: allocator.hh:638
Definition: allocator.hh:670
Definition: allocator.hh:371
SizeHolder()
Default constrution.
Definition: allocator.hh:471
Definition: introspection.hh:55
Definition: allocator.hh:122
Definition: allocator.hh:502
Definition: allocator.hh:112
Definition: allocator.hh:552
Definition: allocator.hh:468