VSIPL++ Tensor objects represent three-dimensional sets of data. The type of values stored in the tensor is given by the first template argument.
A = 0
A = value
value.
The following elementwise unary operations can be performed on tensors, producing a tensor result:
acos(A)
arg(A)
asin(A)
atan(A)
bnot(A)
ceil(A)
conj(A)
cos(A)
cosh(A)
euler(A)
exp(A)
exp10(A)
floor(A)
imag(A)
is_finite(A)
is_nan(A)
is_normal(A)
lnot(A)
log(A)
log10(A)
mag(A)
magsq(A)
neg(A)
real(A)
recip(A)
rsqrt(A)
sin(A)
sinh(A)
sq(A)
sqrt(A)
tan(A)
tanh(A)
The following elementwise binary operations can be performed on tensors, producing a tensor result:
add(A)
atan2(A)
band(A)
bor(A)
bxor(A)
div(A)
eq(A)
fmod(A)
ge(A)
gt(A)
hypot(A)
jmul(A)
land(A)
le(A)
lor(A)
lt(A)
lxor(A)
max(A)
maxmg(A)
maxmgsq(A)
min(A)
minmg(A)
minmgsq(A)
mul(A)
ne(A)
pow(A)
sub(A)
The following elementwise ternary operations can be performed on tensors, producing a tensor result:
am(A)
expoavg(A)
ite(A)
ma(A)
msb(A)
sbm(A)
A tensor with one type of values can be converted a tensor with
another type of values using view_cast.
For example, to convert a tensor of floats A into
a tensor of ints Z:
Tensor<float> A(size); Tensor<int> Z(size); Z = view_cast<int>(A)
The following arithmetic elementwise binary operations and functions are available on tensors:
Z = add(A, B)
Z(n) = A(n) + B(n)(section 4.2.2)Z = div(A, B)
Z(n) = A(n) / B(n)(section 4.2.16)Z = max(A, B)
A(n) and
B(n)Z = min(A, B)
A(n) and
B(n)Z = mul(A, B)
Z(n) = A(n) * B(n)(section 4.2.51)Z = sub(A, B)
Z(n) = A(n) - B(n)(section 4.2.63)Addition, subtraction, multiplication, and division can also be written in operator form:
Z = A + B
Z = add(A, B)Z = A - B
Z = sub(A, B)Z = A * B
Z = mul(A, B)Z = A / B
Z = div(A, B)In all the preceding functions and operations, either of the tensor operands can be replaced with scalar operands.
For example, to perform a scalar-tensor multiply:
Z = a * B;
or
Z = mul(a, B);
Z = eq(A, B)
Z(n) = A(n) == B(n)Z = gt(A, B)
Z(n) = A(n) > B(n)Z = gte(A, B)
Z(n) = A(n) >= B(n)Z = lt(A, B)
Z(n) = A(n) < B(n)Z = lte(A, B)
Z(n) = A(n) <= B(n)Z = ne(A, B)
Z(n) = A(n) != B(n)
The following arithmetic elementwise ternary operations and functions are available on tensors:
Z = ma(A, B, C)
Z(n) = A(n) * B(n) +
C(n)Z = am(A, B, C)
Z(n) = A(n) + B(n) *
C(n)In all the preceding functions and operations, one or more of the tensor operands can be replaced with scalar operands.
For example, to scale a tensor, then apply an offset:
Z = scale * A + offset;
or
Z = ma(scale, A, offset);
(where scale and offset are
scalar values)
Z = ite(bool_tensor, A, B)
Z, sets
value to nth element ofA if m,n,pth element of
bool_tensor is true, otherwise sets value to the m,n,pth element of
B. Notionally equivalent to C
?: operator. (Foreach n) Z[m, n, p] =
bool_tensor[m, n, p] ? A[m, n, p] : B[m, n, p]
In all the preceding functions and operations, one or more of the tensor operands can be replaced with scalar operands.
For example, the apply a scalar threshold b to a
tensor:
Z = ite(A > b, A, b);
The following functions reduce a tensor to a single value:
z = alltrue(A)
A is bool,
the function returns true if all
the elements are true;
otherwise false. When the element type
is something else,
see (section 4.3.1) for more information.
z = anytrue(A)
A is bool,
the function returns true if any
elements are true;
otherwise false. When the element type
is something else,
see (section 4.3.2) for more information.
z = sumval(A)
A's values.z = sumsqval(A)
A's values.z = meanval(A)
A's values.z = meansqval(A)
A's values.The following functions reduce a tensor to a single value that corresponds to an element within the vector.
z = maxval(A, idx)
A.
Set idx to the index of this element
(A.get(idx[0], idx[1], idx[2]) == z).z = maxmgval(A, idx)
A. Set idx to the index of
this element (mag(A.get(idx[0], idx[1], idx[2])) ==
z).z = maxmgsqval(A, idx)
A. Set idx to the index of
this element (magsq(A.get(idx[0], idx[1], idx[2])) ==
z).z = minval(A, idx)
A.
Set idx to the index of this element
(A.get(idx[0], idx[1], idx[2]) == z).z = minmgval(A, idx)
A. Set idx to the index of
this element (mag(A.get(idx[0], idx[1], idx[2])) ==
z).z = minmgsqval(A, idx)
A. Set idx to the index of
this element (magsq(A.get(idx[0], idx[1], idx[2])) ==
z).