Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
7234 Discussions

vector-scalar and vectror-vector subtraction

MilesF
Beginner
594 Views

Hi,

I'm looking for functions in MKL or other libraries that does vector-scalar and vector-vector subtraction efficiently. Elements are doubles.

vector-scalar:
[a1, a2, a3,...an] - b = [(a1 - b), (a2 - b), (a3 - b),...(an - b)]


scalar-vector:
b - [a1, a2, a3,...an] = [(b - a1), (b - a2), (b - a3),...(b - an)]

 

vector-vector 1:
[a1, a2, a3,...an] - [b1, b2, b3,...bm] = [(a1 - b1), (a1 - b2), (a1 - b3),...(a1 - bm),

(a2 - b1), (a2 - b2), (a2 - b3),...(a2 - bm),
...,
(an - b1), (an - b2), (an - b3),...(an - bm)]

 

vector-vector 2:
[a1, a2, a3,...an] - [b1, b2, b3,...bm] = [(a1 - b1), (a2 - b1), (a3 - b1),...(an - b1),

(a1 - b2), (a2 - b2), (a3 - b2),...(an - b2),
...,
(a1 - bm), (a2 - bm), (a3 - bm),...(an - bm)]

I am new to MKL and a bit lost in the documentation, can someone help?

I have also need for addition, multiplication and division, but I think if subtraction is figured out, I should know how to do the rest. 

0 Kudos
2 Replies
Avis682Holmes
Beginner
539 Views

Hello!

For vector-scalar and vector-vector subtraction in MKL, use the vdSub function. This function handles element-wise subtraction for double precision vectors. For vector-scalar subtraction, subtract the scalar from each element of the vector. For vector-vector subtraction, subtract corresponding elements of the two vectors. Similar functions like vdAdd, vdMul, and vdDiv are available for addition, multiplication, and division. If you need more details, feel free to ask.

0 Kudos
MilesF
Beginner
462 Views
Hi, thanks for the answer. I am on holiday and don't have the development computer in hand. I will test and come back to you afterwards.

BR,
Miles
0 Kudos
Reply