Developer Reference for Intel® oneAPI Math Kernel Library for C

ID 766684
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

v?LinearFrac

Performs linear fraction transformation of vectors a and b with scalar parameters.

Syntax

vhLinearFrac( n, a, b, scalea, shifta, scaleb, shiftb, y );

vhLinearFracI(n, a, inca, b, incb, scalea, shifta, scaleb, shiftb, y, incy);

vmhLinearFrac( n, a, b, scalea, shifta, scaleb, shiftb, y, mode );

vmhLinearFracI(n, a, inca, b, incb, scalea, shifta, scaleb, shiftb, y, incy, mode);

vsLinearFrac( n, a, b, scalea, shifta, scaleb, shiftb, y );

vsLinearFracI(n, a, inca, b, incb, scalea, shifta, scaleb, shiftb, y, incy);

vmsLinearFrac( n, a, b, scalea, shifta, scaleb, shiftb, y, mode );

vmsLinearFracI(n, a, inca, b, incb, scalea, shifta, scaleb, shiftb, y, incy, mode);

vdLinearFrac( n, a, b, scalea, shifta, scaleb, shiftb, y )

vdLinearFracI(n, a, inca, b, incb, scalea, shifta, scaleb, shiftb, y, incy);

vmdLinearFrac( n, a, b, scalea, shifta, scaleb, shiftb, y, mode );

vmdLinearFracI(n, a, inca, b, incb, scalea, shifta, scaleb, shiftb, y, incy, mode);

Include Files

  • mkl.h

Input Parameters

Name

Type

Description

n

const MKL_INT

Specifies the number of elements to be calculated.

a, b

const _Float16* for vhLinearFrac, vmhLinearFrac

const float* for vsLinearFrac, vmsLinearFrac

const double* for vdLinearFrac, vmdLinearFrac

Pointers to arrays that contain the input vectors a and b.

inca, incb, incy

const MKL_INT

Specifies increments for the elements of a, b, and y.

scalea, scaleb

const _Float16 for vhLinearFrac, vmhLinearFrac

const float for vsLinearFrac, vmsLinearFrac

const double for vdLinearFrac, vmdLinearFrac

Constant values for scaling multipliers of vectors a and b.

shifta, shiftb

const _Float16 for vhLinearFrac, vmhLinearFrac

const float for vsLinearFrac, vmsLinearFrac

const double for vdLinearFrac, vmdLinearFrac

Constant values for shifting addends of vectors a and b.

mode

const MKL_INT64

Overrides global VM mode setting for this function call. See vmlSetMode for possible values and their description.

Output Parameters

Name

Type

Description

y

_Float16* for vhLinearFrac, vmhLinearFrac

float* for vsLinearFrac, vmsLinearFrac

double* for vdLinearFrac, vmdLinearFrac

Pointer to an array that contains the output vector y.

Description

The v?LinearFrac function performs a linear fraction transformation of vector a by vector b with scalar parameters: scaling multipliers scalea, scaleb and shifting addends shifta, shiftb:

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

The v?LinearFrac function is implemented in the EP accuracy mode only, therefore no special values are defined for this function. If used in HA or LA mode, v?LinearFrac sets the VM Error Status to VML_STATUS_ACCURACYWARNING (see the Values of the VM Status table). Correctness is guaranteed within the threshold limitations defined for each input parameter (see the table below); otherwise, the behavior is unspecified.

 

Threshold Limitations on Input Parameters
2EMIN/2 |scalea| 2(EMAX-2)/2
2EMIN/2 |scaleb| 2(EMAX-2)/2
|shifta| 2EMAX-2
|shiftb| 2EMAX-2
2EMIN/2a[i] 2(EMAX-2)/2
2EMIN/2b[i] 2(EMAX-2)/2
a[i] - (shifta/scalea)*(1-δ1), |δ1| 21-(p-1)/2
b[i] - (shiftb/scaleb)*(1-δ2), |δ2| 21-(p-1)/2

EMIN and EMAX are the minimum and maximum exponents and p is the number of significant bits (precision) for the corresponding data type according to the ANSI/IEEE Standard 754-2008 ([IEEE754]):

  • for single precision EMIN = -126, EMAX = 127, p = 24

  • for double precision EMIN = -1022, EMAX = 1023, p = 53

The thresholds become less strict for common cases with scalea=0 and/or scaleb=0:

  • if scalea=0, there are no limitations for the values of a[i] and shifta.

  • if scaleb=0, there are no limitations for the values of b[i] and shiftb.

To use the v?LinearFrac to shift vector a by a scalar value, set scaleb to 0. Note that even if scaleb is 0, b must be declared.

#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[i],r[i]);
  }

  return 0;
}

To use the v?LinearFrac to compute shifta/(scaleb·b[i]+shiftb), set scalea to 0. Note that even if scalea is 0, a must be declared.