Turn on suggestions

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

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- Element-wise vector comparison

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

Mikhail_K_

Beginner

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

03-17-2017
08:50 AM

218 Views

Element-wise vector comparison

Hi,

I have a huge mxn matrix A where I need to compute A(i,j) > 0, ie. 1 for all values which are positive, and 0 otherwise

I would be better off writing it in C++, but let's assume I'm in a situation where I don't have admin rights and cannot install/compile anything. I'm using a single-threaded scripting language (VBA) to wrap calls to mkl_rt.dll, and any combination of MKL functions is still faster.

One way to solve this is to compute 1-0^(x+abs(x)), ie something like

vdabs m*n, A(1, 1), temp(1, 1)

vdadd m*n, A(1, 1), temp(1, 1), temp(1, 1)

vdpow m*n, res(1, 1), temp(1, 1), res(1, 1) /***** (res() is an array full of zeros)

vdlinearfrac m*n, res(1, 1), res(1, 1), 0, -1, 0, 1, res(1, 1)

But the vdpow function is quite costly computation-wise (overall speed difference is ca x4 in favor of mkl, but I expect more from one single thread in VBA vs compiled multi-threaded code)

Another solution is to find the maximum value in the array, divide by max+1 to force all values into <-1, 1> and apply vdceil, <-1, 0] becomes 0, and <0, 1> becomes 1, but there can be some problems if the numbers are huge and end up as [-1, 1]

Can anyone think of a simpler way to do it?

1 Solution

Ying_H_Intel

Employee

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

03-26-2017
06:19 PM

218 Views

Hi Mikhail,

It seems no simple function in MKL can do such operation

If possible, could you use other library like IPP library, which can do such operation by one function

for example

**Conversion of a grayscale image to a bitonal image**

IppStatus ippiGrayToBin_<srcDataType>1u_C1R (please search IPP's developer guide)

ippiThreshold_GTVal etc.

You mentioned you can't compile on one machine, Could it possible for you to wrap IPP dll on other machine with admin right , then copy the dll to VBA, thus you can use IPP dll?

Best Regards,

Ying

Link Copied

5 Replies

Ying_H_Intel

Employee

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

03-26-2017
06:19 PM

219 Views

Hi Mikhail,

It seems no simple function in MKL can do such operation

If possible, could you use other library like IPP library, which can do such operation by one function

for example

**Conversion of a grayscale image to a bitonal image**

IppStatus ippiGrayToBin_<srcDataType>1u_C1R (please search IPP's developer guide)

ippiThreshold_GTVal etc.

You mentioned you can't compile on one machine, Could it possible for you to wrap IPP dll on other machine with admin right , then copy the dll to VBA, thus you can use IPP dll?

Best Regards,

Ying

Mikhail_K_

Beginner

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

04-11-2017
02:07 AM

218 Views

Hi,

Yep, thanks, that's what I ended up doing.

Wasted whole evening trying to export some functions in ipps.h as stdcall to a custom dll... But then realized stdcall is default in IPP... Is it?

In MKL its cdecl (though most functions have stdcall)?

MK

Mikhail_K_

Beginner

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

04-12-2017
02:59 AM

218 Views

SergeyKostrov

Valued Contributor II

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

04-13-2017
03:49 PM

218 Views

Ying_H_Intel

Employee

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

04-16-2017
06:39 PM

218 Views

Hi MK, Sergey,

Yes, IPP custom dll is using default stdcall.

Thanks

Ying

Topic Options

- 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.