swak 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/swak.rb +28 -0
  2. metadata +2 -2
@@ -99,4 +99,32 @@ class Array
99
99
  def mean
100
100
  return self.avg
101
101
  end
102
+
103
+ def argmax
104
+ max_i = 0
105
+ max_val = self[max_i]
106
+
107
+ self.each_with_index do |x, i|
108
+ if x > max_val
109
+ max_val = x
110
+ max_i = i
111
+ end
112
+ end
113
+
114
+ return max_i
115
+ end
116
+
117
+ def argmin
118
+ min_i = 0
119
+ min_val = self[min_i]
120
+
121
+ self.each_with_index do |x, i|
122
+ if x < min_val
123
+ min_val = x
124
+ min_i = i
125
+ end
126
+ end
127
+
128
+ return min_i
129
+ end
102
130
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: swak
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.4
5
+ version: 0.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jesse Rodriguez
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-15 00:00:00 Z
13
+ date: 2011-09-28 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: Random tools and mixins