25 #ifndef __CUSTOMOPERATORS_HH__
26 #define __CUSTOMOPERATORS_HH__
33 #include "mimmoTypeDef.hpp"
34 #include <bitpit_patchkernel.hpp>
38 std::array<double, 3>
operator-(
const bitpit::Vertex &v1,
const bitpit::Vertex &v2);
45 int countSubstring(
const std::string& str,
const std::string& sub);
54 t.swap(std::vector<T>());
65 std::size_t size = t.size();
66 for(
int i=1; i<size; ++i){
92 if(policy[0]) result = target;
93 if(policy[1]) result = root + target;
96 result = root - target;
99 if(result) result = result - target;
125 result = (bool)root + (
bool)target;
127 result = (bool)root - (
bool)target;
130 if(result) result = result - (bool)target;
143 if(t < 0) result= -1 * result;
157 typename std::vector< T >::iterator it_find = std::find(vect.begin(),vect.end(),target);
158 if (it_find!=vect.end()) {
159 pos = std::distance(vect.begin(),it_find);
172 template <
class T,
size_t d >
175 typename std::array< T,d >::iterator it_find = std::find(vect.begin(),vect.end(),target);
176 if (it_find!=vect.end()){
177 pos = std::distance(vect.begin(),it_find);
192 typename std::vector< T >::iterator it_find = std::find(vect.begin(),vect.end(),target);
193 if (it_find!=vect.end()) check=
true;
204 template <
class T,
size_t d>
207 typename std::array< T,d >::iterator it_find = std::find(vect.begin(),vect.end(),target);
208 if (it_find!=vect.end()) check=
true;
217 template <
class T,
size_t d>
218 std::vector<T>
inline conVect(std::array<T, d> & origin ){
219 std::vector<T> result(d);
220 for(
size_t i=0; i<d; ++i)
221 result[i] = origin[i];
230 template <
class T,
size_t d>
231 std::array<T,d>
inline conArray(std::vector<T> & origin ){
232 std::array<T,d> result;
233 for(
size_t i=0; i<d; ++i)
234 result[i] = origin[i];
243 template <
class T,
size_t d>
244 std::vector< std::vector < T > >
inline conVect(std::vector< std::array<T, d> > & origin ){
245 std::vector<std::vector<T> > result(origin.size());
246 for(
size_t i=0; i<origin.size(); ++i)
247 result[i] =
conVect(origin[i]);
256 template <
class T,
size_t d>
257 std::vector< std::array< T, d > >
inline conArray(std::vector<std::vector<T> > & origin ){
258 std::vector< std::array<T,d> > result(origin.size());
259 for(
size_t i=0; i<origin.size(); ++i)
260 result[i] = conArray< T, d>(origin[i]);
274 typename std::vector< T >::iterator itV = std::find(source.begin(), source.end(), value);
275 if(itV != source.end())
276 result = std::distance(source.begin(), itV);
301 std::vector < T> result;
303 if(i >= (
int)source.size() || j < 0)
return result;
305 result.resize(source.size());
308 int maxElement = source.size() -1;
309 i = std::max(std::min(i,maxElement), 0);
310 j = std::max(std::min(j,maxElement), 0);
313 for(
int k=i; k<source.size(); ++k ){
314 result[counter] = source[k];
317 for(
int k=0; k<j; ++k ){
318 result[counter] = source[k];
322 for(
int k=i; k<j; ++k ){
323 result[counter] = source[k];
327 result.resize(counter);
351 if(i >= source.size() || j < 0)
return;
354 int maxElement = source.size() -1;
355 i = std::max(std::min(i,maxElement), 0);
356 j = std::max(std::min(j,maxElement), 0);
359 for(
int k=i; k<source.size(); ++k ){
362 for(
int k=0; k<j; ++k ){
366 for(
int k=i; k<j; ++k ){
378 #endif //__CUSTOMOPERATORS_HH__