Module: Khiva::Matrix

Defined in:
lib/khiva/matrix.rb

Class Method Summary collapse

Class Method Details

.chains(tss, m) ⇒ Object



61
62
63
64
65
# File 'lib/khiva/matrix.rb', line 61

def chains(tss, m)
  chains = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  FFI.call(:get_chains, tss, m, chains)
  Array.new(chains)
end

.find_best_n_discords(profile, index, m, n, self_join: false) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/khiva/matrix.rb', line 4

def find_best_n_discords(profile, index, m, n, self_join: false)
  discord_distances = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  discord_indices = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  subsequence_indices = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  FFI.call(:find_best_n_discords, profile, index, m, n, discord_distances, discord_indices, subsequence_indices, self_join ? 1 : 0)
  [Array.new(discord_distances), Array.new(discord_indices), Array.new(subsequence_indices)]
end

.find_best_n_motifs(profile, index, m, n, self_join: false) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/khiva/matrix.rb', line 12

def find_best_n_motifs(profile, index, m, n, self_join: false)
  motif_distances = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  motif_indices = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  subsequence_indices = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  FFI.call(:find_best_n_motifs, profile, index, m, n, motif_distances, motif_indices, subsequence_indices, self_join ? 1 : 0)
  [Array.new(motif_distances), Array.new(motif_indices), Array.new(subsequence_indices)]
end

.find_best_n_occurrences(q, t, n) ⇒ Object



20
21
22
23
24
25
# File 'lib/khiva/matrix.rb', line 20

def find_best_n_occurrences(q, t, n)
  distances = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  indices = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  FFI.call(:find_best_n_occurrences, q, t, n, distances, indices)
  [Array.new(distances), Array.new(indices)]
end

.mass(q, t) ⇒ Object



27
28
29
30
31
# File 'lib/khiva/matrix.rb', line 27

def mass(q, t)
  distances = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  FFI.call(:mass, q, t, distances)
  Array.new(distances)
end

.matrix_profile(tssa, tssb, m) ⇒ Object



47
48
49
50
51
52
# File 'lib/khiva/matrix.rb', line 47

def matrix_profile(tssa, tssb, m)
  profile = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  index = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  FFI.call(:matrix_profile, tssa, tssb, m, profile, index)
  [Array.new(profile), Array.new(index)]
end

.matrix_profile_self_join(tss, m) ⇒ Object



54
55
56
57
58
59
# File 'lib/khiva/matrix.rb', line 54

def matrix_profile_self_join(tss, m)
  profile = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  index = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  FFI.call(:matrix_profile_self_join, tss, m, profile, index)
  [Array.new(profile), Array.new(index)]
end

.stomp(tssa, tssb, m) ⇒ Object



33
34
35
36
37
38
# File 'lib/khiva/matrix.rb', line 33

def stomp(tssa, tssb, m)
  profile = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  index = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  FFI.call(:stomp, tssa, tssb, m, profile, index)
  [Array.new(profile), Array.new(index)]
end

.stomp_self_join(tss, m) ⇒ Object



40
41
42
43
44
45
# File 'lib/khiva/matrix.rb', line 40

def stomp_self_join(tss, m)
  profile = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  index = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
  FFI.call(:stomp_self_join, tss, m, profile, index)
  [Array.new(profile), Array.new(index)]
end