operator * Programmers Guide Contents | Index |  Search

Category:intervals,operator Component type:function
Prototype
template <class Tnum>
interval<Tnum> operator * (const interval<Tnum>& x, const interval<Tnum>& y) ;
Description
Multiplies two intervals, returning the product as an outward rounded interval. Uses the algorithm from Moore's book "Methods and Applications of Interval analysis" p12. ``` x = [a,b], y = [c,d] x*y= [ac,bd] if a >= 0 and c >= 0 [bc,bd] if a >= 0 and c < 0 *lt; d [bc,ad] if a >= 0 and d <= 0 [ad,bc] if a < 0 < b and c >= 0 [bd,ad] if a < 0 < b and d<= 0 [ad,bc] if b <= 0 and c >= 0 [ad,ac] if b <= 0 and c < 0 < d [bd,ac] if b <= 0 and d <= 0 [min(bc,ad),max(ac,bd)] if a < 0 < b and c < 0 < d ``` Returns a proper interval in all cases.
Definition
interval.cct
Preconditions
Complexity
Example
In operator.cc:
```  C=A+B;
cout << "A+B = \n" << C << endl;
C-=B;
cout << "A+B-B = \n" << C << endl;
C/=A;
cout << "(A+B-B)/A = \n" << C << endl;
C*=B;
cout << "((A+B-B)/A)*B = \n" << C << endl;
C*=Num(5);
cout << "(((A+B-B)/A)*B)*5.0 = \n" << C << endl;
C+=Num(2);
cout << "((((A+B-B)/A)*B)*5.0)+2.0 = \n" << C << endl;
C-=A;
cout << "(((((A+B-B)/A)*B)*5.0)+2.0)-A = \n" << C << endl;

```
Notes
See also