Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous
Next: Other Specializations Up: NOTE 216 - Lattice Expression Language Implementation Previous: Optimizations

Subsections


Relational and Logical Expressions

Relational Expressions

So far in the discussion, it has been assumed that the result of all expressions was either a numeric array or scalar. However, we also want to be able to handle operations which result in Booleans. For example, consider Lattices

   Lattice<Float> a;
   Lattice<Float> b;
   Lattice<Bool> c;

and the expression

   c.copyData(a>b);

so the Bool Lattice c is True or False depending upon whether the data values of a were greater than those of b or not.

What has to be handled here is that the output of the > operation is Boolean, whereas the type of the data which went into the operation was Float.

This relational operator, and like ones (<, > =, < =, = =, !=) are handled in the class LELBinaryCmp. It is templated on class T but inherits from LELInterface<Bool> rather than LELInterface<T>.

The LELInterface class eval function is declared as

   // Evaluate the expression and fill the result array
      virtual void eval (Array<T>& result,
                         const PixelRegion& region) const = 0;

This indicates that the array, result, which results from evaluating the expression is of type T. Since LELBinaryCmp inherits from LELInterface<Bool>, the type of its evaluation array, result, is Bool. This is just what we want. The result of b>c is a Bool array.

The LELBinaryCmp class itself is still templated in class T because that is the type of the Lattices that go into it.

Logical Expressions

Take as an example,

   Lattice<Bool> a;
   Lattice<Bool> b;
   Lattice<Bool> c;
   c.copyData(a&&b);

so the Bool Lattice c is True if Lattice a and b are True. This kind of operator can only be defined for Boolean Lattices. Therefore the class LELBinaryBool is not templated and inherits from LELInterface<Bool>. If the data types of the Lattices are not Bool it will throw an exception.

Similarly, the class LELUnaryBool exists to handle unary logical operations such as

   c.copyData(!a)


next up previous
Next: Other Specializations Up: NOTE 216 - Lattice Expression Language Implementation Previous: Optimizations
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15