Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7148 Discussions

vector-scalar and vectror-vector subtraction

MilesF
Beginner
250 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
195 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
118 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