Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Jérôme_C_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-19-2014
02:00 AM

126 Views

Correlation

Hi all,

I have a lot of trouble understanding how the correlation/convolution functions are used.

I have looked at the Information from the Manual but the description - involving finite functions - is far too abstract (and I've been used to abstractness as a physicist).

Can someone help me carry out a simple correlation analysis on two trivial vectors, say

v1 =(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

v2 = (1.01, 1.99, 3.01, 3.99, 5.01, 5.99, 7.01, 7.99, 9.01, 9.99)

(which should be approximatively 1) just to get me going?

Concretely: what should be my input, what will my output look like (and, ideally, why...)?

Here's what I have :

#define XSHAPE 10

#define YSHAPE 10

#define ZSHAPE (XSHAPE-1)+(YSHAPE-1)+1

int test6()

{

VSLCorrTaskPtr task; // declare the task

MKL_INT mode, xshape, yshape, zshape; //declare some variables

static double x[XSHAPE], y[YSHAPE], z[ZSHAPE]; //declare the input and output arrays

MKL_INT xstride = 1, ystride = 1, zstride = 1; //declare the "increment"

int status, ok, i;

xshape = XSHAPE; //length of vector

yshape = YSHAPE;

zshape = ZSHAPE;

for (i = 0; i<xshape; i++) // initialize the input vectors.

x* = i+1;*

for (i = 0; i<yshape; i++)

y* = i+1 + 0.01*pow(-1,i);*

ok = 1; // a priori success.

printf("EXAMPLE executing a correlation task\n");

mode = VSL_CORR_MODE_AUTO; //set mode

vsldCorrNewTask1D(&task, mode, xshape, yshape, zshape); //create task with, as an argument: reference to task object, mode, vectors lengths.

status = vsldCorrExec1D(task, x, xstride, y, ystride, z, zstride); // initialize status with task, vectors and respective increments. Execute task, fill vector z.

if (status != VSL_STATUS_OK) { // problem with the initialization of the status. // conversion from "status type" to int?

printf("ERROR: bad status: %d\n", status);

ok = 0; // boolean of success

}

for (i = 0; i < yshape; i++)

{

std::cout << y* << std::endl;*

}

printf("EXAMPLE %s\n", ok ? "PASSED" : "FAILED");

return !ok;}

Thanks in advance!

Jérôme

Link Copied

3 Replies

Zhang_Z_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-19-2014
11:22 AM

126 Views

Please check out this code example in your MKL installation: $MKLROOT/examples/vslc/source/vsldcorr_1d_auto.c

It does exactly what you want to do. You can reuse the code and simply plug in your own X and Y arrays.

Jérôme_C_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-20-2014
12:58 AM

126 Views

Hi Zhang,

I already did. It's not so much that the code doesn't work, but more that I don't understand what it does.

I expect(ed) Pearson's product-moment coefficient (see http://en.wikipedia.org/wiki/Correlation_and_dependence),

i.e. an application (R^n) x (R^n)->R, where R represents the set of real numbers.

So, here are my two questions:

1) Is there a function to compute this Pearson coefficient in the MKL?

2) If not, can you tell me what the Output of vsldcorr_1d_Auto.c is?

Thanks in advance.

Regards,

Jérôme

Andrey_N_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-20-2014
01:23 AM

126 Views

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.