package owl-base

  1. Overview
  2. Docs
OCaml Scientific and Engineering Computing - Base

Install

dune-project
 Dependency

Authors

Maintainers

Sources

owl-1.0.2.tbz
sha256=38d210ce6c1c2f09631fd59951430e4f364b5ae036c71ed1b32ce559b2a29263
sha512=c468100556445384b9c6adad9c37b5a9b8c27db8be35f61979e65fafa88c60221b8bda0a9c06cfbbc8d4e216a1ed08a315dfefb45bb4f5f15aa82d4358f57567

doc/src/owl-base/owl_computation_cpu_device.ml.html

Source file owl_computation_cpu_device.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 1 "src/base/compute/owl_computation_cpu_device.ml"
(*
 * OWL - OCaml Scientific and Engineering Computing
 * Copyright (c) 2016-2020 Liang Wang <liang.wang@cl.cam.ac.uk>
 *)

open Owl_types

(* Functor of making CPU devices *)

module Make (A : Ndarray_Mutable) = struct
  module A = A

  type device =
    { device_type : device_type
    ; initialised : bool
    }

  type value =
    | ArrVal of A.arr
    | EltVal of A.elt

  let make_device () = { device_type = CPU; initialised = false }

  let arr_to_value x = ArrVal x

  let value_to_arr = function
    | ArrVal x -> x
    | _        -> failwith "Owl_computation_device: value_to_arr"


  let elt_to_value x = EltVal x

  let value_to_elt = function
    | EltVal x -> x
    | _        -> failwith "Owl_computation_device: value_to_elt"


  let value_to_float x = A.elt_to_float (value_to_elt x)

  let is_arr = function
    | ArrVal _ -> true
    | EltVal _ -> false


  let is_elt = function
    | ArrVal _ -> false
    | EltVal _ -> true
end