Talk About Network

Google





Programming > C - C++ Learning > Re: vectorized ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 16 Topic 4213 of 4400
Post > Topic >>

Re: vectorized computation in C++ such as those in Matlab (Matlab to

by Leandro Melo <ltcmelo@[EMAIL PROTECTED] > Jul 22, 2008 at 08:00 AM

> Dear all,
>
> Can C++/STL/Boost do the vectorized calculation as those in Matlab?
>
> For example, in the following code, what I really want to do is to
> send in a vector of u's.
>
> All other parameters such as t, l1, l2, l3, etc. are scalars...
>
> But u is a vector.
>
> Thus, t6 becomes a vector.
>
> t9 is an element-wise multiplication...
>
> The following code was actually converted from Matlab.
>
> If vectorized computation is not facilitated, then I have to call this
> function millions of times.
>
> But if vectorized computation is okay, then I can send in just a u
> vector with batch elements a time.
>
> I have many such code in Matlab need to be converted into C++ with
> vectorization.
>
> Any thoughts?
>
> Thank you!
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 double t5, t6, t7, t9, t11, t13, t16,
t20=
, t23, t27, t32, t34, t36,
> t37, t38, t42,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t44, t47, t48, t51, t52,
=
t54, t59, t60, t61, t66, t67, t69, t74,
> t75, t76, t81,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t82, t84, t87, t105,
t106=
, t110, t112;
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t5 =3D exp(-t * l1 - t * l2 - t * l3);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t6 =3D t * u;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t7 =3D mu1 * mu1;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t9 =3D u * u;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t11 =3D kappa * kappa;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t13 =3D 0.1e1 / (t9 * t7 + t11);

Hi.

I think matlab provides a c++ api. Have you checked it out? There's
also the matrix template library for general algebra computations. You
might find it useful.


--
Leandro T. C. Melo
 




 16 Posts in Topic:
vectorized computation in C++ such as those in Matlab (Matlab to
Luna Moon <lunamoonmoo  2008-07-22 07:08:38 
Re: vectorized computation in C++ such as those in Matlab (Matla
Leandro Melo <ltcmelo@  2008-07-22 08:00:51 
Re: vectorized computation in C++ such as those in Matlab (Matla
Luna Moon <lunamoonmoo  2008-07-22 08:38:21 
Re: vectorized computation in C++ such as those in Matlab (Matla
Lionel B <me@[EMAIL PR  2008-07-22 16:37:22 
Re: vectorized computation in C++ such as those in Matlab (Matla
Bart van Ingen Schenau &l  2008-07-22 18:36:31 
Re: vectorized computation in C++ such as those in Matlab (Matla
rocksportrocker <rocks  2008-07-23 06:29:32 
Re: vectorized computation in C++ such as those in Matlab (Matla
Bo Schwarzstein <Bo.Sc  2008-07-24 18:20:52 
Re: vectorized computation in C++ such as those in Matlab (Matla
William Ahern <william  2008-07-26 18:29:16 
Re: vectorized computation in C++ such as those in Matlab (Matla
Giovanni Gherdovich <g  2008-08-06 05:54:29 
Re: vectorized computation in C++ such as those in Matlab (Matla
Rune Allnor <allnor@[E  2008-08-06 06:27:42 
Re: vectorized computation in C++ such as those in Matlab (Matla
dj3vande@[EMAIL PROTECTED  2008-08-06 17:37:47 
Re: vectorized computation in C++ such as those in Matlab (Matla
Uwe Schmitt <rocksport  2008-08-07 07:37:25 
Re: vectorized computation in C++ such as those in Matlab (Matla
Giovanni Gherdovich <g  2008-08-07 09:48:11 
Re: vectorized computation in C++ such as those in Matlab (Matla
Jerry Coffin <jcoffin@  2008-08-07 22:38:18 
Re: vectorized computation in C++ such as those in Matlab (Matla
Francis Glassborow <fr  2008-08-08 13:12:48 
Re: vectorized computation in C++ such as those in Matlab (Matla
Giovanni Gherdovich <g  2008-08-08 09:27:02 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Fri Jan 9 6:21:15 PST 2009.