linear_solver 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 89a38d8dd0b95d3025c5bbb8100e2156735e3ad8
4
+ data.tar.gz: 7908acc0191e1572d0f59ff58d2e6785b518f67a
5
+ SHA512:
6
+ metadata.gz: 79e555385c35e6977d6d0b69d1130ccbb13c69cc3af8c4defb1cb245a0aa00d5aa2a06a5e73ad773ddbb77356455dd57cbeefdc7529aa25d622f20431241018d
7
+ data.tar.gz: 12b010374eb3ce43ab704190a573fc6df5620eb6d96f204a5c35a156f23e796cbfe51e130155c61ac710acc33be60931bbc61208197d48fe5e653a298e4764ef
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.idea/.name ADDED
@@ -0,0 +1 @@
1
+ linear_solver
data/.idea/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build linear_solver-0.0.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install linear_solver-0.0.1.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v0.0.1 and build and push linear_solver-0.0.1.gem to Rubygems" fullCmd="release" taksId="release" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /></RakeGroup></Settings>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="FacetManager">
4
+ <facet type="gem" name="Ruby Gem">
5
+ <configuration>
6
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
+ <option name="GEM_APP_TEST_PATH" value="" />
8
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
+ </configuration>
10
+ </facet>
11
+ </component>
12
+ <component name="NewModuleRootManager">
13
+ <content url="file://$MODULE_DIR$" />
14
+ <orderEntry type="inheritedJdk" />
15
+ <orderEntry type="sourceFolder" forTests="false" />
16
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.3, RVM: ruby-1.9.3-p547 [global]) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, RVM: ruby-1.9.3-p547 [global]) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.3.2, RVM: ruby-1.9.3-p547 [global]) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v2.99.0, RVM: ruby-1.9.3-p547 [global]) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.99.2, RVM: ruby-1.9.3-p547 [global]) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.99.2, RVM: ruby-1.9.3-p547 [global]) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.99.2, RVM: ruby-1.9.3-p547 [global]) [gem]" level="application" />
23
+ </component>
24
+ </module>
data/.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.3-p547 [global]" project-jdk-type="RUBY_SDK" />
4
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/linear_solver.iml" filepath="$PROJECT_DIR$/.idea/linear_solver.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,5 @@
1
+ <component name="DependencyValidationManager">
2
+ <state>
3
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
+ </state>
5
+ </component>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,541 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="d587cdd6-bd36-44b5-876d-fb8380d5e7f4" name="Default" comment="">
5
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/linear_solver/version.rb" afterPath="$PROJECT_DIR$/lib/linear_solver/version.rb" />
6
+ </list>
7
+ <ignored path="linear_solver.iws" />
8
+ <ignored path=".idea/workspace.xml" />
9
+ <ignored path=".idea/dataSources.local.xml" />
10
+ <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
11
+ <option name="TRACKING_ENABLED" value="true" />
12
+ <option name="SHOW_DIALOG" value="false" />
13
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
14
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
15
+ <option name="LAST_RESOLUTION" value="IGNORE" />
16
+ </component>
17
+ <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
18
+ <component name="CreatePatchCommitExecutor">
19
+ <option name="PATCH_PATH" value="" />
20
+ </component>
21
+ <component name="DaemonCodeAnalyzer">
22
+ <disable_hints />
23
+ </component>
24
+ <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
25
+ <component name="FavoritesManager">
26
+ <favorites_list name="linear_solver" />
27
+ </component>
28
+ <component name="FileEditorManager">
29
+ <leaf>
30
+ <file leaf-file-name="linear_solver.gemspec" pinned="false" current-in-tab="false">
31
+ <entry file="file://$PROJECT_DIR$/linear_solver.gemspec">
32
+ <provider selected="true" editor-type-id="text-editor">
33
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="480">
34
+ <caret line="24" column="47" selection-start-line="24" selection-start-column="47" selection-end-line="24" selection-end-column="47" />
35
+ <folding />
36
+ </state>
37
+ </provider>
38
+ </entry>
39
+ </file>
40
+ <file leaf-file-name="Guardfile" pinned="false" current-in-tab="false">
41
+ <entry file="file://$PROJECT_DIR$/Guardfile">
42
+ <provider selected="true" editor-type-id="text-editor">
43
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="240">
44
+ <caret line="10" column="3" selection-start-line="10" selection-start-column="3" selection-end-line="10" selection-end-column="3" />
45
+ <folding />
46
+ </state>
47
+ </provider>
48
+ </entry>
49
+ </file>
50
+ <file leaf-file-name="linear_solver.rb" pinned="false" current-in-tab="false">
51
+ <entry file="file://$PROJECT_DIR$/lib/linear_solver.rb">
52
+ <provider selected="true" editor-type-id="text-editor">
53
+ <state vertical-scroll-proportion="0.0" vertical-offset="66" max-vertical-offset="855">
54
+ <caret line="27" column="29" selection-start-line="27" selection-start-column="29" selection-end-line="27" selection-end-column="29" />
55
+ <folding />
56
+ </state>
57
+ </provider>
58
+ </entry>
59
+ </file>
60
+ <file leaf-file-name="README.md" pinned="false" current-in-tab="false">
61
+ <entry file="file://$PROJECT_DIR$/README.md">
62
+ <provider selected="true" editor-type-id="text-editor">
63
+ <state vertical-scroll-proportion="-10.76" vertical-offset="331" max-vertical-offset="1155">
64
+ <caret line="40" column="9" selection-start-line="40" selection-start-column="9" selection-end-line="40" selection-end-column="9" />
65
+ <folding />
66
+ </state>
67
+ </provider>
68
+ </entry>
69
+ </file>
70
+ <file leaf-file-name="spec_helper.rb" pinned="false" current-in-tab="false">
71
+ <entry file="file://$PROJECT_DIR$/spec/spec_helper.rb">
72
+ <provider selected="true" editor-type-id="text-editor">
73
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="90">
74
+ <caret line="0" column="23" selection-start-line="0" selection-start-column="23" selection-end-line="0" selection-end-column="23" />
75
+ <folding />
76
+ </state>
77
+ </provider>
78
+ </entry>
79
+ </file>
80
+ <file leaf-file-name="version.rb" pinned="false" current-in-tab="true">
81
+ <entry file="file://$PROJECT_DIR$/lib/linear_solver/version.rb">
82
+ <provider selected="true" editor-type-id="text-editor">
83
+ <state vertical-scroll-proportion="0.021459227" vertical-offset="0" max-vertical-offset="699">
84
+ <caret line="1" column="18" selection-start-line="1" selection-start-column="18" selection-end-line="1" selection-end-column="18" />
85
+ <folding />
86
+ </state>
87
+ </provider>
88
+ </entry>
89
+ </file>
90
+ <file leaf-file-name="Rakefile" pinned="false" current-in-tab="false">
91
+ <entry file="file://$PROJECT_DIR$/Rakefile">
92
+ <provider selected="true" editor-type-id="text-editor">
93
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="240">
94
+ <caret line="10" column="22" selection-start-line="10" selection-start-column="22" selection-end-line="10" selection-end-column="22" />
95
+ <folding />
96
+ </state>
97
+ </provider>
98
+ </entry>
99
+ </file>
100
+ <file leaf-file-name="linear_solver_spec.rb" pinned="false" current-in-tab="false">
101
+ <entry file="file://$PROJECT_DIR$/spec/linear_solver_spec.rb">
102
+ <provider selected="true" editor-type-id="text-editor">
103
+ <state vertical-scroll-proportion="0.0" vertical-offset="1701" max-vertical-offset="2400">
104
+ <caret line="88" column="9" selection-start-line="88" selection-start-column="9" selection-end-line="88" selection-end-column="9" />
105
+ <folding />
106
+ </state>
107
+ </provider>
108
+ </entry>
109
+ </file>
110
+ <file leaf-file-name="calculation_unsolvable_error.rb" pinned="false" current-in-tab="false">
111
+ <entry file="file://$PROJECT_DIR$/lib/linear_solver/calculation_unsolvable_error.rb">
112
+ <provider selected="true" editor-type-id="text-editor">
113
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="135">
114
+ <caret line="3" column="3" selection-start-line="3" selection-start-column="3" selection-end-line="3" selection-end-column="3" />
115
+ <folding />
116
+ </state>
117
+ </provider>
118
+ </entry>
119
+ </file>
120
+ </leaf>
121
+ </component>
122
+ <component name="Git.Settings">
123
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
124
+ </component>
125
+ <component name="IdeDocumentHistory">
126
+ <option name="CHANGED_PATHS">
127
+ <list>
128
+ <option value="$PROJECT_DIR$/Rakefile" />
129
+ <option value="$PROJECT_DIR$/linear_solver.gemspec" />
130
+ <option value="$PROJECT_DIR$/Guardfile" />
131
+ <option value="$PROJECT_DIR$/spec/spec_helper.rb" />
132
+ <option value="$PROJECT_DIR$/spec/linear_solver_spec.rb" />
133
+ <option value="$PROJECT_DIR$/lib/linear_solver/calculation_unsolvable_error.rb" />
134
+ <option value="$PROJECT_DIR$/lib/linear_solver.rb" />
135
+ <option value="$PROJECT_DIR$/README.md" />
136
+ <option value="$PROJECT_DIR$/lib/linear_solver/version.rb" />
137
+ </list>
138
+ </option>
139
+ </component>
140
+ <component name="JsGulpfileManager">
141
+ <detection-done>true</detection-done>
142
+ </component>
143
+ <component name="ProjectFrameBounds">
144
+ <option name="width" value="1280" />
145
+ <option name="height" value="800" />
146
+ </component>
147
+ <component name="ProjectLevelVcsManager" settingsEditedManually="false">
148
+ <OptionsSetting value="true" id="Add" />
149
+ <OptionsSetting value="true" id="Remove" />
150
+ <OptionsSetting value="true" id="Checkout" />
151
+ <OptionsSetting value="true" id="Update" />
152
+ <OptionsSetting value="true" id="Status" />
153
+ <OptionsSetting value="true" id="Edit" />
154
+ <ConfirmationsSetting value="0" id="Add" />
155
+ <ConfirmationsSetting value="0" id="Remove" />
156
+ </component>
157
+ <component name="ProjectView">
158
+ <navigator currentView="ProjectPane" proportions="" version="1">
159
+ <flattenPackages />
160
+ <showMembers />
161
+ <showModules />
162
+ <showLibraryContents />
163
+ <hideEmptyPackages />
164
+ <abbreviatePackageNames />
165
+ <autoscrollToSource />
166
+ <autoscrollFromSource />
167
+ <sortByType />
168
+ </navigator>
169
+ <panes>
170
+ <pane id="Scope" />
171
+ <pane id="ProjectPane">
172
+ <subPane>
173
+ <PATH>
174
+ <PATH_ELEMENT>
175
+ <option name="myItemId" value="linear_solver" />
176
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
177
+ </PATH_ELEMENT>
178
+ </PATH>
179
+ <PATH>
180
+ <PATH_ELEMENT>
181
+ <option name="myItemId" value="linear_solver" />
182
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
183
+ </PATH_ELEMENT>
184
+ <PATH_ELEMENT>
185
+ <option name="myItemId" value="linear_solver" />
186
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
187
+ </PATH_ELEMENT>
188
+ </PATH>
189
+ <PATH>
190
+ <PATH_ELEMENT>
191
+ <option name="myItemId" value="linear_solver" />
192
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
193
+ </PATH_ELEMENT>
194
+ <PATH_ELEMENT>
195
+ <option name="myItemId" value="linear_solver" />
196
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
197
+ </PATH_ELEMENT>
198
+ <PATH_ELEMENT>
199
+ <option name="myItemId" value="spec" />
200
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
201
+ </PATH_ELEMENT>
202
+ </PATH>
203
+ <PATH>
204
+ <PATH_ELEMENT>
205
+ <option name="myItemId" value="linear_solver" />
206
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
207
+ </PATH_ELEMENT>
208
+ <PATH_ELEMENT>
209
+ <option name="myItemId" value="linear_solver" />
210
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
211
+ </PATH_ELEMENT>
212
+ <PATH_ELEMENT>
213
+ <option name="myItemId" value="lib" />
214
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
215
+ </PATH_ELEMENT>
216
+ </PATH>
217
+ <PATH>
218
+ <PATH_ELEMENT>
219
+ <option name="myItemId" value="linear_solver" />
220
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
221
+ </PATH_ELEMENT>
222
+ <PATH_ELEMENT>
223
+ <option name="myItemId" value="linear_solver" />
224
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
225
+ </PATH_ELEMENT>
226
+ <PATH_ELEMENT>
227
+ <option name="myItemId" value="lib" />
228
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
229
+ </PATH_ELEMENT>
230
+ <PATH_ELEMENT>
231
+ <option name="myItemId" value="linear_solver" />
232
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
233
+ </PATH_ELEMENT>
234
+ </PATH>
235
+ </subPane>
236
+ </pane>
237
+ </panes>
238
+ </component>
239
+ <component name="PropertiesComponent">
240
+ <property name="last_opened_file_path" value="$PROJECT_DIR$" />
241
+ <property name="WebServerToolWindowFactoryState" value="false" />
242
+ <property name="FullScreen" value="true" />
243
+ </component>
244
+ <component name="RunManager">
245
+ <configuration default="true" type="BashConfigurationType" factoryName="Bash">
246
+ <option name="INTERPRETER_OPTIONS" value="" />
247
+ <option name="INTERPRETER_PATH" value="/bin/bash" />
248
+ <option name="WORKING_DIRECTORY" value="" />
249
+ <option name="PARENT_ENVS" value="true" />
250
+ <option name="SCRIPT_NAME" value="" />
251
+ <option name="PARAMETERS" value="" />
252
+ <module name="" />
253
+ <envs />
254
+ <method />
255
+ </configuration>
256
+ <configuration default="true" type="RSpecRunConfigurationType" factoryName="RSpec">
257
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
258
+ <module name="" />
259
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
260
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="" />
261
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
262
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
263
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
264
+ <envs />
265
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
266
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
267
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
268
+ <COVERAGE_PATTERN ENABLED="true">
269
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
270
+ </COVERAGE_PATTERN>
271
+ </EXTENSION>
272
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
273
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
274
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
275
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
276
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
277
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
278
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
279
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
280
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
281
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
282
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
283
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
284
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
285
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
286
+ <method />
287
+ </configuration>
288
+ <configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
289
+ <method />
290
+ </configuration>
291
+ <configuration default="true" type="TestUnitRunConfigurationType" factoryName="Test::Unit/Shoulda/Minitest">
292
+ <predefined_log_file id="RUBY_TESTUNIT" enabled="true" />
293
+ <module name="" />
294
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
295
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="" />
296
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
297
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
298
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
299
+ <envs />
300
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
301
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
302
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
303
+ <COVERAGE_PATTERN ENABLED="true">
304
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
305
+ </COVERAGE_PATTERN>
306
+ </EXTENSION>
307
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
308
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
309
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
310
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="" />
311
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
312
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
313
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
314
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
315
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
316
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_OPTIONS" VALUE="" />
317
+ <method />
318
+ </configuration>
319
+ <configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
320
+ <node-options />
321
+ <gulpfile />
322
+ <tasks />
323
+ <pass-parent-envs>true</pass-parent-envs>
324
+ <envs />
325
+ <method />
326
+ </configuration>
327
+ <list size="0" />
328
+ </component>
329
+ <component name="ShelveChangesManager" show_recycled="false" />
330
+ <component name="SvnConfiguration">
331
+ <configuration />
332
+ </component>
333
+ <component name="TaskManager">
334
+ <task active="true" id="Default" summary="Default task">
335
+ <changelist id="d587cdd6-bd36-44b5-876d-fb8380d5e7f4" name="Default" comment="" />
336
+ <created>1442775703448</created>
337
+ <option name="number" value="Default" />
338
+ <updated>1442775703448</updated>
339
+ </task>
340
+ <servers />
341
+ </component>
342
+ <component name="ToolWindowManager">
343
+ <frame x="0" y="0" width="1280" height="800" extended-state="0" />
344
+ <editor active="true" />
345
+ <layout>
346
+ <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
347
+ <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
348
+ <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
349
+ <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
350
+ <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
351
+ <window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
352
+ <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.20274636" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
353
+ <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
354
+ <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.31086656" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
355
+ <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
356
+ <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
357
+ <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
358
+ <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
359
+ <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
360
+ <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
361
+ <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
362
+ <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
363
+ <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
364
+ <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
365
+ </layout>
366
+ </component>
367
+ <component name="Vcs.Log.UiProperties">
368
+ <option name="RECENTLY_FILTERED_USER_GROUPS">
369
+ <collection />
370
+ </option>
371
+ <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
372
+ <collection />
373
+ </option>
374
+ </component>
375
+ <component name="VcsContentAnnotationSettings">
376
+ <option name="myLimit" value="2678400000" />
377
+ </component>
378
+ <component name="VcsManagerConfiguration">
379
+ <option name="myTodoPanelSettings">
380
+ <TodoPanelSettings />
381
+ </option>
382
+ </component>
383
+ <component name="XDebuggerManager">
384
+ <breakpoint-manager />
385
+ <watches-manager />
386
+ </component>
387
+ <component name="editorHistoryManager">
388
+ <entry file="file://$PROJECT_DIR$/linear_solver.gemspec">
389
+ <provider selected="true" editor-type-id="text-editor">
390
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="450">
391
+ <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
392
+ <folding />
393
+ </state>
394
+ </provider>
395
+ </entry>
396
+ <entry file="file://$PROJECT_DIR$/lib/linear_solver.rb">
397
+ <provider selected="true" editor-type-id="text-editor">
398
+ <state vertical-scroll-proportion="0.0" vertical-offset="415" max-vertical-offset="915">
399
+ <caret line="41" column="27" selection-start-line="41" selection-start-column="27" selection-end-line="41" selection-end-column="27" />
400
+ <folding />
401
+ </state>
402
+ </provider>
403
+ </entry>
404
+ <entry file="file://$PROJECT_DIR$/lib/linear_solver/version.rb">
405
+ <provider selected="true" editor-type-id="text-editor">
406
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="135">
407
+ <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
408
+ <folding />
409
+ </state>
410
+ </provider>
411
+ </entry>
412
+ <entry file="file://$PROJECT_DIR$/Rakefile">
413
+ <provider selected="true" editor-type-id="text-editor">
414
+ <state vertical-scroll-proportion="0.0" vertical-offset="150" max-vertical-offset="240">
415
+ <caret line="10" column="22" selection-start-line="10" selection-start-column="22" selection-end-line="10" selection-end-column="22" />
416
+ <folding />
417
+ </state>
418
+ </provider>
419
+ </entry>
420
+ <entry file="file://$PROJECT_DIR$/spec/linear_solver_spec.rb">
421
+ <provider selected="true" editor-type-id="text-editor">
422
+ <state vertical-scroll-proportion="0.0" vertical-offset="2310" max-vertical-offset="2400">
423
+ <caret line="154" column="3" selection-start-line="154" selection-start-column="3" selection-end-line="154" selection-end-column="3" />
424
+ <folding />
425
+ </state>
426
+ </provider>
427
+ </entry>
428
+ <entry file="file://$PROJECT_DIR$/linear_solver.gemspec">
429
+ <provider selected="true" editor-type-id="text-editor">
430
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="450">
431
+ <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
432
+ <folding />
433
+ </state>
434
+ </provider>
435
+ </entry>
436
+ <entry file="file://$PROJECT_DIR$/lib/linear_solver.rb">
437
+ <provider selected="true" editor-type-id="text-editor">
438
+ <state vertical-scroll-proportion="0.0" vertical-offset="415" max-vertical-offset="915">
439
+ <caret line="41" column="27" selection-start-line="41" selection-start-column="27" selection-end-line="41" selection-end-column="27" />
440
+ <folding />
441
+ </state>
442
+ </provider>
443
+ </entry>
444
+ <entry file="file://$PROJECT_DIR$/lib/linear_solver/version.rb">
445
+ <provider selected="true" editor-type-id="text-editor">
446
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="135">
447
+ <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
448
+ <folding />
449
+ </state>
450
+ </provider>
451
+ </entry>
452
+ <entry file="file://$PROJECT_DIR$/Rakefile">
453
+ <provider selected="true" editor-type-id="text-editor">
454
+ <state vertical-scroll-proportion="0.0" vertical-offset="150" max-vertical-offset="240">
455
+ <caret line="10" column="22" selection-start-line="10" selection-start-column="22" selection-end-line="10" selection-end-column="22" />
456
+ <folding />
457
+ </state>
458
+ </provider>
459
+ </entry>
460
+ <entry file="file://$PROJECT_DIR$/spec/linear_solver_spec.rb">
461
+ <provider selected="true" editor-type-id="text-editor">
462
+ <state vertical-scroll-proportion="0.0" vertical-offset="2310" max-vertical-offset="2400">
463
+ <caret line="154" column="3" selection-start-line="154" selection-start-column="3" selection-end-line="154" selection-end-column="3" />
464
+ <folding />
465
+ </state>
466
+ </provider>
467
+ </entry>
468
+ <entry file="file://$PROJECT_DIR$/linear_solver.gemspec">
469
+ <provider selected="true" editor-type-id="text-editor">
470
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="480">
471
+ <caret line="24" column="47" selection-start-line="24" selection-start-column="47" selection-end-line="24" selection-end-column="47" />
472
+ <folding />
473
+ </state>
474
+ </provider>
475
+ </entry>
476
+ <entry file="file://$PROJECT_DIR$/lib/linear_solver/calculation_unsolvable_error.rb">
477
+ <provider selected="true" editor-type-id="text-editor">
478
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="135">
479
+ <caret line="3" column="3" selection-start-line="3" selection-start-column="3" selection-end-line="3" selection-end-column="3" />
480
+ <folding />
481
+ </state>
482
+ </provider>
483
+ </entry>
484
+ <entry file="file://$PROJECT_DIR$/Rakefile">
485
+ <provider selected="true" editor-type-id="text-editor">
486
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="240">
487
+ <caret line="10" column="22" selection-start-line="10" selection-start-column="22" selection-end-line="10" selection-end-column="22" />
488
+ <folding />
489
+ </state>
490
+ </provider>
491
+ </entry>
492
+ <entry file="file://$PROJECT_DIR$/spec/spec_helper.rb">
493
+ <provider selected="true" editor-type-id="text-editor">
494
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="90">
495
+ <caret line="0" column="23" selection-start-line="0" selection-start-column="23" selection-end-line="0" selection-end-column="23" />
496
+ <folding />
497
+ </state>
498
+ </provider>
499
+ </entry>
500
+ <entry file="file://$PROJECT_DIR$/Guardfile">
501
+ <provider selected="true" editor-type-id="text-editor">
502
+ <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="240">
503
+ <caret line="10" column="3" selection-start-line="10" selection-start-column="3" selection-end-line="10" selection-end-column="3" />
504
+ <folding />
505
+ </state>
506
+ </provider>
507
+ </entry>
508
+ <entry file="file://$PROJECT_DIR$/spec/linear_solver_spec.rb">
509
+ <provider selected="true" editor-type-id="text-editor">
510
+ <state vertical-scroll-proportion="0.0" vertical-offset="1701" max-vertical-offset="2400">
511
+ <caret line="88" column="9" selection-start-line="88" selection-start-column="9" selection-end-line="88" selection-end-column="9" />
512
+ <folding />
513
+ </state>
514
+ </provider>
515
+ </entry>
516
+ <entry file="file://$PROJECT_DIR$/lib/linear_solver.rb">
517
+ <provider selected="true" editor-type-id="text-editor">
518
+ <state vertical-scroll-proportion="0.0" vertical-offset="66" max-vertical-offset="855">
519
+ <caret line="27" column="29" selection-start-line="27" selection-start-column="29" selection-end-line="27" selection-end-column="29" />
520
+ <folding />
521
+ </state>
522
+ </provider>
523
+ </entry>
524
+ <entry file="file://$PROJECT_DIR$/README.md">
525
+ <provider selected="true" editor-type-id="text-editor">
526
+ <state vertical-scroll-proportion="-10.76" vertical-offset="331" max-vertical-offset="1155">
527
+ <caret line="40" column="9" selection-start-line="40" selection-start-column="9" selection-end-line="40" selection-end-column="9" />
528
+ <folding />
529
+ </state>
530
+ </provider>
531
+ </entry>
532
+ <entry file="file://$PROJECT_DIR$/lib/linear_solver/version.rb">
533
+ <provider selected="true" editor-type-id="text-editor">
534
+ <state vertical-scroll-proportion="0.021459227" vertical-offset="0" max-vertical-offset="699">
535
+ <caret line="1" column="18" selection-start-line="1" selection-start-column="18" selection-end-line="1" selection-end-column="18" />
536
+ <folding />
537
+ </state>
538
+ </provider>
539
+ </entry>
540
+ </component>
541
+ </project>
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in linear_solver.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard 'rspec' do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 stantoncbradley
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # LinearSolver
2
+
3
+ Given y in y = f(x), solves for x in log(n) time.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'linear_solver'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install linear_solver
18
+
19
+ ## Usage
20
+
21
+ Use the linear solver when it is difficult/inconvenient/impossible to invert y = f(x) to solve for x.<br />
22
+ *Notes:<br />
23
+ 1. this gem only solves for linear equations, and thus only returns one value. For example, given y = x^2, solving for y = 16 will return EITHER 4 OR -4 (depending on the starting value provided).<br />
24
+ 2. linear solver cannot handle formula specific edge-cases (like divide by 0). If the equation you provide has invalid cases, you must be responsible for handling them yourself.<br />
25
+
26
+ Linear solver works in 5 steps:<br />
27
+ 1. Evaluate x = 0.0 case. This eliminates solving for the 0 limit, of which the solver only approaches.<br />
28
+ 2. Convert starting_value to 1 if it is 0. The solver works by iteratively multiplying and dividing this value, so it cannot be 0.<br />
29
+ 3. Determine whether x will be greater than or less than 0. The solver needs to know if the bounds are -infinity to 0 or 0 to infinity.<br />
30
+ 4. Determine upper limit (toward +/-infinity) by iteratively multiplying by 2 until f(x) > goal (< goal if x is negative).<br />
31
+ 5. Iteratively decrease and increase x by 1/2 step intervals until stopping condition is satisfied (hence log(n) performance).<br />
32
+
33
+ Linear solver has two methods:
34
+
35
+ <b>solve_equal</b> solves for x using (y == goal). For example:
36
+
37
+ ```
38
+ def f(x)
39
+ 2 * x
40
+ end
41
+ goal = 10
42
+ starting_value = 0
43
+ LinearSolver::solve_equal(goal, starting_value) do |result|
44
+ y = f(result)
45
+ end
46
+ ```
47
+ LinearSolver will return 5.
48
+
49
+ For more flexibility, the method <b>solve_with_stopper</b> takes a lamdba expression in the form of<br />
50
+ ```->(output,goal){ conditional expression }```
51
+ which allows custom rules for solving the equation. Example:
52
+
53
+ ```
54
+ def f(x)
55
+ 2 * x
56
+ end
57
+ goal = 10
58
+ starting_value = 0
59
+ LinearSolver::solve_with_stopper(goal, starting_value, ->(output, goal) { output > goal }) do |result|
60
+ y = f(result)
61
+ end
62
+ ```
63
+ In this case, LinearSolver will return the first value it generates that satisfies f(x) > 10.
64
+
65
+ ## Contributing
66
+
67
+ 1. Fork it ( https://github.com/stantoncbradley/linear_solver/fork )
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+ require 'bundler/gem_tasks'
4
+
5
+ # Default directory to look in is `/specs`
6
+ # Run with `rake spec`
7
+ RSpec::Core::RakeTask.new(:spec) do |task|
8
+ task.rspec_opts = ['--color', '--format', 'nested']
9
+ end
10
+
11
+ task :default => :spec
@@ -0,0 +1,51 @@
1
+ require "linear_solver/version"
2
+ require "linear_solver/calculation_unsolvable_error"
3
+
4
+ module LinearSolver
5
+
6
+ def self.solve_equal(goal, starting_value, &block)
7
+ self.solve_with_stopper(goal, starting_value, ->(a, b) { a == b }, &block)
8
+ end
9
+
10
+ def self.solve_with_stopper(goal, starting_value, stopping_comparator, &block)
11
+ raise StandardError unless block_given?
12
+
13
+ return 0.0 if stopping_comparator.call(block.call(0.0), goal)
14
+
15
+ starting_value = 1 if starting_value == 0
16
+ starting_value = starting_value.to_f
17
+ goal = goal.to_f
18
+
19
+ block.call(0) < goal ? input = starting_value.abs : input = -(starting_value.abs)
20
+
21
+ upper_bounds_counter = 0
22
+ if input < 0
23
+ while block.call(input) > goal && upper_bounds_counter < 10000
24
+ input *= 2
25
+ upper_bounds_counter += 1
26
+ end
27
+ else
28
+ while block.call(input) < goal && upper_bounds_counter < 10000
29
+ input *= 2
30
+ upper_bounds_counter += 1
31
+ end
32
+ end
33
+ raise CalculationUnsolvableError.new("Upper bound reached, goal: #{goal}, starting value: #{starting_value}, input: #{input}") if upper_bounds_counter >= 10000
34
+
35
+ output = block.call(input)
36
+ unless stopping_comparator.call(output, goal)
37
+ difference = input.abs
38
+ asymptote_counter = 0
39
+ begin
40
+ difference /= 2
41
+ input += difference if output < goal
42
+ input -= difference if output > goal
43
+ asymptote_counter += 1
44
+ output = block.call(input)
45
+ end until (stopping_comparator.call(output, goal) || asymptote_counter == 10000)
46
+ raise CalculationUnsolvableError.new("Lower bound asymptote reached, goal: #{goal}, starting value: #{starting_value}, input: #{input}") if asymptote_counter == 10000
47
+ end
48
+ return input
49
+ end
50
+
51
+ end
@@ -0,0 +1,4 @@
1
+ # raised when linear solver reaches upper limit or asymptote limit
2
+ class CalculationUnsolvableError < StandardError
3
+
4
+ end
@@ -0,0 +1,3 @@
1
+ module LinearSolver
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'linear_solver/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "linear_solver"
8
+ spec.version = LinearSolver::VERSION
9
+ spec.authors = ["stantoncbradley"]
10
+ spec.email = ["stantoncbradley@gmail.com"]
11
+ spec.summary = ["Brute force solve equations in log(n) time"]
12
+ spec.description = ["For y = f(x), given y, solves for x."]
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "guard"
25
+ spec.add_development_dependency "guard-rspec"
26
+ end
@@ -0,0 +1,155 @@
1
+ require 'spec_helper'
2
+ describe LinearSolver do
3
+
4
+ context 'given invalid params' do
5
+
6
+ it 'raises calculation unsolvable error if upper bounds limit is reached before input > goal' do
7
+ expect {
8
+ goal = 1
9
+ LinearSolver::solve_equal(goal, 1) do |input|
10
+ input = 1 if input == 0
11
+ 0 / input
12
+ end
13
+ }.to raise_exception(CalculationUnsolvableError)
14
+ end
15
+
16
+ it 'raises calculation unsolvable error if lower bound asymptote reached before f(input) = goal' do
17
+ expect {
18
+ goal = 0
19
+ LinearSolver::solve_equal(goal, 1) do |input|
20
+ input = 1 if input == 0
21
+ 0 / input + 1
22
+ end
23
+ }.to raise_exception(CalculationUnsolvableError)
24
+ end
25
+
26
+ it 'raises error if no code block given' do
27
+ goal = 10
28
+ starting_value = 5
29
+ expect do
30
+ LinearSolver::solve_equal(goal, starting_value)
31
+ end.to raise_exception
32
+ end
33
+
34
+ end
35
+
36
+
37
+ context 'given valid params' do
38
+
39
+ context 'y = x/2 + 5' do
40
+ before(:each) do
41
+ def self.function(input)
42
+ input / 2 + 5
43
+ end
44
+
45
+ @starting_value = 100
46
+ end
47
+
48
+ it 'solves for positive goal and positive input' do
49
+ goal = 10
50
+ input = LinearSolver::solve_equal(goal, @starting_value) do |input|
51
+ self.function(input)
52
+ end
53
+ expect(input).to eql(10.000000000000002)
54
+ end
55
+
56
+ it 'solves for positive y and x = 0' do
57
+ goal = 5
58
+ input = LinearSolver::solve_equal(goal, @starting_value) do |input|
59
+ self.function(input)
60
+ end
61
+ expect(input).to eql(0.0)
62
+ end
63
+
64
+ it 'solves for positive y and negative x' do
65
+ starting_value = -100
66
+ goal = 4
67
+ input = LinearSolver::solve_equal(goal, starting_value) do |input|
68
+ self.function(input)
69
+ end
70
+ expect(input).to eql(-1.9999999999999991)
71
+ end
72
+
73
+ it 'solves for y = 0 and negative x' do
74
+ starting_value = -100
75
+ goal = 0
76
+ input = LinearSolver::solve_equal(goal, starting_value) do |input|
77
+ self.function(input)
78
+ end
79
+ expect(input).to eql(-10.0)
80
+ end
81
+
82
+ it 'solves for negative y and negative x' do
83
+ starting_value = -100
84
+ goal = -10
85
+ input = LinearSolver::solve_equal(goal, starting_value) do |input|
86
+ self.function(input)
87
+ end
88
+ expect(input).to eql(-30.0)
89
+ end
90
+
91
+ end
92
+
93
+ context 'y = x/2' do
94
+
95
+ it 'solves for the origin (0,0)' do
96
+ def self.function(input)
97
+ input / 2
98
+ end
99
+
100
+ starting_value = -100
101
+ goal = 0
102
+ input = LinearSolver::solve_equal(goal, starting_value) do |input|
103
+ self.function(input)
104
+ end
105
+ expect(input).to eql(0.0)
106
+ end
107
+
108
+ end
109
+
110
+ context 'y = x/2 - 5' do
111
+ before(:each) do
112
+ def self.function(input)
113
+ input / 2 - 5
114
+ end
115
+
116
+ @starting_value = 1
117
+ end
118
+
119
+ it 'solves goal = 0' do
120
+ goal = 0
121
+ input = LinearSolver::solve_equal(goal, @starting_value) do |input|
122
+ self.function(input)
123
+ end
124
+ expect(input).to eql(10.0)
125
+ end
126
+
127
+ it 'solves positive x and negative y' do
128
+ goal = -4
129
+ input = LinearSolver::solve_equal(goal, @starting_value) do |input|
130
+ self.function(input)
131
+ end
132
+ expect(input).to eql(2.0)
133
+ end
134
+
135
+ it 'solves x = 0 and negative y' do
136
+ goal = -5
137
+ input = LinearSolver::solve_equal(goal, @starting_value) do |input|
138
+ self.function(input)
139
+ end
140
+ expect(input).to eql(0.0)
141
+ end
142
+
143
+ it 'solvers if starting value is 0' do
144
+ goal = 10
145
+ starting_value = 0
146
+ input = LinearSolver::solve_equal(goal, starting_value) do |input|
147
+ input
148
+ end
149
+ expect(input).to eql 10.0
150
+ end
151
+
152
+ end
153
+ end
154
+
155
+ end
@@ -0,0 +1 @@
1
+ require 'linear_solver'
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: linear_solver
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - stantoncbradley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: '["For y = f(x), given y, solves for x."]'
84
+ email:
85
+ - stantoncbradley@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .idea/.name
92
+ - .idea/.rakeTasks
93
+ - .idea/encodings.xml
94
+ - .idea/linear_solver.iml
95
+ - .idea/misc.xml
96
+ - .idea/modules.xml
97
+ - .idea/scopes/scope_settings.xml
98
+ - .idea/vcs.xml
99
+ - .idea/workspace.xml
100
+ - Gemfile
101
+ - Guardfile
102
+ - LICENSE.txt
103
+ - README.md
104
+ - Rakefile
105
+ - lib/linear_solver.rb
106
+ - lib/linear_solver/calculation_unsolvable_error.rb
107
+ - lib/linear_solver/version.rb
108
+ - linear_solver.gemspec
109
+ - spec/linear_solver_spec.rb
110
+ - spec/spec_helper.rb
111
+ homepage: ''
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.2.2
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: '["Brute force solve equations in log(n) time"]'
135
+ test_files:
136
+ - spec/linear_solver_spec.rb
137
+ - spec/spec_helper.rb