summaryrefslogtreecommitdiff
path: root/utils/star.h
blob: 3295112c77e03831f2722ba156cbc83bfcfd8a80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#ifndef _STAR_H_
#define _STAR_H_

template <typename T>
T star(const T& x) {
  if (!x) return T();
  if (x > T(1)) return std::numeric_limits<T>::infinity();
  if (x < -T(1)) return -std::numeric_limits<T>::infinity();
  return T(1) / (T(1) - x);
}

#endif