Revision 651c5f56
utility/vector.h | ||
---|---|---|
81 | 81 |
double magnitude() const |
82 | 82 |
{ |
83 | 83 |
double res = 0; |
84 |
int i; |
|
85 |
for(i = 0; i < N; i++) |
|
86 |
res += (p_vec[i] * p_vec[i]); |
|
84 |
for (int i = 0; i < N; i++) |
|
85 |
res += p_vec[i] * p_vec[i]; |
|
87 | 86 |
|
88 | 87 |
if(isnan(res)) |
89 | 88 |
return 0; |
... | ... | |
106 | 105 |
double dot(const Vector& v) const |
107 | 106 |
{ |
108 | 107 |
double ret = 0; |
109 |
int i; |
|
110 |
for(i = 0; i < N; i++) |
|
108 |
for (int i = 0; i < N; i++) |
|
111 | 109 |
ret += p_vec[i] * v.p_vec[i]; |
112 | 110 |
|
113 | 111 |
return ret; |
... | ... | |
213 | 211 |
|
214 | 212 |
|
215 | 213 |
private: |
216 |
double p_vec[N];
|
|
214 |
double p_vec[N]; |
|
217 | 215 |
}; |
218 | 216 |
|
219 | 217 |
|
Also available in: Unified diff