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

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?

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

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

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

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

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

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

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

By the way, why are multi-threaded vector arithmetic functions (like ippsMul_64f) depreciated in IPP, but its seemingly ok to have multi-threaded vdMul in MKL?

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

**[ ippdefs.h ]**... #if defined( _WIN32 ) || defined ( _WIN64 ) #define

**__STDCALL**

**__stdcall**#define __CDECL __cdecl #define __INT64 __int64 #define __UINT64 unsigned __int64 #else #define __STDCALL #define __CDECL #define __INT64 long long #define __UINT64 unsigned long long #endif #if !defined( IPPAPI ) #if defined( IPP_W32DLL ) && (defined( _WIN32 ) || defined( _WIN64 )) #if defined( _MSC_VER ) || defined( __ICL ) #define IPPAPI( type,name,arg ) \ __declspec(dllimport) type

**__STDCALL**name arg; #else #define IPPAPI( type,name,arg ) type

**__STDCALL**name arg; #endif #else #define IPPAPI( type,name,arg ) type

**__STDCALL**name arg; #endif #endif ...

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

Hi MK, Sergey,

Yes, IPP custom dll is using default stdcall.

Thanks

Ying

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