mesh_conv::MC_double_vector Class Reference

A container class for a vector of double. More...

#include <MC_double_vector.hpp>

Collaboration diagram for mesh_conv::MC_double_vector:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MC_double_vector ()
 standard constructor
 MC_double_vector (const double &u0)
 direct constructor with one value
 MC_double_vector (const double &u0, const double &u1)
 direct constructor with multiple values
 MC_double_vector (const double &u0, const double &u1, const double &u2)
 direct constructor with multiple values
 MC_double_vector (const double &u0, const double &u1, const double &u2, const double &u3)
 direct constructor with multiple values
 MC_double_vector (const double &u0, const double &u1, const double &u2, const double &u3, const double &u4)
 direct constructor with multiple values
 MC_double_vector (const double &u0, const double &u1, const double &u2, const double &u3, const double &u4, const double &u5)
 direct constructor with multiple values
 MC_double_vector (const std::string &in, const std::string &separator=" ")
 direct constructor from string
 MC_double_vector (const std::set< double > &vec)
 constructor from a set
 MC_double_vector (const std::map< double, int > &vec)
 constructor from an indexed map
 MC_double_vector (const std::vector< double > &vec)
 constructor from a vector
 MC_double_vector (const MC_v3d &vec)
 constructor from a MC_v3d
 MC_double_vector (const MC_double_vector &vec)
 copy constructor
void assert_bounds (const int &u) const
 Assert the value stays within the bounds.
std::vector< double > & get_vector ()
 get the internal vector
const std::vector< double > & to_vector () const
 convert to vector (get internal vector)
std::set< double > to_set () const
 convert to std::set
std::map< double, int > to_map () const
 convert to std::map
void clear ()
 clear the vector to size 0
MC_double_vectorresize (const int &new_size)
 resize the vector in deleting value of adding zeros
MC_double_vectoradd (const double &val)
 add a value at the end of the vector
MC_double_vectoradd (const MC_double_vector &val)
 add some values at the end of the vector
MC_double_vectorset (const int &k_index, const double &new_value)
 set an indexed value to a certain component. Adjust the size automatically
MC_double_vectorset (const MC_int_vector &k_index, const MC_double_vector &new_value)
 set an indexed value to a certain component. Adjust the size automatically
std::pair< MC_double_vector,
double > 
delete_index (const int &index_to_delete) const
 delete the k_th value
std::pair< MC_double_vector,
MC_double_vector
delete_index (const MC_int_vector &index_to_delete) const
 delete the k_th value
std::pair< MC_double_vector,
MC_int_vector
sort () const
 ordonate the vector in increasing order
MC_double_vector inverted () const
 invert values of the vector (last<->first)
int size () const
 return the size of the MC_double_vector
std::pair< double, int > min () const
 get min value and its position
std::pair< double, int > max () const
 get max value and its position
MC_double_vectoroperator+= (const double &to_add)
 internal add a value
MC_double_vectoroperator-= (const double &to_sub)
 internal substraction
MC_double_vectoroperator*= (const double &to_mult)
 internal multiplication
MC_double_vectoroperator/= (const double &to_subdiv)
 internal divide
MC_double_vectoroperator+= (const MC_double_vector &to_add)
 internal add values
MC_double_vectoroperator-= (const MC_double_vector &to_sub)
 internal substraction
MC_double_vectoroperator*= (const MC_double_vector &to_mult)
 internal multiplication
MC_double_vectoroperator/= (const MC_double_vector &to_subdiv)
 internal divide
double norm_2 () const
 return the norm 2 of the vector
double dot (const MC_double_vector &v) const
 perform dot product between the current vector and an other one if size are consistent
const double & operator() (const int &index) const
 get operator with bounds checks
double & operator() (const int &index)
 get operator with bounds checks
const double & operator[] (const int &index) const
 get operator with bounds asserts
double & operator[] (const int &index)
 get operator with bounds asserts
MC_double_vector operator() (const MC_int_vector &index) const
 get a set of value
MC_double_vector operator[] (const MC_int_vector &index) const
 get a set of value
const double & first () const
 return the first value
double & first ()
 return the first value
const double & last () const
 return the last value
double & last ()
 return the last value
const double * pointer () const
 get the pointer on the value
double * pointer_unprotected ()
 get the pointer on the value

Static Public Member Functions

static MC_double_vector zeros (const int &new_size)
 build a vector of size new_size filled with zero
static MC_double_vector linspace (const double &begin, const double &end, const double &iteration=1)
 initialize a linspace vector
static MC_double_vector sample (const double &begin=0, const double &end=1, const int &N_sample=100)
 initialize a vector with constant space and given number of sample
static double sum (const MC_double_vector &input)
 sum the values of the double_vector
static MC_double_vector abs (const MC_double_vector &input)
 return the absolute value componentwise

Private Attributes

std::vector< double > double_list
 the internal storage: vector of double

Friends

MC_double_vector operator<< (const MC_double_vector &vec, const double &value)
 add a value at the end of the vertex
MC_double_vector operator<< (const MC_double_vector &vec, const MC_double_vector &to_add)
 add some values at the end of the vertex
MC_double_vector operator- (const MC_double_vector &v)
 change the opposite sign of the current vector (unary negation)
MC_double_vector operator+ (const MC_double_vector &vec, const double &to_add)
 add a double value to the vector
MC_double_vector operator- (const MC_double_vector &vec, const double &to_sub)
 substract a double value to the vector
MC_double_vector operator* (const MC_double_vector &vec, const double &to_mult)
 multiply a double value to the vector
MC_double_vector operator* (const double &to_mult, const MC_double_vector &vec)
 multiply a double value to the vector
MC_double_vector operator/ (const MC_double_vector &vec, const double &to_subdiv)
 divide a double value to the vector
