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

Highlighted
##

Is there any method to compute sum of powers without using extra space?

Vitali_Haravy

Beginner

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

10-25-2010
07:16 AM

5 Views

Sum of powers

P.S. I need this to compute p-norm of the vector.

12 Replies

Highlighted
##

Naveen_G_Intel

Employee

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

10-25-2010
08:03 AM

5 Views

Hi,

Here are list of power functions implemented in IPP as per IEEE-754 standard.

http://software.intel.com/sites/products/documentation/hpc/ipp/ipps/ipps_ch12/ch12_Intro.html

Regards,

Naveen Gv

Highlighted
##

Thanks.

Vitali_Haravy

Beginner

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

10-25-2010
08:21 AM

5 Views

But I need to compute the following:

s = pow(a[0], p) + pow(a[1], p) + ... + pow(a[n - 1], p)

To calculate such a sum I need an extra space because I can't destroy the original content of the array:

1. Use **Powx** function to compute powers:

b* = pow(a**, p), i = 0 .. n - 1*

2. Use **Sum**function to compute sum:

s = b[0] + b[1] + ... + b[n - 1]

In certain situations I should also compute absolute values before computing powers.

The question was whether I could compute such sums without utilizing an extra space. Do you have any suggestions how to do it?

Highlighted
##

Hello,

It does not look easy with IPP function call. If the code cares about the memory use it will cause, can it use a small temporary data block, for example, 128size ofdata? Calculate the first 128 data first, then next 128 data,etc.

Thanks,

Chao

Chao_Y_Intel

Employee

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

10-25-2010
07:08 PM

5 Views

It does not look easy with IPP function call. If the code cares about the memory use it will cause, can it use a small temporary data block, for example, 128size ofdata? Calculate the first 128 data first, then next 128 data,etc.

Thanks,

Chao

Highlighted
##

*Hello, *

It does not look easy with IPP function call. If the code cares about the memory use it will cause, can it use a small temporary data block, for example, 128size ofdata? Calculate the first 128 data first, then next 128 data,etc.

Thanks,

ChaoWhat about MKL + IPP? Maybe using these two libraries it's possible to accomplish the required result?

Vitali_Haravy

Beginner

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

10-26-2010
08:18 AM

5 Views

Quoting Chao Y (Intel)

It does not look easy with IPP function call. If the code cares about the memory use it will cause, can it use a small temporary data block, for example, 128size ofdata? Calculate the first 128 data first, then next 128 data,etc.

Thanks,

Chao

Highlighted
##

Chao_Y_Intel

Employee

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

10-26-2010
07:44 PM

5 Views

MKL vdPowx( n, a, b, y ) support in-place operation. You may call this function, put the out-put value into a*, then sum the a value. *

Thanks,

Chao

Highlighted
##

I know about this, but this function will destroy the original content of the array. I'd like to find a way to compute sum of powers without using additional buffer. Of course, I can do it in the following manner:

Vitali_Haravy

Beginner

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

10-27-2010
05:02 AM

5 Views

Quoting Chao Y (Intel)

MKL vdPowx( n, a, b, y ) support in-place operation. You may call this function, put the out-put value into a*, then sum the a value. *

Thanks,

Chao

double sum = 0.0;

for (int i = 0; i < n; ++i)

{

sum += pow(a*, x);*

}

But I was hoping to find a way to do it faster by using MKL and IPP.

Highlighted
##

Hello,

I think it should be possible to achieve that with call of two IPP functions (ippsPowx and ippsSum) something like pseudo code below

// allocate memory for vector ofresulted power values

// n - is lenght of vector

pow_a_x = ippMalloc(n*sizeof(Ipp32f))

Ipp32f x; //value of power you want to raise elements of vector a

//raise eachelements of vector a to power x

ippsPowx_32f_A24(a, x, pow_a_x);

Ipp32f sum;

// compute sum of elements of array pow_a_x

ippsSum_32f(pow_a_x, n, ∑, ippAlgHintAccurate);

Function ippsPowx declared in ippvm.h and function ippsSum decleared in ipps.h file. You will need to link with ipps.lib and ippvm.lib libraries.

Regards,

Vladimir

Vladimir_D_Intel

Employee

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

10-27-2010
10:29 AM

5 Views

I think it should be possible to achieve that with call of two IPP functions (ippsPowx and ippsSum) something like pseudo code below

// allocate memory for vector ofresulted power values

// n - is lenght of vector

pow_a_x = ippMalloc(n*sizeof(Ipp32f))

Ipp32f x; //value of power you want to raise elements of vector a

//raise eachelements of vector a to power x

