Page 1 of 1

vector division

PostPosted: Sat Jul 19, 2008 3:27 pm
by asp
hello,

i'm looking for a lapack function equivalent to MATLAB's "./" operation which e.g. for two vectors x and y of the same dimensions does element wise division, i.e. it returns a vector of the same dimentions as x and y whose elements are x_i/y_i.
is there anything similar in lapack?

thanks a lot!

Re: vector division

PostPosted: Sat Jul 19, 2008 3:55 pm
by Julien Langou
Nope. Not "./".

I know to emulate " .* " with a BLAS call:
Code: Select all
cblas dgbmv( CblasColMajor, CblasNoTrans, m, m, 0, 0, 1, 0e0, X, 1, Y, 1, 0, 0e0, Z, 1);


I do not recommend this kind of trick though ... Most of the people are not able to read the previous line,
while they have no problem understanding the following:
Code: Select all
for(i=0;i<m;i++) Z[i] = X[i]*Y[i];


-julien.

Re: vector division

PostPosted: Sat Jul 19, 2008 4:48 pm
by sven
If you are happy to use Fortran, then it is part of the language since Fortran 90. That is, if x and y are 1-d arrays, then x/y is elementwise division. The array operations are a very nice feature of the language.

Sven.

Re: vector division

PostPosted: Sun Jul 20, 2008 4:39 pm
by asp
oh well... disappointing what else is there to say
thanks though anyway