# ocmath_d_stretch

## Description

Stretch (or squeeze) data in a vector or a matrix of type double by scaling all the data within a given range.

## Syntax

int ocmath_d_stretch( double * pX, uint nSize, double low1, double high1, double low2, double high2 )


## Parameters

pX
[modify] pointer to vector or matrix data
nSize
[input] size of vector, or nRows * nCols of a matrix
low1
[input] low value of the range of data to be scaled, for data < low1, they will become low2
high1
[input] high value of the range of data to be scaled, for data > high1, they will become high2
low2
[input] new low value of the data after the scaling
high2
[input] new high value of the data after the scaling

## Return

FALSE if low1 == high1 which renders the operation impossible, otherwise returns TURE

## Examples

EX1

// Create two identical matrices, use ocmath_d_stretch on one and plot both
void    ocmath_d_stretch_Ex1()
{
MatrixPage        mp1;
mp1.Create("origin", CREATE_VISIBLE);
MatrixObject        mo1(mp1.GetName(), 0);
LT_execute("matrix -v 50-abs(16.5-i)-abs(16.5-j);");

MatrixPage        mp2;
mp2.Create("origin", CREATE_VISIBLE);
MatrixObject        mo2(mp2.GetName(), 0);
LT_execute("matrix -v 50-abs(16.5-i)-abs(16.5-j);");

matrix                mat;
mat = mo1.GetDataObject();
int                    nRows, nCols;
mat.GetSourceDim(nRows, nCols);
// Values in the range 25 to 35 will be squeezed into a range from 0 to 10
// Values less than 25 become 0 and values greater than 35 become 10
ocmath_d_stretch(mat, nRows * nCols, 25, 35, 0, 10);

GraphPage        gp1;
gp1.Create("cmap", CREATE_VISIBLE);
GraphLayer        gl1(gp1.GetName());
gl1.Rescale();

GraphPage        gp2;
gp2.Create("cmap", CREATE_VISIBLE);
GraphLayer        gl2(gp2.GetName());
gl2.Rescale();
}


## Remark

Stretch (or squeeze) data in a vector or a matrix of type double by scaling all the data within a given range.

Values outside the given range are truncated.

Data types supported

double: ocmath_d_stretch

float: ocmath_f_stretch

unsigned short: ocmath_us_stretch