ippsPowx_32f_A24(a, x, pow_a_x);

Ipp32f sum;

// compute sum of elements of array pow_a_x

ippsSum_32f(pow_a_x, n, ∑, ippAlgHintAccurate);

Function ippsPowx declared in ippvm.h and function ippsSum decleared in ipps.h file. You will need to link with ipps.lib and ippvm.lib libraries.

Regards,

Vladimir

Highlighted
##

*Hello,*

I think it should be possible to achieve that with call of two IPP functions (ippsPowx and ippsSum) something like pseudo code below

// allocate memory for vector ofresulted power values

// n - is lenght of vector

pow_a_x = ippMalloc(n*sizeof(Ipp32f))

Ipp32f x; //value of power you want to raise elements of vector a

//raise eachelements of vector a to power x

ippsPowx_32f_A24(a, x, pow_a_x);

Ipp32f sum;

// compute sum of elements of array pow_a_x

ippsSum_32f(pow_a_x, n, ∑, ippAlgHintAccurate);

Function ippsPowx declared in ippvm.h and function ippsSum decleared in ipps.h file. You will need to link with ipps.lib and ippvm.lib libraries.

Regards,

VladimirThanks. But you have not read my posts carefully. The question is **if I can compute sum of powers without allocating extra array and without destroying the content of original array**.

Vitali_Haravy

Beginner

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

10-27-2010
10:52 AM

5 Views

Quoting Vladimir Dudnik (Intel)

I think it should be possible to achieve that with call of two IPP functions (ippsPowx and ippsSum) something like pseudo code below

// allocate memory for vector ofresulted power values

// n - is lenght of vector

pow_a_x = ippMalloc(n*sizeof(Ipp32f))

Ipp32f x; //value of power you want to raise elements of vector a

//raise eachelements of vector a to power x

ippsPowx_32f_A24(a, x, pow_a_x);

Ipp32f sum;

// compute sum of elements of array pow_a_x

ippsSum_32f(pow_a_x, n, ∑, ippAlgHintAccurate);

Function ippsPowx declared in ippvm.h and function ippsSum decleared in ipps.h file. You will need to link with ipps.lib and ippvm.lib libraries.

Regards,

Vladimir

Currently I have several alternatives:

1. Allocate full length array and use MKL/IPP in the way similar to the one you proposed.

2. Do it manually. No extra space is required.

3. Allocate small array and compute the sum of powers by blocks (thanks to Chao Y for proposition).

It seems strange that such libraries like MKL and IPP doesn't have required functionality.

Highlighted
##

Oh, yes. I did not notice you already consider that variant. But I do not thinkit is really strange that libraries does not have this particular variant implemented as single call. More important they provide you with building blocks which are primitive enough that you may construct any variant. That is more flexible approach, I think.

Vladimir

Vladimir_D_Intel

Employee

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

10-27-2010
11:07 AM

5 Views

Vladimir

Highlighted
##

You are right, but in some situations (i.e. like this) there are not enough building blocks to perform required operations efficiently.

Vitali_Haravy

Beginner

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

10-27-2010
11:20 AM

5 Views

P. S. By the way, Intel IPP library has routines for computing L1, L2 or infinity norm, but has no routine to compute the general case (I mean p-norm).

Highlighted
##

Vitali,

are you bound to MKL/IPP?? Otherwise you could program a simple loop using intrinsics and short vector math library, see compiler documentation. You only need _mm_pow_pd, _mm_add_pd and a final _mm_hadd_pd.

Best regards, TJ

Thomas_B_3

Beginner

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

10-28-2010
12:42 AM

5 Views

are you bound to MKL/IPP?? Otherwise you could program a simple loop using intrinsics and short vector math library, see compiler documentation. You only need _mm_pow_pd, _mm_add_pd and a final _mm_hadd_pd.

Best regards, TJ

Highlighted
##

*Vitali,*

are you bound to MKL/IPP?? Otherwise you could program a simple loop using intrinsics and short vector math library, see compiler documentation. You only need _mm_pow_pd, _mm_add_pd and a final _mm_hadd_pd.

Best regards, TJTJ,

Vitali_Haravy

Beginner

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

10-28-2010
01:37 AM

5 Views

Quoting TJ04

are you bound to MKL/IPP?? Otherwise you could program a simple loop using intrinsics and short vector math library, see compiler documentation. You only need _mm_pow_pd, _mm_add_pd and a final _mm_hadd_pd.

Best regards, TJ

I am afraid that I'm bound to MKL+IPP (we don't use Intel Compiler), but in any case thanks for information.

Best regards,

Vitali.

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