SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Private Attributes | Friends | List of all members
Fixed< IntType, IntBits > Class Template Reference

#include <fixed.h>

+ Collaboration diagram for Fixed< IntType, IntBits >:

Classes

struct  internal
 

Public Member Functions

 Fixed ()
 
 Fixed (internal, IntType nVal)
 
 Fixed (int64_t nVal)
 
 Fixed (int nVal)
 
 Fixed (short nVal)
 
 Fixed (uint64_t nVal)
 
 Fixed (unsigned int nVal)
 
 Fixed (unsigned short nVal)
 
 Fixed (double nVal)
 
 Fixed (float nVal)
 
template<typename T >
Fixedoperator= (T other)
 
Fixedoperator= (Fixed const &other)
 
 operator bool () const
 
 operator double () const
 
IntType as_internal () const
 
float as_float () const
 
double as_double () const
 
int64_t as_long () const
 
int64_t as_int64 () const
 
int as_int () const
 
uint64_t as_unsigned_long () const
 
uint64_t as_unsigned_int64 () const
 
unsigned int as_unsigned_int () const
 
short as_short () const
 
unsigned short as_unsigned_short () const
 
Fixed operator++ ()
 
Fixed operator-- ()
 
Fixed floor () const
 
Fixed ceil () const
 
Fixed sqrt () const
 
Fixed exp () const
 
Fixed log () const
 
Fixedoperator%= (Fixed const &other)
 
Fixedoperator*= (Fixed const &val)
 
Fixedoperator/= (Fixed const &val)
 
Fixedoperator-= (Fixed const &val)
 
Fixedoperator+= (Fixed const &val)
 
Fixedoperator*= (double val)
 
Fixedoperator*= (float val)
 
Fixedoperator*= (int64_t val)
 
Fixedoperator*= (int val)
 
Fixedoperator*= (short val)
 
Fixedoperator*= (char val)
 
Fixedoperator*= (uint64_t val)
 
Fixedoperator*= (unsigned int val)
 
Fixedoperator*= (unsigned short val)
 
Fixedoperator*= (unsigned char val)
 
Fixedoperator/= (double val)
 
Fixedoperator/= (float val)
 
Fixedoperator/= (int64_t val)
 
Fixedoperator/= (int val)
 
Fixedoperator/= (short val)
 
Fixedoperator/= (char val)
 
Fixedoperator/= (uint64_t val)
 
Fixedoperator/= (unsigned int val)
 
Fixedoperator/= (unsigned short val)
 
Fixedoperator/= (unsigned char val)
 
bool operator! () const
 
Fixed modf (Fixed *integral_part) const
 
Fixed atan () const
 
Fixed sin () const
 
Fixed cos () const
 
Fixed tan () const
 
Fixed operator- () const
 
Fixed abs () const
 

Static Public Member Functions

static void sin_cos (Fixed const &theta, Fixed *s, Fixed *c)
 
static void to_polar (Fixed const &x, Fixed const &y, Fixed *r, Fixed *theta)
 

Static Public Attributes

static const Fixed fixed_max
 
static const Fixed fixed_one
 
static const Fixed fixed_zero
 
static const Fixed fixed_half
 
static const Fixed fixed_pi
 
static const Fixed fixed_two_pi
 
static const Fixed fixed_half_pi
 
static const Fixed fixed_quarter_pi
 

Static Private Member Functions

static int64_t scale_cordic_result (int64_t a)
 
static int64_t right_shift (int64_t val, int shift)
 
static void perform_cordic_rotation (int64_t &px, int64_t &py, int64_t theta)
 
static void perform_cordic_polarization (int64_t &argx, int64_t &argy)
 

Private Attributes

IntType m_nVal
 

Friends

bool operator== (Fixed const &lhs, Fixed const &rhs)
 
bool operator!= (Fixed const &lhs, Fixed const &rhs)
 
bool operator< (Fixed const &lhs, Fixed const &rhs)
 
bool operator> (Fixed const &lhs, Fixed const &rhs)
 
bool operator<= (Fixed const &lhs, Fixed const &rhs)
 
bool operator>= (Fixed const &lhs, Fixed const &rhs)
 

Detailed Description

template<typename IntType, uint32_t IntBits>
class Fixed< IntType, IntBits >

Definition at line 42 of file fixed.h.

Constructor & Destructor Documentation

◆ Fixed() [1/10]

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::Fixed ( )
inline

Definition at line 65 of file fixed.h.

Referenced by Fixed< IntType, IntBits >::operator*=(), Fixed< IntType, IntBits >::operator-(), Fixed< IntType, IntBits >::operator/=(), and Fixed< IntType, IntBits >::operator=().

65  :
66  m_nVal(0)
67  {}
IntType m_nVal
Definition: fixed.h:45
+ Here is the caller graph for this function:

◆ Fixed() [2/10]

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::Fixed ( internal  ,
IntType  nVal 
)
inline

Definition at line 69 of file fixed.h.

69  :
70  m_nVal(nVal)
71  {}
IntType m_nVal
Definition: fixed.h:45

◆ Fixed() [3/10]

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::Fixed ( int64_t  nVal)
inline

Definition at line 72 of file fixed.h.

72  :
74  {}
IntType m_nVal
Definition: fixed.h:45

◆ Fixed() [4/10]

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::Fixed ( int  nVal)
inline

Definition at line 76 of file fixed.h.

76  :
78  {}
__int64 int64_t
Definition: rtptypes_win.h:47
IntType m_nVal
Definition: fixed.h:45

