The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

Cannot find routine for: matrix-vector-product

Open discussion regarding features, bugs, issues, vendors, etc.

Cannot find routine for: matrix-vector-product

Postby Mat » Sun Sep 09, 2007 5:16 pm

Hello,

i'm to blind to find the Lapack routine for a matrix-vector multiplication.
what i need is to solve the following:

r = Av - w

where A is a matrix, v and w are vectors.

It would be very nice if anybode could help me....thanks a lot.
Mat
 
Posts: 47
Joined: Sat Aug 19, 2006 9:54 am

Re: Cannot find routine for: matrix-vector-product

Postby buttari » Sun Sep 09, 2007 6:51 pm

Mat wrote:Hello,

i'm to blind to find the Lapack routine for a matrix-vector multiplication.
what i need is to solve the following:

r = Av - w

where A is a matrix, v and w are vectors.

It would be very nice if anybode could help me....thanks a lot.


Mat,
there's no matrix multiplication routine in LAPACK. Matrix multiplication is in BLAS and it is called _GEMM where "_" can be D, S, C, Z depending on the precision/data format you are using.

Alfredo
buttari
 
Posts: 51
Joined: Tue Jul 11, 2006 2:11 pm

Postby Julien Langou » Sun Sep 09, 2007 8:11 pm

Yep, and the matrix-vector product is _GEMV
First copy r in w with _COPY and then the _GEMV routine will do:
Code: Select all
r <- Av - r

if you set ALPHA = 1.0 and BETA = 0.0.
Julien Langou
 
Posts: 835
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Postby buttari » Mon Sep 10, 2007 12:54 am

Julien Langou wrote:Yep, and the matrix-vector product is _GEMV
First copy r in w with _COPY and then the _GEMV routine will do:
Code: Select all
r <- Av - r

if you set ALPHA = 1.0 and BETA = 0.0.


yep, thanks Julien.

Alfredo
buttari
 
Posts: 51
Joined: Tue Jul 11, 2006 2:11 pm

Postby Mat » Tue Sep 11, 2007 6:21 am

Thanks a lot.

Julien, for my task i want to solve: r = Av - w; so i think i have to copy w into r and set BETA to 1.0. The solution is with the routine DGEMV than in r.

Could anybode explain the DGEMV argument INCY to me?
What is that:

* INCY - INTEGER.
* On entry, INCY specifies the increment for the elements of
* Y. INCY must not be zero.
* Unchanged on exit.

What value should INCY have?

And what is INCX?
Perhaps both 1 ?
Mat
 
Posts: 47
Joined: Sat Aug 19, 2006 9:54 am

Postby sven » Tue Sep 11, 2007 6:43 am

Dear Mat,

You want to copy w into r and set ALPHA = 1.0D0, BETA = -1.0D0. DGEMV computes

r <= alpha*A*v + beta*r

The increment allows you to stride through a vector. For example, with INCY = 2, the routine accesses every second element of Y, that is Y(1), Y(3), Y(5), ..., Y(2*N-1).

It is mainly used to allow a row of a matrix to be passed to the routine. If the leading dimension of X is LDX, then passing Y as X(2,1) and INCY as LDX,
would take Y as the second row of X.

Sven Hammarling.
sven
 
Posts: 146
Joined: Wed Dec 22, 2004 4:28 am

Postby Mat » Tue Sep 11, 2007 6:55 am

Thank you very much Sven,

so for a simple matrix-vector operation a need both with "1".

Thanks
Mat
 
Posts: 47
Joined: Sat Aug 19, 2006 9:54 am

Postby sven » Tue Sep 11, 2007 7:06 am

Yes, both increments equal to 1,

Sven.
sven
 
Posts: 146
Joined: Wed Dec 22, 2004 4:28 am

Postby Mat » Wed Sep 12, 2007 10:22 am

Hello,

it's me again:
Now i'm searching a routine for a vector-vector multiplication.

for this: r^T * v
where r is a transposed vector and v is a vector.

Or should i use _GEMV with A as a vector?

Thanks a lot.
Mat
 
Posts: 47
Joined: Sat Aug 19, 2006 9:54 am

Postby sven » Wed Sep 12, 2007 10:39 am

Hello Mat,

Look at the Level 1 BLAS. DAXPY does

y <- alpha*x + y

and DDOT

alpha = x^T*y

Sven.
sven
 
Posts: 146
Joined: Wed Dec 22, 2004 4:28 am

Postby Mat » Wed Sep 12, 2007 10:55 am

Thanks a lot sven,

does the Level1-Blas routine exits for COMPLEX values as well? I cannot find something like zdot ?

I would like to be able to do x^T*y for Complex vectors...

Thanks for your patience.
Mat
 
Posts: 47
Joined: Sat Aug 19, 2006 9:54 am

Postby sven » Wed Sep 12, 2007 11:06 am

Hi Mat,

Yes, ZDOTU for x^T*y and ZDOTC for x^H*y. The netlib page for the BLAS is at:

http://www.netlib.org/blas/index.html

The BLAS also come with LAPACK, together with documentation in the form of man pages and html files.

Of course, for efficiency it is preferable to use vendor supplied BLAS, or the Atlas BLAS.

Sven.
sven
 
Posts: 146
Joined: Wed Dec 22, 2004 4:28 am

Postby Mat » Wed Sep 12, 2007 11:47 am

THanks,

do i need something special? Perhaps i need to install BLAS of level 1?

Like the _gemv routine i have the following in my c++ code:
Code: Select all
extern "C" {
void   zgemv_(char*   TRANS,
               int*      M,
               int*      N,
                  COMPLEX*   ALPHA,
               COMPLEX   A[],
               int*      LDA,
                  COMPLEX   X[],
               int*      INCX,
                  COMPLEX*   BETA,
                  COMPLEX   Y[],
               int*      INCY);
   
   
   
   
   double   DDOT(   int       N,
             double       DX[],
            int       INCX,
                double       DY[],
                int       INCY);
};



But using it the way i use for example zgemv_ i get an undefined reference to DDOT ?

EDIT: I got the point: I have to use the small letters like in dgemv with an underscore at the end: ddot_
Mat
 
Posts: 47
Joined: Sat Aug 19, 2006 9:54 am


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 4 guests