Section: Mathematical Operators
y = a - b
where a
and b
are n
-dimensional arrays of numerical type. In the
first case, the two arguments are the same size, in which case, the
output y
is the same size as the inputs, and is the element-wise
difference of a
and b
. In the second case, either a
or b
is a scalar,
in which case y
is the same size as the larger argument,
and is the difference of the scalar to each element of the other argument.
The rules for manipulating types has changed in FreeMat 4.0. See typerules
for more details.
If a
is a scalar, then the output is computed via
On the other hand, if b
is a scalar, then the output is computed via
--> 3 - 8 ans = -5
Next, we subtract a vector of values from a scalar:
--> 3.1 - [2,4,5,6,7] ans = 1.1000 -0.9000 -1.9000 -2.9000 -3.9000
With complex values
--> a = 3 - 4*i a = 3.0000 - 4.0000i --> b = a - 2 b = 1.0000 - 4.0000i
Finally, the element-wise version:
--> a = [1,2;3,4] a = 1 2 3 4 --> b = [2,3;6,7] b = 2 3 6 7 --> c = a - b c = -1 -1 -3 -3