◆ Fixed() [5/10]

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::Fixed ( short  nVal)
inline

Definition at line 80 of file fixed.h.

80  :
82  {}
__int64 int64_t
Definition: rtptypes_win.h:47
IntType m_nVal
Definition: fixed.h:45

◆ Fixed() [6/10]

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::Fixed ( uint64_t  nVal)
inline

Definition at line 84 of file fixed.h.

84  :
86  {}
IntType m_nVal
Definition: fixed.h:45

◆ Fixed() [7/10]

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::Fixed ( unsigned int  nVal)
inline

Definition at line 88 of file fixed.h.

88  :
90  {}
__int64 int64_t
Definition: rtptypes_win.h:47
IntType m_nVal
Definition: fixed.h:45

◆ Fixed() [8/10]

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::Fixed ( unsigned short  nVal)
inline

Definition at line 91 of file fixed.h.

91  :
93  {}
__int64 int64_t
Definition: rtptypes_win.h:47
IntType m_nVal
Definition: fixed.h:45

◆ Fixed() [9/10]

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::Fixed ( double  nVal)
inline

Definition at line 94 of file fixed.h.

94  :
95  m_nVal(static_cast<int64_t>(nVal*static_cast<double>(FixedTraits<IntBits>::fixed_resolution)))
96  {}
IntType m_nVal
Definition: fixed.h:45

◆ Fixed() [10/10]

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::Fixed ( float  nVal)
inline

Definition at line 97 of file fixed.h.

97  :
98  m_nVal(static_cast<int64_t>(nVal*static_cast<float>(FixedTraits<IntBits>::fixed_resolution)))
99  {}
IntType m_nVal
Definition: fixed.h:45

Member Function Documentation

◆ abs()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::abs ( ) const
inline

Definition at line 2383 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal.

Referenced by abs(), and Fixed< IntType, IntBits >::operator!().

2384 {
2386 }
Definition: fixed.h:42
IntType m_nVal
Definition: fixed.h:45
+ Here is the caller graph for this function:

◆ as_double()

template<typename IntType, uint32_t IntBits>
double Fixed< IntType, IntBits >::as_double ( ) const
inline

Definition at line 164 of file fixed.h.

Referenced by Fixed< IntType, IntBits >::operator double().

165  {
167  }
IntType m_nVal
Definition: fixed.h:45
+ Here is the caller graph for this function:

◆ as_float()

template<typename IntType, uint32_t IntBits>
float Fixed< IntType, IntBits >::as_float ( ) const
inline

Definition at line 159 of file fixed.h.

160  {
162  }
IntType m_nVal
Definition: fixed.h:45

◆ as_int()

template<typename IntType, uint32_t IntBits>
int Fixed< IntType, IntBits >::as_int ( ) const
inline

Definition at line 178 of file fixed.h.

179  {
181  }
IntType m_nVal
Definition: fixed.h:45

◆ as_int64()

template<typename IntType, uint32_t IntBits>
int64_t Fixed< IntType, IntBits >::as_int64 ( ) const
inline

Definition at line 173 of file fixed.h.

174  {
176  }
IntType m_nVal
Definition: fixed.h:45

◆ as_internal()

template<typename IntType, uint32_t IntBits>
IntType Fixed< IntType, IntBits >::as_internal ( ) const
inline

Definition at line 154 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal.

Referenced by DSPDeviceSourceEngine::iqCorrections(), and DSPDeviceMIMOEngine::iqCorrections().

155  {
156  return m_nVal;
157  }
IntType m_nVal
Definition: fixed.h:45
+ Here is the caller graph for this function:

◆ as_long()

template<typename IntType, uint32_t IntBits>
int64_t Fixed< IntType, IntBits >::as_long ( ) const
inline

Definition at line 169 of file fixed.h.

170  {
172  }
__int64 int64_t
Definition: rtptypes_win.h:47
IntType m_nVal
Definition: fixed.h:45

◆ as_short()

template<typename IntType, uint32_t IntBits>
short Fixed< IntType, IntBits >::as_short ( ) const
inline

Definition at line 197 of file fixed.h.

198  {
200  }
IntType m_nVal
Definition: fixed.h:45

◆ as_unsigned_int()

template<typename IntType, uint32_t IntBits>
unsigned int Fixed< IntType, IntBits >::as_unsigned_int ( ) const
inline

Definition at line 192 of file fixed.h.

193  {
194  return (unsigned int) (m_nVal / FixedTraits<IntBits>::fixed_resolution);
195  }
IntType m_nVal
Definition: fixed.h:45

◆ as_unsigned_int64()

template<typename IntType, uint32_t IntBits>
uint64_t Fixed< IntType, IntBits >::as_unsigned_int64 ( ) const
inline

Definition at line 187 of file fixed.h.

188  {
190  }
IntType m_nVal
Definition: fixed.h:45
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48

◆ as_unsigned_long()

template<typename IntType, uint32_t IntBits>
uint64_t Fixed< IntType, IntBits >::as_unsigned_long ( ) const
inline

Definition at line 183 of file fixed.h.

184  {
186  }
IntType m_nVal
Definition: fixed.h:45
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48

◆ as_unsigned_short()

template<typename IntType, uint32_t IntBits>
unsigned short Fixed< IntType, IntBits >::as_unsigned_short ( ) const
inline

Definition at line 202 of file fixed.h.

203  {
204  return (unsigned short) (m_nVal / FixedTraits<IntBits>::fixed_resolution);
205  }
IntType m_nVal
Definition: fixed.h:45

