/usr/include/ossim/base/ossimRationalNumber.h is in libossim-dev 1.8.16-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | //*******************************************************************
//
// License: See top level LICENSE.txt file.
//
// Author: Garrett Potts (gpotts@imagelinks.com)
//
//*******************************************************************
// $Id: ossimRationalNumber.h 9968 2006-11-29 14:01:53Z gpotts $
#ifndef ossimRationalNumber_HEADER
#define ossimRationalNumber_HEADER
#include <ossim/base/ossimCommon.h>
#include <ossim/base/ossimConstants.h>
#include <iostream>
class OSSIMDLLEXPORT ossimRationalNumber
{
public:
friend std::ostream& operator<<(std::ostream& out, const ossimRationalNumber& rhs)
{
out<<rhs.theNum << "/" << rhs.theDen;
return out;
}
ossimRationalNumber()
:theNum(1),
theDen(1)
{
}
ossimRationalNumber(ossim_int32 num,
ossim_int32 den)
:theNum(num),
theDen(den)
{
}
ossimRationalNumber(ossim_int32 num)
:theNum(num),
theDen(1)
{}
double toDouble()const
{
return (static_cast<double>(theNum)/
static_cast<double>(theDen));
}
float toFloat()const
{
return (static_cast<float>(theNum)/
static_cast<float>(theDen));
}
void normalize();
const ossimRationalNumber& operator=(ossim_int32 n)
{
return assign(n, 1);
}
const ossimRationalNumber& operator=(double n)
{
return assign(n);
}
ossimRationalNumber operator-()const
{
return ossimRationalNumber(-theNum, theDen);
}
const ossimRationalNumber& operator+= (const ossimRationalNumber& r);
const ossimRationalNumber& operator-= (const ossimRationalNumber& r);
const ossimRationalNumber& operator*= (const ossimRationalNumber& r);
const ossimRationalNumber& operator/= (const ossimRationalNumber& r);
inline const ossimRationalNumber& operator+= (ossim_int32 i);
inline const ossimRationalNumber& operator-= (ossim_int32 i);
inline const ossimRationalNumber& operator*= (ossim_int32 i);
inline const ossimRationalNumber& operator/= (ossim_int32 i);
ossimRationalNumber operator+ (const ossimRationalNumber& r)const;
ossimRationalNumber operator- (const ossimRationalNumber& r)const;
ossimRationalNumber operator* (const ossimRationalNumber& r)const;
ossimRationalNumber operator/ (const ossimRationalNumber& r)const;
inline ossimRationalNumber operator+ (ossim_int32 i)const;
inline ossimRationalNumber operator- (ossim_int32 i)const;
inline ossimRationalNumber operator* (ossim_int32 i)const;
inline ossimRationalNumber operator/ (ossim_int32 i)const;
friend inline ossimRationalNumber operator+ (ossim_int32 i, ossimRationalNumber& r);
friend inline ossimRationalNumber operator- (ossim_int32 i, ossimRationalNumber& r);
friend inline ossimRationalNumber operator* (ossim_int32 i, ossimRationalNumber& r);
friend inline ossimRationalNumber operator/ (ossim_int32 i, ossimRationalNumber& r);
// Comparison operators
// inline bool operator< (const ossimRationalNumber& r) const;
inline bool operator== (const ossimRationalNumber& r) const;
inline bool operator== (ossim_int32 i) const;
// Increment and decrement
inline const ossimRationalNumber& operator++();
inline const ossimRationalNumber& operator--();
// Assign in place
inline const ossimRationalNumber& assign(ossim_int32 n, ossim_int32 d);
/*!
* default estimation is out to the 10000 place. Will set this
* rational to a value that is close to the passed in number.
*/
const ossimRationalNumber& assign(double value, long precision=10000);
/*!
* Holds the value of the numberator.
*/
ossim_int32 theNum;
/*!
* Holds the value of the denominator.
*/
ossim_int32 theDen;
};
inline const ossimRationalNumber& ossimRationalNumber::assign(ossim_int32 n, ossim_int32 d)
{
theNum = n;
theDen = d;
normalize();
return *this;
}
// Mixed-mode operators
inline ossimRationalNumber ossimRationalNumber::operator+(ossim_int32 i)const
{
return operator + (ossimRationalNumber(i));
}
inline ossimRationalNumber ossimRationalNumber::operator-(ossim_int32 i)const
{
return operator - (ossimRationalNumber(i));
}
inline ossimRationalNumber ossimRationalNumber::operator*(ossim_int32 i)const
{
return operator * (ossimRationalNumber(i));
}
inline ossimRationalNumber ossimRationalNumber::operator/(ossim_int32 i)const
{
return operator / (ossimRationalNumber(i));
}
inline ossimRationalNumber operator+ (ossim_int32 i, ossimRationalNumber& r)
{
return ossimRationalNumber(i)+r;
}
inline ossimRationalNumber operator- (ossim_int32 i, ossimRationalNumber& r)
{
return ossimRationalNumber(i)-r;
}
inline ossimRationalNumber operator* (ossim_int32 i, ossimRationalNumber& r)
{
return ossimRationalNumber(i)*r;
}
inline ossimRationalNumber operator/ (ossim_int32 i, ossimRationalNumber& r)
{
return ossimRationalNumber(i)/r;
}
inline const ossimRationalNumber& ossimRationalNumber::operator++()
{
theNum += theDen;
return *this;
}
inline const ossimRationalNumber& ossimRationalNumber::operator--()
{
theNum -= theDen;
return *this;
}
inline bool ossimRationalNumber::operator== (const ossimRationalNumber& r)const
{
return ((theNum == r.theNum) && (theDen == r.theDen));
}
inline bool ossimRationalNumber::operator== (ossim_int32 i) const
{
return ((theDen == ossim_int32(1)) && (theNum == i));
}
#endif
|