common: qvec: add component-wise qv::pow, qv::min, qv::max

This commit is contained in:
Eric Wasylishen 2017-04-23 21:20:25 -06:00
parent 779b2045c2
commit af8f4912b5
1 changed files with 27 additions and 0 deletions

View File

@ -184,6 +184,33 @@ namespace qv {
return res;
}
template <int N, class T>
qvec<N,T> pow(const qvec<N,T> &v1, const qvec<N,T> &v2) {
qvec<N,T> res;
for (int i=0; i<N; i++) {
res[i] = std::pow(v1[i], v2[i]);
}
return res;
}
template <int N, class T>
qvec<N,T> min(const qvec<N,T> &v1, const qvec<N,T> &v2) {
qvec<N,T> res;
for (int i=0; i<N; i++) {
res[i] = qmin(v1[i], v2[i]);
}
return res;
}
template <int N, class T>
qvec<N,T> max(const qvec<N,T> &v1, const qvec<N,T> &v2) {
qvec<N,T> res;
for (int i=0; i<N; i++) {
res[i] = qmax(v1[i], v2[i]);
}
return res;
}
template <int N, class T>
T length2(const qvec<N,T> &v1) {
T len2 = 0;