◆ atan()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::atan ( ) const

Definition at line 763 of file fixed.h.

References Fixed< IntType, IntBits >::to_polar().

Referenced by Fixed< IntType, IntBits >::operator!().

764 {
765  Fixed<IntType, IntBits> r, theta;
766  to_polar(1, *this, &r, &theta);
767  return theta;
768 }
static void to_polar(Fixed const &x, Fixed const &y, Fixed *r, Fixed *theta)
Definition: fixed.h:771
Definition: fixed.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ceil()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::ceil ( ) const
inline

Definition at line 2325 of file fixed.h.

References Fixed< IntType, IntBits >::floor(), and Fixed< IntType, IntBits >::m_nVal.

Referenced by ceil(), and Fixed< IntType, IntBits >::operator--().

2326 {
2328  return floor()+1;
2329  } else {
2330  return *this;
2331  }
2332 }
Fixed floor() const
Definition: fixed.h:2335
IntType m_nVal
Definition: fixed.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cos()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::cos ( ) const
inline

Definition at line 2361 of file fixed.h.

References Fixed< IntType, IntBits >::sin_cos().

Referenced by cos(), and Fixed< IntType, IntBits >::operator!().

2362 {
2363  Fixed res;
2364  sin_cos(*this, 0, &res);
2365  return res;
2366 }
static void sin_cos(Fixed const &theta, Fixed *s, Fixed *c)
Definition: fixed.h:726
Definition: fixed.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exp()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::exp ( ) const

Definition at line 532 of file fixed.h.

References Fixed< IntType, IntBits >::fixed_max, and Fixed< IntType, IntBits >::m_nVal.

Referenced by exp(), and Fixed< IntType, IntBits >::operator--().

533 {
535  {
536  return fixed_max;
537  }
538 
540  {
541  return Fixed<IntType, IntBits>(internal(), 0);
542  }
543 
544  if (!m_nVal)
545  {
547  }
548 
550 
551  if (m_nVal > 0)
552  {
555  int64_t temp=m_nVal;
556 
557  while (temp && power>(-(int)FixedTraits<IntBits>::fixed_resolution_shift))
558  {
559  while (!power || (temp<*log_entry))
560  {
561  if (!power) {
563  } else {
564  ++log_entry;
565  }
566 
567  --power;
568  }
569 
570  temp -= *log_entry;
571 
572  if (power < 0) {
573  res += (res >> (-power));
574  } else {
575  res <<= power;
576  }
577  }
578  }
579  else
580  {
581  int power = FixedTraits<IntBits>::fixed_resolution_shift;
583  int64_t temp=m_nVal;
584 
585  while (temp && (power > (-(int) FixedTraits<IntBits>::fixed_resolution_shift)))
586  {
587  while (!power || (temp > (-*log_entry)))
588  {
589  if(!power) {
591  } else {
592  ++log_entry;
593  }
594 
595  --power;
596  }
597 
598  temp += *log_entry;
599 
600  if (power <0 ) {
601  res -= (res >> (-power));
602  } else {
603  res >>= power;
604  }
605  }
606  }
607 
609 }
static const Fixed fixed_max
Definition: fixed.h:53
__int64 int64_t
Definition: rtptypes_win.h:47
Definition: fixed.h:42
IntType m_nVal
Definition: fixed.h:45
+ Here is the caller graph for this function:

◆ floor()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::floor ( ) const
inline

Definition at line 2335 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal.

Referenced by Fixed< IntType, IntBits >::ceil(), floor(), and Fixed< IntType, IntBits >::operator--().

2336 {
2337  Fixed res(*this);
2339 
2340  if (remainder)
2341  {
2342  res.m_nVal -= remainder;
2343 
2344  if(m_nVal<0) {
2345  res-=1;
2346  }
2347  }
2348 
2349  return res;
2350 }
__int64 int64_t
Definition: rtptypes_win.h:47
Definition: fixed.h:42
IntType m_nVal
Definition: fixed.h:45
+ Here is the caller graph for this function:

◆ log()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::log ( ) const

Definition at line 612 of file fixed.h.

References Fixed< IntType, IntBits >::fixed_max, Fixed< IntType, IntBits >::fixed_zero, Fixed< IntType, IntBits >::m_nVal, and Fixed< IntType, IntBits >::right_shift().

Referenced by log(), and Fixed< IntType, IntBits >::operator--().

613 {
614  if ( m_nVal <= 0) {
615  return -fixed_max;
616  }
617 
619  return fixed_zero;
620  }
621 
622  uint64_t temp = m_nVal;
623  int left_shift = 0;
624  uint64_t const scale_position = 0x8000000000000000ULL;
625 
626  while (temp < scale_position)
627  {
628  ++left_shift;
629  temp <<= 1;
630  }
631 
632  int64_t res = (left_shift < FixedTraits<IntBits>::max_power) ?
635  unsigned int right_shift = 1;
636  uint64_t shifted_temp = temp >> 1;
637 
638  while (temp && (right_shift < FixedTraits<IntBits>::fixed_resolution_shift))
639  {
640  while ((right_shift < FixedTraits<IntBits>::fixed_resolution_shift) && (temp < (shifted_temp + scale_position)))
641  {
642  shifted_temp >>= 1;
643  ++right_shift;
644  }
645 
646  temp -= shifted_temp;
647  shifted_temp = temp >> right_shift;
649  }
650 
652 }
static const Fixed fixed_max
Definition: fixed.h:53
__int64 int64_t
Definition: rtptypes_win.h:47
Definition: fixed.h:42
static int64_t right_shift(int64_t val, int shift)
Definition: fixed.h:662
IntType m_nVal
Definition: fixed.h:45
static const Fixed fixed_zero
Definition: fixed.h:55
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ modf()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::modf ( Fixed< IntType, IntBits > *  integral_part) const
inline

