[go: up one dir, main page]

Menu

[e5459b]: / lib / finita / common.rb  Maximize  Restore  History

Download this file

59 lines (43 with data), 926 Bytes

 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
50
51
52
53
54
55
56
57
58
59
require "autoc"
require "symbolic"
module Finita
Version = "0.2"
# Simplification level
if true
def self.expand(obj)
Symbolic.expand(obj)
end
def self.simplify(obj)
Symbolic.simplify(obj)
end
else
def self.expand(obj)
Symbolic.coerce(obj).convert!.expand!
end
def self.simplify(obj)
Symbolic.coerce(obj).convert!.revert!
end
end
def self.check_type(obj, cls)
if obj.is_a?(cls)
obj
else
raise "expected an instance of class #{cls}"
end
end
CType = {
Integer => "int",
Float => "double",
Complex => "_Complex double"
}
MPIType = {
Integer => "MPI_INT",
Float => "MPI_DOUBLE",
Complex => "MPI_DOUBLE" # no MPI type corrsponding to C complex therefore is has to be constructed manually from a pair of floats
}
CAbs = {
Integer => "abs",
Float => "fabs",
Complex => "cabs"
}
end # Finita