ASL  0.1.7
Advanced Simulation Library
aslVectorsUtilities.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 
25 
26 #ifndef _aslVectors
27 #define _aslVectors
28 
29 
30 #include "aslVectors.h"
31 #include <cmath>
32 
33 
34 namespace asl {
35 
36 
37 /*
39  template <int I,typename T> inline std::ostream& operator<<(std::ostream &f,const Vec<I,T> &a) {
40  for (int i(0);i<I-1;++i)f<<a[i]<<' '; return f<<a[I-1];
41  }
42 
43  template <int I,typename T> inline const Vec<I,T> & operator+=(Vec<I,T> &a,const Vec<I,T> &b){
44  for (int i(0);i<I;++i) a[i]+=b[i]; return a;
45  }
46  template <int I,typename T> inline const Vec<I,T> & operator-=(Vec<I,T> &a,const Vec<I,T> &b){
47  for (int i(0);i<I;++i) a[i]-=b[i]; return a;
48  }
49  template <int I,typename T> inline const int operator== (const Vec<I,T> &a,const Vec<I,T> &b) {
50  int c(1); for (int i(0);i<I;++i) c&=(a[i]==b[i]); return c;
51  }
52 // template <int I,typename T> inline const Vec<I,T> operator/ (const Vec<I,T> &b,const T &a) {return (1./a)*b;}
53 
55  template <int I,typename T> inline const T bvol (const Vec<I,T> &a) {T p(1); for (int i(0);i<I;++i) p*=a[i]; return p;}
57  template <int I,typename T,class IT> inline bool nonneg(const Vec<I,T,IT> &a) {
58  int c(1); for (int i(0);i<I;++i) c&=(a[i]>=0); return c;
59  }
60 
61 
62  template <int I,typename T> inline const Vec<I,T> operator+ (const Vec<I,T> &a,const Vec<I,T> &b) {
63  Vec<I,T> c; for (int i(0);i<I;++i) c[i]=a[i]+b[i]; return c;
64  };
65  template <int I,typename T> inline const Vec<I,T> operator- (const Vec<I,T> &a,const Vec<I,T> &b) {
66  Vec<I,T> c; for (int i(0);i<I;++i) c[i]=a[i]-b[i]; return c;
67  };
68  template <int I,typename T> inline const Vec<I,T> operator* (const T &a,const Vec<I,T> &b) {
69  Vec<I,T> c; for (int i(0);i<I;++i) c[i]=a*b[i]; return c;
70  };
71  template <int I,typename T> inline const T operator* (const Vec<I,T> &a,const Vec<I,T> &b) {
72  T c=0; for (int i(0);i<I;++i) c+=a[i]*b[i]; return c;
73  };
74 
75 // inline Vec<1,int> vceil(const Vec<1> &a) {return Vec<1,int>((int)ceil(a.x()));}
76 // inline Vec<1,int> vfloor(const Vec<1> &a) {return Vec<1,int>((int)floor(a.x()));}
77 */
78 
80 /* template <typename T> inline Vec<3,T> cast_max(const Vec<3,T> &a,const Vec<3,T> &b) {
81  return Vec<3,T>(max(a.x(),b.x()),max(a.y(),b.y()),max(a.z(),b.z()));
82  }
84  template <typename T> inline Vec<3,T> cast_min(const Vec<3,T> &a,const Vec<3,T> &b) {
85  return Vec<3,T>(min(a.x(),b.x()),min(a.y(),b.y()),min(a.z(),b.z()));
86  }
87  template <typename T> inline Vec<3,T> vabs(const Vec<3,T> &a) {
88  return Vec<3,T>(fabs(a.x()),fabs(a.y()),fabs(a.z()));
89  }*/
90 
91 // inline Vec<3,int> vround(const Vec<3> &a) {return Vec<3,int>((int)round(a.x()),(int)round(a.y()),(int)round(a.z()));}
92 // inline Vec<3,int> vtrunc(const Vec<3> &a) {return Vec<3,int>((int)a.x(),(int)a.y(),(int)a.z());}
93 
94 
96 // template <typename T> inline const T min(const Vec<1,T>& a){return a.x();}
98 // template <typename T> inline const T max(const Vec<1,T>& a){return a.x();}
99 
101 // template <typename T> inline const Vec<3,T> cprod(const Vec<3,T> &a,const Vec<3,T> &b) {
102 // return Vec<3,T>(a.x()*b.x(),a.y()*b.y(),a.z()*b.z());
103 // }
104 
105 /* inline Vec<1,int> vec(int x){return Vec<1,int>(x);}
106  inline Vec<2,int> vec(int x,int y){return Vec<2,int>(x,y);}
107  inline Vec<3,int> vec(int x,int y,int z){return Vec<3,int>(x,y,z);}
108  inline Vec<1> vec(lFl x){return Vec<1>(x);}
109  inline Vec<2> vec(lFl x,lFl y){return Vec<2>(x,y);}
110  inline Vec<3> vec(lFl x,lFl y,lFl z){return Vec<3>(x,y,z);}
111 */
112 
113 }
114 
115 #endif
Advanced Simulation Library.
Definition: aslDataInc.h:30
definition of class АVec<T>