Definition at line 2389 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal.

Referenced by modf(), and Fixed< IntType, IntBits >::operator!().

2390 {
2392  if ((m_nVal < 0) && (fractional_part > 0)) {
2393  fractional_part -= FixedTraits<IntBits>::fixed_resolution;
2394  }
2395 
2396  integral_part->m_nVal = m_nVal - fractional_part;
2398 }
__int64 int64_t
Definition: rtptypes_win.h:47
Definition: fixed.h:42
IntType m_nVal
Definition: fixed.h:45
+ Here is the caller graph for this function:

◆ operator bool()

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::operator bool ( ) const
inline

Definition at line 144 of file fixed.h.

145  {
146  return m_nVal ? true : false;
147  }
IntType m_nVal
Definition: fixed.h:45

◆ operator double()

template<typename IntType, uint32_t IntBits>
Fixed< IntType, IntBits >::operator double ( ) const
inline

Definition at line 149 of file fixed.h.

References Fixed< IntType, IntBits >::as_double().

150  {
151  return as_double();
152  }
double as_double() const
Definition: fixed.h:164
+ Here is the call graph for this function:

◆ operator!()

template<typename IntType, uint32_t IntBits>
bool Fixed< IntType, IntBits >::operator! ( ) const
inline

◆ operator%=()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > & Fixed< IntType, IntBits >::operator%= ( Fixed< IntType, IntBits > const &  other)

Definition at line 382 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal.

Referenced by Fixed< IntType, IntBits >::operator--().

383 {
384  m_nVal = m_nVal%other.m_nVal;
385  return *this;
386 }
IntType m_nVal
Definition: fixed.h:45
+ Here is the caller graph for this function:

◆ operator*=() [1/11]

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > & Fixed< IntType, IntBits >::operator*= ( Fixed< IntType, IntBits > const &  val)

Definition at line 389 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal.

Referenced by Fixed< IntType, IntBits >::operator--().

390 {
391  bool const val_negative = val.m_nVal < 0;
392  bool const this_negative = m_nVal < 0;
393  bool const negate = val_negative ^ this_negative;
394  uint64_t const other = val_negative ? -val.m_nVal : val.m_nVal;
395  uint64_t const self = this_negative ? -m_nVal : m_nVal;
396 
397  if (uint64_t const self_upper = (self >> 32)) {
398  m_nVal = (self_upper*other) << (32 - FixedTraits<IntBits>::fixed_resolution_shift);
399  } else {
400  m_nVal = 0;
401  }
402 
403  if (uint64_t const self_lower = (self&0xffffffff))
404  {
405  uint64_t const other_upper = static_cast<uint64_t>(other >> 32);
406  uint64_t const other_lower = static_cast<uint64_t>(other & 0xffffffff);
407  uint64_t const lower_self_upper_other_res = self_lower*other_upper;
408  uint64_t const lower_self_lower_other_res = self_lower*other_lower;
409  m_nVal += (lower_self_upper_other_res << (32 - FixedTraits<IntBits>::fixed_resolution_shift))
410  + (lower_self_lower_other_res >> FixedTraits<IntBits>::fixed_resolution_shift);
411  }
412 
413  if (negate) {
414  m_nVal=-m_nVal;
415  }
416 
417  return *this;
418 }
IntType m_nVal
Definition: fixed.h:45
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
+ Here is the caller graph for this function:

