Commits

Cyrille Berger  committed fa85c59

add Infinity

  • Participants
  • Parent commits 6ceb70c

Comments (0)

Files changed (4)

File Runtime/Cauchy/Eigen3.cfd

+#
+# Number
+#
+constant Inf in Cauchy/Eigen3/Infinity.h named Cauchy::Inf
+
 #
 # Complex
 #

File Runtime/Cauchy/Eigen3/Infinity.h

+/*
+ *  Copyright (c) 2010 Cyrille Berger <cberger@cberger.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; see the file COPYING.RUNTIME.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * The file COPYING.RUNTIME.EXCEPTION contains an exception that allow
+ * to use this file with other open source license
+ */
+
+#ifndef _CAUCHY_INFINITY_H_
+#define _CAUCHY_INFINITY_H_
+
+#include "NumberTypes.h"
+
+namespace Cauchy {
+
+  class Infinity {
+    public:
+      operator float ()
+      {
+        union {float f; uint32 i;} u;
+        u.i = 0x7f800000;
+        return u.f;
+      }
+      operator double ()
+      {
+        union {double d; uint64 i;} u;
+        u.i = UINT64_C(0x7ff0000000000000);
+        return u.d;
+      }
+      bool operator==(Infinity )
+      {
+        return true;
+      }
+      bool operator==(float f )
+      {
+        return (float)(*this) == f;
+      }
+      bool operator==(double f )
+      {
+        return (double)(*this) == f;
+      }
+  };
+  bool operator==(double d, Infinity i)
+  {
+    return i == d;
+  }
+  Infinity Inf;
+}
+
+#endif

File Runtime/Cauchy/Eigen3/NumberTypes.h

+/*
+ *  Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _CAUCHY_NUMBER_TYPES_H_
+#define _CAUCHY_NUMBER_TYPES_H_
+
+namespace Cauchy {
+
+#ifndef _MSC_VER
+
+#define __STDC_CONSTANT_MACROS
+
+#include <stdint.h>
+
+typedef int8_t int8;
+typedef int16_t int16;
+typedef int32_t int32;
+typedef int64_t int64;
+typedef uint8_t uint8;
+typedef uint16_t uint16;
+typedef uint32_t uint32;
+typedef uint64_t uint64;
+
+#else // _MSC_VER
+
+// include everywhere
+#include <sys/types.h>
+
+/* Exact-width integer types */
+typedef signed char int8;
+typedef signed short int16;
+typedef signed long int32;
+typedef signed long long int64;
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+typedef unsigned long uint32;
+typedef unsigned long long uint64;
+
+/* Limits of exact-width integer types */
+
+#define INT8_MIN (-128)
+#define INT16_MIN (-32768)
+#define INT32_MIN (-2147483647 - 1)
+#define INT64_MIN (-9223372036854775807LL - 1LL)
+
+#define INT8_MAX (127)
+#define INT16_MAX (32767)
+#define INT32_MAX (2147483647)
+#define INT64_MAX (9223372036854775807LL)
+
+#define UINT8_MAX (255)
+#define UINT16_MAX (65535)
+#define UINT32_MAX (4294967295UL)
+#define UINT64_MAX (18446744073709551615ULL)
+
+/* Macros for minimum-width integer constant expressions */
+
+#define INT8_C(x) x
+#define INT16_C(x) x
+#define INT32_C(x) x ## L
+#define INT64_C(x) x ## LL
+
+#define UINT8_C(x) x ## U
+#define UINT16_C(x) x ## U
+#define UINT32_C(x) x ## UL
+#define UINT64_C(x) x ## ULL
+
+/* Macros for greatest-width integer constant expressions */
+
+#define INTMAX_C(x) x ## L
+#define UINTMAX_C(x) x ## UL
+
+#endif
+
+}
+
+#endif

File Runtime/Cauchy/Standard.cfd

+#
+# Number
+#
+constant Inf is Number
+
 #
 # Complex
 #