Math Operations with PinSiteData
The PinSiteData
type supports various math operations which include both binary and unary math operations.
Binary Math Operations with PinSiteData
The following table outlines the binary operator-based mathematical operations available for PinSiteData<T>
and specifies the permitted data types for T
for each operation.
Table of Binary Math Operations for PinSiteData:
Methods | Operator | Description | Supported Data Types |
---|---|---|---|
Add | + | Performs an add operation between every element in current PinSiteData object and the given value. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
BitwiseAnd | & | Performs a bitwise AND operation with a scalar for each element across each pin and each site. |
int , unint , long , ulong , byte , sbyte , short , ushort |
BitwiseOr | | | Performs a bitwise OR operation with a scalar for each element across each pin and each site. |
int , unint , long , ulong , byte , sbyte , short , ushort |
BitwiseXor | ^ | Performs a bitwise XOR operation with a scalar for each element across each pin and each site. |
int , unint , long , ulong , byte , sbyte , short , ushort |
Compare | Performs a compare operation between every element in current PinSiteData object and the given value. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
Divide | / | Performs a divide operation between every element in current PinSiteData object and the given value. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
Maximum | Returns the larger one of the elements in current PinSiteData object and the given value. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
Minimum | Returns the smaller one of the elements in current PinSiteData object and the given value. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
Multiply | * | Performs a multiply operation on every element in current PinSiteData object and the given value. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
Power | Raises every element in current PinSiteData object to the power of the given value. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
Subtract | - | Subtracts the given value from every element in current PinSiteData object. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
Usage Considerations for Binary Math Operations with PinSiteData
When performing binary math operations on PinSiteData
objects you should consider the following:
- The
PinSiteData
object on which the method operates, and the input argument provided to the method serve as the two operands in the binary math operation being performed. - All methods can accept either a scalar, an array,
SiteData
object orPinSiteData
as an input argument. - Operators can only accept a scalar,
SiteData
orPinSiteData
object as the second operand. - When the input is a
SiteData
orPinSiteData
object it must match the same underlying type,T
, as thePinSiteData
object being operated on. - When both operands are scaler, they must have identical data types, and that data type must be supported by the desired method.
- When one of the operand is
PinSiteData<T>
and other operand is scaler, then both operand must be of identical data type,T
, and that data type must be supported by the desired method. - When the underlying data,
T
, of thePinSiteData<T>
object is an array type, if the second operand is:- Also an array type, the second operand must have the same length, dimensions, and underlying type as the array contained within the
PinSiteData<T>
object. - Scalar type, the scalar type must match the array element type of the underlining data within the
PinSiteData<T>
object. SiteData<T>
object, both operand objects must be of identical data types,T
.PinSiteData<T>
object, both operand objects must be of identical data types,T
.
- Also an array type, the second operand must have the same length, dimensions, and underlying type as the array contained within the
- The Bitwise methods are only supported when the underlying data type of the
PinSiteData
object,T
, is an integer type, either a scalar integer, array of integers, or anotherPinSiteData
object of the same integer type. - When the input argument is an array or a
PinSiteData
object of an array type, the array element data type must match the underlying type of thePinSiteData<T>
object,T
, and be of equal or lesser dimensions (i.e. TOther cannot be 2D whenT
is 1D). - The
Divide
method returns a scalar double value per site by default. When the underlying data typeT
of thePinSiteData<T>
object is an array, theTResult
type must be explicitly specified as a double array with the same dimensions asT
. Otherwise, aNISemiconductorTestException
exception is thrown with exception message matching the exception scenarios of Mismatched Array Dimensions. Refer to theDivide<TOther, TResult>(TOther)
,Divide<TOther, TResult>(SiteData<TOther>)
andDivide<TOther, TResult>(PinSiteData<TOther>)
method signatures in the API Reference documentation. - The
Compare
method returns a boolean value per site by default. When the underlying data typeT
of thePinSiteData<T>
object is an array, theTResult
type must be explicitly specified as a boolean array with the same dimensions asT
. Otherwise, aNISemiconductorTestException
exception is thrown with exception message matching the exception scenarios of Mismatched Array Dimensions. Refer to theCompare<TOther, TResult>(ComparisonType, TOther)
,Compare<TOther, TResult>(ComparisonType, SiteData<TOther>)
andCompare<TOther, TResult>(ComparisonType, PinSiteData<TOther>)
method signatures in the API Reference documentation.
Note
For more information on specific exception conditions when preforming math operations refer to Exception Conditions For Math Operations.
Examples for Binary Math Operations with PinSiteData
Example of binary math operations ✔️ ALLOWED with PinSiteData
:
var pinSiteData = new PinSiteData<double>(new Dictionary<string, IDictionary<int, double>>
{
["VCC1"] = new Dictionary<int, double> { [0] = 3.5 }
});
var siteData = new SiteData<double>(new Dictionary<int, double> { [0] = 1 });
var result = pinSiteData.Add(siteData);
// The result is a PinSiteData<double> object containing scalar data for one pin, one site equivalent to:
// { ["VCC1"] = { [0] = 4.5 } }
var operatorOverloadResult = pinSiteData + 2;
// The operatorOverloadResult is a PinSiteData<double> object containing scalar data for one pin, one site equivalent to:
// { ["VCC1"] = { [0] = 5.5 } }
Example of a binary math operation ❌ NOT ALLOWED with PinSiteData
:
var pinSiteData = new PinSiteData<double>(new Dictionary<string, IDictionary<int, double>>
{
["VCC1"] = new Dictionary<int, double> { [0] = 3.5 }
});
var siteData = new SiteData<long>(new Dictionary<int, long> { { 0, 1 } });
var result = pinSiteData.Add(siteData);
// The above operation will throw an NISemiconductorTestException with the following message:
// "For Add operation, the inner data type of the first operand (System.Double) and that of the second operand (System.Int64) must match."
Unary Math Operations with PinSiteData
The following table outlines the unary operator-based mathematical operations available for PinSiteData<T>
and specifies the permitted data types for T
for each operation.
Table of Unary Math Operations for PinSiteData:
Methods | Operator | Description | Supported Data Types |
---|---|---|---|
Abs | Performs Math.Abs operation on every element in current PinSiteData object. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
BitwiseComplement | ~ | Gets the bitwise complement of the original PinSiteData object. |
int , unint , long , ulong , byte , sbyte , short , ushort |
Invert | Performs invert operation on every element in current PinSiteData object. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
Log10 | Performs Math.Log10 operation on every element in current PinSiteData object. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
Max | Calculates the maximum value across sites. | double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
MaxByPin | Gets the maximum value across pins for each site and returns both the maximum value and each pin(s) where the maximum value was found for each site. | double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
MaxBySite | Gets the maximum value across sites for each pin and returns both the maximum value and each site(s) where the maximum value was found for each pin. | double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
Mean | Calculates the mean value across pins for each site and returns the mean value for each site. | double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
MeanBySite | Calculates the mean value across sites for each pin and returns the site-to-site mean value for each pin. | double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
Min | Gets the minimum value across pins for each site. | double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
MinByPin | Gets the minimum value across pins for each site and returns both the minimum value and each pin(s) where the minimum value was found for each site. | double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
MinBySite | Gets the minimum value across sites for each pin and returns both the minimum value and each site(s) where the minimum value was found for each pin. | double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
Negate | Returns the negative value of every element in current PinSiteData object. |
int , long , sbyte , short , double , decimnal , float |
|
ShiftLeft | << | Shifts the value to the left by the specified bit count for each element per site. | int , unint , long , ulong , byte , sbyte , short , ushort |
ShiftRight | >> | Shifts the value to the right by the specified bit count. | int , unint , long , ulong , byte , sbyte , short , ushort |
SquareRoot | Returns the square root of every element in the current PinSiteData object. |
double , decimal , float , int , unint , long , ulong , byte , sbyte , short , ushort |
|
Truncate | Returns integer portion of every element in current PinSiteData object. |
double , decimnal , float |
Usage Considerations for Unary Math Operations with PinSiteData
When performing unary math operations on PinSiteData
objects you should consider the following:
- The
Invert
,Log10
, andSquareRoot
methods return a scalar double value per site by default. When the underlying data typeT
of thePinSiteData<T>
object is an array, theTResult
type must be explicitly specified as adouble
array with the same dimensions asT
. Otherwise, aNISemiconductorTestException
exception is thrown with exception message matching the exception scenarios of Mismatched Array Dimensions. - The
count
input value passed to theShiftLeft
andShiftRight
operators must be positive, otherwise an exceptionNISemiconductorTestException
is thrown with exception message matching the exception scenarios of Shift Count Must Be Positive.
Note
For more information on specific exception conditions when preforming math operations refer to Exception Conditions For Math Operations.
Examples for Unary Math Operations with PinSiteData
Example of a unary math operation ✔️ ALLOWED with PinSiteData
:
var pinSiteData = new PinSiteData<double>(new Dictionary<string, IDictionary<int, double>>
{
["VCC1"] = new Dictionary<int, double> { [0] = -3.5 }
});
var result = pinSiteData.Abs();
// The result is a PinSiteData<double> object containing scalar data for one pin, one site equivalent to: { ["VCC1"] = { [0] = 3.5 } }
Example of a unary math operation ❌ NOT ALLOWED with PinSiteData
:
var pinSiteData = new PinSiteData<string>(new Dictionary<string, IDictionary<int, string>>
{
["VCC1"] = new Dictionary<int, string> { [0] = "Negative 3.5" }
});
var result = pinSiteData.Abs();
// Above operation with throw an exception of NISemiconductorTestException with the following message:
// "Math operations not supported on the System.String type data."