◆ operator*=() [2/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator*= ( double  val)
inline

Definition at line 240 of file fixed.h.

References Fixed< IntType, IntBits >::Fixed().

241  {
242  return (*this) *= Fixed(val);
243  }
Fixed()
Definition: fixed.h:65
+ Here is the call graph for this function:

◆ operator*=() [3/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator*= ( float  val)
inline

Definition at line 245 of file fixed.h.

References Fixed< IntType, IntBits >::Fixed().

246  {
247  return (*this) *= Fixed(val);
248  }
Fixed()
Definition: fixed.h:65
+ Here is the call graph for this function:

◆ operator*=() [4/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator*= ( int64_t  val)
inline

Definition at line 250 of file fixed.h.

251  {
252  m_nVal *= val;
253  return *this;
254  }
IntType m_nVal
Definition: fixed.h:45

◆ operator*=() [5/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator*= ( int  val)
inline

Definition at line 256 of file fixed.h.

257  {
258  m_nVal *= val;
259  return *this;
260  }
IntType m_nVal
Definition: fixed.h:45

◆ operator*=() [6/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator*= ( short  val)
inline

Definition at line 262 of file fixed.h.

263  {
264  m_nVal *= val;
265  return *this;
266  }
IntType m_nVal
Definition: fixed.h:45

◆ operator*=() [7/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator*= ( char  val)
inline

Definition at line 268 of file fixed.h.

269  {
270  m_nVal *= val;
271  return *this;
272  }
IntType m_nVal
Definition: fixed.h:45

◆ operator*=() [8/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator*= ( uint64_t  val)
inline

Definition at line 274 of file fixed.h.

275  {
276  m_nVal *= val;
277  return *this;
278  }
IntType m_nVal
Definition: fixed.h:45

◆ operator*=() [9/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator*= ( unsigned int  val)
inline

Definition at line 280 of file fixed.h.

281  {
282  m_nVal *= val;
283  return *this;
284  }
IntType m_nVal
Definition: fixed.h:45

◆ operator*=() [10/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator*= ( unsigned short  val)
inline

Definition at line 286 of file fixed.h.

287  {
288  m_nVal *= val;
289  return *this;
290  }
IntType m_nVal
Definition: fixed.h:45

◆ operator*=() [11/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator*= ( unsigned char  val)
inline

Definition at line 292 of file fixed.h.

293  {
294  m_nVal *= val;
295  return *this;
296  }
IntType m_nVal
Definition: fixed.h:45

◆ operator++()

template<typename IntType, uint32_t IntBits>
Fixed Fixed< IntType, IntBits >::operator++ ( )
inline

Definition at line 207 of file fixed.h.

208  {
210  return *this;
211  }
IntType m_nVal
Definition: fixed.h:45

◆ operator+=()

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator+= ( Fixed< IntType, IntBits > const &  val)
inline

Definition at line 234 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal.

235  {
236  m_nVal += val.m_nVal;
237  return *this;
238  }
IntType m_nVal
Definition: fixed.h:45

◆ operator-()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::operator- ( ) const
inline

Definition at line 2377 of file fixed.h.

References Fixed< IntType, IntBits >::Fixed(), and Fixed< IntType, IntBits >::m_nVal.

Referenced by Fixed< IntType, IntBits >::operator!().

2378 {
2379  return Fixed(internal(), -m_nVal);
2380 }
Fixed()
Definition: fixed.h:65
IntType m_nVal
Definition: fixed.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator--()

template<typename IntType, uint32_t IntBits>
Fixed Fixed< IntType, IntBits >::operator-- ( )
inline

◆ operator-=()

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator-= ( Fixed< IntType, IntBits > const &  val)
inline

Definition at line 228 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal.

229  {
230  m_nVal -= val.m_nVal;
231  return *this;
232  }
IntType m_nVal
Definition: fixed.h:45

◆ operator/=() [1/11]

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > & Fixed< IntType, IntBits >::operator/= ( Fixed< IntType, IntBits > const &  val)

Definition at line 421 of file fixed.h.

References Fixed< IntType, IntBits >::fixed_max, Fixed< IntType, IntBits >::m_nVal, and Fixed< IntType, IntBits >::right_shift().

Referenced by Fixed< IntType, IntBits >::operator--().

422 {
423  if( !divisor.m_nVal)
424  {
426  }
427  else
428  {
429  bool const negate_this = (m_nVal < 0);
430  bool const negate_divisor = (divisor.m_nVal < 0);
431  bool const negate = negate_this ^ negate_divisor;
432  uint64_t a = negate_this ? -m_nVal : m_nVal;
433  uint64_t b = negate_divisor ? -divisor.m_nVal : divisor.m_nVal;
434 
435  uint64_t res = 0;
436 
437  uint64_t temp = b;
438  bool const a_large = a > b;
440 
441  if(a_large)
442  {
443  uint64_t const half_a = a>>1;
444 
445  while (temp < half_a)
446  {
447  temp <<= 1;
448  ++shift;
449  }
450  }
451 
452  uint64_t d = 1LL << shift;
453 
454  if (a_large)
455  {
456  a -= temp;
457  res += d;
458  }
459 
460  while (a && temp && shift)
461  {
462  unsigned right_shift = 0;
463 
464  while(right_shift < shift && (temp > a))
465  {
466  temp >>= 1;
467  ++right_shift;
468  }
469 
470  d >>= right_shift;
471  shift -= right_shift;
472  a -= temp;
473  res += d;
474  }
475 
476  m_nVal = (negate ? -(int64_t) res : res);
477  }
478 
479  return *this;
480 }
static const Fixed fixed_max
Definition: fixed.h:53
__int64 int64_t
Definition: rtptypes_win.h:47
static int64_t right_shift(int64_t val, int shift)
Definition: fixed.h:662
IntType m_nVal
Definition: fixed.h:45
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator/=() [2/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator/= ( double  val)
inline

Definition at line 298 of file fixed.h.

References Fixed< IntType, IntBits >::Fixed().

299  {
300  return (*this) /= Fixed(val);
301  }
Fixed()
Definition: fixed.h:65
+ Here is the call graph for this function:

◆ operator/=() [3/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator/= ( float  val)
inline

Definition at line 303 of file fixed.h.

References Fixed< IntType, IntBits >::Fixed().

304  {
305  return (*this) /= Fixed(val);
306  }
Fixed()
Definition: fixed.h:65
+ Here is the call graph for this function:

◆ operator/=() [4/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator/= ( int64_t  val)
inline

Definition at line 308 of file fixed.h.

309  {
310  m_nVal /= val;
311  return *this;
312  }
IntType m_nVal
Definition: fixed.h:45

◆ operator/=() [5/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator/= ( int  val)
inline

Definition at line 314 of file fixed.h.

315  {
316  m_nVal /= val;
317  return *this;
318  }
IntType m_nVal
Definition: fixed.h:45

◆ operator/=() [6/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator/= ( short  val)
inline

Definition at line 320 of file fixed.h.

321  {
322  m_nVal /= val;
323  return *this;
324  }
IntType m_nVal
Definition: fixed.h:45

◆ operator/=() [7/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator/= ( char  val)
inline

Definition at line 326 of file fixed.h.

327  {
328  m_nVal /= val;
329  return *this;
330  }
IntType m_nVal
Definition: fixed.h:45

◆ operator/=() [8/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator/= ( uint64_t  val)
inline

Definition at line 332 of file fixed.h.

333  {
334  m_nVal /= val;
335  return *this;
336  }
IntType m_nVal
Definition: fixed.h:45

◆ operator/=() [9/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator/= ( unsigned int  val)
inline

Definition at line 338 of file fixed.h.

339  {
340  m_nVal/=val;
341  return *this;
342  }
IntType m_nVal
Definition: fixed.h:45

◆ operator/=() [10/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator/= ( unsigned short  val)
inline

Definition at line 344 of file fixed.h.

345  {
346  m_nVal /= val;
347  return *this;
348  }
IntType m_nVal
Definition: fixed.h:45

◆ operator/=() [11/11]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator/= ( unsigned char  val)
inline

Definition at line 350 of file fixed.h.

351  {
352  m_nVal /= val;
353  return *this;
354  }
IntType m_nVal
Definition: fixed.h:45

◆ operator=() [1/2]

template<typename IntType, uint32_t IntBits>
template<typename T >
Fixed& Fixed< IntType, IntBits >::operator= ( other)
inline

Definition at line 102 of file fixed.h.

References Fixed< IntType, IntBits >::Fixed().

103  {
104  m_nVal = Fixed(other).m_nVal;
105  return *this;
106  }
Fixed()
Definition: fixed.h:65
IntType m_nVal
Definition: fixed.h:45
+ Here is the call graph for this function:

◆ operator=() [2/2]

template<typename IntType, uint32_t IntBits>
Fixed& Fixed< IntType, IntBits >::operator= ( Fixed< IntType, IntBits > const &  other)
inline

Definition at line 108 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal.

109  {
110  m_nVal = other.m_nVal;
111  return *this;
112  }
IntType m_nVal
Definition: fixed.h:45

◆ perform_cordic_polarization()

template<typename IntType , uint32_t IntBits>
void Fixed< IntType, IntBits >::perform_cordic_polarization ( int64_t argx,
int64_t argy 
)
staticprivate

Definition at line 696 of file fixed.h.

References i, Fixed< IntType, IntBits >::right_shift(), and Fixed< IntType, IntBits >::scale_cordic_result().

Referenced by Fixed< IntType, IntBits >::to_polar().

697 {
698  int64_t theta = 0;
699  int64_t x = argx, y = argy;
700  int64_t const *arctanptr = FixedTraits<IntBits>::arctantab;
701 
702  for (int i = -1; i <= (int) FixedTraits<IntBits>::fixed_resolution_shift; ++i)
703  {
704  int64_t const yshift = right_shift(y,i);
705  int64_t const xshift = right_shift(x,i);
706 
707  if(y < 0)
708  {
709  y += xshift;
710  x -= yshift;
711  theta -= *arctanptr++;
712  }
713  else
714  {
715  y -= xshift;
716  x += yshift;
717  theta += *arctanptr++;
718  }
719  }
720 
721  argx = scale_cordic_result(x);
722  argy = theta;
723 }
__int64 int64_t
Definition: rtptypes_win.h:47
int32_t i
Definition: decimators.h:244
static int64_t scale_cordic_result(int64_t a)
Definition: fixed.h:655
static int64_t right_shift(int64_t val, int shift)
Definition: fixed.h:662
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ perform_cordic_rotation()

template<typename IntType , uint32_t IntBits>
void Fixed< IntType, IntBits >::perform_cordic_rotation ( int64_t px,
int64_t py,
int64_t  theta 
)
staticprivate

Definition at line 668 of file fixed.h.

References i, Fixed< IntType, IntBits >::right_shift(), and Fixed< IntType, IntBits >::scale_cordic_result().

Referenced by Fixed< IntType, IntBits >::sin_cos().

669 {
670  int64_t x = px, y = py;
671  int64_t const *arctanptr = FixedTraits<IntBits>::arctantab;
672  for (int i = -1; i <= (int) FixedTraits<IntBits>::fixed_resolution_shift; ++i)
673  {
674  int64_t const yshift = right_shift(y,i);
675  int64_t const xshift = right_shift(x,i);
676 
677  if (theta < 0)
678  {
679  x += yshift;
680  y -= xshift;
681  theta += *arctanptr++;
682  }
683  else
684  {
685  x -= yshift;
686  y += xshift;
687  theta -= *arctanptr++;
688  }
689  }
690 
691  px = scale_cordic_result(x);
692  py = scale_cordic_result(y);
693 }
__int64 int64_t
Definition: rtptypes_win.h:47
int32_t i
Definition: decimators.h:244
static int64_t scale_cordic_result(int64_t a)
Definition: fixed.h:655
static int64_t right_shift(int64_t val, int shift)
Definition: fixed.h:662
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ right_shift()

template<typename IntType , uint32_t IntBits>
int64_t Fixed< IntType, IntBits >::right_shift ( int64_t  val,
int  shift 
)
staticprivate

Definition at line 662 of file fixed.h.

Referenced by Fixed< IntType, IntBits >::log(), Fixed< IntType, IntBits >::operator/=(), Fixed< IntType, IntBits >::perform_cordic_polarization(), Fixed< IntType, IntBits >::perform_cordic_rotation(), and Fixed< IntType, IntBits >::to_polar().

663 {
664  return (shift < 0) ? (val << -shift) : (val >> shift);
665 }
+ Here is the caller graph for this function:

◆ scale_cordic_result()

template<typename IntType , uint32_t IntBits>
int64_t Fixed< IntType, IntBits >::scale_cordic_result ( int64_t  a)
staticprivate

Definition at line 655 of file fixed.h.

Referenced by Fixed< IntType, IntBits >::perform_cordic_polarization(), and Fixed< IntType, IntBits >::perform_cordic_rotation().

656 {
657  int64_t const cordic_scale_factor = 0x22C2DD1C; /* 0.271572 * 2^31*/
658  return (int64_t)((((int64_t)a)*cordic_scale_factor) >> 31);
659 }
__int64 int64_t
Definition: rtptypes_win.h:47
+ Here is the caller graph for this function:

◆ sin()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::sin ( ) const
inline

Definition at line 2353 of file fixed.h.

References Fixed< IntType, IntBits >::sin_cos().

Referenced by Fixed< IntType, IntBits >::operator!(), and sin().

2354 {
2355  Fixed res;
2356  sin_cos(*this, &res, 0);
2357  return res;
2358 }
static void sin_cos(Fixed const &theta, Fixed *s, Fixed *c)
Definition: fixed.h:726
Definition: fixed.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sin_cos()

template<typename IntType , uint32_t IntBits>
void Fixed< IntType, IntBits >::sin_cos ( Fixed< IntType, IntBits > const &  theta,
Fixed< IntType, IntBits > *  s,
Fixed< IntType, IntBits > *  c 
)
static

Definition at line 726 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal, and Fixed< IntType, IntBits >::perform_cordic_rotation().

Referenced by Fixed< IntType, IntBits >::cos(), Fixed< IntType, IntBits >::operator!(), polar(), Fixed< IntType, IntBits >::sin(), and Fixed< IntType, IntBits >::tan().

727 {
729 
730  if (x < 0) {
732  }
733 
734  bool negate_cos = false;
735  bool negate_sin = false;
736 
738  {
740  negate_sin=true;
741  }
742 
744  {
746  negate_cos=true;
747  }
748 
750 
751  perform_cordic_rotation(x_cos, x_sin, (int64_t) x);
752 
753  if (s) {
754  s->m_nVal = negate_sin ? -x_sin : x_sin;
755  }
756 
757  if(c) {
758  c->m_nVal = negate_cos ? -x_cos : x_cos;
759  }
760 }
__int64 int64_t
Definition: rtptypes_win.h:47
static void perform_cordic_rotation(int64_t &px, int64_t &py, int64_t theta)
Definition: fixed.h:668
IntType m_nVal
Definition: fixed.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sqrt()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::sqrt ( ) const

Definition at line 483 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal.

Referenced by Fixed< IntType, IntBits >::operator--(), and sqrt().

484 {
485  unsigned int const max_shift = 62;
486  uint64_t a_squared = 1LL << max_shift;
487  unsigned int b_shift = (max_shift + FixedTraits<IntBits>::fixed_resolution_shift) / 2;
488  uint64_t a = 1LL << b_shift;
489 
490  uint64_t x = m_nVal;
491 
492  while (b_shift && (a_squared > x))
493  {
494  a >>= 1;
495  a_squared >>= 2;
496  --b_shift;
497  }
498 
499  uint64_t remainder = x - a_squared;
500  --b_shift;
501 
502  while (remainder && b_shift)
503  {
504  uint64_t b_squared = 1LL << (2*b_shift - FixedTraits<IntBits>::fixed_resolution_shift);
505  int const two_a_b_shift = b_shift + 1 - FixedTraits<IntBits>::fixed_resolution_shift;
506  uint64_t two_a_b = (two_a_b_shift > 0) ? (a << two_a_b_shift) : (a >> -two_a_b_shift);
507 
508  while (b_shift && (remainder < (b_squared+two_a_b)))
509  {
510  b_squared >>= 2;
511  two_a_b >>= 1;
512  --b_shift;
513  }
514 
515  uint64_t const delta = b_squared + two_a_b;
516 
517  if ((2*remainder) > delta)
518  {
519  a += (1LL << b_shift);
520  remainder -= delta;
521 
522  if (b_shift) {
523  --b_shift;
524  }
525  }
526  }
527 
529 }
Definition: fixed.h:42
IntType m_nVal
Definition: fixed.h:45
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
+ Here is the caller graph for this function:

◆ tan()

template<typename IntType , uint32_t IntBits>
Fixed< IntType, IntBits > Fixed< IntType, IntBits >::tan ( ) const
inline

Definition at line 2369 of file fixed.h.

References Fixed< IntType, IntBits >::sin_cos().

Referenced by Fixed< IntType, IntBits >::operator!(), and tan().

2370 {
2371  Fixed s, c;
2372  sin_cos(*this, &s, &c);
2373  return s/c;
2374 }
static void sin_cos(Fixed const &theta, Fixed *s, Fixed *c)
Definition: fixed.h:726
Definition: fixed.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ to_polar()

template<typename IntType , uint32_t IntBits>
void Fixed< IntType, IntBits >::to_polar ( Fixed< IntType, IntBits > const &  x,
Fixed< IntType, IntBits > const &  y,
Fixed< IntType, IntBits > *  r,
Fixed< IntType, IntBits > *  theta 
)
static

Definition at line 771 of file fixed.h.

References Fixed< IntType, IntBits >::m_nVal, Fixed< IntType, IntBits >::perform_cordic_polarization(), and Fixed< IntType, IntBits >::right_shift().

Referenced by arg(), Fixed< IntType, IntBits >::atan(), and Fixed< IntType, IntBits >::operator!().

772 {
773  bool const negative_x = x.m_nVal < 0;
774  bool const negative_y = y.m_nVal < 0;
775 
776  uint64_t a = negative_x ? -x.m_nVal : x.m_nVal;
777  uint64_t b = negative_y ? -y.m_nVal : y.m_nVal;
778 
779  unsigned int right_shift = 0;
780  unsigned const max_value = 1U << FixedTraits<IntBits>::fixed_resolution_shift;
781 
782  while ((a >= max_value) || (b >= max_value))
783  {
784  ++right_shift;
785  a >>= 1;
786  b >>= 1;
787  }
788 
789  int64_t xtemp = (int64_t) a;
790  int64_t ytemp = (int64_t) b;
791 
792  perform_cordic_polarization(xtemp, ytemp);
793 
794  r->m_nVal = int64_t(xtemp) << right_shift;
795  theta->m_nVal = ytemp;
796 
797  if (negative_x && negative_y) {
799  } else if (negative_x) {
801  }
802 
803  else if(negative_y) {
804  theta->m_nVal = -theta->m_nVal;
805  }
806 }
static void perform_cordic_polarization(int64_t &argx, int64_t &argy)
Definition: fixed.h:696
__int64 int64_t
Definition: rtptypes_win.h:47
static int64_t right_shift(int64_t val, int shift)
Definition: fixed.h:662
IntType m_nVal
Definition: fixed.h:45
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator!=

template<typename IntType, uint32_t IntBits>
bool operator!= ( Fixed< IntType, IntBits > const &  lhs,
Fixed< IntType, IntBits > const &  rhs 
)
friend

Definition at line 119 of file fixed.h.

120  {
121  return lhs.m_nVal != rhs.m_nVal;
122  }

◆ operator<

template<typename IntType, uint32_t IntBits>
bool operator< ( Fixed< IntType, IntBits > const &  lhs,
Fixed< IntType, IntBits > const &  rhs 
)
friend

Definition at line 124 of file fixed.h.

125  {
126  return lhs.m_nVal < rhs.m_nVal;
127  }

◆ operator<=

template<typename IntType, uint32_t IntBits>
bool operator<= ( Fixed< IntType, IntBits > const &  lhs,
Fixed< IntType, IntBits > const &  rhs 
)
friend

Definition at line 134 of file fixed.h.

135  {
136  return lhs.m_nVal <= rhs.m_nVal;
137  }

◆ operator==

template<typename IntType, uint32_t IntBits>
bool operator== ( Fixed< IntType, IntBits > const &  lhs,
Fixed< IntType, IntBits > const &  rhs 
)
friend

Definition at line 114 of file fixed.h.

115  {
116  return lhs.m_nVal == rhs.m_nVal;
117  }

◆ operator>

template<typename IntType, uint32_t IntBits>
bool operator> ( Fixed< IntType, IntBits > const &  lhs,
Fixed< IntType, IntBits > const &  rhs 
)
friend

Definition at line 129 of file fixed.h.

130  {
131  return lhs.m_nVal > rhs.m_nVal;
132  }

◆ operator>=

template<typename IntType, uint32_t IntBits>
bool operator>= ( Fixed< IntType, IntBits > const &  lhs,
Fixed< IntType, IntBits > const &  rhs 
)
friend

Definition at line 139 of file fixed.h.

140  {
141  return lhs.m_nVal >= rhs.m_nVal;
142  }

Member Data Documentation

◆ fixed_half

template<typename IntType, uint32_t IntBits>
const Fixed< IntType, IntBits > Fixed< IntType, IntBits >::fixed_half
static

Definition at line 56 of file fixed.h.

Referenced by polar().

◆ fixed_half_pi

template<typename IntType, uint32_t IntBits>
const Fixed< IntType, IntBits > Fixed< IntType, IntBits >::fixed_half_pi
static

Definition at line 59 of file fixed.h.

Referenced by polar().

◆ fixed_max

template<typename IntType, uint32_t IntBits>
const Fixed< IntType, IntBits > Fixed< IntType, IntBits >::fixed_max
static

◆ fixed_one

template<typename IntType, uint32_t IntBits>
const Fixed< IntType, IntBits > Fixed< IntType, IntBits >::fixed_one
static

Definition at line 54 of file fixed.h.

Referenced by polar().

◆ fixed_pi

template<typename IntType, uint32_t IntBits>
const Fixed< IntType, IntBits > Fixed< IntType, IntBits >::fixed_pi
static

Definition at line 57 of file fixed.h.

Referenced by polar().

◆ fixed_quarter_pi

template<typename IntType, uint32_t IntBits>
const Fixed< IntType, IntBits > Fixed< IntType, IntBits >::fixed_quarter_pi
static

Definition at line 60 of file fixed.h.

Referenced by polar().

◆ fixed_two_pi

template<typename IntType, uint32_t IntBits>
const Fixed< IntType, IntBits > Fixed< IntType, IntBits >::fixed_two_pi
static

Definition at line 58 of file fixed.h.

Referenced by polar().

◆ fixed_zero

template<typename IntType, uint32_t IntBits>
const Fixed< IntType, IntBits > Fixed< IntType, IntBits >::fixed_zero
static

Definition at line 55 of file fixed.h.

Referenced by Fixed< IntType, IntBits >::log(), and polar().

◆ m_nVal

template<typename IntType, uint32_t IntBits>
IntType Fixed< IntType, IntBits >::m_nVal
private

The documentation for this class was generated from the following file: