Binary operations

From Horace

Jump to: navigation, search

Contents

minus

Subtraction of either one dnd from another dnd, where both objects are exactly the same size. Alternatively subtract a scalar from every element of a dnd or sqw. You can use input arguments that are arrays of dnds, in which case the arrays must be the same size if both arguments are dnd. If the first argument is an array of dnds then the second argument can be a scalar, or an array of scalars that is the same size as the array of dnds.

You can also subtract a dnd from an sqw object, provided they have the same dimensionality and cover the same data range. If you wish to subtract one sqw from another then they must have identical .data.pix arrays (which in practise is never).

e.g.

wout=minus(win1,win2)

where win1 and win2 are d2d objects of the same size. The output wout is also a d2d the same size as win1 and win2. Or:

wout=minus(win,2)

wout is the same size as win, and has had 2 subtracted from every element. Finally:

wout=minus(win,[2 5 7])

if win is a 1x3 array of dnd objects, then the scalar 2 is subtracted from the first one, 5 from the second, and 7 from the 3rd.

plus

Works in precisely the same way as minus, except objects and scalars are added...

mtimes

Matrix multiplication of two dnd objects. It is the equivalent in Matlab of using .* instead of *, since the latter is matrix multiplication, and what is required is element-by-element multiplication.

wout=mtimes(win1,win2)

As with plus, minus, etc, it can be used either on two dnd objects that are the same size, a dnd object and a scalar, or arrays of the above.


mrdivide

Works in the same way as mtimes, i.e. a dnd implementation of the Matlab command ./. Note that it is called mrdivide because the operation is specifically matrix right-divide, as opposed to matrix left-divide (see Matlab help for a full description of left-division).

single_minus

More generic version of minus. Class type for the object must be specified, i.e.

wout=single_minus(w1,w2,'d2d');

for the subtraction of the two d2d objects w1 and w2.

mpower

Implementation for dnd objects of the Matlab command .^, i.e. element-by-element power.

single_plus

As single_minus, but for addition of objects.

single_mpower

As single_minus, but for element-by-element power operation.

single_mrdivide

As single_minus, but for element-by-element division of objects.

single_mtimes

As single_minus, but for element-by-element multiplication of objects.

Personal tools