MC_v3d_vector operator* (const MC_double_vector &vec, const MC_v3d &to_mult)
 multiply a double_vector to a MC_v3d
MC_v3d_vector operator* (const MC_v3d &to_mult, const MC_double_vector &vec)
 multiply a double_vector to a MC_v3d
MC_v3d_vector operator/ (const MC_v3d &vec, const MC_double_vector &to_subdiv)
 divide a double value to a vector
MC_double_vector operator+ (const MC_double_vector &vec, const MC_double_vector &to_add)
 add a set of value to the vector
MC_double_vector operator- (const MC_double_vector &vec, const MC_double_vector &to_sub)
 substract set of value to the vector
MC_double_vector operator* (const MC_double_vector &vec, const MC_double_vector &to_mult)
 multiply a set of value to the vector (pointwise mult)
MC_double_vector operator/ (const MC_double_vector &vec, const MC_double_vector &to_subdiv)
 divide a set of double value to the vector
MC_int_vector operator< (const MC_double_vector &vec, const double &val)
 pointwise boolean comparison
MC_int_vector operator<= (const MC_double_vector &vec, const double &val)
 pointwise boolean comparison
MC_int_vector operator> (const MC_double_vector &vec, const double &val)
 pointwise boolean comparison
MC_int_vector operator>= (const MC_double_vector &vec, const double &val)
 pointwise boolean comparison
MC_int_vector operator== (const MC_double_vector &vec, const double &val)
 pointwise boolean comparison (with an epsilon equality)
MC_int_vector operator< (const double &val, const MC_double_vector &vec)
 pointwise boolean comparison
MC_int_vector operator<= (const double &val, const MC_double_vector &vec)
 pointwise boolean comparison
MC_int_vector operator> (const double &val, const MC_double_vector &vec)
 pointwise boolean comparison
MC_int_vector operator>= (const double &val, const MC_double_vector &vec)
 pointwise boolean comparison
MC_int_vector operator== (const double &val, const MC_double_vector &vec)
 pointwise boolean comparison
std::ostream & operator<< (std::ostream &output, const MC_double_vector &in)
 write to ostream the list (u0 u1 u2 ... )
MC_double_vectoroperator>> (std::istream &input, MC_double_vector &vec)
 load from istream a list

Detailed Description

A container class for a vector of double.

internal storage is std::vector <double>

Definition at line 52 of file MC_double_vector.hpp.


Constructor & Destructor Documentation

mesh_conv::MC_double_vector::MC_double_vector (  ) 

standard constructor

Definition at line 16 of file MC_double_vector.cpp.

00016 {}

mesh_conv::MC_double_vector::MC_double_vector ( const double &  u0  ) 

direct constructor with one value

Definition at line 18 of file MC_double_vector.cpp.

References double_list.

00019   {double_list.push_back(u0);}

mesh_conv::MC_double_vector::MC_double_vector ( const double &  u0,
const double &  u1 
)

direct constructor with multiple values

Definition at line 20 of file MC_double_vector.cpp.

References double_list.

00020 {double_list.push_back(u0);double_list.push_back(u1);}

mesh_conv::MC_double_vector::MC_double_vector ( const double &  u0,
const double &  u1,
const double &  u2 
)

direct constructor with multiple values

Definition at line 21 of file MC_double_vector.cpp.

References double_list.

00021 {double_list.push_back(u0);double_list.push_back(u1);double_list.push_back(u2);}

mesh_conv::MC_double_vector::MC_double_vector ( const double &  u0,
const double &  u1,
const double &  u2,
const double &  u3 
)

direct constructor with multiple values

Definition at line 22 of file MC_double_vector.cpp.

References double_list.

00022 {double_list.push_back(u0);double_list.push_back(u1);double_list.push_back(u2);double_list.push_back(u3);}

mesh_conv::MC_double_vector::MC_double_vector ( const double &  u0,
const double &  u1,
const double &  u2,
const double &  u3,
const double &  u4 
)

direct constructor with multiple values

Definition at line 23 of file MC_double_vector.cpp.

References double_list.

00023 {double_list.push_back(u0);double_list.push_back(u1);double_list.push_back(u2);double_list.push_back(u3);double_list.push_back(u4);}

mesh_conv::MC_double_vector::MC_double_vector ( const double &  u0,
const double &  u1,
const double &  u2,
const double &  u3,
const double &  u4,
const double &  u5 
)

direct constructor with multiple values

Definition at line 24 of file MC_double_vector.cpp.

References double_list.

00024 {double_list.push_back(u0);double_list.push_back(u1);double_list.push_back(u2);double_list.push_back(u3);double_list.push_back(u4);double_list.push_back(u5);}

mesh_conv::MC_double_vector::MC_double_vector ( const std::string &  in,
const std::string &  separator = " " 
)

direct constructor from string

Can handle any string with given separator "5.4,4.5,6.1,7.8,4.1..." means <5.4,4.5,6.1,7.8,4.1,...>

Definition at line 57 of file MC_double_vector.cpp.

References add(), and mesh_conv::MC_string_tokenizer::tokenize().

00058   {
00059     std::vector <std::string> v_string=MC_string_tokenizer::tokenize(in,delimiter);
00060     bool is_converted=false;
00061     for(unsigned int k=0;k<v_string.size();k++)
00062       {
00063         double value=MC_string_converter::value_of<double>(v_string[k],&is_converted);
00064         if(is_converted==true)
00065           add(value);
00066       }
00067   }  

Here is the call graph for this function:

mesh_conv::MC_double_vector::MC_double_vector ( const std::set< double > &  vec  ) 

constructor from a set

Definition at line 136 of file MC_double_vector.cpp.

References double_list.

00137   {
00138     for(std::set <double> :: const_iterator it=vec.begin();it!=vec.end();++it)
00139         double_list.push_back(*it);
00140   }

mesh_conv::MC_double_vector::MC_double_vector ( const std::map< double, int > &  vec  ) 

constructor from an indexed map

suppose that the second value is the index of the values

Definition at line 141 of file MC_double_vector.cpp.

00142   {
00143     for(std::map <double,int> :: const_iterator it=vec.begin();it!=vec.end();++it)
00144       set(it->second,it->first);
00145   }

mesh_conv::MC_double_vector::MC_double_vector ( const std::vector< double > &  vec  ) 

constructor from a vector

Definition at line 146 of file MC_double_vector.cpp.

References double_list.

00147   {double_list=vec;}

mesh_conv::MC_double_vector::MC_double_vector ( const MC_v3d vec  ) 

constructor from a MC_v3d

Definition at line 673 of file MC_double_vector.cpp.

References double_list.

00674     {
00675         double_list.push_back(vec[0]);
00676         double_list.push_back(vec[1]);
00677         double_list.push_back(vec[2]);
00678     }

mesh_conv::MC_double_vector::MC_double_vector ( const MC_double_vector vec  ) 

copy constructor

Definition at line 149 of file MC_double_vector.cpp.

References double_list, and to_vector().

00150   {double_list=vec.to_vector();}

Here is the call graph for this function:


Member Function Documentation

MC_double_vector mesh_conv::MC_double_vector::abs ( const MC_double_vector input  )  [static]

return the absolute value componentwise

Definition at line 682 of file MC_double_vector.cpp.

References size(), and zeros().

00683     {
00684         int N=input.size();
00685         MC_double_vector res=MC_double_vector::zeros(N);
00686         for(int k=0;k<N;++k)
00687             res[k]=std::abs(input[k]);
00688         return res;
00689     }

Here is the call graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::add ( const MC_double_vector val  ) 

add some values at the end of the vector

Returns:
the new current vector

Definition at line 78 of file MC_double_vector.cpp.

References double_list, and size().

00079   {
00080       int N=val.size();
00081       int end=double_list.size();
00082       double_list.resize(double_list.size()+N);
00083       for(int k=0;k<N;++k)
00084           double_list[end+k]=val[k];
00085       return *this;
00086   }

Here is the call graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::add ( const double &  val  ) 

add a value at the end of the vector

Returns:
the current vector

Definition at line 70 of file MC_double_vector.cpp.

References double_list.

Referenced by mesh_conv::MC_curve::build_B_spline(), mesh_conv::MC_mesh_index_vector_draw::concatenation(), delete_index(), linspace(), MC_double_vector(), mesh_conv::operator>>(), sample(), and mesh_conv::MC_mesh_index_vector::segment_intersection().

00071   {double_list.push_back(val);return *this;}

Here is the caller graph for this function:

void mesh_conv::MC_double_vector::assert_bounds ( const int &  u  )  const

Assert the value stays within the bounds.

Returns:
nothing, but stop the programm if it goes outside bounds

Definition at line 26 of file MC_double_vector.cpp.

References double_list.

Referenced by operator()(), and operator[]().

00027   {
00028     if(u<0 || u>=int(double_list.size()))
00029       {std::cout<<"Assert MC_double_vector::assert_bounds("<<u<<") failed, because size="<<double_list.size()<<std::endl;exit(-1);}
00030   }  

Here is the caller graph for this function:

void mesh_conv::MC_double_vector::clear (  ) 

clear the vector to size 0

Definition at line 44 of file MC_double_vector.cpp.

References double_list.

00045   {double_list.clear();}

std::pair< MC_double_vector, MC_double_vector > mesh_conv::MC_double_vector::delete_index ( const MC_int_vector index_to_delete  )  const

delete the k_th value

Warning:
, this is internaly slow

return <the new vector,the deleted value>

Definition at line 448 of file MC_double_vector.cpp.

References add(), double_list, size(), and mesh_conv::MC_int_vector::to_set().

00449   {
00450     std::set <int> set_index=index_to_delete.to_set();
00451     MC_double_vector new_vec;
00452     MC_double_vector deleted_vec;
00453     int N=size();
00454     for(int k=0;k<N;k++)
00455       {
00456         if(set_index.find(k)!=set_index.end())
00457           new_vec.add(double_list[k]);
00458         else
00459           deleted_vec.add(double_list[k]);
00460       }
00461     return std::pair <MC_double_vector,MC_double_vector> (new_vec,deleted_vec);
00462   }

Here is the call graph for this function:

std::pair< MC_double_vector, double > mesh_conv::MC_double_vector::delete_index ( const int &  index_to_delete  )  const

delete the k_th value

Warning:
, this is internaly slow

return <the new vector, the deleted value>

Definition at line 437 of file MC_double_vector.cpp.

References add(), double_list, and size().

00438   {
00439     if(index_to_delete<0 || index_to_delete>=size())
00440       {std::cout<<"Error in MC_double_vector::delete("<<index_to_delete<<", when size="<<size()<<std::endl;exit(-1);}
00441     MC_double_vector new_vec;
00442     int N=size();
00443     for(int k=0;k<N;++k)
00444       if(k!=index_to_delete)
00445         new_vec.add(double_list[k]);
00446     return std::pair <MC_double_vector,double>(new_vec,double_list[index_to_delete]);
00447   }

Here is the call graph for this function:

double mesh_conv::MC_double_vector::dot ( const MC_double_vector v  )  const

perform dot product between the current vector and an other one if size are consistent

Definition at line 716 of file MC_double_vector.cpp.

References double_list, pointer(), and size().

Referenced by mesh_conv::MC_triangle::pn_triangle().

00717     {
00718         int N=size();
00719         if(N!=v.size())
00720         {std::cout<<"Error in MC_double_vector::dot(const MC_double_vector& v), size are not consistent: "<<N<<" "<<v.size()<<std::endl;exit(-1);}
00721 
00722         const double* p_v=v.pointer();
00723 
00724         double res=0.0;
00725         for(int k=0;k<N;++k)
00726             res += double_list[k]*p_v[k];
00727 
00728         return res;
00729     }

Here is the call graph for this function:

Here is the caller graph for this function:

double & mesh_conv::MC_double_vector::first (  ) 

return the first value

Definition at line 408 of file MC_double_vector.cpp.

References double_list, and size().

00409   {
00410     if(size()>0)
00411       return double_list[0];
00412     else
00413       {
00414         std::cout<<"Error, call MC_double_vector::first() with size=0"<<std::endl;exit(-1);
00415         exit(-1);
00416       }
00417   }

Here is the call graph for this function:

const double & mesh_conv::MC_double_vector::first (  )  const

return the first value

Definition at line 398 of file MC_double_vector.cpp.

References double_list, and size().

Referenced by mesh_conv::MC_curve::closest_point(), max(), min(), mesh_conv::operator*(), mesh_conv::MC_v3d_vector::operator*=(), operator*=(), mesh_conv::operator+(), operator+=(), mesh_conv::operator-(), operator-=(), mesh_conv::operator/(), and operator/=().

00399   {
00400     if(size()>0)
00401       return double_list[0];
00402     else
00403       {
00404         std::cout<<"Error, call MC_double_vector::first() with size=0"<<std::endl;exit(-1);
00405         exit(-1);
00406       }
00407   }

Here is the call graph for this function:

std::vector< double > & mesh_conv::MC_double_vector::get_vector (  ) 

get the internal vector

Returns:
the std::vector of the internal parameters

Definition at line 88 of file MC_double_vector.cpp.

References double_list.

00088 {return double_list;}

MC_double_vector mesh_conv::MC_double_vector::inverted (  )  const

invert values of the vector (last<->first)

Definition at line 731 of file MC_double_vector.cpp.

References double_list, size(), and zeros().

00732     {
00733         unsigned int N=size();
00734         MC_double_vector inv=MC_double_vector::zeros(N);
00735         for(int k=0;k<N;++k)
00736             inv[k]=double_list[N-k-1];
00737         return inv;
00738     }

Here is the call graph for this function:

double & mesh_conv::MC_double_vector::last (  ) 

return the last value

Definition at line 427 of file MC_double_vector.cpp.

References double_list, and size().

00428   {
00429     if(size()>0)
00430       return double_list[size()-1];
00431     else
00432       {
00433         std::cout<<"Error, call MC_double_vector::last() with size=0"<<std::endl;exit(-1);
00434       }
00435   }

Here is the call graph for this function:

const double & mesh_conv::MC_double_vector::last (  )  const

return the last value

Definition at line 418 of file MC_double_vector.cpp.

References double_list, and size().

00419   {
00420     if(size()>0)
00421       return double_list[size()-1];
00422     else
00423       {
00424         std::cout<<"Error, call MC_double_vector::last() with size=0"<<std::endl;exit(-1);
00425       }
00426   }

Here is the call graph for this function:

MC_double_vector mesh_conv::MC_double_vector::linspace ( const double &  begin,
const double &  end,
const double &  iteration = 1 
) [static]

initialize a linspace vector

Definition at line 555 of file MC_double_vector.cpp.

References add(), and size().

Referenced by mesh_conv::MC_mesh_index_vector::sweep_surface().

00556    {
00557        if( (begin<end && iteration<0) || (begin>end && iteration>0) || fabs(iteration)<0.0000001)
00558        {std::cout<<"Error in MC_double_vector::linspace("<<begin<<","<<end<<","<<iteration<<"), loop will never end"<<std::endl;exit(-1);}
00559 
00560        MC_double_vector temp;
00561        for(double u=begin;u<=(end+iteration/5.0);u+=iteration)
00562            temp.add(u);
00563        if(temp.size()>2)
00564            temp[temp.size()-1]=end; //avoid floating point problem
00565        return temp;
00566    }

Here is the call graph for this function:

Here is the caller graph for this function:

std::pair< double, int > mesh_conv::MC_double_vector::max (  )  const

get max value and its position

Definition at line 624 of file MC_double_vector.cpp.

References double_list, first(), and size().

00625     {
00626         if(size()<=0)
00627         {std::cout<<"Error in MC_double_vector::max(), size()="<<size()<<std::endl;exit(-1);}
00628 
00629         double current_max=first();
00630         int current_index=0;
00631 
00632         int N=size();
00633         for(int k=0;k<N;++k)
00634             if(current_max<double_list[k])
00635             {current_max=double_list[k];current_index=k;}
00636 
00637         return std::pair <double,int> (current_max,current_index);
00638     }

Here is the call graph for this function:

std::pair< double, int > mesh_conv::MC_double_vector::min (  )  const

get min value and its position

Definition at line 608 of file MC_double_vector.cpp.

References double_list, first(), and size().

00609     {
00610 
00611         if(size()<=0)
00612         {std::cout<<"Error in MC_double_vector::min(), size()="<<size()<<std::endl;exit(-1);}
00613 
00614         double current_min=first();
00615         int current_index=0;
00616 
00617         int N=size();
00618         for(int k=0;k<N;++k)
00619             if(current_min>double_list[k])
00620             {current_min=double_list[k];current_index=k;}
00621 
00622         return std::pair <double,int> (current_min,current_index);
00623     }

Here is the call graph for this function:

double mesh_conv::MC_double_vector::norm_2 (  )  const

return the norm 2 of the vector

Definition at line 706 of file MC_double_vector.cpp.

References double_list, and size().

00707     {
00708         double n=0.0;
00709         for(int k=0,N=size();k<N;++k)
00710         {
00711             double a=double_list[k];
00712             n += a*a;
00713         }
00714         return std::sqrt(n);
00715     }

Here is the call graph for this function:

MC_double_vector mesh_conv::MC_double_vector::operator() ( const MC_int_vector index  )  const

get a set of value

Definition at line 464 of file MC_double_vector.cpp.

References double_list, mesh_conv::MC_int_vector::size(), size(), and zeros().

00465   {
00466     int N=size();
00467     int N2=index.size();
00468     MC_double_vector new_vec=zeros(N2);
00469     for(int k=0;k<N2;++k)
00470       {
00471         if(index[k]<0 || index[k]>N)
00472           {std::cout<<"Error in MC_double_vector::operator()(MC_double_vector), value index["<<k<<"]="<<index[k]<<" not correct for size="<<N<<std::endl;exit(-1);}
00473         new_vec[k]=double_list[index[k]];
00474       }
00475     return new_vec;
00476   }

Here is the call graph for this function:

double & mesh_conv::MC_double_vector::operator() ( const int &  index  ) 

get operator with bounds checks

Definition at line 37 of file MC_double_vector.cpp.

References assert_bounds(), and double_list.

00038   {assert_bounds(index); return double_list[index];}

Here is the call graph for this function:

const double & mesh_conv::MC_double_vector::operator() ( const int &  index  )  const

get operator with bounds checks

Definition at line 35 of file MC_double_vector.cpp.

References assert_bounds(), and double_list.

00036   {assert_bounds(index); return double_list[index];}

Here is the call graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::operator*= ( const MC_double_vector to_mult  ) 

internal multiplication

to_add must be of size 1 or this->size()

Definition at line 361 of file MC_double_vector.cpp.

References double_list, first(), and size().

00362   {
00363     if(to_mult.size()==1)
00364       return *this*=to_mult.first();
00365     else
00366       {
00367         if(size()!=to_mult.size())
00368           {std::cout<<"Error in MC_double_vector::operator*=(MC_double_vector), size are not compatible "<<size()<<";"<<to_mult.size()<<std::endl;exit(-1);}
00369         
00370         int N=size();
00371         for(int k=0;k<N;++k)
00372           double_list[k]*=to_mult[k];
00373         return *this;
00374       }
00375   }

Here is the call graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::operator*= ( const double &  to_mult  ) 

internal multiplication

Definition at line 234 of file MC_double_vector.cpp.

References double_list, and size().

00235   {
00236     int N=size();
00237     for(int k=0;k<N;++k)
00238       double_list[k]*=to_mult;
00239     return *this;
00240   }

Here is the call graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::operator+= ( const MC_double_vector to_add  ) 

internal add values

to_add must be of size 1 or this->size()

Definition at line 330 of file MC_double_vector.cpp.

References double_list, first(), and size().

00331   {
00332     if(to_add.size()==1)
00333       return *this+=to_add.first();
00334     else
00335       {
00336         if(size()!=to_add.size())
00337           {std::cout<<"Error in MC_double_vector::operator+=(MC_double_vector), size are not compatible "<<size()<<";"<<to_add.size()<<std::endl;exit(-1);}
00338         
00339         int N=size();
00340         for(int k=0;k<N;++k)
00341           double_list[k]+=to_add[k];
00342         return *this;
00343       }
00344   }

Here is the call graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::operator+= ( const double &  to_add  ) 

internal add a value

Definition at line 220 of file MC_double_vector.cpp.

References double_list, and size().

00221   {
00222     int N=size();
00223     for(int k=0;k<N;++k)
00224       double_list[k]+=to_add;
00225     return *this;
00226   }

Here is the call graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::operator-= ( const MC_double_vector to_sub  ) 

internal substraction

to_add must be of size 1 or this->size()

Definition at line 345 of file MC_double_vector.cpp.

References double_list, first(), and size().

00346   {
00347     if(to_sub.size()==1)
00348       return *this-=to_sub.first();
00349     else
00350       {
00351         if(size()!=to_sub.size())
00352           {std::cout<<"Error in MC_double_vector::operator-=(MC_double_vector), size are not compatible "<<size()<<";"<<to_sub.size()<<std::endl;exit(-1);}
00353         
00354         int N=size();
00355         for(int k=0;k<N;++k)
00356           double_list[k]-=to_sub[k];
00357         return *this;
00358       }
00359 
00360   }

Here is the call graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::operator-= ( const double &  to_sub  ) 

internal substraction

Definition at line 227 of file MC_double_vector.cpp.

References double_list, and size().

00228   {
00229     int N=size();
00230     for(int k=0;k<N;++k)
00231         double_list[k]-=to_sub;
00232     return *this;
00233   }

Here is the call graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::operator/= ( const MC_double_vector to_subdiv  ) 

internal divide

to_add must be of size 1 or this->size()

Definition at line 376 of file MC_double_vector.cpp.

References double_list, first(), and size().

00377   {
00378     if(to_subdiv.size()==1)
00379       return *this/=to_subdiv.first();
00380     else
00381       {
00382         if(size()!=to_subdiv.size())
00383           {std::cout<<"Error in MC_double_vector::operator/=(MC_double_vector), size are not compatible "<<size()<<";"<<to_subdiv.size()<<std::endl;exit(-1);}
00384         
00385         int N=size();
00386         for(int k=0;k<N;++k)
00387           {
00388             double current=to_subdiv[k];
00389             double epsilon=0.0000001;
00390             if(fabs(current)<epsilon)
00391               {std::cout<<"Error in MC_double_vector::operator/=(MC_double_vector), try do divide by u["<<k<<"]=0"<<std::endl;exit(-1);}
00392             double_list[k]*=current;
00393           }
00394         return *this;
00395       }
00396   }

Here is the call graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::operator/= ( const double &  to_subdiv  ) 

internal divide

Definition at line 241 of file MC_double_vector.cpp.

References double_list, and size().

00242   {
00243       double epsilon=0.000001;
00244       if(fabs(to_subdiv)<epsilon)
00245       {std::cout<<"Error in MC_double_vector::operator/=(double), double value is 0"<<std::endl;exit(-1);}
00246       int N=size();
00247       for(int k=0;k<N;++k)
00248           double_list[k]/=to_subdiv;
00249       return *this;
00250   }

Here is the call graph for this function:

MC_double_vector mesh_conv::MC_double_vector::operator[] ( const MC_int_vector index  )  const

get a set of value

Definition at line 477 of file MC_double_vector.cpp.

00478   {return (*this)(index);}

double & mesh_conv::MC_double_vector::operator[] ( const int &  index  ) 

get operator with bounds asserts

Definition at line 41 of file MC_double_vector.cpp.

References assert_bounds(), and double_list.

00042   {assert_bounds(index); return double_list[index];}

Here is the call graph for this function:

const double & mesh_conv::MC_double_vector::operator[] ( const int &  index  )  const

get operator with bounds asserts

Definition at line 39 of file MC_double_vector.cpp.

References assert_bounds(), and double_list.

00040   {assert_bounds(index); return double_list[index];}

Here is the call graph for this function:

const double * mesh_conv::MC_double_vector::pointer (  )  const

get the pointer on the value

Warning:
use with care

Definition at line 552 of file MC_double_vector.cpp.

References double_list.

Referenced by dot(), mesh_conv::MC_opengl_drawer::draw(), mesh_conv::MC_opengl_drawer::draw_grid(), and mesh_conv::MC_matrix::pointer().

00553   {return (&double_list[0]);}

Here is the caller graph for this function:

double * mesh_conv::MC_double_vector::pointer_unprotected (  ) 

get the pointer on the value

Warning:
use with care

Definition at line 679 of file MC_double_vector.cpp.

References double_list.

00680     {return &double_list[0];}

MC_double_vector & mesh_conv::MC_double_vector::resize ( const int &  new_size  ) 

resize the vector in deleting value of adding zeros

Returns:
the new value

Definition at line 158 of file MC_double_vector.cpp.

References double_list.

Referenced by mesh_conv::MC_curve::build_B_spline(), mesh_conv::MC_matrix::clear(), mesh_conv::operator-(), mesh_conv::MC_mesh_fast_draw::set_color(), mesh_conv::MC_mesh_fast_draw::set_normal(), mesh_conv::MC_mesh_fast_draw::set_point_set(), mesh_conv::MC_mesh_fast_draw::set_texture(), and zeros().

00159   {
00160     int N=double_list.size();
00161     if(N==new_size) //same size
00162       return *this;
00163     
00164     if(new_size<0)
00165       {std::cout<<"Error in MC_double_vector::resize("<<new_size<<") new size must be >0"<<std::endl;exit(-1);}
00166     
00167     double_list.resize(new_size);
00168     return *this;
00169     
00170   }

Here is the caller graph for this function:

MC_double_vector mesh_conv::MC_double_vector::sample ( const double &  begin = 0,
const double &  end = 1,
const int &  N_sample = 100 
) [static]

initialize a vector with constant space and given number of sample

Definition at line 567 of file MC_double_vector.cpp.

References add(), and zeros().

Referenced by mesh_conv::MC_curve::sample_linear().

00568    {
00569        if(N_sample<1){std::cout<<"Error in MC_double_vector::sample("<<begin<<","<<end<<","<<N_sample<<"), N_sample must be>=1"<<std::endl;exit(-1);}
00570        if(N_sample==1)
00571            return begin;
00572 
00573        double iteration=(end-begin)/static_cast<double>(N_sample-1);
00574        MC_double_vector res=MC_double_vector::zeros(N_sample-1);
00575        res.add(begin);
00576        for(int k=1;k<N_sample;++k)
00577            res[k]=res[k-1]+iteration;
00578        res(N_sample-1)=end;
00579        return res;
00580    }

Here is the call graph for this function:

Here is the caller graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::set ( const MC_int_vector k_index,
const MC_double_vector new_value 
)

set an indexed value to a certain component. Adjust the size automatically

Returns:
the new vector

new_value and k_index must have the same size, or new_value must be of size 1 ex. set(MC_int_vector("1 7 5 8"),MC_double_vector("4.1 -5.5 6.7 8.1")) or set(MC_int_vector("1 7 5 8"),MC_double_vector("-1.5"))

Definition at line 120 of file MC_double_vector.cpp.

References mesh_conv::MC_int_vector::size(), size(), and zeros().

00121   {
00122     MC_double_vector v_new_value=new_value;
00123     if(new_value.size()!=1 && new_value.size()!=k_index.size())
00124       {std::cout<<"Error in MC_double_vector::set(MC_int_vector,MC_double_vector), size are not correct: "<<k_index.size()<<","<<new_value.size()<<std::endl;exit(-1);}
00125     if(new_value.size()==1)
00126       v_new_value=MC_double_vector::zeros(k_index.size())+new_value;
00127     
00128     
00129     int N=v_new_value.size();
00130     for(int k=0;k<N;k++)
00131       set(k_index[k],v_new_value[k]);
00132     return *this;
00133   }

Here is the call graph for this function:

MC_double_vector & mesh_conv::MC_double_vector::set ( const int &  k_index,
const double &  new_value 
)

set an indexed value to a certain component. Adjust the size automatically

Returns:
the new vector

Definition at line 110 of file MC_double_vector.cpp.

References double_list, and size().

00111   {
00112     if(k_index<0)
00113       {std::cout<<"Error in MC_double_vector::set("<<k_index<<","<<new_value<<"), index must be >0"<<std::endl;exit(-1);}
00114     if(k_index>=size())
00115       double_list.resize(k_index+1);
00116     double_list[k_index]=new_value;
00117     return *this;
00118   }

