forum.alglib.net

ALGLIB forum
It is currently Sat Apr 27, 2024 11:42 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: vdotproduct
PostPosted: Fri Oct 29, 2010 11:17 am 
Offline

Joined: Wed Oct 20, 2010 10:12 am
Posts: 20
Hi there,
I want to use the vdotproduct, but the syntax is not clear. I have 2 arrays (char), I've used these

alglib::vdotproduct((double)*hypercubeA, (double)*hypercubeB, col);

dotmux = vdotproduct((double)*hypercubeA, (double)*hypercubeB, col);

according to the syntax

double vdotproduct(const double *v1, const double *v2, ae_int_t N);

but still fail.

Can you also explain about the below syntax:

double vdotproduct(
const double *v0,
ae_int_t stride0,
const double *v1,
ae_int_t stride1,
ae_int_t n);

It is not clear from the documentation page.

Thanks in advance.
Rizuan


Top
 Profile  
 
 Post subject: Re: vdotproduct
PostPosted: Fri Oct 29, 2010 11:28 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
Yes, documentation on this subject is very sparse, and I think that I'll expand it in the near future.

Code:
double vdotproduct(
const double *v0,
ae_int_t stride0,
const double *v1,
ae_int_t stride1,
ae_int_t n);


It calculates dot product of two vectors, n elements each. First one is given by (v0,stride0) and is stored in {v0, v0+1*stride0, v0+2*stride0, ...}. Usual C++/C pointer arithmetics is used, i.e. stride is measured in 8-byte chunks (size of double), not in bytes. Second vector uses same storage. This function has highest performance when stride0==stride1==1.

BTW, recently you talked about covariance matrix estimation... I've finally decided to implement it in the ALGLIB 3.1 which will be released within two days. I recommend you to wait for the release because I'll implement very good algorithm which uses cache-efficient BLAS (performance measured in GFLOPs does not drop when matrix grows) and correctly handles tricky cases when some columns of matrix are actually constant, but because of numerical errors you still get nonzero correlation between them.


Top
 Profile  
 
 Post subject: Re: vdotproduct
PostPosted: Fri Oct 29, 2010 11:29 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
Quote:
I want to use the vdotproduct, but the syntax is not clear. I have 2 arrays (char), I've used these
alglib::vdotproduct((double)*hypercubeA, (double)*hypercubeB, col);
dotmux = vdotproduct((double)*hypercubeA, (double)*hypercubeB, col);
according to the syntax
double vdotproduct(const double *v1, const double *v2, ae_int_t N);
but still fail.

What does this char mean? It must be doubles =) which are stored in contiguous memory (stride=1).


Top
 Profile  
 
 Post subject: Re: vdotproduct
PostPosted: Fri Oct 29, 2010 2:37 pm 
Offline

Joined: Wed Oct 20, 2010 10:12 am
Posts: 20
Hi Sergey,

I never received any good support from any forum before. This is my first time. Congratulation to ALGLIB and your team! There are a lot that you guys can improve in future.

Thanks for the replies. Sorry, actually my input is not char, it is signed __int16, can't I just cast the variable, (double)hypercube, can I? I'm using the double vdotproduct(const double *v1, const double *v2, ae_int_t N); not the other 3 syntax as in the documentation.

Ok, let's said I have double input, with size 512 x 512, hypercubeA and hypercubeB, how can I invoke this command ?

alglib::vdotproduct(hypercubeA, hypercubeB, 512);

or

result = vdotproduct(hypercubeA, hypercubeB, 512);

Hope this is clear.

About the covariance matrix, thanks. I open this new thread so that anyone can find this problem through search.

Well done and thanks man!

Rizuan


Top
 Profile  
 
 Post subject: Re: vdotproduct
PostPosted: Fri Oct 29, 2010 7:09 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
If your data are actually array of int16's - not array of doubles for some reason passed as pointer to int16 - then you can't use vdotproduct. It will work with double precision numbers only, even float's won't do. So you should convert all your data to double before using ALGLIB.

If you have two vectors, each 512x1, then you can use
Code:
double result = vdotproduct(hypercubeA, 1, hypercubeB, 1, 512);


However, this "hypercube" looks suspicious to me - do you really have vectors? These functions won't work with matrices or tensors or anything else.


Top
 Profile  
 
 Post subject: Re: vdotproduct
PostPosted: Sat Oct 30, 2010 2:39 pm 
Offline

Joined: Wed Oct 20, 2010 10:12 am
Posts: 20
Hi Sergey,

I thought vdotproduct is for matrices. Yeah, both of my input are matrices. Sorry. I didn't notice earlier.

Regards,
Rizuan


Top
 Profile  
 
 Post subject: Re: vdotproduct
PostPosted: Sat Oct 30, 2010 4:49 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
You can use alglib::rmatrixgemm() for matrix-matrix products, there are more functions in ablas subpackage which work with matrices.


Top
 Profile  
 
 Post subject: Re: vdotproduct
PostPosted: Sun Oct 31, 2010 11:48 am 
Offline

Joined: Wed Oct 20, 2010 10:12 am
Posts: 20
Hi Sergey,
As far as I'm concern, rmatrixgemm() is not dot-product. It is A(MxN) multiply by B(NxK) that results in output with size of (MxK). Correct me if I'm wrong. I think maybe you should improve the documentation page. Anyway, all you've been doing is great! Thanks.

Regards,
Rizuan


Top
 Profile  
 
 Post subject: Re: vdotproduct
PostPosted: Sun Oct 31, 2010 3:09 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 906
Yes, rmatrixgemm is matrix-matrix product - a separate kind of multiplication, which is not dot-product.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 305 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group