public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* design of functions in miltimin
@ 2003-07-01  4:43 Andrey V. Panov
  2003-07-01  6:47 ` Fabrice Rossi
  0 siblings, 1 reply; 3+ messages in thread
From: Andrey V. Panov @ 2003-07-01  4:43 UTC (permalink / raw)
  To: gsl-discuss

I think that the body of take_step() function in 
multimin/directional_minimize.c :

{
  gsl_vector_set_zero (dx);
  gsl_blas_daxpy (-step * lambda, p, dx);
    
  gsl_vector_memcpy (x1, x);
  gsl_blas_daxpy (1.0, dx, x1);
}

can be replaced by more efficient code:

{
int i;
double dx_temp;
for(i = 0; i < dx->size; i++)
{
  dx_temp = -step * lambda * gsl_vector_get(p, i);
  gsl_vector_set(dx, i, dx_temp);
  gsl_vector_set(x1, i, gsl_vector_get(x, i) + dx_temp);
}
}

There are also similar parts of code inside miltimin routines which may be 
replaced.

-- 
Andrey V. Panov
http://canopus.iacp.dvo.ru/~panov/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: design of functions in miltimin
  2003-07-01  4:43 design of functions in miltimin Andrey V. Panov
@ 2003-07-01  6:47 ` Fabrice Rossi
  2003-07-02  2:41   ` Andrey V. Panov
  0 siblings, 1 reply; 3+ messages in thread
From: Fabrice Rossi @ 2003-07-01  6:47 UTC (permalink / raw)
  To: panov; +Cc: gsl-discuss

Hi.

My understanding of vector calculation optimization is that one should 
rely on BLAS as much as possible. I'm not sure that your code is really 
more efficient than the BLAS code if you use an optimized implementation 
of BLAS such as ATLAS, but of course, I might be wrong. Did you make 
some timing with GSL+ATLAS to compare both solutions?

Fabrice

Andrey V. Panov wrote:

> I think that the body of take_step() function in
> multimin/directional_minimize.c :
>
> {
>   gsl_vector_set_zero (dx);
>   gsl_blas_daxpy (-step * lambda, p, dx);
>
>   gsl_vector_memcpy (x1, x);
>   gsl_blas_daxpy (1.0, dx, x1);
> }
>
> can be replaced by more efficient code:
>
> {
> int i;
> double dx_temp;
> for(i = 0; i < dx->size; i++)
> {
>   dx_temp = -step * lambda * gsl_vector_get(p, i);
>   gsl_vector_set(dx, i, dx_temp);
>   gsl_vector_set(x1, i, gsl_vector_get(x, i) + dx_temp);
> }
> }
>
> There are also similar parts of code inside miltimin routines which 
> may be
> replaced.
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: design of functions in miltimin
  2003-07-01  6:47 ` Fabrice Rossi
@ 2003-07-02  2:41   ` Andrey V. Panov
  0 siblings, 0 replies; 3+ messages in thread
From: Andrey V. Panov @ 2003-07-02  2:41 UTC (permalink / raw)
  To: gsl-discuss

Hi.

I disagree. Each call to a cblas function leads to additional for cycle.
There is no much difference when unique call is used (only cost of a function 
call). But in the case of serial 4 calls this leads to 4 for cycles instead 
of one.

On Tuesday 01 July 2003 17:48, Fabrice Rossi wrote:
> Hi.
>
> My understanding of vector calculation optimization is that one should
> rely on BLAS as much as possible. I'm not sure that your code is really
> more efficient than the BLAS code if you use an optimized implementation
> of BLAS such as ATLAS, but of course, I might be wrong. Did you make
> some timing with GSL+ATLAS to compare both solutions?
>
> Fabrice
>
> Andrey V. Panov wrote:
> > I think that the body of take_step() function in
> > multimin/directional_minimize.c :
> >
> > {
> >   gsl_vector_set_zero (dx);
> >   gsl_blas_daxpy (-step * lambda, p, dx);
> >
> >   gsl_vector_memcpy (x1, x);
> >   gsl_blas_daxpy (1.0, dx, x1);
> > }
> >
> > can be replaced by more efficient code:
> >
> > {
> > int i;
> > double dx_temp;
> > for(i = 0; i < dx->size; i++)
> > {
> >   dx_temp = -step * lambda * gsl_vector_get(p, i);
> >   gsl_vector_set(dx, i, dx_temp);
> >   gsl_vector_set(x1, i, gsl_vector_get(x, i) + dx_temp);
> > }
> > }
> >
> > There are also similar parts of code inside miltimin routines which
> > may be
> > replaced.

-- 
Andrey V. Panov
panov /@/ canopus.iacp.dvo.ru

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-07-02  2:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-01  4:43 design of functions in miltimin Andrey V. Panov
2003-07-01  6:47 ` Fabrice Rossi
2003-07-02  2:41   ` Andrey V. Panov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).