Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
half.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef HalfFloat_INCLUDE_ONCE
33 #define HalfFloat_INCLUDE_ONCE
34 
35 #include <vlCore/Matrix4.hpp>
36 
37 namespace vl
38 {
40  class half
41  {
42  public:
43  half(): bits(0) {}
44 
45  half(const half& hf): bits(hf.bits) {}
46 
47  half(int i): bits(convertFloatToHalf((float)i).bits) {}
48 
49  half(long long i): bits(convertFloatToHalf((float)i).bits) {}
50 
51  half(float f): bits(convertFloatToHalf(f).bits) {}
52 
53  half(double d): bits(convertFloatToHalf((float)d).bits) {}
54 
55  operator float() const
56  {
57  return convertHalfToFloat(*this);
58  }
59 
60  operator double() const
61  {
62  return (double)convertHalfToFloat(*this);
63  }
64 
65  operator int() const
66  {
67  return (int)convertHalfToFloat(*this);
68  }
69 
70  operator long long() const
71  {
72  return (long long)convertHalfToFloat(*this);
73  }
74 
75  half& operator=(const half& other)
76  {
77  bits = other.bits;
78  return *this;
79  }
80 
81  half operator+(const half& other) const
82  {
84  }
85 
86  half& operator+=(const half& other)
87  {
88  return *this = convertFloatToHalf( convertHalfToFloat(*this) + convertHalfToFloat(other) );
89  }
90 
91  half operator-(const half& other) const
92  {
94  }
95 
96  half& operator-=(const half& other)
97  {
98  return *this = convertFloatToHalf( convertHalfToFloat(*this) - convertHalfToFloat(other) );
99  }
100 
101  half operator*(const half& other) const
102  {
103  return convertFloatToHalf( convertHalfToFloat(*this) * convertHalfToFloat(other) );
104  }
105 
106  half& operator*=(const half& other)
107  {
108  return *this = convertFloatToHalf( convertHalfToFloat(*this) * convertHalfToFloat(other) );
109  }
110 
111  half operator/(const half& other) const
112  {
113  return convertFloatToHalf( convertHalfToFloat(*this) / convertHalfToFloat(other) );
114  }
115 
116  half& operator/=(const half& other)
117  {
118  return *this = convertFloatToHalf( convertHalfToFloat(*this) / convertHalfToFloat(other) );
119  }
120 
121  bool isZero() const
122  {
123  return (bits & ((1 << 15)-1)) == 0;
124  }
125 
126  operator bool() const
127  {
128  return !isZero();
129  }
130 
131  bool operator==(const half& other) const
132  {
133  if (isNaN() && other.isNaN())
134  return false;
135  else
136  if (isZero() && other.isZero())
137  return true;
138  else
139  return bits == other.bits;
140  }
141 
142  bool operator==(const float& other) const
143  {
144  return operator==( convertFloatToHalf(other) );
145  }
146 
147  bool operator==(const double& other) const
148  {
149  return operator==( convertFloatToHalf((float)other) );
150  }
151 
152  bool operator==(const int& other) const
153  {
154  return operator==( convertFloatToHalf((float)other) );
155  }
156 
157  bool operator==(const long long& other) const
158  {
159  return operator==( convertFloatToHalf((float)other) );
160  }
161 
162  bool operator!=(const half& other) const
163  {
164  if (isNaN() && other.isNaN())
165  return false;
166  else
167  if (isZero() && other.isZero())
168  return false;
169  else
170  return bits != other.bits;
171  }
172 
173  bool operator!=(const float& other) const
174  {
175  return operator!=( convertFloatToHalf(other) );
176  }
177 
178  bool operator!=(const double& other) const
179  {
180  return operator!=( convertFloatToHalf((float)other) );
181  }
182 
183  bool operator!=(const int& other) const
184  {
185  return operator!=( convertFloatToHalf((float)other) );
186  }
187 
188  bool operator!=(const long long& other) const
189  {
190  return operator!=( convertFloatToHalf((float)other) );
191  }
192 
193  bool operator<(const half& other) const
194  {
195  return convertHalfToFloat(*this) < convertHalfToFloat(other);
196  }
197 
198  bool operator>(const half& other) const
199  {
200  return convertHalfToFloat(*this) < convertHalfToFloat(other);
201  }
202 
203  bool isNaN() const
204  {
205  unsigned int mantissa = (unsigned int) (bits & (( 1 << 10) - 1) );
206  unsigned int exp = (unsigned int) (bits & HALF_FLOAT_MAX_BIASED_EXP);
207  return exp == HALF_FLOAT_MAX_BIASED_EXP && mantissa != 0;
208  }
209 
210  bool isinf() const
211  {
212  unsigned int mantissa = (unsigned int) (bits & (( 1 << 10) - 1) );
213  unsigned int exp = (unsigned int) (bits & HALF_FLOAT_MAX_BIASED_EXP);
214  return exp == HALF_FLOAT_MAX_BIASED_EXP && mantissa == 0;
215  }
216 
217  bool isinf_pos() const
218  {
219  unsigned int sign = (unsigned int) ( bits >> 15);
220  unsigned int mantissa = (unsigned int) (bits & (( 1 << 10) - 1) );
221  unsigned int exp = (unsigned int) (bits & HALF_FLOAT_MAX_BIASED_EXP);
222  return exp == HALF_FLOAT_MAX_BIASED_EXP && mantissa == 0 && sign == 0;
223  }
224 
225  bool isinf_neg() const
226  {
227  unsigned int sign = (unsigned int) ( bits >> 15);
228  unsigned int mantissa = (unsigned int) (bits & (( 1 << 10) - 1) );
229  unsigned int exp = (unsigned int) (bits & HALF_FLOAT_MAX_BIASED_EXP);
230  return exp == HALF_FLOAT_MAX_BIASED_EXP && mantissa == 0 && sign == 1;
231  }
232 
233  bool isdenorm() const
234  {
235  unsigned int mantissa = (unsigned int) (bits & (( 1 << 10) - 1) );
236  unsigned int exp = (unsigned int) (bits & HALF_FLOAT_MAX_BIASED_EXP);
237  return exp == 0 && mantissa != 0;
238  }
239 
240  half operator-() const
241  {
242  half h = *this;
243  h.bits ^= 1 << 15;
244  return h;
245  }
246 
247  //---------------------------------------------------------------------------
248  static half infinity()
249  {
250  half h;
251  h.bits = HALF_FLOAT_MAX_BIASED_EXP;
252  return h;
253  }
254  //---------------------------------------------------------------------------
255  static half NaN()
256  {
257  half h;
258  h.bits = HALF_FLOAT_MAX_BIASED_EXP | (( 1 << 10) - 1);
259  return h;
260  }
261  //---------------------------------------------------------------------------
262  static void convertDoubleToHalf(const double* d, half* h, int count)
263  {
264  for(int i=0; i<count; ++i)
265  h[i] = convertFloatToHalf((float)d[i]);
266  }
267  //---------------------------------------------------------------------------
268  static void convertHalfToDouble(const half* h, double* d, int count)
269  {
270  for(int i=0; i<count; ++i)
271  d[i] = (double)convertHalfToFloat(h[i]);
272  }
273  //---------------------------------------------------------------------------
274  static half convertFloatToHalf(float f)
275  {
276  union { float f; unsigned int x; } val;
277  val.f = f;
278  unsigned int sign = (unsigned short)(val.x>>31);
279  unsigned int mantissa = val.x & ((1 << 23)-1);
280  unsigned int exp = val.x & FLOAT_MAX_BIASED_EXP;
281  typedef unsigned short hfloat;
282  half hf;
283 
284  if (exp >= HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP)
285  {
286  // check if the original single precision float number is a NaN
287  if (mantissa && (exp == FLOAT_MAX_BIASED_EXP))
288  {
289  // we have a single precision NaN
290  mantissa = (1<<23) - 1;
291  }
292  else
293  {
294  // 16-bit half-float representation stores number as Inf
295  mantissa = 0;
296  }
297  hf.bits = (((hfloat)sign) << 15) | (hfloat)(HALF_FLOAT_MAX_BIASED_EXP) | (hfloat)(mantissa >> 13);
298  }
299  // check if exponent is <= -15
300  else
301  if (exp <= HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP)
302  {
303  // store a denorm half-float value or zero
304  exp = (HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP - exp) >> 23;
305  mantissa >>= (14 + exp);
306  hf.bits = (((hfloat)sign) << 15) | (hfloat)(mantissa);
307  }
308  else
309  {
310  hf.bits = (((hfloat)sign)<<15) |
311  (hfloat)((exp - HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP) >> 13) |
312  (hfloat)(mantissa >> 13);
313  }
314  return hf;
315  }
316  //---------------------------------------------------------------------------
317  static float convertHalfToFloat(const half& h)
318  {
319  unsigned short hf = h.bits;
320  unsigned int sign = (unsigned int) ( hf >> 15);
321  unsigned int mantissa = (unsigned int) (hf & (( 1 << 10) - 1) );
322  unsigned int exp = (unsigned int) (hf & HALF_FLOAT_MAX_BIASED_EXP);
323 
324  if (exp == HALF_FLOAT_MAX_BIASED_EXP)
325  {
326  // we have a half-float NaN or Inf
327  // half-float NaNs will be converted to a single precision NaN
328  // half-float Infs will be converted to a single precision Inf
329  exp = FLOAT_MAX_BIASED_EXP;
330  if ( mantissa)
331  mantissa = (1 << 23 ) - 1; // set all bits to indicate a NaN
332  }
333  else if (exp == 0x0)
334  {
335  // convert half-float zero/denorm to single precision value
336  if ( mantissa)
337  {
338  mantissa <<= 1;
339  exp = HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
340  // check for leading 1 in denorm mantissa
341  while ((mantissa & (1 << 10) ) == 0)
342  {
343  // for every leading 0, decrement single precision exponent by 1
344  // and shift half-float mantissa value to the left
345  mantissa <<= 1;
346  exp -= (1 << 23 );
347  }
348  // clamp the mantissa to 10-bits
349  mantissa &= (( 1 << 10) - 1);
350  // shift left to generate single-precision mantissa of 23-bits
351  mantissa <<= 13;
352  }
353  }
354  else
355  {
356  // shift left to generate single-precision mantissa of 23-bits
357  mantissa <<= 13;
358  // generate single precision biased exponent value
359  exp = ( exp << 13) + HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
360  }
361  union { float f; unsigned int x; } val;
362  val.x = ( sign << 31) | exp | mantissa;
363  return val.f;
364  }
365  //---------------------------------------------------------------------------
366  static void convertFloatToHalf(const float* f, half* h, int count)
367  {
368  for(int i=0; i<count; ++i)
369  {
370  union { float f; unsigned int x; } val;
371  val.f = f[i];
372  unsigned int sign = (unsigned short)(val.x>>31);
373  unsigned int mantissa = val.x & ((1 << 23)-1);
374  unsigned int exp = val.x & FLOAT_MAX_BIASED_EXP;
375  typedef unsigned short hfloat;
376  hfloat& hf = h[i].bits;
377 
378  if (exp >= HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP)
379  {
380  // check if the original single precision float number is a NaN
381  if (mantissa && (exp == FLOAT_MAX_BIASED_EXP))
382  {
383  // we have a single precision NaN
384  mantissa = (1<<23) - 1;
385  }
386  else
387  {
388  // 16-bit half-float representation stores number as Inf
389  mantissa = 0;
390  }
391  hf = (((hfloat)sign) << 15) | (hfloat)(HALF_FLOAT_MAX_BIASED_EXP) | (hfloat)(mantissa >> 13);
392  }
393  // check if exponent is <= -15
394  else
395  if (exp <= HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP)
396  {
397  // store a denorm half-float value or zero
398  exp = (HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP - exp) >> 23;
399  mantissa >>= (14 + exp);
400  hf = (((hfloat)sign) << 15) | (hfloat)(mantissa);
401  }
402  else
403  {
404  hf = (((hfloat)sign)<<15) |
405  (hfloat)((exp - HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP) >> 13) |
406  (hfloat)(mantissa >> 13);
407  }
408  }
409  }
410  //---------------------------------------------------------------------------
411  static void convertHalfToFloat(const half* h, float *f, int count)
412  {
413  for(int i=0; i<count; ++i)
414  {
415  const unsigned short& hf = h[i].bits;
416  unsigned int sign = (unsigned int) ( hf >> 15);
417  unsigned int mantissa = (unsigned int) (hf & (( 1 << 10) - 1) );
418  unsigned int exp = (unsigned int) (hf & HALF_FLOAT_MAX_BIASED_EXP);
419 
420  if (exp == HALF_FLOAT_MAX_BIASED_EXP)
421  {
422  // we have a half-float NaN or Inf
423  // half-float NaNs will be converted to a single precision NaN
424  // half-float Infs will be converted to a single precision Inf
425  exp = FLOAT_MAX_BIASED_EXP;
426  if ( mantissa)
427  mantissa = (1 << 23 ) - 1; // set all bits to indicate a NaN
428  }
429  else if (exp == 0x0)
430  {
431  // convert half-float zero/denorm to single precision value
432  if ( mantissa)
433  {
434  mantissa <<= 1;
435  exp = HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
436  // check for leading 1 in denorm mantissa
437  while ((mantissa & (1 << 10) ) == 0)
438  {
439  // for every leading 0, decrement single precision exponent by 1
440  // and shift half-float mantissa value to the left
441  mantissa <<= 1;
442  exp -= (1 << 23 );
443  }
444  // clamp the mantissa to 10-bits
445  mantissa &= (( 1 << 10) - 1);
446  // shift left to generate single-precision mantissa of 23-bits
447  mantissa <<= 13;
448  }
449  }
450  else
451  {
452  // shift left to generate single-precision mantissa of 23-bits
453  mantissa <<= 13;
454  // generate single precision biased exponent value
455  exp = ( exp << 13) + HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP;
456  }
457  union { float f; unsigned int x; } val;
458  val.x = ( sign << 31) | exp | mantissa;
459  f[i] = val.f;
460  }
461  }
462  //---------------------------------------------------------------------------
463  public:
464  unsigned short bits;
465 
466  private:
467  // -15 stored using a single precision bias of 127
468  static const unsigned int HALF_FLOAT_MIN_BIASED_EXP_AS_SINGLE_FP_EXP = 0x38000000;
469 
470  // max exponent value in single precision that will be converted
471  // to Inf or Nan when stored as a half-float
472  static const unsigned int HALF_FLOAT_MAX_BIASED_EXP_AS_SINGLE_FP_EXP = 0x47800000;
473 
474  // 255 is the max exponent biased value
475  static const unsigned int FLOAT_MAX_BIASED_EXP = (0xFF << 23);
476  static const unsigned int HALF_FLOAT_MAX_BIASED_EXP = (0x1F << 10);
477 
478  };
479  //-----------------------------------------------------------------------------
480  inline float operator/(float a, const half& b)
481  {
482  return (float)a / half::convertHalfToFloat(b);
483  }
484  //-----------------------------------------------------------------------------
485  inline float operator/(double a, const half& b)
486  {
487  return (float)a / half::convertHalfToFloat(b);
488  }
489  //-----------------------------------------------------------------------------
490  inline float operator/(int a, const half& b)
491  {
492  return (float)a / half::convertHalfToFloat(b);
493  }
494  //-----------------------------------------------------------------------------
495  inline float operator*(float a, const half& b)
496  {
497  return (float)a * half::convertHalfToFloat(b);
498  }
499  //-----------------------------------------------------------------------------
500  inline float operator*(double a, const half& b)
501  {
502  return (float)a * half::convertHalfToFloat(b);
503  }
504  //-----------------------------------------------------------------------------
505  inline float operator*(int a, const half& b)
506  {
507  return (float)a * half::convertHalfToFloat(b);
508  }
509  //-----------------------------------------------------------------------------
510  inline float operator+(float a, const half& b)
511  {
512  return (float)a + half::convertHalfToFloat(b);
513  }
514  //-----------------------------------------------------------------------------
515  inline float operator+(double a, const half& b)
516  {
517  return (float)a + half::convertHalfToFloat(b);
518  }
519  //-----------------------------------------------------------------------------
520  inline float operator+(int a, const half& b)
521  {
522  return (float)a + half::convertHalfToFloat(b);
523  }
524  //-----------------------------------------------------------------------------
525  inline float operator-(float a, const half& b)
526  {
527  return (float)a - half::convertHalfToFloat(b);
528  }
529  //-----------------------------------------------------------------------------
530  inline float operator-(double a, const half& b)
531  {
532  return (float)a - half::convertHalfToFloat(b);
533  }
534  //-----------------------------------------------------------------------------
535  inline float operator-(int a, const half& b)
536  {
537  return (float)a - half::convertHalfToFloat(b);
538  }
539  //-----------------------------------------------------------------------------
540  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
541  //-----------------------------------------------------------------------------
542  inline float operator/(const half& a, float b)
543  {
544  return half::convertHalfToFloat(a) / (float)b ;
545  }
546  //-----------------------------------------------------------------------------
547  inline float operator/(const half& a, double b)
548  {
549  return half::convertHalfToFloat(a) / (float)b ;
550  }
551  //-----------------------------------------------------------------------------
552  inline float operator/(const half& a, int b)
553  {
554  return half::convertHalfToFloat(a) / (float)b ;
555  }
556  //-----------------------------------------------------------------------------
557  inline float operator*(const half& a, float b)
558  {
559  return half::convertHalfToFloat(a) * (float)b ;
560  }
561  //-----------------------------------------------------------------------------
562  inline float operator*(const half& a, double b)
563  {
564  return half::convertHalfToFloat(a) * (float)b ;
565  }
566  //-----------------------------------------------------------------------------
567  inline float operator*(const half& a, int b)
568  {
569  return half::convertHalfToFloat(a) * (float)b ;
570  }
571  //-----------------------------------------------------------------------------
572  inline float operator+(const half& a, float b)
573  {
574  return half::convertHalfToFloat(a) + (float)b ;
575  }
576  //-----------------------------------------------------------------------------
577  inline float operator+(const half& a, double b)
578  {
579  return half::convertHalfToFloat(a) + (float)b ;
580  }
581  //-----------------------------------------------------------------------------
582  inline float operator+(const half& a, int b)
583  {
584  return half::convertHalfToFloat(a) + (float)b ;
585  }
586  //-----------------------------------------------------------------------------
587  inline float operator-(const half& a, float b)
588  {
589  return half::convertHalfToFloat(a) - (float)b ;
590  }
591  //-----------------------------------------------------------------------------
592  inline float operator-(const half& a, double b)
593  {
594  return half::convertHalfToFloat(a) - (float)b ;
595  }
596  //-----------------------------------------------------------------------------
597  inline float operator-(const half& a, int b)
598  {
599  return half::convertHalfToFloat(a) - (float)b ;
600  }
601  //-----------------------------------------------------------------------------
602  template<> inline half Vector4<half>::length() const { return (half)::sqrt( (float)x()*(float)x()+(float)y()*(float)y()+(float)z()*(float)z()+(float)w()*(float)w()); }
603  template<> inline half Vector4<half>::lengthSquared() const { return (half)((float)x()*(float)x()+(float)y()*(float)y()+(float)z()*(float)z()+(float)w()*(float)w()); }
604 
605  template<> inline half Vector3<half>::length() const { return (half)::sqrt( (float)x()*(float)x()+(float)y()*(float)y()+(float)z()*(float)z()); }
606  template<> inline half Vector3<half>::lengthSquared() const { return (half)((float)x()*(float)x()+(float)y()*(float)y()+(float)z()*(float)z()); }
607 
608  template<> inline half Vector2<half>::length() const { return (half)::sqrt( (float)x()*(float)x()+(float)y()*(float)y()); }
609  template<> inline half Vector2<half>::lengthSquared() const { return (half)((float)x()*(float)x()+(float)y()*(float)y()); }
610  //-----------------------------------------------------------------------------
614  //-----------------------------------------------------------------------------
618  //-----------------------------------------------------------------------------
619 }
620 
621 #endif
half(const half &hf)
Definition: half.hpp:45
Vector2< half > hvec2
Definition: half.hpp:613
bool operator==(const half &other) const
Definition: half.hpp:131
T sqrt(T a)
Definition: glsl_math.hpp:592
Vector4< half > hvec4
Definition: half.hpp:611
bool operator==(const double &other) const
Definition: half.hpp:147
half operator+(const half &other) const
Definition: half.hpp:81
static void convertDoubleToHalf(const double *d, half *h, int count)
Definition: half.hpp:262
half(float f)
Definition: half.hpp:51
T sign(T a)
Definition: glsl_math.hpp:669
Vector3< half > hvec3
Definition: half.hpp:612
bool isNaN() const
Definition: half.hpp:203
Matrix3< half > hmat3
Definition: half.hpp:616
static void convertFloatToHalf(const float *f, half *h, int count)
Definition: half.hpp:366
bool operator==(const long long &other) const
Definition: half.hpp:157
half operator/(const half &other) const
Definition: half.hpp:111
bool isinf_pos() const
Definition: half.hpp:217
The Matrix2 class is a template class that implements a generic 2x2 matrix, see also vl::dmat2...
Definition: Matrix2.hpp:49
T_Scalar length() const
Definition: Vector4.hpp:252
half operator-() const
Definition: half.hpp:240
bool operator!=(const int &other) const
Definition: half.hpp:183
T_Scalar lengthSquared() const
Definition: Vector2.hpp:256
bool isZero() const
Definition: half.hpp:121
bool operator==(const float &other) const
Definition: half.hpp:142
static half convertFloatToHalf(float f)
Definition: half.hpp:274
static half NaN()
Definition: half.hpp:255
The Vector4 class is a template class that implements a generic 4 components vector, see also vl::fvec4, vl::dvec4, vl::uvec4, vl::ivec4, vl::svec4, vl::usvec4, vl::bvec4, vl::ubvec4.
Definition: Vector4.hpp:44
bool operator!=(const half &other) const
Definition: half.hpp:162
T_Scalar lengthSquared() const
Definition: Vector4.hpp:253
half(long long i)
Definition: half.hpp:49
bool operator<(const half &other) const
Definition: half.hpp:193
Matrix2< half > hmat2
Definition: half.hpp:617
Visualization Library main namespace.
Represents an half-precision floating point value.
Definition: half.hpp:40
static float convertHalfToFloat(const half &h)
Definition: half.hpp:317
bool operator!=(const float &other) const
Definition: half.hpp:173
The Matrix3 class is a template class that implements a generic 3x3 matrix, see also vl::dmat3...
Definition: Matrix3.hpp:48
half & operator+=(const half &other)
Definition: half.hpp:86
T_Scalar length() const
Definition: Vector2.hpp:255
static void convertHalfToDouble(const half *h, double *d, int count)
Definition: half.hpp:268
T_Scalar lengthSquared() const
Definition: Vector3.hpp:226
The Vector3 class is a template class that implements a generic 3 components vector, see also vl::fvec3, vl::dvec3, vl::uvec3, vl::ivec3, vl::svec3, vl::usvec3, vl::bvec3, vl::ubvec3.
Definition: Vector3.hpp:44
bool operator!=(const long long &other) const
Definition: half.hpp:188
T_Scalar length() const
Definition: Vector3.hpp:225
Matrix4< half > hmat4
Definition: half.hpp:615
bool isdenorm() const
Definition: half.hpp:233
bool operator==(const int &other) const
Definition: half.hpp:152
half operator-(const half &other) const
Definition: half.hpp:91
The Matrix4 class is a template class that implements a generic 4x4 matrix, see also vl::dmat4...
Definition: Matrix4.hpp:48
bool isinf_neg() const
Definition: half.hpp:225
half & operator-=(const half &other)
Definition: half.hpp:96
T exp(T a)
Definition: glsl_math.hpp:460
bool operator!=(const double &other) const
Definition: half.hpp:178
The Vector2 class is a template class that implements a generic 2 components vector, see also vl::fvec2, vl::dvec2, vl::uvec2, vl::ivec2, vl::svec2, vl::usvec2, vl::bvec2, vl::ubvec2.
Definition: Vector2.hpp:97
half & operator/=(const half &other)
Definition: half.hpp:116
half(double d)
Definition: half.hpp:53
bool isinf() const
Definition: half.hpp:210
half(int i)
Definition: half.hpp:47
static half infinity()
Definition: half.hpp:248
static void convertHalfToFloat(const half *h, float *f, int count)
Definition: half.hpp:411
bool operator>(const half &other) const
Definition: half.hpp:198
half & operator*=(const half &other)
Definition: half.hpp:106
half operator*(const half &other) const
Definition: half.hpp:101
half & operator=(const half &other)
Definition: half.hpp:75
half()
Definition: half.hpp:43
unsigned short bits
Definition: half.hpp:464