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

## Better way to compute phi0 + sigma*vector? Beginner
344 Views

Hello!

I want to compute this quantity prob = phi0 + sigma*atilde, where phi0 and sigma are scalars and atilde a vector 1xind. I have computed it like this:

```for(i=0;i<ind;i++){ones = 1.0;}

cblas_dcopy(ind, ones, 1, B, 1);
cblas_dscal(ind, phi0, B, 1);
cblas_dcopy(ind, atilde, 1, Bcan, 1);
cblas_dscal(ind, sqrt(sigma2), Bcan, 1);
```

I would like to ask if there is a better way to do it.

Thank you very much.

1 Solution Employee
344 Views

Hi,

you might want to have a look at Intel MKL VM v?LinearFrac() function with shifta=phi, scalea=sigma, a=atilde, scaleb=0, b declared, and shiftb=1.The additional details on the function and respective examples are available https://software.intel.com/en-us/node/521774

Andrey

2 Replies Employee
345 Views

Hi,

you might want to have a look at Intel MKL VM v?LinearFrac() function with shifta=phi, scalea=sigma, a=atilde, scaleb=0, b declared, and shiftb=1.The additional details on the function and respective examples are available https://software.intel.com/en-us/node/521774

Andrey Beginner
344 Views

You are the best!!! Thanks a lot!!! 