KASKADE 7 development version
numaMatrix.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the library KASKADE 7 */
4/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
5/* */
6/* Copyright (C) 2013-2015 Zuse Institute Berlin */
7/* */
8/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
9/* see $KASKADE/academic.txt */
10/* */
11/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13#ifndef NUMAMATRIX_HH
14#define NUMAMATRIX_HH
15
16#include <algorithm>
17#include <cassert>
18#include <vector>
19
20#include <boost/iterator/iterator_facade.hpp>
21
24
25namespace Kaskade {
26
27 // forward declaration
28 template <class Entry> class NumaDenseMatrix;
29
33 namespace NumaDenseMatrixDetail
34 {
35
36 template <class Entry>
37 class ColumnIterator: public boost::iterator_facade<ColumnIterator<Entry>,Entry,boost::random_access_traversal_tag>
38 {
39 public:
40 ColumnIterator() = default;
41
42 ColumnIterator(Entry* base_, size_t stride_, size_t idx_=0)
43 : base(base_), stride(stride_), idx(idx_) {}
44
45 size_t index() const { return idx; }
46
47 private:
48 friend class boost::iterator_core_access;
49
50 bool equal(ColumnIterator<Entry> const& p) const
51 {
52 return idx==p.idx;
53 }
54
55 void increment() { ++idx; }
56 void decrement() { --idx; }
57 void advance(typename ColumnIterator<Entry>::difference_type n) { idx += n; }
58 template <class E>
59 typename ColumnIterator<Entry>::difference_type distance_to(ColumnIterator<E> const& i) const { return i.idx - idx; }
60
61
62 Entry& dereference() const { return base[idx*stride]; }
63
64 Entry* base;
65 size_t stride;
66 size_t idx;
67 };
68
69 // ----------------------------------------------------------------------------------------------
70
71 template <class Entry>
72 class Row
73 {
74 public:
75 typedef ColumnIterator<Entry> iterator;
76 typedef ColumnIterator<Entry const> const_iterator;
77
78 Row() = default;
79
80 Row(Entry* first_, size_t stride_, std::size_t cols_)
81 : first(first_), stride(stride_), cols(cols_) {}
82
83 iterator begin() { return iterator(first,stride,0); }
84 iterator end() { return iterator(first,stride,cols); }
85 const_iterator begin() const { return const_iterator(first,stride,0); }
86 const_iterator end() const { return const_iterator(first,stride,cols); }
87
88 Entry& operator[](size_t c) { return first[stride*c]; }
89 Entry const& operator[](size_t c) const { return first[stride*c]; }
90
91 private:
92 Entry* first;
93 size_t stride;
94 size_t cols;
95 };
96
97 // ----------------------------------------------------------------------------------------------
98
99 template <class Entry>
100 class RowIterator: public boost::iterator_facade<RowIterator<Entry>,
101 typename std::conditional<std::is_const<Entry>::value,
102 Row<typename std::remove_const<Entry>::type> const,
103 Row<Entry>>::type,
104 boost::random_access_traversal_tag>
105 {
106 typedef typename std::remove_const<Entry>::type NonConstEntry;
107
108 typedef typename std::conditional<std::is_const<Entry>::value,
109 NumaDenseMatrix<NonConstEntry> const,
110 NumaDenseMatrix<Entry>>::type Matrix;
111
112 typedef boost::iterator_facade<RowIterator<Entry>,
113 typename std::conditional<std::is_const<Entry>::value,
114 Row<NonConstEntry> const,
115 Row<Entry>>::type,
116 boost::random_access_traversal_tag> Base;
117
118
119 public:
120 RowIterator() = default;
121
122 RowIterator(Matrix& mat_, size_t idx_)
123 : mat(&mat_)
124 {
125 update(idx_);
126 }
127
128 size_t index() const { return idx; }
129
130 private:
131 friend class boost::iterator_core_access;
132 using DifferenceType = Base::difference_type;
133
134 bool equal(RowIterator<Entry> const& other) const { return idx==other.idx;}
135 void increment() { update(idx+1); }
136 void decrement() { update(idx-1); }
137 void advance(typename RowIterator<Entry>::difference_type n) { update(idx+n); }
138 template <class E> DifferenceType distance_to(RowIterator<E> const& i) const { return static_cast<DifferenceType>(i.idx) - idx; }
139 typename Base::reference dereference() const { return row; }
140
141 // moves row as to represent row with index newidx.
142 void update(size_t newidx)
143 {
144 idx = newidx;
145 if (idx<mat->N()) // to not trip over the edge when arriving at end()
146 {
147 size_t chunk = uniformWeightRange(idx,mat->chunks.size(),mat->N());
148 size_t rowStart = uniformWeightRangeStart(chunk,mat->chunks.size(),mat->N());
149 size_t stride = uniformWeightRangeStart(chunk+1,mat->chunks.size(),mat->N()) - rowStart; // that's "LDA"
150 row = typename Base::value_type(const_cast<NonConstEntry*>(&mat->chunks[chunk][idx-rowStart]),stride,mat->M());
151 }
152 }
153
154 Matrix* mat;
155 size_t idx; // row index
156 mutable typename Base::value_type row; // dereference is const method, but can "point to" mutable row value type..
157 };
158
159 // ----------------------------------------------------------------------------------------------
160
161 template <class T, int n>
162 typename Dune::FieldTraits<T>::field_type frobenius_product(Dune::FieldVector<T,n> const& x, Dune::FieldVector<T,n> const& y)
163 {
164 typename Dune::FieldTraits<T>::field_type result = 0;
165 for (int i=0; i<n; ++i)
166 result += frobenius_product(x[i],y[i]);
167 return result;
168 }
169
170 template <class T, int n, int m>
171 typename Dune::FieldTraits<T>::field_type frobenius_product(Dune::FieldMatrix<T,n,m> const& x, Dune::FieldMatrix<T,n,m> const& y)
172 {
173 typename Dune::FieldTraits<T>::field_type result = 0;
174 for (int i=0; i<n; ++i)
175 for (int j=0; j<m; ++j)
176 result += frobenius_product(x[i][j],y[i][j]);
177 return result;
178 }
179
180 double frobenius_product(double x, double y) { return x*y; }
181 float frobenius_product(float x, float y) { return x*y; }
182
183
184
185 template <class T, int n>
186 typename Dune::FieldTraits<typename Dune::FieldTraits<T>::field_type>::real_type frobenius_norm2(Dune::FieldVector<T,n> const& x) { return x.two_norm2(); }
187
188 template <class T, int n, int m>
189 typename Dune::FieldTraits<typename Dune::FieldTraits<T>::field_type>::real_type frobenius_norm2(Dune::FieldMatrix<T,n,m> const& x) { return x.frobenius_norm2(); }
190
191 double frobenius_norm2(double x) { return x*x; }
192 float frobenius_norm2(float x) { return x*x; }
193
194
195 template <class T, int n>
196 typename Dune::FieldTraits<typename Dune::FieldTraits<T>::field_type>::real_type one_norm(Dune::FieldVector<T,n> const& x) { return x.one_norm(); }
197
198 template <class T, int n, int m>
199 typename Dune::FieldTraits<typename Dune::FieldTraits<T>::field_type>::real_type one_norm(Dune::FieldMatrix<T,n,m> const& x) { return x.one_norm(); }
200
201 double one_norm(double x) { return std::abs(x); }
202 float one_norm(float x) { return std::abs(x); }
203
204 template <class T, int n>
205 void axpy(Dune::FieldVector<T,n>& y, typename Dune::FieldTraits<T>::field_type const& a, Dune::FieldVector<T,n> const& x) { y.axpy(a,x); }
206
207 template <class T, int n, int m>
208 void axpy(Dune::FieldMatrix<T,n,m>& y, typename Dune::FieldTraits<T>::field_type const& a, Dune::FieldMatrix<T,n,m> const& x) { y += a*x; }
209
210 void axpy(double& y, double a, double x) { y += a*x; }
211 void axpy(float& y, float a, float x) { y += a*x; }
212
213 // ----------------------------------------------------------------------------------------------
214
215 // forward declaration
216 template <class Entry> class VectorIterator;
217
225 template <class Entry>
226 class NumaDenseBase
227 {
228 protected:
229 typedef std::vector<Entry,NumaAllocator<Entry>> Chunk; // the actual data storage type
230 typedef NumaDenseBase<Entry> Self;
231
232 public:
233 typedef size_t size_type;
234 typedef Entry value_type;
235
239 typedef typename Dune::FieldTraits<Entry>::field_type field_type;
240 typedef typename Dune::FieldTraits<field_type>::real_type real_type;
241
245 typedef Entry block_type;
246
255 NumaDenseBase (): NumaDenseBase(0,0)
256 {
257 }
258
262 NumaDenseBase (NumaDenseBase const& other)
263 : rows(other.rows), cols(other.cols), chunks(other.chunks.size())
264 {
265 parallelForNodes([&](int i, int n) // perform data copy on the respective
266 { // NUMA node
267 chunks[i] = other.chunks[i];
268 });
269 }
270
274 NumaDenseBase(NumaDenseBase&& a) = default;
275
279 NumaDenseBase (size_type r, size_type c, value_type v = value_type()) :
280 rows(r), cols(c)
281 {
282 size_type n = NumaThreadPool::instance().nodes();
283 chunks.reserve(n);
284 for (size_type i=0; i<n; ++i)
285 chunks.emplace_back((uniformWeightRangeStart(i+1,n,r)-uniformWeightRangeStart(i,n,r))*c,v,NumaAllocator<Entry>(i));
286 }
287
291 NumaDenseBase& operator=(NumaDenseBase const& other)
292 {
293 assert(chunks.size() == other.chunks.size()); // this can only be violated if the number of NUMA nodes changes...
294 rows = other.rows;
295 cols = other.cols;
296 parallelForNodes([&](int i, int n) // perform data copy on the respective
297 { // NUMA node
298 chunks[i] = other.chunks[i];
299 });
300 }
301
305 Self& operator=(field_type const& a)
306 {
307 for_each([&](Entry& e) { e = a; });
308 }
309
311
312 protected:
318 void resize (size_type r, size_type c)
319 {
320 // Check whether we need to change anything. Note that due to row blocking,
321 // the check rows*cols==n*m is NOT sufficient (the distribution of rows on
322 // NUMA nodes may change nevertheless).
323 if (rows==r && cols==c)
324 return;
325
326 rows = r;
327 cols = c;
328 for (int i=0; i<chunks.size(); ++i) // TODO: parallelize
329 chunks[i].resize((uniformWeightRangeStart(i+1,chunks.size(),r)-uniformWeightRangeStart(i,chunks.size(),r))*c);
330 }
331
332 public:
336 size_type N() const { return rows; }
337
338 protected:
342 size_type M() const { return cols; }
343
344
348 field_type dot(Self const& other) const
349 {
350 assert(rows==other.rows && cols==other.cols);
351 std::vector<field_type> dots(chunks.size());
352 parallelForNodes([&](int i, int n)
353 {
354 assert(n==chunks.size());
355 field_type sum = 0;
356 for (size_t k=0; k<chunks[i].size(); ++k)
357 sum += NumaDenseMatrixDetail::frobenius_product(chunks[i][k],other.chunks[i][k]);
358 dots[i] = sum;
359 });
360 return std::accumulate(dots.begin(),dots.end(),0);
361 }
362
369 template <class Result, class F>
370 Result accumulate(F f, Result const& init) const
371 {
372 std::vector<Result> rs(chunks.size());
373 parallelForNodes([&](int i, int n)
374 {
375 assert(n==this->chunks.size());
376 Result r = init;
377 for (auto const& e: chunks[i])
378 r = f(r,e);
379 rs[i] = r;
380 });
381 return std::accumulate(rs.begin()+1,rs.end(),rs[0],f);
382 }
383
387 template <class F>
388 void for_each(F const& f)
389 {
390 parallelForNodes([&](int i, int n)
391 {
392 assert(n==this->chunks.size());
393 std::for_each(begin(chunks[i]),end(chunks[i]),f);
394 });
395 }
396
400 template <class F>
401 void for_each2(F const& f, Self const& other)
402 {
403 assert(rows==other.rows && cols==other.cols);
404 parallelForNodes([&](int i, int n)
405 {
406 assert(n==this->chunks.size());
407 for (size_t j=0; j<chunks[i].size(); ++j)
408 f(chunks[i][j],other.chunks[i][j]);
409 });
410 }
411
412 private:
413 friend class NumaDenseMatrixDetail::RowIterator<Entry>;
414 friend class NumaDenseMatrixDetail::RowIterator<Entry const>;
415 friend class NumaDenseMatrixDetail::VectorIterator<Entry>;
416 friend class NumaDenseMatrixDetail::VectorIterator<Entry const>;
417
418 size_type rows, cols; // the matrix dimensions
419 std::vector<Chunk> chunks; // for each NUMA node a separate array to store the entries
420 };
421
422 }
427 //-------------------------------------------------------------------------------------------
428
446 template <class Entry>
447 class NumaDenseMatrix: public NumaDenseMatrixDetail::NumaDenseBase<Entry>
448 {
450 typedef NumaDenseMatrixDetail::NumaDenseBase<Entry> Base;
451
452 public:
453 typedef size_t size_type;
454 typedef Entry value_type;
455
459 typedef typename Dune::FieldTraits<Entry>::field_type field_type;
460 typedef typename Dune::FieldTraits<field_type>::real_type real_type;
461
462 typedef NumaDenseMatrixDetail::RowIterator<Entry> RowIterator;
463 typedef NumaDenseMatrixDetail::RowIterator<Entry const> ConstRowIterator;
464
465 typedef typename RowIterator::value_type row_type;
466 typedef typename ConstRowIterator::value_type const_row_type;
467
476 NumaDenseMatrix () = default;
477
481 NumaDenseMatrix (NumaDenseMatrix const& a) = default;
482
487
492 : Base(r,c,v)
493 {}
494
499
504 {
505 Base::operator=(a);
506 return *this;
507 }
508
515 {
516 Base::resize(r,c);
517 }
518
525 {
526 resize(r,c);
527 }
528
530
539 RowIterator begin() { return RowIterator(*this,0); }
540
544 RowIterator end() { return RowIterator(*this,this->N()); }
545
549 ConstRowIterator begin() const { return ConstRowIterator(*this,0); }
550
554 ConstRowIterator end() const { return ConstRowIterator(*this,this->N()); }
555
562 row_type operator[] (size_type row) { return *RowIterator(*this,row); }
563
570 const_row_type const operator[] (size_type row) const { return *ConstRowIterator(*this,row); }
571
573
577 size_type M() const { return Base::M(); }
578
588 {
589 this->for_each([&](Entry& e) { e *= a; });
590 return *this;
591 }
592
597 {
598 return (*this) *= (1/scalar);
599 }
600
606 {
607 this->for_each2([](Entry& y, Entry const& x) { y += x; },b);
608 return *this;
609 }
610
615 {
616 this->for_each2([](Entry& y, Entry const& x) { y -= x; },b);
617 return *this;
618 }
619
621
625 real_type frobenius_norm () const { return std::sqrt(frobenius_norm2()); }
626
631 {
632 return this->accumulate([](real_type s, Entry const& e) { return s+NumaDenseMatrixDetail::frobenius_norm2(e); }, real_type(0));
633 }
634 };
635
639 template <class Entry>
640 std::ostream& operator<<(std::ostream& out, NumaDenseMatrix<Entry> const& mat)
641 {
642 for (auto ri=mat.begin(); ri!=mat.end(); ++ri)
643 {
644 std::copy(ri->begin(),ri->end(),std::ostream_iterator<Entry>(out," "));
645 out << '\n';
646 }
647 return out;
648 }
649
650 // --------------------------------------------------------------------------
651
652 // forward declaration
653 template <class Entry> class NumaVector;
654
658 namespace NumaDenseMatrixDetail
659 {
660
661 template <class Entry>
662 class VectorIterator: public boost::iterator_facade<VectorIterator<Entry>,Entry,boost::random_access_traversal_tag>
663 {
664 typedef typename std::remove_const<Entry>::type NonConstEntry;
665
666 typedef typename std::conditional<std::is_const<Entry>::value,
669 public:
670 VectorIterator() = default;
671
672 VectorIterator(Vector& vec_, typename Vector::size_type idx_)
673 : vec(&vec_), idx(idx_) {}
674
675 size_t index() const { return idx; }
676
677 private:
678 friend class boost::iterator_core_access;
679
680 bool equal(VectorIterator<Entry> const& p) const
681 {
682 return idx==p.idx;
683 }
684
685 void increment() { ++idx; }
686 void decrement() { --idx; }
687 void advance(typename VectorIterator<Entry>::difference_type n) { idx += n; }
688 template <class E>
689 typename VectorIterator<Entry>::difference_type distance_to(VectorIterator<E> const& i) const { return i.idx - idx; }
690 Entry& dereference() const
691 {
692 size_t chunk = uniformWeightRange(idx,vec->chunks.size(),vec->N());
693 size_t chunkStart = uniformWeightRangeStart(chunk,vec->chunks.size(),vec->N());
694 return vec->chunks[chunk][idx-chunkStart];
695 }
696
697 Vector* vec;
698 typename Vector::size_type idx;
699 };
700 }
715 template <class Entry>
716 class NumaVector: public NumaDenseMatrixDetail::NumaDenseBase<Entry>
717 {
718 typedef NumaVector<Entry> Self;
719 typedef NumaDenseMatrixDetail::NumaDenseBase<Entry> Base;
720
721 public:
722 typedef typename Dune::FieldTraits<Entry>::field_type field_type;
723 typedef typename Dune::FieldTraits<field_type>::real_type real_type;
724 typedef typename Base::size_type size_type;
725 typedef typename Base::value_type value_type;
726 typedef NumaDenseMatrixDetail::VectorIterator<Entry> iterator;
727 typedef NumaDenseMatrixDetail::VectorIterator<Entry const> const_iterator;
728
729
738 NumaVector(): Base(0,1)
739 {}
740
744 NumaVector(NumaVector const& a) = default;
745
749 NumaVector (NumaVector&& a) = default;
750
755 Base(r,1,v)
756 {}
757
761 NumaVector& operator=(NumaVector const& a) = default;
762
768 void resize (size_type r) { Base::resize(r,1); }
769
771
779 iterator begin() { return iterator(*this,0); }
780
784 iterator end() { return iterator(*this,this->N()); }
785
789 const_iterator begin() const { return const_iterator(*this,0); }
790
794 const_iterator end() const { return const_iterator(*this,this->N()); }
795
799 Entry& operator[] (size_type row) { return *iterator(*this,row); }
800
804 Entry const& operator[] (size_type row) const { return *const_iterator(*this,row); }
805
807
818 {
819 this->for_each([&](Entry& e) { e *= a; });
820 return *this;
821 }
822
827 {
828 return (*this) *= (1/a);
829 }
830
837 {
838 this->for_each2([](Entry& yi, Entry const& xi) { yi += xi; },x);
839 return *this;
840 }
841
848 {
849 this->for_each2([](Entry& yi, Entry const& xi) { yi -= xi; },x);
850 return *this;
851 }
852
856 Self& axpy(field_type const& a, Self const& x)
857 {
858 this->for_each2([&](Entry& yi, Entry const& xi) { NumaDenseMatrixDetail::axpy(yi,a,xi); },x);
859 return *this;
860 }
861
863
874 real_type two_norm () const { return std::sqrt(two_norm2()); }
875
880 {
881 return this->accumulate([](real_type s, Entry const& e) { return s+NumaDenseMatrixDetail::frobenius_norm2(e); }, real_type(0));
882 }
883
888 {
889 return this->accumulate([](real_type s, Entry const& e) { return s+NumaDenseMatrixDetail::one_norm(e); }, real_type(0));
890 }
891
895 field_type dot(Self const& other) const { return Base::dot(other); }
896
898 };
899
903 template <class Entry>
904 std::ostream& operator<<(std::ostream& out, NumaVector<Entry> const& vec)
905 {
906 using namespace std;
907 copy(begin(vec),end(vec),ostream_iterator<Entry>(out," "));
908 return out;
909 }
910}
911
912#endif
A dense matrix class tailored towards NUMA architectures.
Definition: numaMatrix.hh:448
NumaDenseMatrix()=default
Creates a 0 x 0 matrix.
NumaDenseMatrix(NumaDenseMatrix const &a)=default
Copy constructor.
void resize(size_type r, size_type c)
Resizes the matrix to r x c, leaving the entries in an undefined state.
Definition: numaMatrix.hh:514
real_type frobenius_norm() const
frobenius norm: sqrt(sum over squared frobenius norms of entries)
Definition: numaMatrix.hh:625
Dune::FieldTraits< field_type >::real_type real_type
Definition: numaMatrix.hh:460
size_type M() const
Return the number of columns.
Definition: numaMatrix.hh:577
real_type frobenius_norm2() const
frobenius norm squared: sum over squared frobenius norms of entries
Definition: numaMatrix.hh:630
RowIterator::value_type row_type
Definition: numaMatrix.hh:465
Self & operator=(field_type const &a)
Assignment from scalar.
Definition: numaMatrix.hh:503
NumaDenseMatrixDetail::RowIterator< Entry > RowIterator
Definition: numaMatrix.hh:462
Self & operator-=(Self const &b)
Matrix subtraction.
Definition: numaMatrix.hh:614
ConstRowIterator end() const
Get const iterator to one beyond last row.
Definition: numaMatrix.hh:554
std::ostream & operator<<(std::ostream &out, NumaDenseMatrix< Entry > const &mat)
Definition: numaMatrix.hh:640
Self & operator/=(field_type const &scalar)
Division by a scalar.
Definition: numaMatrix.hh:596
Dune::FieldTraits< Entry >::field_type field_type
the type of the scalar field.
Definition: numaMatrix.hh:459
RowIterator end()
Get iterator to one beyond last row.
Definition: numaMatrix.hh:544
ConstRowIterator begin() const
Get const iterator to first row.
Definition: numaMatrix.hh:549
ConstRowIterator::value_type const_row_type
Definition: numaMatrix.hh:466
NumaDenseMatrixDetail::RowIterator< Entry const > ConstRowIterator
Definition: numaMatrix.hh:463
Self & operator+=(Self const &b)
Matrix addition. Both matrices have to have the same sizes.
Definition: numaMatrix.hh:605
NumaDenseMatrix(size_type r, size_type c, value_type v=value_type())
Creates an r x c matrix with given entries.
Definition: numaMatrix.hh:491
Self & operator*=(field_type const &a)
Multiplication with a scalar.
Definition: numaMatrix.hh:587
RowIterator begin()
Get iterator to first row.
Definition: numaMatrix.hh:539
row_type operator[](size_type row)
The subscript operator.
Definition: numaMatrix.hh:562
NumaDenseMatrix(NumaDenseMatrix &&a)=default
Move constructor.
void setSize(size_type r, size_type c)
Resizes the matrix to r x c, leaving the entries in an undefined state.
Definition: numaMatrix.hh:524
NumaDenseMatrix & operator=(NumaDenseMatrix const &a)=default
Copy assignment.
static NumaThreadPool & instance(int maxThreads=std::numeric_limits< int >::max())
Returns a globally unique thread pool instance.
int nodes() const
Reports the number of NUMA nodes (i.e., memory interfaces/CPU sockets)
Definition: threading.hh:316
A vector class tailored towards NUMA architectures. This vector distributes its entries in blocks of ...
Definition: numaMatrix.hh:717
Self & operator*=(field_type const &a)
Definition: numaMatrix.hh:817
iterator begin()
iterator to first entry.
Definition: numaMatrix.hh:779
const_iterator begin() const
const iterator to first row.
Definition: numaMatrix.hh:789
const_iterator end() const
const iterator to one beyond last entry.
Definition: numaMatrix.hh:794
NumaVector(size_type r, value_type v=value_type())
Creates an r vector with given entries.
Definition: numaMatrix.hh:754
NumaVector(NumaVector const &a)=default
Copy constructor.
real_type one_norm() const
one-norm: sum over absolute values of entries
Definition: numaMatrix.hh:887
real_type two_norm2() const
euclidean norm squared: sum over squared euclidean norms of entries
Definition: numaMatrix.hh:879
Self & operator/=(field_type const &a)
Definition: numaMatrix.hh:826
NumaVector & operator=(NumaVector const &a)=default
Copy assignment.
Base::value_type value_type
Definition: numaMatrix.hh:725
NumaDenseMatrixDetail::VectorIterator< Entry > iterator
Definition: numaMatrix.hh:726
field_type dot(Self const &other) const
Definition: numaMatrix.hh:895
NumaDenseMatrixDetail::VectorIterator< Entry const > const_iterator
Definition: numaMatrix.hh:727
iterator end()
iterator to one beyond last entry.
Definition: numaMatrix.hh:784
void resize(size_type r)
Resizes the vector to r entries, leaving the entries in an undefined state.
Definition: numaMatrix.hh:768
Entry & operator[](size_type row)
The subscript operator.
Definition: numaMatrix.hh:799
Self & axpy(field_type const &a, Self const &x)
Definition: numaMatrix.hh:856
NumaVector()
Creates a 0 vector.
Definition: numaMatrix.hh:738
Base::size_type size_type
Definition: numaMatrix.hh:724
NumaVector(NumaVector &&a)=default
Move constructor.
Dune::FieldTraits< Entry >::field_type field_type
Definition: numaMatrix.hh:722
std::ostream & operator<<(std::ostream &out, NumaVector< Entry > const &vec)
Definition: numaMatrix.hh:904
Dune::FieldTraits< field_type >::real_type real_type
Definition: numaMatrix.hh:723
Self & operator-=(Self const &x)
Definition: numaMatrix.hh:847
real_type two_norm() const
euclidean norm: sqrt(sum over squared euclidean norms of entries)
Definition: numaMatrix.hh:874
Self & operator+=(Self const &x)
Definition: numaMatrix.hh:836
void for_each2(Seq1 const &s1, Seq2 &s2, Func const &func)
Definition: fixfusion.hh:28
Index uniformWeightRangeStart(BlockIndex i, BlockIndex n, Index m)
Computes partitioning points of ranges for uniform weight distributions.
Definition: threading.hh:75
void parallelForNodes(Func const &f, int maxTasks=std::numeric_limits< int >::max())
A parallel for loop that executes the given functor in parallel on different NUMA nodes.
Definition: threading.hh:604
Index uniformWeightRange(Index j, Index n, Index m)
Computes the range in which an index is to be found when partitioned for uniform weights.
Definition: threading.hh:91
void axpy(Dune::BCRSMatrix< Dune::FieldMatrix< Scalar, 1, 1 > > const &P, Dune::BlockVector< Dune::FieldVector< Scalar, n > > const &x, Dune::BlockVector< Dune::FieldVector< Scalar, n > > &y, Scalar alpha=1.0)
Compute . If resetSolution=true computes .
Dune::FieldVector< Scalar, dim > Vector
EntryTraits< Entry >::real_type frobenius_norm2(Entry const &x)
Definition: scalar.hh:111