summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/fixed.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/fixed.h b/noncore/unsupported/qpdf/fixed.h
index e42aea0..d073421 100644
--- a/noncore/unsupported/qpdf/fixed.h
+++ b/noncore/unsupported/qpdf/fixed.h
@@ -119,71 +119,73 @@ private:
119 friend bool operator <= <> ( int i, const fixed &f ); 119 friend bool operator <= <> ( int i, const fixed &f );
120 friend bool operator >= <> ( int i, const fixed &f ); 120 friend bool operator >= <> ( int i, const fixed &f );
121 friend bool operator == <> ( int i, const fixed &f ); 121 friend bool operator == <> ( int i, const fixed &f );
122 friend bool operator != <> ( int i, const fixed &f ); 122 friend bool operator != <> ( int i, const fixed &f );
123 123
124 friend long int lrint ( const fixed &f ); 124 friend long int lrint ( const fixed &f );
125 friend fixed sqrt ( const fixed &f ); 125 friend fixed sqrt ( const fixed &f );
126 friend fixed fabs ( const fixed &f ); 126 friend fixed fabs ( const fixed &f );
127#endif 127#endif
128}; 128};
129 129
130 130
131template <unsigned int SH> inline fixed<SH> operator + ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f( i ) + f. m_f, true ); } 131template <unsigned int SH> inline fixed<SH> operator + ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f( i ) + f. m_f, true ); }
132template <unsigned int SH> inline fixed<SH> operator - ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f( i ) - f. m_f, true ); } 132template <unsigned int SH> inline fixed<SH> operator - ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f( i ) - f. m_f, true ); }
133template <unsigned int SH> inline fixed<SH> operator * ( int i, const fixed<SH> &f ) { return fixed<SH> ( i * f. m_f, true ); } 133template <unsigned int SH> inline fixed<SH> operator * ( int i, const fixed<SH> &f ) { return fixed<SH> ( i * f. m_f, true ); }
134template <unsigned int SH> inline fixed<SH> operator / ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::div ( fixed<SH>::i2f( i ), f. m_f ), true ); } 134template <unsigned int SH> inline fixed<SH> operator / ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::div ( fixed<SH>::i2f( i ), f. m_f ), true ); }
135//template <unsigned int SH> inline fixed<SH> operator / ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f ( i / fixed<SH>::f2i ( f. m_f )), true ); } 135//template <unsigned int SH> inline fixed<SH> operator / ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f ( i / fixed<SH>::f2i ( f. m_f )), true ); }
136 136
137template <unsigned int SH> inline fixed<SH> operator + ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::d2f( d ) + f. m_f, true ); } 137template <unsigned int SH> inline fixed<SH> operator + ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::d2f( d ) + f. m_f, true ); }
138template <unsigned int SH> inline fixed<SH> operator - ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::d2f( d ) - f. m_f, true ); } 138template <unsigned int SH> inline fixed<SH> operator - ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::d2f( d ) - f. m_f, true ); }
139template <unsigned int SH> inline fixed<SH> operator * ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::mul ( fixed<SH>::d2f( d ), f. m_f ), true ); } 139template <unsigned int SH> inline fixed<SH> operator * ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::mul ( fixed<SH>::d2f( d ), f. m_f ), true ); }
140template <unsigned int SH> inline fixed<SH> operator / ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::mul ( fixed<SH>::d2f( d ), f. m_f ), true ); } 140template <unsigned int SH> inline fixed<SH> operator / ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::mul ( fixed<SH>::d2f( d ), f. m_f ), true ); }
141 141
142template <unsigned int SH> inline bool operator < ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) < f. m_f; } 142template <unsigned int SH> inline bool operator < ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) < f. m_f; }
143template <unsigned int SH> inline bool operator > ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) > f. m_f; } 143template <unsigned int SH> inline bool operator > ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) > f. m_f; }
144template <unsigned int SH> inline bool operator <= ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) <= f. m_f; } 144template <unsigned int SH> inline bool operator <= ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) <= f. m_f; }
145template <unsigned int SH> inline bool operator >= ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) >= f. m_f; } 145template <unsigned int SH> inline bool operator >= ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) >= f. m_f; }
146template <unsigned int SH> inline bool operator == ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) == f. m_f; } 146template <unsigned int SH> inline bool operator == ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) == f. m_f; }
147template <unsigned int SH> inline bool operator != ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) != f. m_f; } 147template <unsigned int SH> inline bool operator != ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) != f. m_f; }
148 148
149template <unsigned int SH> inline bool operator < ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) < f. m_f; } 149template <unsigned int SH> inline bool operator < ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) < f. m_f; }
150template <unsigned int SH> inline bool operator > ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) > f. m_f; } 150template <unsigned int SH> inline bool operator > ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) > f. m_f; }
151template <unsigned int SH> inline bool operator <= ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) <= f. m_f; } 151template <unsigned int SH> inline bool operator <= ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) <= f. m_f; }
152template <unsigned int SH> inline bool operator >= ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) >= f. m_f; } 152template <unsigned int SH> inline bool operator >= ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) >= f. m_f; }
153template <unsigned int SH> inline bool operator == ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) == f. m_f; } 153template <unsigned int SH> inline bool operator == ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) == f. m_f; }
154template <unsigned int SH> inline bool operator != ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) != f. m_f; } 154template <unsigned int SH> inline bool operator != ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) != f. m_f; }
155 155
156template <unsigned int SH> inline long int lrint ( const fixed<SH> &f ) 156template <unsigned int SH> inline long int lrint ( const fixed<SH> &f )
157{ 157{
158 return fixed<SH>::f2i (( f. m_f < 0 ) ? f. m_f - ( 1 << ( SH - 1 )) : f. m_f + ( 1 << ( SH - 1 ))); 158 return fixed<SH>::f2i (( f. m_f < 0 ) ? f. m_f - ( 1 << ( SH - 1 )) : f. m_f + ( 1 << ( SH - 1 )));
159} 159}
160 160
161template <unsigned int SH> inline fixed<SH> fabs ( const fixed<SH> &f ) 161template <unsigned int SH> inline fixed<SH> fabs ( const fixed<SH> &f )
162{ 162{
163 return ( f. m_f < 0 ) ? fixed<SH> ( -f. m_f, true ) : f; 163 return ( f. m_f < 0 ) ? fixed<SH> ( -f. m_f, true ) : f;
164} 164}
165 165
166// roughly from QPE / qmath.h 166// roughly from QPE / qmath.h
167template <unsigned int SH> inline fixed<SH> sqrt ( const fixed<SH> &f ) 167template <unsigned int SH> inline fixed<SH> sqrt ( const fixed<SH> &f )
168{ 168{
169 if ( f. m_f <= 0 ) 169 if ( f. m_f <= 0 )
170 return fixed<SH> ( 0, true ); 170 return fixed<SH> ( 0, true );
171 171
172 fixed<SH>::fix_t a0 = 0; 172 fixed<SH>::fix_t a0 = 0;
173 fixed<SH>::fix_t a1 = f. m_f; // take value as first approximation 173 fixed<SH>::fix_t a1 = f. m_f; // take value as first approximation
174 174
175 do { 175 do {
176 a0 = a1; 176 a0 = a1;
177 a1 = ( a0 + fixed<SH>::div ( f. m_f, a0 )) >> 1; 177 a1 = ( a0 + fixed<SH>::div ( f. m_f, a0 )) >> 1;
178 } while ( abs ( fixed<SH>::div ( a1 - a0, a1 )) > 1 ); 178 } while ( abs ( fixed<SH>::div ( a1 - a0, a1 )) > 1 );
179 179
180 return fixed<SH> ( a1, true ); 180 return fixed<SH> ( a1, true );
181} 181}
182 182
183#if 0 // no std::ostream needed in OPIE
183template <unsigned int SH> inline std::ostream &operator << ( std::ostream &o, const fixed<SH> &f ) 184template <unsigned int SH> inline std::ostream &operator << ( std::ostream &o, const fixed<SH> &f )
184{ 185{
185 o << double( f ); 186 o << double( f );
186 return o; 187 return o;
187} 188}
189#endif
188 190
189#endif 191#endif