lundi 2 mars 2015

Element wise operation on multiple vector using standard functions .

Can the following function be written using only one transform and possibly one bind()? Basically, I want to avoid for loop and multiple transform calls.



VectorMultiplySubtractMultiplyDivide(const vec_dbl &v1, const vec_dbl &v2,
const vec_dbl &v3, const vec_dbl &v4,
const vec_dbl &v5, vec_dbl &ovec_result){
if (v1.size() == v2.size() == v3.size() == v4.size() == v5.size()){

ovec_result.empty();

for (int i = 0; i < v1.size(); i++){
ovec_result.push_back((v1[i]*v2[i]-v3[i]*v4[i])/v5[i]);
}
}
}else{
//throw error;
}

Aucun commentaire:

Enregistrer un commentaire