common: qvec: add component-wise qv::pow, qv::min, qv::max
This commit is contained in:
parent
779b2045c2
commit
af8f4912b5
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue