rameshk <[EMAIL PROTECTED]> wrote in message...
> Hi,
> I was trying to get gcc to vectorize a simple loop:
>
> #include <vector>
// > int test(double *x , int size);
>
> int test(double *x, int size){
>         int ret = 1;
>         std::vector<double>     v;
>         v.resize(size);
>         double  *a = &v[0];

   std::cout<<"sizeof(double)="<<sizeof(double)<<std::endl;
   std::vector<double> vD( 10 );
   std::cout<<"sizeof(vD)="<<sizeof(vD)<<std::endl;
/* - out -
sizeof(double)=8
sizeof(vD)=12
*/

>         for(int i = 0;i < size; ++i )
>         {
>                 a[i ] = 1/x[i];      // ka-boom
>         }
>
> }

int test( double *x, int size ){
     int ret = 1;
     // std::vector<double> v( size );
     // for( std::size_t a(0); a < v.size(); ++a ){  v.at( i ) = 1/x[i]; }
// for(a)

     std::vector<double> v( x, x + size );

     // .... do something with 'v'
     return ret;
     }

--
Bob R
POVrookie


_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to