| Prev | Next | powerof2 |
| Syntax |
y = powerof2(x) |
| Include: |
include spt\powerof2.oms |
| See Also |
ARGUMENTS:
INPUTS:
x = MATRIX, any numerical type.
RETURN: MATRIX,INTEGER, 1=power-of-2, 0=otherwise
Determines on an element-by-element basis whether input values are an integral power-of-2.
Any numerical type may be input. All values are coerced to DOUBLE before local processing.
All input values must be strictly positive or 'novalue' is returned. An INTEGER matrix is
returned where each element is a "1" if the input entry was a power-of-2, returns 0 otherwise.
For Sclars:
O>powerof2(1/8192.)
1
For Vector Input:
O>x = {.125, 1, 5, 8, 128, 200}
O>powerof2(x)
{
1
1
0
1
1
0
}
For Matrices:
O>A = {[.25, 32], [.1, 100]}
O>powerof2(A)
{
[ 1 , 1 ]
[ 0 , 0 ]
}
Error Response:
O>x = powerof2({0.0, -1})
ERROR: powerof2(), Contains non-positive elements.
Returning 'novalue'.
O>type(x)
novalue