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

Vector plus/minus one floating point number

Marcus_W_1
Beginner
350 Views

Hi,

v?Add(n,a,b) performs element by element addition of vector a and vector b. Sometimes a single shift is required only, i.e. in this case b can be interpreted as a floating point number, i.e. a + b. One example is the calculation of centered values (with respect to the empirical distribution). Does MKL provides such a function as well? Off cause I can create a vector b of the same size as the input vector a and set b =b for each k, but I would like to avoid the memory allocation.

Best wishes

Markus Wendt

0 Kudos
5 Replies
Andrey_N_Intel
Employee
350 Views

Hi Markus,

Please, have a look at Intel(R) MKL v?LinearFrac function which computes

y[i]=(scalea·a[i]+shifta)/(scaleb·b[i]+shiftb), i=1,2 … n

Thanks,

Andrey

 

 

0 Kudos
Andrey_N_Intel
Employee
350 Views

Hi Markus,

I attach the example which shows how to use the function in your specific case. I will check with our internal team how to improve documentation for this function.

Andrey

0 Kudos
Andrey_N_Intel
Employee
350 Views

I'm not sure if the file is successfully attached. Copying the code of the

#include <stdio.h>
#include "mkl_vml.h"


int main()
{
  double a[10], *b;
  double r[10];
  double scalea = 1.0, scaleb = 0.0;
  double shifta = -1.0, shiftb = 1.0;


  MKL_INT i=0,n=10;

  a[0]=-10000.0000;
  a[1]=-7777.7777;
  a[2]=-5555.5555;
  a[3]=-3333.3333;
  a[4]=-1111.1111;
  a[5]=1111.1111;
  a[6]=3333.3333;
  a[7]=5555.5555;
  a[8]=7777.7777;
  a[9]=10000.0000;
 
  vdLinearFrac( n, a, b, scalea, shifta, scaleb, shiftb, r );


  for(i=0;i<10;i++) {
    printf("%25.14f %25.14f\n",a,r);
  }

  return 0;
}

example here

0 Kudos
Andrey_N_Intel
Employee
350 Views

Hi Markus,

yes, the function checks the parameters: if you provide a null denominator to the function, it will return error. I requested the owners of the functionality to have a look at your question and have more specific description of the function in the docs.

Andrey

 

 

0 Kudos
Ying_H_Intel
Employee
350 Views

Hi Markus,

Yes,  we have tracking system for all requests. The one have been recorded in :

CQ DPD200572021 requires more details on behavior of linearFrac function in the documentation.

and one more DPD200331505 add a  c interface for dzgemm  for the early one.

Regards,

Ying

0 Kudos
Reply