Here is the call graph for this function:

int mesh_conv::MC_double_vector::size (  )  const

return the size of the MC_double_vector

Definition at line 32 of file MC_double_vector.cpp.

References double_list.

Referenced by abs(), add(), mesh_conv::MC_matrix::add_col(), mesh_conv::MC_matrix::add_row(), mesh_conv::MC_v3d_vector::build_from_concatenated_vector(), mesh_conv::MC_matrix::check_integrity(), delete_index(), dot(), mesh_conv::MC_opengl_drawer::draw(), mesh_conv::MC_grid_3d_scalar_slicer::export_square_ppm(), mesh_conv::MC_grid_3d_scalar_slicer::export_square_ppm_file(), first(), inverted(), mesh_conv::MC_matrix::kronecker(), last(), linspace(), max(), mesh_conv::MC_matrix::MC_matrix(), mesh_conv::MC_v3d::MC_v3d(), mesh_conv::MC_v3d_vector::MC_v3d_vector(), min(), norm_2(), mesh_conv::MC_mesh_index_vector::normal_vertex(), mesh_conv::MC_matrix::operator()(), operator()(), mesh_conv::operator*(), mesh_conv::MC_v3d_vector::operator*=(), mesh_conv::MC_matrix::operator*=(), operator*=(), mesh_conv::operator+(), mesh_conv::MC_matrix::operator+=(), operator+=(), mesh_conv::operator-(), operator-=(), mesh_conv::operator/(), mesh_conv::MC_matrix::operator/=(), operator/=(), mesh_conv::operator<(), mesh_conv::operator<<(), mesh_conv::operator<=(), mesh_conv::operator==(), mesh_conv::operator>(), mesh_conv::operator>=(), mesh_conv::MC_quaternion::quat_interp(), mesh_conv::MC_matrix::reshaped(), mesh_conv::MC_matrix::reshaped_1(), mesh_conv::MC_matrix::reshaped_2(), set(), mesh_conv::MC_matrix::set_col(), mesh_conv::MC_mesh_fast_draw::set_color(), mesh_conv::MC_mesh_fast_draw::set_normal(), mesh_conv::MC_matrix::set_row(), sort(), sum(), to_map(), mesh_conv::MC_connectivity_index::triangle_propagation_using_vertex_field(), mesh_conv::MC_curve::value(), and mesh_conv::MC_curve::value_t().

00033   {return double_list.size();}

std::pair< MC_double_vector, MC_int_vector > mesh_conv::MC_double_vector::sort (  )  const

ordonate the vector in increasing order

Returns:
the ordonated value (MC_double_vector)
the corresponding mapping (MC_int_vector)

Definition at line 649 of file MC_double_vector.cpp.

References double_list, and size().

Referenced by mesh_conv::MC_mesh_index_vector::segment_intersection().

00650     {
00651         //prepare the sorting structure
00652         int N=size();
00653         std::vector <std::pair<double,int> > vec_to_sort(N);
00654         for(int k=0;k<N;++k)
00655             vec_to_sort[k]=std::pair <double,int>(double_list[k],k);
00656 
00657         //sort
00658         std::sort(vec_to_sort.begin(),
00659                   vec_to_sort.end(),
00660                   comparator_less_double_int());
00661 
00662         //redistribute
00663         std::pair <MC_double_vector,MC_int_vector> res;
00664         res.first.resize(N);res.second.resize(N);
00665         for(int k=0;k<N;++k)
00666         {
00667             res.first[k]=vec_to_sort[k].first;
00668             res.second[k]=vec_to_sort[k].second;
00669         }
00670         return res;
00671     }

Here is the call graph for this function:

Here is the caller graph for this function:

double mesh_conv::MC_double_vector::sum ( const MC_double_vector input  )  [static]

sum the values of the double_vector

Definition at line 640 of file MC_double_vector.cpp.

References size().

00641     {
00642         double s=0.0;
00643         int N=input.size();
00644         for(int k=0;k<N;++k)
00645             s+=input[k];
00646         return s;
00647     }

Here is the call graph for this function:

std::map< double, int > mesh_conv::MC_double_vector::to_map (  )  const

convert to std::map

Returns:
the std::map corresponding to this vector (the int value return its index in the vector)

Definition at line 98 of file MC_double_vector.cpp.

References size().

Referenced by mesh_conv::MC_mesh_index_vector::segment_intersection().

00099   {
00100     std::map <double,int> map_double;
00101     int N=size();
00102     for(int k=0;k<N;k++)
00103       map_double.insert(std::pair<double,int>(this->operator()(k),k));
00104     return map_double;
00105   }

Here is the call graph for this function:

Here is the caller graph for this function:

std::set< double > mesh_conv::MC_double_vector::to_set (  )  const

convert to std::set

Returns:
the std::set corresponding to this vector

Definition at line 92 of file MC_double_vector.cpp.

References double_list.

00093   {
00094     std::set <double> set_double;
00095     set_double.insert(double_list.begin(),double_list.end());
00096     return set_double;
00097   }

const std::vector< double > & mesh_conv::MC_double_vector::to_vector (  )  const

convert to vector (get internal vector)

Returns:
the std::vector corresponding to the MC_double_vector

return the const reference of the internal parameter.

Definition at line 89 of file MC_double_vector.cpp.

References double_list.

Referenced by MC_double_vector().

00089 {return double_list;}

Here is the caller graph for this function:

MC_double_vector mesh_conv::MC_double_vector::zeros ( const int &  new_size  )  [static]

build a vector of size new_size filled with zero

Definition at line 152 of file MC_double_vector.cpp.

References resize().

