| 1 |
-- ISC License |
| 2 |
-- |
| 3 |
-- Copyright (c) 2013-2018. DIKU, University of Copenhagen |
| 4 |
-- |
| 5 |
-- Permission to use, copy, modify, and/or distribute this software for |
| 6 |
-- any purpose with or without fee is hereby granted, provided that the |
| 7 |
-- above copyright notice and this permission notice appear in all |
| 8 |
-- copies. |
| 9 |
-- |
| 10 |
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 11 |
-- WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 12 |
-- WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 13 |
-- AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 14 |
-- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 15 |
-- PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 16 |
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 17 |
-- PERFORMANCE OF THIS SOFTWARE. |
| 18 |
-- |
| 19 |
-- | The default prelude that is implicitly available in all Futhark |
| 20 |
-- files. |
| 21 |
|
| 22 |
open import "soacs" |
| 23 |
open import "array" |
| 24 |
open import "math" |
| 25 |
open import "functional" |
| 26 |
open import "ad" |
| 27 |
|
| 28 |
-- | Create single-precision float from integer. |
| 29 |
def r32 (x: i32): f32 = f32.i32 x |
| 30 |
-- | Create integer from single-precision float. |
| 31 |
def t32 (x: f32): i32 = i32.f32 x |
| 32 |
|
| 33 |
-- | Create double-precision float from integer. |
| 34 |
def r64 (x: i32): f64 = f64.i32 x |
| 35 |
-- | Create integer from double-precision float. |
| 36 |
def t64 (x: f64): i32 = i32.f64 x |
| 37 |
|
| 38 |
-- | Negate a boolean. `not x` is the same as `!x`. This function is |
| 39 |
-- mostly useful for passing to `map`. |
| 40 |
def not (x: bool): bool = !x |
| 41 |
|
| 42 |
-- | Semantically just identity, but serves as an optimisation |
| 43 |
-- inhibitor. The compiler will treat this function as a black box. |
| 44 |
-- You can use this to work around optimisation deficiencies (or |
| 45 |
-- bugs), although it should hopefully rarely be necessary. |
| 46 |
-- Deprecated: use `#[opaque]` attribute instead. |
| 47 |
def opaque 't (x: t): t = |
| 48 |
#[opaque] x |
| 49 |
|
| 50 |
-- | Semantically just identity, but at runtime, the argument value |
| 51 |
-- will be printed. Deprecated: use `#[trace]` attribute instead. |
| 52 |
def trace 't (x: t): t = |
| 53 |
#[trace(trace)] x |
| 54 |
|
| 55 |
-- | Semantically just identity, but acts as a break point in |
| 56 |
-- `futhark repl`. Deprecated: use `#[break]` attribute instead. |
| 57 |
def break 't (x: t): t = |
| 58 |
#[break] x |