DATAMANIP (kdatamanip) functions


LIBRARY ROUTINE

lkarith2 - perform pointwise dual operand arithmetic on data object(s)

LIBRARY CALL

int lkarith2 (
   kobject  src1,
   kobject  src2,
   double   real,
   double   imag,
   int	    imag_flag,
   char    *function,
   int      use_subpos,
   kobject  dest)

INPUT

OUTPUT

RETURN VALUE

TRUE (1) on success, FALSE (0) otherwise

DESCRIPTION

The lkarith2 library routine performs an arithmetic operation on two source data objects. The routine takes two input data objects (or a single data object and a complex constant), a function name, and a destination data object in which to store the result of the function.

The supported functions are:

.TS 
center tab(:) ;
l l .
add     :  dest = src1 + (src2 or val)
sub     :  dest = src1 - (src2 or val)
subfrom :  dest = (src2 or val) - src1
mult    :  dest = src1 * (src2 or val)
div     :  dest = src1 / (src2 or val)
divinto :  dest = (src2 or val) / src1 
pow     :  dest = src1 raised to power of (src2 or val)
absdiff :  dest = | src1 - (src2 or val) |
mod     :  dest = remainder (src1/(src2 or val))
atan2   :  dest = atan(src1,(src2 or val)) = atan(src1/(src2 or val))
hypot   :  dest = hypot(src1,src2)=sqrt(src1*src1+src2*src2)
minimum :  dest = lower value between src1 and (src2 or val)
maximum :  dest = higher value between src1 and (src2 or val)
ldexp   :  dest = ldexp(src1,(src2 or val)) = src1 * 2**(src2 or val)
.TE
Where val is defined by the real and imag parameters passed into lkarith2.

Therefore if lkarith2() were called with two input data objects:

lkarith2(src1, src2, 0.0, 0.0, FALSE, NULL, "add", dest);

then the following would be performed:

dest = src1 + src2

If lkarith2 were called with a single data object and a constant:

lkarith2(src1, NULL, 10.0, 0.0, FALSE, NULL, "add", dest);

then the following would be performed:

dest = src1 + 10.0

If the use_subpos flag is TRUE, the subobject position for each source object that has value or mask data is used to determine the minimum common subobject position between them. This minimum position, along with the individual subobject positions, is used when calculating the final destination object size. Size and offsets are calculated so that the subobject positions of the source objects are aligned. These changes are applied before the arithmetic operation is performed. The resulting subobject position attribute of the destination object will be be the minimum common subobject position described above.

The data type of the destination object's data is cast to the highest order data type of the source objects' data. If the imaginary flag imag_flag is set and src2 is not provided, the input image data type is preserved. Internally, lkarith2() processes data using one of the following types: unsigned byte, long, unsigned long, double, or double complex.

If either source has mask data, the destination will have a mask that is the logical and of the source masks. Masks are padded with 1.

If a single source object is supplied, and it has map data, then the operation is performed on the map. If both source objects are supplied with combinations of map and value data, then the objects are operated on as described in the kapu_upgrade_objects() man page.

If the first source object has location or time data, they will be transferred to the destination object. If the object is resized, uniform location attributes will not be modified. If the location data is curvilinear or rectilinear, padded may occur using the src1 object's location/time pad attributes.

ADDITIONAL INFORMATION

none

EXAMPLES

none

SIDE EFFECTS

none

RESTRICTIONS

none

MODIFICATION

none

FILES

$DATAMANIP/objects/library/kdatamanip/src/lkarith2.c

SEE ALSO

kdatamanip(3)

COPYRIGHT

Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.