Referenced by abs(), inverted(), mesh_conv::MC_segment::linear_sampling(), mesh_conv::MC_mesh_index_vector::normal_vertex(), operator()(), mesh_conv::operator*(), mesh_conv::operator+(), mesh_conv::operator-(), mesh_conv::operator/(), sample(), set(), and mesh_conv::MC_grid_3d_scalar_slicer::slice().

00153   {
00154     MC_double_vector vec;vec.resize(new_size);
00155     return vec;
00156   }

Here is the call graph for this function:


Friends And Related Function Documentation

MC_double_vector operator* ( const MC_double_vector vec,
const MC_double_vector to_mult 
) [friend]

multiply a set of value to the vector (pointwise mult)

Returns:
the new vector

to_mult must be of size 1 or vec.size()

MC_v3d_vector operator* ( const MC_v3d to_mult,
const MC_double_vector vec 
) [friend]

multiply a double_vector to a MC_v3d

Returns:
the MC_v3d_vector corresponding

pointwise multiplication

MC_v3d_vector operator* ( const MC_double_vector vec,
const MC_v3d to_mult 
) [friend]

multiply a double_vector to a MC_v3d

Returns:
the MC_v3d_vector corresponding

pointwise multiplication

MC_double_vector operator* ( const double &  to_mult,
const MC_double_vector vec 
) [friend]

multiply a double value to the vector

Returns:
the new vector
MC_double_vector operator* ( const MC_double_vector vec,
const double &  to_mult 
) [friend]

multiply a double value to the vector

Returns:
the new vector
MC_double_vector operator+ ( const MC_double_vector vec,
const MC_double_vector to_add 
) [friend]

add a set of value to the vector

Returns:
the new vector

to_add must be of size 1 or vec.size()

MC_double_vector operator+ ( const MC_double_vector vec,
const double &  to_add 
) [friend]

add a double value to the vector

Returns:
the new vector
MC_double_vector operator- ( const MC_double_vector vec,
const MC_double_vector to_sub 
) [friend]

substract set of value to the vector

Returns:
the new vector

to_sub must be of size 1 or vec.size()

MC_double_vector operator- ( const MC_double_vector vec,
const double &  to_sub 
) [friend]

substract a double value to the vector

Returns:
the new vector
MC_double_vector operator- ( const MC_double_vector v  )  [friend]

change the opposite sign of the current vector (unary negation)

Returns:
a new vector with opposite sign
MC_double_vector operator/ ( const MC_double_vector vec,
const MC_double_vector to_subdiv 
) [friend]

divide a set of double value to the vector

Returns:
the new vector

to_subdiv must be of size 1 or vec.size()

MC_v3d_vector operator/ ( const MC_v3d vec,
const MC_double_vector to_subdiv 
) [friend]

divide a double value to a vector

Returns:
the MC_v3d_vector corresponding
MC_double_vector operator/ ( const MC_double_vector vec,
const double &  to_subdiv 
) [friend]

divide a double value to the vector

Returns:
the new vector
MC_int_vector operator< ( const double &  val,
const MC_double_vector vec 
) [friend]

pointwise boolean comparison

Returns:
a MC_double_vector with the same size as the entry (result is given by 0 or 1)
MC_int_vector operator< ( const MC_double_vector vec,
const double &  val 
) [friend]

pointwise boolean comparison

Returns:
a MC_double_vector with the same size as the entry (result is given by 0 or 1)
std::ostream& operator<< ( std::ostream &  output,
const MC_double_vector in 
) [friend]

write to ostream the list (u0 u1 u2 ... )

MC_double_vector operator<< ( const MC_double_vector vec,
const MC_double_vector to_add 
) [friend]

add some values at the end of the vertex

Returns:
the new vector (copy)
MC_double_vector operator<< ( const MC_double_vector vec,
const double &  value 
) [friend]

add a value at the end of the vertex

Returns:
the current vector (copy)
MC_int_vector operator<= ( const double &  val,
const MC_double_vector vec 
) [friend]

pointwise boolean comparison

Returns:
a MC_double_vector with the same size as the entry (result is given by 0 or 1)
MC_int_vector operator<= ( const MC_double_vector vec,
const double &  val 
) [friend]

pointwise boolean comparison

Returns:
a MC_double_vector with the same size as the entry (result is given by 0 or 1)
MC_int_vector operator== ( const double &  val,
const MC_double_vector vec 
) [friend]

pointwise boolean comparison

Returns:
a MC_double_vector with the same size as the entry (result is given by 0 or 1)
MC_int_vector operator== ( const MC_double_vector vec,
const double &  val 
) [friend]

pointwise boolean comparison (with an epsilon equality)

Returns:
a MC_double_vector with the same size as the entry (result is given by 0 or 1)
MC_int_vector operator> ( const double &  val,
const MC_double_vector vec 
) [friend]

pointwise boolean comparison

Returns:
a MC_double_vector with the same size as the entry (result is given by 0 or 1)
MC_int_vector operator> ( const MC_double_vector vec,
const double &  val 
) [friend]

pointwise boolean comparison

Returns:
a MC_double_vector with the same size as the entry (result is given by 0 or 1)
MC_int_vector operator>= ( const double &  val,
const MC_double_vector vec 
) [friend]

pointwise boolean comparison

Returns:
a MC_double_vector with the same size as the entry (result is given by 0 or 1)
MC_int_vector operator>= ( const MC_double_vector vec,
const double &  val 
) [friend]

pointwise boolean comparison

Returns:
a MC_double_vector with the same size as the entry (result is given by 0 or 1)
MC_double_vector& operator>> ( std::istream &  input,
MC_double_vector vec 
) [friend]

load from istream a list

stop at the first bad character encountered


Member Data Documentation

std::vector<double> mesh_conv::MC_double_vector::double_list [private]

The documentation for this class was generated from the following files:

Generated on Sun Apr 18 20:24:48 2010 by  doxygen 1.6.1