FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
power_vector.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
9#include <kernel/lafem/meta_element.hpp>
10#include <kernel/lafem/container.hpp>
11
12
13// includes, system
14#include <iostream>
15
16namespace FEAT
17{
18 namespace LAFEM
19 {
35 template<
36 typename SubType_,
37 int count_>
39 {
40 private:
41 // Note: the case = 1 is specialized below
42 static_assert(count_ > 1, "invalid block size");
43
44 // declare this class template as a friend for recursive inheritance
45 template<typename, int>
46 friend class PowerVector;
47
49 typedef PowerVector<SubType_, count_ - 1> RestClass;
50
52 void _read_from_binary(std::istream& file)
53 {
54 //process first
55 _first.read_from(FileMode::fm_binary, file);
56
57 // append rest
59 }
60
62 void _write_out_binary(std::ostream& file) const
63 {
64 //process first
65 _first.write_out(FileMode::fm_binary, file);
66
67 // append rest
69 }
70
71 public:
73 typedef SubType_ SubVectorType;
75 typedef typename SubVectorType::DataType DataType;
77 typedef typename SubVectorType::IndexType IndexType;
79 template <typename DT2_ = DataType, typename IT2_ = IndexType>
81
83 template <typename DataType2_, typename IndexType2_>
85
87 static constexpr int num_blocks = count_;
88
89 protected:
94
95 public:
98 {
99 }
100
107 explicit PowerVector(Index sub_size) :
108 _first(sub_size),
109 _rest(sub_size)
110 {
111 }
112
122 explicit PowerVector(Index sub_size, DataType value) :
123 _first(sub_size, value),
124 _rest(sub_size, value)
125 {
126 }
127
129 explicit PowerVector(SubVectorType&& the_first, RestClass&& the_rest) :
130 _first(std::move(the_first)),
131 _rest(std::move(the_rest))
132 {
133 }
134
137 _first(std::move(other._first)),
138 _rest(std::move(other._rest))
139 {
140 }
141
144 {
145 if(this != &other)
146 {
147 _first = std::move(other._first);
148 _rest = std::move(other._rest);
149 }
150 return *this;
151 }
152
154 PowerVector(const PowerVector&) = delete;
157
159 virtual ~PowerVector()
160 {
161 }
162
171 {
172 return PowerVector(_first.clone(mode), _rest.clone(mode));
173 }
174
182 void clone(const PowerVector& other, CloneMode clone_mode)
183 {
184 _first.clone(other._first, clone_mode);
185 _rest.clone(other._rest, clone_mode);
186 }
187
194 void clone(const PowerVector& other)
195 {
196 _first.clone(other._first);
197 _rest.clone(other._rest);
198 }
199
209 template<int i_>
211 {
212 static_assert((0 <= i_) && (i_ < count_), "invalid sub-vector index");
214 }
215
217 template<int i_>
218 const SubVectorType& at() const
219 {
220 static_assert((0 <= i_) && (i_ < count_), "invalid sub-vector index");
222 }
223
234 {
235 XASSERTM((0 <= i) && (i < count_), "invalid sub-vector index");
236 return (i == 0) ? _first : _rest.get(i-1);
237 }
238
240 const SubVectorType& get(int i) const
241 {
242 XASSERTM((0 <= i) && (i < count_), "invalid sub-vector index");
243 return (i == 0) ? _first : _rest.get(i-1);
244 }
245
247 std::uint64_t get_checkpoint_size(SerialConfig& config)
248 {
249 return sizeof(std::uint64_t) + _first.get_checkpoint_size(config) + _rest.get_checkpoint_size(config); //sizeof(std::uint64_t) bits needed to store lenght of checkpointed _first
250 }
251
253 void restore_from_checkpoint_data(std::vector<char> & data)
254 {
255 std::uint64_t isize = *(std::uint64_t*) data.data(); //get size of checkpointed _first
256 std::vector<char>::iterator start = std::begin(data) + sizeof(std::uint64_t);
257 std::vector<char>::iterator last_of_first = std::begin(data) + sizeof(std::uint64_t) + (int) isize;
258 std::vector<char> buffer_first(start, last_of_first);
259 _first.restore_from_checkpoint_data(buffer_first);
260
261 data.erase(std::begin(data), last_of_first);
263 }
264
266 std::uint64_t set_checkpoint_data(std::vector<char>& data, SerialConfig& config)
267 {
268 std::size_t old_size = data.size();
269 data.insert(std::end(data), sizeof(std::uint64_t), 0); //add placeholder
270 std::uint64_t ireal_size = _first.set_checkpoint_data(data, config); //add data of _first to the overall checkpoint and save its size
271 char* csize = reinterpret_cast<char*>(&ireal_size);
272 for(std::size_t i(0) ; i < sizeof(std::uint64_t) ; ++i) //overwrite the guessed datalength
273 {
274 data[old_size +i] = csize[i];
275 }
276
277 return sizeof(std::uint64_t) + ireal_size + _rest.set_checkpoint_data(data, config); //generate and add checkpoint data for the _rest
278 }
279
281 SubVectorType& first()
282 {
283 return _first;
284 }
285
286 const SubVectorType& first() const
287 {
288 return _first;
289 }
290
291 RestClass& rest()
292 {
293 return _rest;
294 }
295
296 const RestClass& rest() const
297 {
298 return _rest;
299 }
301
303 int blocks() const
304 {
305 return num_blocks;
306 }
307
309 template <Perspective perspective_ = Perspective::native>
310 Index size() const
311 {
312 return first().template size<perspective_>() + rest().template size<perspective_>();
313 }
314
322 {
323 first().format(value);
324 rest().format(value);
325 }
326
334 void format(Random & rng, DataType min, DataType max)
335 {
336 first().format(rng, min, max);
337 rest().format(rng, min, max);
338 }
339
341 void clear()
342 {
343 first().clear();
344 rest().clear();
345 }
346
348 static String name()
349 {
350 return String("PowerVector<") + SubVectorType::name() + "," + stringify(count_) + ">";
351 }
352
359 template<typename SubType2_>
360 void copy(const PowerVector<SubType2_, count_>& x, bool full = false)
361 {
362 first().copy(x.first(), full);
363 rest().copy(x.rest(), full);
364 }
365
378 void axpy(const PowerVector& x, DataType alpha = DataType(1))
379 {
380 first().axpy(x.first(), alpha);
381 rest().axpy(x.rest(), alpha);
382 }
383
390 void component_product(const PowerVector & x, const PowerVector & y)
391 {
392 first().component_product(x.first(), y.first());
393 rest().component_product(x.rest(), y.rest());
394 }
395
406 {
407 first().component_invert(x.first(), alpha);
408 rest().component_invert(x.rest(), alpha);
409 }
410
420 void scale(const PowerVector& x, DataType alpha)
421 {
422 first().scale(x.first(), alpha);
423 rest().scale(x.rest(), alpha);
424 }
425
432 DataType dot(const PowerVector& x) const
433 {
434 return first().dot(x.first()) + rest().dot(x.rest());
435 }
436
440 DataType triple_dot(const PowerVector& x, const PowerVector& y) const
441 {
442 return first().triple_dot(x.first(), y.first())
443 + rest().triple_dot(x.rest(), y.rest());
444 }
445
450 {
451 return first().norm2sqr() + rest().norm2sqr();
452 }
453
458 {
459 return Math::sqrt(norm2sqr());
460 }
461
468 {
469 return Math::max(first().max_abs_element(), rest().max_abs_element());
470 }
471
478 {
479 return Math::min(first().min_abs_element(), rest().min_abs_element());
480 }
481
488 {
489 return Math::max(first().max_element(), rest().max_element());
490 }
491
498 {
499 return Math::min(first().min_element(), rest().min_element());
500 }
501
509 {
510 return Math::max(first().max_rel_diff(x.first()), rest().max_rel_diff(x.rest()));
511 }
512
521 bool same_layout(const PowerVector& x) const
522 {
523 return (first().same_layout(x.first())) && (rest().same_layout(x.rest()));
524 }
525
533 const DataType operator()(Index index) const
534 {
535 ASSERT(index < size());
536
537 if (index < first().size())
538 {
539 return first()(index);
540 }
541 else
542 {
543 return rest()(index - first().size());
544 }
545 }
546
554 {
555 ASSERT(index < size());
556
557 if (index < first().size())
558 {
559 first()(index, value);
560 }
561 else
562 {
563 rest()(index - first().size(), value);
564 }
565 }
566
569 void set_vec(DataType * const pval_set) const
570 {
571 this->first().set_vec(pval_set);
572 this->rest().set_vec(pval_set + this->first().template size<Perspective::pod>());
573 }
574
576 void set_vec_inv(const DataType * const pval_set)
577 {
578 this->first().set_vec_inv(pval_set);
579 this->rest().set_vec_inv(pval_set + this->first().template size<Perspective::pod>());
580 }
582
590 template<typename SubType2_>
592 {
593 this->first().convert(other.first());
594 this->rest().convert(other.rest());
595 }
596
598 std::size_t bytes() const
599 {
600 return _first.bytes() + _rest.bytes();
601 }
602
609 void read_from(FileMode mode, const String& filename)
610 {
611 std::ifstream file(filename.c_str(), std::ifstream::in | std::ifstream::binary);
612 if (! file.is_open())
613 XABORTM("Unable to open Vector file " + filename);
614 read_from(mode, file);
615 file.close();
616 }
617
624 void read_from(FileMode mode, std::istream& file)
625 {
626 switch(mode)
627 {
629 {
630 std::uint64_t magic; // magic_number
631 file.read((char *)&magic, (long)(sizeof(std::uint64_t)));
632 if (magic != 100)
633 XABORTM("Given file or file component is no PowerVector!");
634 std::uint64_t count; // subvector count
635 file.read((char *)&count, (long)(sizeof(std::uint64_t)));
636 if (count != count_)
637 XABORTM("PowerVector file read in component count mismatch: class has " + stringify(count_) + "- " + stringify(count) + " read in!");
638
639 _read_from_binary(file);
640 break;
641 }
642 default:
643 XABORTM("Filemode not supported!");
644 }
645 }
646
653 void write_out(FileMode mode, const String& filename) const
654 {
655 std::ofstream file(filename.c_str(), std::ofstream::out | std::ofstream::binary);
656 if (! file.is_open())
657 XABORTM("Unable to open Vector file " + filename);
658 write_out(mode, file);
659 file.close();
660 }
661
668 void write_out(FileMode mode, std::ostream& file) const
669 {
670 switch(mode)
671 {
673 {
674 size_t gsize(2 * sizeof(std::uint64_t)); // magic_number and subvector count
675 std::vector<char> result(gsize);
676 char * array(result.data());
677 std::uint64_t * uiarray(reinterpret_cast<std::uint64_t *>(array));
678 uiarray[0] = 100;
679 uiarray[1] = count_;
680
681 file.write(result.data(), long(result.size()));
682
683 _write_out_binary(file);
684 break;
685 }
686 default:
687 XABORTM("Filemode not supported!");
688 }
689 }
690 }; // class PowerVector<...>
691
693
698 template<typename SubType_>
699 class PowerVector<SubType_, 1>
700 {
701 private:
702
703 template<typename, int>
704 friend class PowerVector;
705
707 void _read_from_binary(std::istream& file)
708 {
709 //process first
710 _first.read_from(FileMode::fm_binary, file);
711 }
712
714 void _write_out_binary(std::ostream& file) const
715 {
716 //process first
717 _first.write_out(FileMode::fm_binary, file);
718 }
719
720 public:
721 typedef SubType_ SubVectorType;
722
723 typedef typename SubVectorType::DataType DataType;
724 typedef typename SubVectorType::IndexType IndexType;
725 template <typename DT2_ = DataType, typename IT2_ = IndexType>
726 using ContainerType = PowerVector<typename SubType_::template ContainerType<DT2_, IT2_>, Index(1)>;
727
729 template <typename DataType2_, typename IndexType2_>
730 using ContainerTypeByDI = ContainerType<DataType2_, IndexType2_>;
731
732 static constexpr int num_blocks = 1;
733
734 protected:
736
737 public:
738 PowerVector()
739 {
740 }
741
742 explicit PowerVector(Index sub_size)
743 : _first(sub_size)
744 {
745 }
746
747 explicit PowerVector(Index sub_size, DataType value)
748 : _first(sub_size, value)
749 {
750 }
751
752 explicit PowerVector(SubVectorType&& the_first) :
753 _first(std::move(the_first))
754 {
755 }
756
757 PowerVector(PowerVector&& other) :
758 _first(std::move(other._first))
759 {
760 }
761
762 PowerVector& operator=(PowerVector&& other)
763 {
764 if(this != &other)
765 {
766 _first = std::move(other._first);
767 }
768 return *this;
769 }
770
772 PowerVector(const PowerVector&) = delete;
774 PowerVector& operator=(const PowerVector&) = delete;
775
776 virtual ~PowerVector()
777 {
778 }
779
787 PowerVector clone(LAFEM::CloneMode mode = LAFEM::CloneMode::Weak) const
788 {
789 return PowerVector(_first.clone(mode));
790 }
791
799 void clone(const PowerVector& other, CloneMode clone_mode)
800 {
801 _first.clone(other._first, clone_mode);
802 }
803
810 void clone(const PowerVector& other)
811 {
812 _first.clone(other._first);
813 }
814
815 template<int i>
817 {
818 static_assert(i == 0, "invalid sub-vector index");
819 return _first;
820 }
821
822 template<int i>
823 const SubVectorType& at() const
824 {
825 static_assert(i == 0, "invalid sub-vector index");
826 return _first;
827 }
828
829 SubVectorType& get(int i)
830 {
831 XASSERTM(i == 0, "invalid sub-vector index");
832 return _first;
833 }
834
835 const SubVectorType& get(int i) const
836 {
837 XASSERTM(i == 0, "invalid sub-vector index");
838 return _first;
839 }
840
841 SubVectorType& first()
842 {
843 return _first;
844 }
845
846 const SubVectorType& first() const
847 {
848 return _first;
849 }
850
852 std::uint64_t get_checkpoint_size(SerialConfig& config)
853 {
854 return _first.get_checkpoint_size(config);
855 }
856
858 void restore_from_checkpoint_data(std::vector<char> & data)
859 {
860 _first.restore_from_checkpoint_data(data);
861 }
862
864 std::uint64_t set_checkpoint_data(std::vector<char>& data, SerialConfig& config)
865 {
866 return _first.set_checkpoint_data(data, config);
867 }
868
869 int blocks() const
870 {
871 return 1;
872 }
873
874 template <Perspective perspective_ = Perspective::native>
875 Index size() const
876 {
877 return _first.template size<perspective_>();
878 }
879
880 void format(DataType value = DataType(0))
881 {
882 _first.format(value);
883 }
884
885 void format(Random & rng, DataType min, DataType max)
886 {
887 first().format(rng, min, max);
888 }
889
890 void clear()
891 {
892 first().clear();
893 }
894
895 static String name()
896 {
897 return String("PowerVector<") + SubVectorType::name() + ",1>";
898 }
899
900 template<typename SubType2_>
901 void copy(const PowerVector<SubType2_, 1>& x, bool full = false)
902 {
903 first().copy(x.first(), full);
904 }
905
906 void axpy(const PowerVector& x, DataType alpha = DataType(1))
907 {
908 first().axpy(x.first(), alpha);
909 }
910
911 void component_product(const PowerVector & x, const PowerVector & y)
912 {
913 first().component_product(x.first(), y.first());
914 }
915
916 void component_invert(const PowerVector& x, DataType alpha = DataType(1))
917 {
918 first().component_invert(x.first(), alpha);
919 }
920
921 void scale(const PowerVector& x, DataType alpha)
922 {
923 first().scale(x.first(), alpha);
924 }
925
926 DataType dot(const PowerVector& x) const
927 {
928 return first().dot(x.first());
929 }
930
931 DataType triple_dot(const PowerVector& x, const PowerVector& y) const
932 {
933 return first().triple_dot(x.first(), y.first());
934 }
935
936 DataType triple_dot_i(const PowerVector& x, const PowerVector& y) const
937 {
938 return first().triple_dot_i(x.first(), y.first());
939 }
940
941 DataType norm2sqr() const
942 {
943 return first().norm2sqr();
944 }
945
946 DataType norm2() const
947 {
948 return Math::sqrt(norm2sqr());
949 }
950
952 {
953 return first().max_abs_element();
954 }
955
957 {
958 return first().min_abs_element();
959 }
960
961 DataType max_element() const
962 {
963 return first().max_element();
964 }
965
966 DataType min_element() const
967 {
968 return first().min_element();
969 }
970
971 const DataType operator()(Index index) const
972 {
973 ASSERT(index < size());
974
975 return first()(index);
976 }
977
978 void operator()(Index index, DataType value)
979 {
980 ASSERT(index < size());
981
982 first()(index, value);
983 }
984
985 void set_vec(DataType * const pval_set) const
986 {
987 this->first().set_vec(pval_set);
988 }
989
990 void set_vec_inv(const DataType * const pval_set)
991 {
992 this->first().set_vec_inv(pval_set);
993 }
994
1002 template<typename SubType2_>
1003 void convert(const PowerVector<SubType2_, 1>& other)
1004 {
1005 this->first().convert(other.first());
1006 }
1007
1009 std::size_t bytes() const
1010 {
1011 return _first.bytes();
1012 }
1013
1020 void read_from(FileMode mode, const String& filename)
1021 {
1022 switch(mode)
1023 {
1025 read_from_binary(filename);
1026 break;
1027 default:
1028 XABORTM("Filemode not supported!");
1029 }
1030 }
1031
1038 void read_from(FileMode mode, std::istream& file)
1039 {
1040 switch(mode)
1041 {
1043 read_from_binary(file);
1044 break;
1045 default:
1046 XABORTM("Filemode not supported!");
1047 }
1048 }
1049
1055 void read_from_binary(const String& filename)
1056 {
1057 std::ifstream file(filename.c_str(), std::ifstream::in | std::ifstream::binary);
1058 if (! file.is_open())
1059 XABORTM("Unable to open Vector file " + filename);
1060 read_from_binary(file);
1061 file.close();
1062 }
1063
1069 void read_from_binary(std::istream& file)
1070 {
1071 std::uint64_t magic; // magic_number
1072 file.read((char *)&magic, (long)(sizeof(std::uint64_t)));
1073 if (magic != 100)
1074 XABORTM("Given file or file component is no PowerVector!");
1075 std::uint64_t count; // subvector count
1076 file.read((char *)&count, (long)(sizeof(std::uint64_t)));
1077 if (count != 1)
1078 XABORTM("PowerVector file read in component count mismatch: class has 1 - " + stringify(count) + " read in!");
1079
1080 _read_from_binary(file);
1081 }
1082
1089 void write_out(FileMode mode, const String& filename) const
1090 {
1091 switch(mode)
1092 {
1094 write_out_binary(filename);
1095 break;
1096 default:
1097 XABORTM("Filemode not supported!");
1098 }
1099 }
1100
1107 void write_out(FileMode mode, std::ostream& file) const
1108 {
1109 switch(mode)
1110 {
1112 write_out_binary(file);
1113 break;
1114 default:
1115 XABORTM("Filemode not supported!");
1116 }
1117 }
1118
1124 void write_out_binary(const String& filename) const
1125 {
1126 std::ofstream file(filename.c_str(), std::ofstream::out | std::ofstream::binary);
1127 if (! file.is_open())
1128 XABORTM("Unable to open Vector file " + filename);
1129 write_out_binary(file);
1130 file.close();
1131 }
1132
1140 void write_out_binary(std::ostream& file) const
1141 {
1142 size_t gsize(2 * sizeof(std::uint64_t)); // magic_number and subvector count
1143 std::vector<char> result(gsize);
1144 char * array(result.data());
1145 std::uint64_t * uiarray(reinterpret_cast<std::uint64_t *>(array));
1146 uiarray[0] = 100;
1147 uiarray[1] = 1; //fixed count_ for power vector specialization
1148
1149 file.write(result.data(), long(result.size()));
1150
1151 _write_out_binary(file);
1152 }
1153 }; // class PowerVector<...,1>
1154
1155 template <typename SubType_, Index count_>
1156 inline void dump_power_vector(std::ostream & os, const PowerVector<SubType_, count_>& x)
1157 {
1158 os << "," << x.first();
1159 dump_power_vector(os, x.rest());
1160 }
1161
1162 template <typename SubType_>
1163 inline void dump_power_vector(std::ostream & os, const PowerVector<SubType_, 1>& x)
1164 {
1165 os << x.first();
1166 }
1167
1168 template <typename SubType_, Index count_>
1169 inline std::ostream& operator<< (std::ostream & os, const PowerVector<SubType_, count_>& x)
1170 {
1171 os << "[";
1172 dump_power_vector(os, x);
1173 os << "]";
1174 return os;
1175 }
1177 } // namespace LAFEM
1178} // namespace FEAT
#define ASSERT(expr)
Debug-Assertion macro definition.
Definition: assertion.hpp:229
#define XABORTM(msg)
Abortion macro definition with custom message.
Definition: assertion.hpp:192
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
Power-Vector meta class template.
PowerVector & operator=(const PowerVector &)=delete
deleted copy-assign operator
void _write_out_binary(std::ostream &file) const
write binary data of _first and _rest to file.
void convert(const PowerVector< SubType2_, count_ > &other)
Conversion method.
void write_out(FileMode mode, const String &filename) const
Write out vector to file.
DataType norm2sqr() const
Returns the squared euclid norm of this vector.
bool same_layout(const PowerVector &x) const
Checks if the structural layout of this vector matches that of another vector. This excludes comparis...
SubType_ SubVectorType
sub-vector type
const SubVectorType & get(int i) const
Returns a sub-vector block.
void operator()(Index index, DataType value)
Set specific PowerVector element.
PowerVector(SubVectorType &&the_first, RestClass &&the_rest)
base-class constructor; for internal use only
static String name()
Returns a descriptive string for this container.
PowerVector(PowerVector &&other)
move CTOR
PowerVector(const PowerVector &)=delete
deleted copy-ctor
void scale(const PowerVector &x, DataType alpha)
Performs .
SubVectorType::IndexType IndexType
sub-vector index type
DataType min_abs_element() const
Retrieve the absolute minimum value of this vector.
PowerVector(Index sub_size, DataType value)
Constructor.
static constexpr int num_blocks
number of vector blocks
ContainerType< DataType2_, IndexType2_ > ContainerTypeByDI
this typedef lets you create a vector container with different Data and Index types
RestClass _rest
the remaining part
PowerVector< typename SubType_::template ContainerType< DT2_, IT2_ >, count_ > ContainerType
Our 'base' class type.
void clone(const PowerVector &other)
Turns this vector into a clone of other.
void copy(const PowerVector< SubType2_, count_ > &x, bool full=false)
Performs .
void restore_from_checkpoint_data(std::vector< char > &data)
Extract object from checkpoint.
void axpy(const PowerVector &x, DataType alpha=DataType(1))
Performs .
void component_invert(const PowerVector &x, DataType alpha=DataType(1))
Performs .
PowerVector clone(LAFEM::CloneMode mode=LAFEM::CloneMode::Weak) const
Creates and returns a copy of this vector.
const SubVectorType & at() const
Returns a sub-vector block.
void write_out(FileMode mode, std::ostream &file) const
Write out vector to file.
DataType min_element() const
Retrieve the minimum value of this vector.
const DataType operator()(Index index) const
Retrieve specific PowerVector element.
void clear()
Free all allocated arrays.
int blocks() const
Returns the number of blocks in this power-vector.
PowerVector< SubType_, count_ - 1 > RestClass
base-class typedef
std::uint64_t set_checkpoint_data(std::vector< char > &data, SerialConfig &config)
SubVectorType::DataType DataType
sub-vector data type
std::uint64_t get_checkpoint_size(SerialConfig &config)
Calculate size.
SubVectorType _first
the first sub-vector
DataType max_abs_element() const
Retrieve the absolute maximum value of this vector.
DataType max_element() const
Retrieve the maximum value of this vector.
void _read_from_binary(std::istream &file)
read binary data of _first and _rest to file.
DataType triple_dot(const PowerVector &x, const PowerVector &y) const
Calculate .
DataType max_rel_diff(const PowerVector &x) const
Retrieve the maximum relative difference of this vector and another one y.max_rel_diff(x) returns .
Index size() const
Returns the total number of scalar entries of this power-vector.
PowerVector & operator=(PowerVector &&other)
move-assign operator
std::size_t bytes() const
Returns the total amount of bytes allocated.
void format(Random &rng, DataType min, DataType max)
Reset all elements of the container to random values.
void read_from(FileMode mode, const String &filename)
Read in vector from file.
SubVectorType & at()
Returns a sub-vector block.
void format(DataType value=DataType(0))
Reset all elements of the container to a given value or zero if missing.
SubVectorType & get(int i)
Returns a sub-vector block.
PowerVector(Index sub_size)
Constructor.
void read_from(FileMode mode, std::istream &file)
Read in vector from stream.
DataType norm2() const
Returns the euclid norm of this vector.
void component_product(const PowerVector &x, const PowerVector &y)
Performs .
DataType dot(const PowerVector &x) const
Returns the dot-product of this vector and another vector.
void clone(const PowerVector &other, CloneMode clone_mode)
Turns this vector into a clone of other.
virtual ~PowerVector()
virtual destructor
Config class for serialize parameter.
Definition: container.hpp:47
Pseudo-Random Number Generator.
Definition: random.hpp:54
String class implementation.
Definition: string.hpp:46
@ other
generic/other permutation strategy
T_ sqrt(T_ x)
Returns the square-root of a value.
Definition: math.hpp:300
T_ min(T_ a, T_ b)
Returns the minimum of two values.
Definition: math.hpp:123
T_ max(T_ a, T_ b)
Returns the maximum of two values.
Definition: math.hpp:137
@ rest
restriction (multigrid)
FEAT namespace.
Definition: adjactor.hpp:12
String stringify(const T_ &item)
Converts an item into a String.
Definition: string.hpp:944
@ value
specifies whether the space should supply basis function values
std::uint64_t Index
Index data type.
Power container element helper class template.