ASL  0.1.7
Advanced Simulation Library
aclVectorOfElementsOperations.h
Go to the documentation of this file.
1 /*
2  * Advanced Simulation Library <http://asl.org.il>
3  *
4  * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5  *
6  *
7  * This file is part of Advanced Simulation Library (ASL).
8  *
9  * ASL is free software: you can redistribute it and/or modify it
10  * under the terms of the GNU Affero General Public License as
11  * published by the Free Software Foundation, version 3 of the License.
12  *
13  * ASL is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Affero General Public License for more details.
17  *
18  * You should have received a copy of the GNU Affero General Public License
19  * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 
24 #ifndef ACLVECTORELEMENTSOPERATIONS_H
25 #define ACLVECTORELEMENTSOPERATIONS_H
26 
27 #include "aclVectorOfElementsDef.h"
28 
29 namespace acl
30 {
31 
32  class ElementBase;
33  class MemBlock;
34  class KernelConfiguration;
35 
36 
37  typedef std::shared_ptr<ElementBase> Element;
38  typedef std::shared_ptr<MemBlock> ElementData;
39 
40  class VectorOfElements;
41 
42  typedef shared_ptr<VectorOfElementsData> SPVectorOfElementsData;
43  typedef shared_ptr<VectorOfElements> SPVectorOfElements;
44 
47  VectorOfElementsData clone(VectorOfElementsData a);
48 
51  VectorOfElementsData clone(VectorOfElementsData a, unsigned int n);
52 
53 
56  void initData(VectorOfElements a,
57  VectorOfElements initializationValue,
58  const KernelConfiguration & kernelConfig);
59 
62  void initData(VectorOfElements a,
63  VectorOfElements initializationValue);
64 
65 
67 
70  void copy(const vector<Element> & source,
71  VectorOfElements & destination);
72 
74 
77  void copy(const vector<ElementData> & source,
78  VectorOfElements & destination);
79 
81 
85  void copy(const vector<Element> & source,
86  VectorOfElements & destination, unsigned int start, unsigned int end);
87 
88 
90 
93  void copy(const VectorOfElementsData & source,
94  VectorOfElementsData & destination);
95 
96 
99  VectorOfElements subVE(const VectorOfElements & source,
100  unsigned int start,
101  unsigned int end);
102 
105  VectorOfElements subVE(const VectorOfElements & source,
106  unsigned int i);
107 
110  VectorOfElements subVE(const VectorOfElements & source,
111  const vector<unsigned int> & iList);
112 
115  VectorOfElementsData subVE(const VectorOfElementsData & source,
116  unsigned int start,
117  unsigned int end);
118 
119 
123  void swapBuffers(const VectorOfElementsData & a,
124  const VectorOfElementsData & b);
125 
127 
130 
133  VectorOfElements assignmentSafe(const VectorOfElements & a,
134  const VectorOfElements & b);
135 
136 
139  VectorOfElements operator-(const VectorOfElements & a);
140 
141 
145  VectorOfElements operator+=(const VectorOfElements & a,
146  const VectorOfElements & b);
147 
148 
151  VectorOfElements operator-=(const VectorOfElements & a,
152  const VectorOfElements & b);
153 
154 
158  VectorOfElements operator*=(const VectorOfElements & a,
159  const VectorOfElements & b);
160 
161 
165  VectorOfElements operator/=(const VectorOfElements & a,
166  const VectorOfElements & b);
167 
168 
171  VectorOfElements operator+(const VectorOfElements & a,
172  const VectorOfElements & b);
173 
174 
177  VectorOfElements operator-(const VectorOfElements & a,
178  const VectorOfElements & b);
179 
180 
185  VectorOfElements operator*(const VectorOfElements & a,
186  const VectorOfElements & b);
187 
188 
191  VectorOfElements operator/(const VectorOfElements & a,
192  const VectorOfElements & b);
193 
196  VectorOfElements operator%(const VectorOfElements & a,
197  const VectorOfElements & b);
198 
199 
202  VectorOfElements operator==(const VectorOfElements & a,
203  const VectorOfElements & b);
204 
205 
208  VectorOfElements operator!=(const VectorOfElements & a,
209  const VectorOfElements & b);
210 
211 
214  VectorOfElements operator>(const VectorOfElements & a, const VectorOfElements & b);
215 
216 
219  VectorOfElements operator<(const VectorOfElements & a,
220  const VectorOfElements & b);
221 
224  VectorOfElements operator<=(const VectorOfElements & a,
225  const VectorOfElements & b);
226 
229  VectorOfElements operator>=(const VectorOfElements & a,
230  const VectorOfElements & b);
231 
234  VectorOfElements operator&&(const VectorOfElements & a,
235  const VectorOfElements & b);
236 
239  VectorOfElements operator||(const VectorOfElements & a,
240  const VectorOfElements & b);
241 
244  VectorOfElements operator!(const VectorOfElements & a);
245 
246 
250  VectorOfElements crossProduct(const VectorOfElements & a,
251  const VectorOfElements & b);
252 
253 
257  inline VectorOfElements l2(const VectorOfElements & a);
258 
259 
263  VectorOfElements productOfElements(const VectorOfElements & a,
264  const VectorOfElements & b);
265 
269  VectorOfElements productOfElements(const VectorOfElements & a);
270 
273  VectorOfElements divisionOfElements(const VectorOfElements & a,
274  const VectorOfElements & b);
275 
278  VectorOfElements min(const VectorOfElements & a,
279  const VectorOfElements & b);
280 
283  VectorOfElements min(const VectorOfElements & a,
284  const VectorOfElements & b,
285  TypeID type);
286 
289  VectorOfElements minAbs(const VectorOfElements & a,
290  const VectorOfElements & b);
291 
294  VectorOfElements max(const VectorOfElements & a,
295  const VectorOfElements & b);
296 
299  VectorOfElements max(const VectorOfElements & a,
300  const VectorOfElements & b,
301  TypeID type);
302 
305  VectorOfElements copysign(const VectorOfElements & a,
306  const VectorOfElements & b);
307 
310  VectorOfElements copysign(const VectorOfElements & a,
311  const VectorOfElements & b,
312  TypeID t);
313 
316  VectorOfElements sign(const VectorOfElements & a);
317 
322  VectorOfElements excerpt(const VectorOfElements & source,
323  const VectorOfElements & filter);
324 
325 
329 
334  VectorOfElements select(const VectorOfElements & a,
335  const VectorOfElements & b,
336  const VectorOfElements & c);
337 
341 
346  VectorOfElements select(const VectorOfElements & a,
347  const VectorOfElements & b,
348  const VectorOfElements & c,
349  TypeID t);
350 
354 
359  VectorOfElements select(const VectorOfElements & b,
360  const VectorOfElements & c,
361  TypeID t);
362 
367  VectorOfElements mad(const VectorOfElements & a,
368  const VectorOfElements & b,
369  const VectorOfElements & c);
370 
375  VectorOfElements mad(const VectorOfElements & a,
376  const VectorOfElements & b,
377  const VectorOfElements & c,
378  TypeID t);
379 
382  VectorOfElements log(const VectorOfElements & a);
383 
384 
387  VectorOfElements log10(const VectorOfElements & a);
388 
389 
392  VectorOfElements powI(const VectorOfElements & a, unsigned int i);
393 
394 
397  VectorOfElements exp(const VectorOfElements & a);
398 
401  VectorOfElements sqrt(const VectorOfElements & a);
402 
405  VectorOfElements rsqrt(const VectorOfElements & a);
406 
409  VectorOfElements fabs(const VectorOfElements & a);
410 
413  VectorOfElements abs(const VectorOfElements & a);
414 
417  VectorOfElements abs_diff(const VectorOfElements & a, const VectorOfElements & b);
418 
421  VectorOfElements floor(const VectorOfElements & a);
422 
425  VectorOfElements convert(acl::TypeID type, const VectorOfElements & a, bool strong=true);
426 
429  VectorOfElements minElement(const VectorOfElements & a);
430 
433  VectorOfElements minAbsElement(const VectorOfElements & a);
434 
437  VectorOfElements maxElement(const VectorOfElements & a);
438 
441  VectorOfElements sumOfElements(const VectorOfElements & a);
442 
445  VectorOfElements andOfElements(const VectorOfElements & a);
446 
449  VectorOfElements orOfElements(const VectorOfElements & a);
450 
453 
466  VectorOfElements cat(const VectorOfElements & a,
467  const VectorOfElements & b);
468 
471 
484  VectorOfElementsData cat(const VectorOfElementsData & a,
485  const VectorOfElementsData & b);
486 
489 
507  VectorOfElements cat(const VectorOfElements & a,
508  const VectorOfElements & b,
509  const VectorOfElements & c);
510 
513  VectorOfElements cat(const VectorOfElements * a,
514  unsigned int n);
515 
518  VectorOfElements catN(const VectorOfElements & a,
519  unsigned int n);
520 
521 
525  template <typename T> VectorOfElements operator+=(const VectorOfElements & a,
526  const T & b);
527 
528 
533  template <typename T> VectorOfElements operator-=(const VectorOfElements & a,
534  const T & b);
535 
536 
539 
542  template <typename T> VectorOfElements operator*=(const VectorOfElements & a,
543  const T & b);
544 
545 
548 
551  template <typename T> VectorOfElements operator/=(const VectorOfElements & a,
552  const T & b);
553 
554 
557 
560  template <typename T> VectorOfElements operator+(const VectorOfElements & a,
561  const T & b);
562 
563 
566 
569  template <typename T> VectorOfElements operator+(const T & a,
570  const VectorOfElements & b);
571 
572 
577  template <typename T> VectorOfElements operator-(const VectorOfElements & a,
578  const T & b);
579 
580 
585  template <typename T> VectorOfElements operator-(const T & a,
586  const VectorOfElements & b);
587 
588 
593  template <typename T> VectorOfElements operator*(const VectorOfElements & a,
594  const T & b);
595 
596 
601  template <typename T> VectorOfElements operator*(const T & a,
602  const VectorOfElements & b);
603 
604 
607 
610  template <typename T> VectorOfElements operator/(const VectorOfElements & a,
611  const T & b);
612 
615 
618  template <typename T> VectorOfElements operator%(const VectorOfElements & a,
619  const T & b);
620 
623 
626  template <typename T> VectorOfElements operator/(const T & b,
627  const VectorOfElements & a);
628 
631 
634  template <typename T> VectorOfElements operator%(const T & b,
635  const VectorOfElements & a);
636 
639 
642  template <typename T> VectorOfElements operator>(const VectorOfElements & a,
643  const T & b);
644 
645 
648 
651  template <typename T> VectorOfElements operator>(const T & b,
652  const VectorOfElements & a);
653 
654 
657 
660  template <typename T> VectorOfElements operator<(const VectorOfElements & a,
661  const T & b);
662 
663 
666 
669  template <typename T> VectorOfElements operator<(const T & b,
670  const VectorOfElements & a);
671 
674 
677  template <typename T> VectorOfElements operator>=(const VectorOfElements & a,
678  const T & b);
679 
680 
683 
686  template <typename T> VectorOfElements operator>=(const T & b,
687  const VectorOfElements & a);
688 
691 
694  template <typename T> VectorOfElements operator<=(const VectorOfElements & a,
695  const T & b);
696 
697 
700 
703  template <typename T> VectorOfElements operator<=(const T & b,
704  const VectorOfElements & a);
705 
708 
711  template <typename T> VectorOfElements operator==(const VectorOfElements & a,
712  const T & b);
713 
714 
717 
720  template <typename T> VectorOfElements operator==(const T & b,
721  const VectorOfElements & a);
722 
723 
726 
729  template <typename T> VectorOfElements operator!=(const VectorOfElements & a,
730  const T & b);
731 
732 
737  template <typename T> VectorOfElements operator!=(const T & b,
738  const VectorOfElements & a);
740 
742  vector<Element> gcNormalize(const VectorOfElements & a);
744  vector<Element> gcLength2(const VectorOfElements & a, const VectorOfElements & l2);
746  vector<Element> gcLength(const VectorOfElements & a, const VectorOfElements & l);
747 
748 
749 //------------------------------ Implementation ----------------
750 
752  {
753  return a * a;
754  }
755 
756 
757 } //namespace acl
758 
759 #endif // ACLVECTORELEMENTSOPERATIONS_H
Element abs_diff(Element a, Element b)
const AVec< T > divisionOfElements(const AVec< T > &a, const AVec< T > &b)
Advanced Computational Language.
Definition: acl.h:40
vector< Element > gcLength2(const VectorOfElements &a, const VectorOfElements &l2)
generates code corresponding . Result will be stored in l2
Element operator+(Element e1, Element e2)
Element sign(Element a)
Element log10(Element e)
Element operator+=(Element e1, Element e2)
Element floor(Element a)
const AVec< T > crossProduct(const AVec< T > &a, const AVec< T > &b)
Element abs(Element a)
Element operator>(Element e1, Element e2)
Element fabs(Element a)
Element max(Element a, Element b)
Element min(Element a, Element b)
bool operator==(const std::vector< T > &vector1, const std::vector< T > &vector2)
Compares two vectors.
Definition: aslUtilities.h:185
Element operator/(Element e1, Element e2)
Element operator!(Element e)
T productOfElements(const AVec< T > &a)
Element operator-(Element e)
Element operator||(Element e1, Element e2)
shared_ptr< VectorOfElements > SPVectorOfElements
shared_ptr< VectorOfElementsData > SPVectorOfElementsData
Element mad(Element e1, Element e2, Element e3)
std::shared_ptr< MemBlock > ElementData
Definition: acl.h:47
VectorOfElements l2(const VectorOfElements &a)
Element copysign(Element a, Element b)
Element select(Element e1, Element e2, Element e3)
Element operator>=(Element e1, Element e2)
T sumOfElements(const AVec< T > &a)
acl::TypeID type(acl::typeToTypeID< FlT >())
The class represents several Element.
Element sqrt(Element e)
void swapBuffers(std::shared_ptr< Array< T > >a, std::shared_ptr< Array< T > > b)
vector< Element > gcNormalize(const VectorOfElements &a)
generates code corresponding
Element operator<(Element e1, Element e2)
Element operator&&(Element e1, Element e2)
Element log(Element e)
Element powI(Element a, unsigned int i)
Element operator/=(Element e1, Element e2)
std::shared_ptr< ElementBase > Element
Definition: acl.h:49
Element rsqrt(Element e)
Element exp(Element a)
Element excerpt(Element source, Element filter)
TypeID
Definition: aclTypes.h:38
Element operator*=(Element e1, Element e2)
Element convert(const TypeID tName, Element e1, bool strong=true)
Element operator-=(Element e1, Element e2)
vector< Element > gcLength(const VectorOfElements &a, const VectorOfElements &l)
generates code corresponding . Result will be stored in l
void copy(MemBlock &source, T *destination)
void initData(Element a, Element initializationValue, const KernelConfiguration &kernelConfig=KERNEL_BASIC)
const bool operator!=(const AVec< T > &a, const AVec< T > &b)
Element operator*(Element e1, Element e2)
Element operator%(Element e1, Element e2)
Element operator<=(Element e1, Element e2)
SPDataWithGhostNodesACLData clone(SPDataWithGhostNodesACLData d)