linmeric 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/Rakefile +10 -0
- data/bin/help/Help.rb +184 -0
- data/bin/help/Help_inst.rb +244 -0
- data/bin/linguide +23 -0
- data/bin/linmeric +36 -70
- data/doc/Archive.html +352 -0
- data/doc/Calculator/Evaluator.html +477 -0
- data/doc/Calculator/Lexer.html +186 -0
- data/doc/Calculator/Token.html +257 -0
- data/doc/Calculator.html +181 -0
- data/doc/Dim.html +257 -0
- data/doc/Filename.html +246 -0
- data/doc/Fixnum.html +253 -0
- data/doc/Float.html +253 -0
- data/doc/Function.html +784 -0
- data/doc/InputError.html +102 -0
- data/doc/Instructions_en.txt +6 -7
- data/doc/Instructions_it.txt +6 -9
- data/doc/Integrators.html +436 -0
- data/doc/LU.html +435 -0
- data/doc/Lexer.html +261 -0
- data/doc/Linmeric.html +109 -0
- data/doc/Listener.html +605 -0
- data/doc/Matrix.html +1719 -0
- data/doc/MyArgError.html +102 -0
- data/doc/NilClass.html +202 -0
- data/doc/Numeric.html +251 -0
- data/doc/Parser.html +389 -0
- data/doc/PrintError.html +622 -0
- data/doc/README_md.html +142 -0
- data/doc/Scp.html +530 -0
- data/doc/Sizer.html +652 -0
- data/doc/String.html +540 -0
- data/doc/Token.html +341 -0
- data/doc/Tool.html +394 -0
- data/doc/created.rid +18 -0
- data/doc/css/fonts.css +167 -0
- data/doc/css/rdoc.css +590 -0
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +190 -0
- data/doc/js/darkfish.js +161 -0
- data/doc/js/jquery.js +9404 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +109 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +228 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +834 -0
- data/lib/linmeric/Archive.rb +22 -1
- data/lib/linmeric/Calculator.rb +252 -0
- data/lib/linmeric/CnGal_Matrix_class.rb +130 -49
- data/lib/linmeric/CnGal_new_classes.rb +139 -37
- data/lib/linmeric/CnGal_tools.rb +23 -40
- data/lib/linmeric/Error_print.rb +35 -1
- data/lib/linmeric/Function_class.rb +70 -11
- data/lib/linmeric/Integrators.rb +81 -35
- data/lib/linmeric/LU.rb +26 -5
- data/lib/linmeric/Lexer.rb +19 -1
- data/lib/linmeric/Listener.rb +25 -5
- data/lib/linmeric/Parser.rb +23 -1
- data/lib/linmeric/Scopify.rb +52 -31
- data/lib/linmeric/Sizer.rb +43 -10
- data/lib/linmeric/Token.rb +23 -4
- data/lib/linmeric/version.rb +3 -0
- data/lib/linmeric.rb +10 -8
- data/lib/linmeric_bin.rb +12 -0
- metadata +126 -22
- data/doc/Instructions_en.html +0 -231
- data/doc/Instructions_it.html +0 -231
- data/doc/README_en.html +0 -177
- data/doc/README_en.txt +0 -30
- data/doc/README_it.html +0 -187
- data/doc/README_it.txt +0 -32
data/doc/InputError.html
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
|
|
7
|
+
<title>class InputError - RDoc Documentation</title>
|
|
8
|
+
|
|
9
|
+
<script type="text/javascript">
|
|
10
|
+
var rdoc_rel_prefix = "./";
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script src="./js/jquery.js"></script>
|
|
14
|
+
<script src="./js/darkfish.js"></script>
|
|
15
|
+
|
|
16
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
|
17
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<body id="top" role="document" class="class">
|
|
22
|
+
<nav role="navigation">
|
|
23
|
+
<div id="project-navigation">
|
|
24
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
|
25
|
+
<h2>
|
|
26
|
+
<a href="./index.html" rel="home">Home</a>
|
|
27
|
+
</h2>
|
|
28
|
+
|
|
29
|
+
<div id="table-of-contents-navigation">
|
|
30
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
|
31
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
|
32
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
|
37
|
+
<form action="#" method="get" accept-charset="utf-8">
|
|
38
|
+
<div id="search-field-wrapper">
|
|
39
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
|
40
|
+
aria-autocomplete="list" aria-controls="search-results"
|
|
41
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
|
42
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<ul id="search-results" aria-label="Search Results"
|
|
46
|
+
aria-busy="false" aria-expanded="false"
|
|
47
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
|
48
|
+
</form>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
<div id="class-metadata">
|
|
56
|
+
|
|
57
|
+
<div id="parent-class-section" class="nav-section">
|
|
58
|
+
<h3>Parent</h3>
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
<p class="link">ArgumentError
|
|
62
|
+
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
</div>
|
|
69
|
+
</nav>
|
|
70
|
+
|
|
71
|
+
<main role="main" aria-labelledby="class-InputError">
|
|
72
|
+
<h1 id="class-InputError" class="class">
|
|
73
|
+
class InputError
|
|
74
|
+
</h1>
|
|
75
|
+
|
|
76
|
+
<section class="description">
|
|
77
|
+
|
|
78
|
+
</section>
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
</section>
|
|
94
|
+
</main>
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
<footer id="validator-badges" role="contentinfo">
|
|
98
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
|
99
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
|
100
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
|
101
|
+
</footer>
|
|
102
|
+
|
data/doc/Instructions_en.txt
CHANGED
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
Examples: fx = f: "x*log(x)"
|
|
68
68
|
gx = f: "y^z"
|
|
69
69
|
|
|
70
|
-
At the moment, the following algebric
|
|
70
|
+
At the moment, the following algebric functions are supported: log, sin, cos, exp, tan
|
|
71
71
|
Constants: PI (PI = 3,14...)
|
|
72
72
|
|
|
73
73
|
Restriction: parameters must be composed by only one letter (x,y,k,a...)
|
|
@@ -114,9 +114,7 @@
|
|
|
114
114
|
/ (Matrix-number) It divides each element of the specified matrix for the given number
|
|
115
115
|
^ (Matrix-number) It elevates each element at the given exponent
|
|
116
116
|
|
|
117
|
-
It is possible to insert as value simple operations as 3/4, 10^5...
|
|
118
|
-
so it may not give the correct output in case of complex operations. I'll provide as soon as possible a new version
|
|
119
|
-
of this gem with this improvement
|
|
117
|
+
It is possible to insert as value simple operations as 3/4, 10^5...
|
|
120
118
|
|
|
121
119
|
__________________________
|
|
122
120
|
#_OPERATIONS ON MATRICES_#
|
|
@@ -192,10 +190,11 @@
|
|
|
192
190
|
or
|
|
193
191
|
<variable_name> > "<file_path>"
|
|
194
192
|
|
|
195
|
-
Examples: 23 > "home/usr/Desktop/val.txt" // the number 23 will be written in val.txt. If the file does not exist,
|
|
196
|
-
|
|
193
|
+
Examples: 23 > "/home/usr/Desktop/val.txt" // the number 23 will be written in val.txt. If the file does not exist,
|
|
194
|
+
it will be created
|
|
195
|
+
s*q0+1 > "/home/usr/Desktop/val.txt" // the result of 's*q0+1' will be written in val.txt (s,q0 are variables)
|
|
197
196
|
// mk: 8x8 matrix
|
|
198
|
-
mk > "home/usr/Desktop/matrx.csv" // Matrix 'mk' will be written in matrix.csv
|
|
197
|
+
mk > "/home/usr/Desktop/matrx.csv" // Matrix 'mk' will be written in matrix.csv
|
|
199
198
|
|
|
200
199
|
|
|
201
200
|
|
data/doc/Instructions_it.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
LINMERIC:
|
|
2
|
+
LINMERIC: progettato e sviluppato da Massimiliano Dal Mas
|
|
3
3
|
|
|
4
4
|
Email: max.codeware@gmail.com
|
|
5
5
|
|
|
@@ -111,10 +111,7 @@
|
|
|
111
111
|
|
|
112
112
|
Operazioni consentite: +,-,*,/ (per uno scalare),^ (per uno scalare)
|
|
113
113
|
|
|
114
|
-
E' possibile inserire come valori in una matrice semplici operazioni come 3/4, 10^5;
|
|
115
|
-
l'algoritmo di conversione non è particolarmente performante, pertanto potrebbe non restituire il risultato corretto in caso di operazioni
|
|
116
|
-
un po' più complesse.
|
|
117
|
-
Provvederò non appena possibile a pubblicare una nuova versione della gem con questo miglioramento
|
|
114
|
+
E' possibile inserire come valori in una matrice semplici operazioni come 3/4, 10^5;
|
|
118
115
|
|
|
119
116
|
_________________________
|
|
120
117
|
#_OPERAZIONI SU MATRICI_#
|
|
@@ -189,10 +186,10 @@
|
|
|
189
186
|
oppure
|
|
190
187
|
<nome_variabile> > "<percorso_file>"
|
|
191
188
|
|
|
192
|
-
Esempi: 23 > "home/usr/Desktop/val.txt" // scrive il numero 23 sul file indicato. Se non esiste il file viene creato
|
|
193
|
-
s*q0+1 > "home/usr/Desktop/val.txt" // scrive il risultato dell'espressione sul file indicato
|
|
194
|
-
|
|
195
|
-
mk > "home/usr/Desktop/matrice.csv" // scrive la matrice 'mk' sul file csv indicato.
|
|
189
|
+
Esempi: 23 > "/home/usr/Desktop/val.txt" // scrive il numero 23 sul file indicato. Se non esiste il file viene creato
|
|
190
|
+
s*q0+1 > "/home/usr/Desktop/val.txt" // scrive il risultato dell'espressione sul file indicato
|
|
191
|
+
// mk: matrice 8x8
|
|
192
|
+
mk > "/home/usr/Desktop/matrice.csv" // scrive la matrice 'mk' sul file csv indicato.
|
|
196
193
|
|
|
197
194
|
|
|
198
195
|
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
|
|
7
|
+
<title>module Integrators - RDoc Documentation</title>
|
|
8
|
+
|
|
9
|
+
<script type="text/javascript">
|
|
10
|
+
var rdoc_rel_prefix = "./";
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script src="./js/jquery.js"></script>
|
|
14
|
+
<script src="./js/darkfish.js"></script>
|
|
15
|
+
|
|
16
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
|
17
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<body id="top" role="document" class="module">
|
|
22
|
+
<nav role="navigation">
|
|
23
|
+
<div id="project-navigation">
|
|
24
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
|
25
|
+
<h2>
|
|
26
|
+
<a href="./index.html" rel="home">Home</a>
|
|
27
|
+
</h2>
|
|
28
|
+
|
|
29
|
+
<div id="table-of-contents-navigation">
|
|
30
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
|
31
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
|
32
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
|
37
|
+
<form action="#" method="get" accept-charset="utf-8">
|
|
38
|
+
<div id="search-field-wrapper">
|
|
39
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
|
40
|
+
aria-autocomplete="list" aria-controls="search-results"
|
|
41
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
|
42
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<ul id="search-results" aria-label="Search Results"
|
|
46
|
+
aria-busy="false" aria-expanded="false"
|
|
47
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
|
48
|
+
</form>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
<div id="class-metadata">
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
<!-- Method Quickref -->
|
|
61
|
+
<div id="method-list-section" class="nav-section">
|
|
62
|
+
<h3>Methods</h3>
|
|
63
|
+
|
|
64
|
+
<ul class="link-list" role="directory">
|
|
65
|
+
|
|
66
|
+
<li ><a href="#method-c-boole">::boole</a>
|
|
67
|
+
|
|
68
|
+
<li ><a href="#method-c-midpoint">::midpoint</a>
|
|
69
|
+
|
|
70
|
+
<li ><a href="#method-c-rettdx">::rettdx</a>
|
|
71
|
+
|
|
72
|
+
<li ><a href="#method-c-rettsx">::rettsx</a>
|
|
73
|
+
|
|
74
|
+
<li ><a href="#method-c-simpson">::simpson</a>
|
|
75
|
+
|
|
76
|
+
<li ><a href="#method-c-trapezi">::trapezi</a>
|
|
77
|
+
|
|
78
|
+
</ul>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
</div>
|
|
82
|
+
</nav>
|
|
83
|
+
|
|
84
|
+
<main role="main" aria-labelledby="module-Integrators">
|
|
85
|
+
<h1 id="module-Integrators" class="module">
|
|
86
|
+
module Integrators
|
|
87
|
+
</h1>
|
|
88
|
+
|
|
89
|
+
<section class="description">
|
|
90
|
+
|
|
91
|
+
<p>This module provides some method to integrate a function</p>
|
|
92
|
+
<dl class="rdoc-list note-list"><dt>Author
|
|
93
|
+
<dd>
|
|
94
|
+
<p>Massimiliano Dal Mas (<a
|
|
95
|
+
href="mailto:max.codeware@gmail.com">max.codeware@gmail.com</a>)</p>
|
|
96
|
+
</dd><dt>License
|
|
97
|
+
<dd>
|
|
98
|
+
<p>Distributed under MIT license</p>
|
|
99
|
+
</dd></dl>
|
|
100
|
+
|
|
101
|
+
</section>
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
|
117
|
+
<header>
|
|
118
|
+
<h3>Public Class Methods</h3>
|
|
119
|
+
</header>
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
<div id="method-c-boole" class="method-detail ">
|
|
123
|
+
|
|
124
|
+
<div class="method-heading">
|
|
125
|
+
<span class="method-name">boole</span><span
|
|
126
|
+
class="method-args">(a,b,n) { |a| ... }</span>
|
|
127
|
+
|
|
128
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
129
|
+
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
<div class="method-description">
|
|
134
|
+
|
|
135
|
+
<p>Implementation of Boole's method</p>
|
|
136
|
+
<ul><li>
|
|
137
|
+
<p>*<strong>argument</strong>*: left range value</p>
|
|
138
|
+
</li><li>
|
|
139
|
+
<p>*<strong>argument</strong>*: right range value</p>
|
|
140
|
+
</li><li>
|
|
141
|
+
<p>*<strong>argument</strong>*: number of integration points</p>
|
|
142
|
+
</li><li>
|
|
143
|
+
<p>*<strong>returns</strong>*: result of the operation (Numeric)</p>
|
|
144
|
+
</li></ul>
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
<div class="method-source-code" id="boole-source">
|
|
150
|
+
<pre><span class="ruby-comment"># File lib/linmeric/Integrators.rb, line 109</span>
|
|
151
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">boole</span>(<span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span>,<span class="ruby-identifier">n</span>)
|
|
152
|
+
<span class="ruby-identifier">h</span> = (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">/</span> (<span class="ruby-value">4</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">to_f</span>)
|
|
153
|
+
<span class="ruby-identifier">part</span> = <span class="ruby-value">0</span>
|
|
154
|
+
<span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> <span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">n</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
|
|
155
|
+
<span class="ruby-identifier">part</span> <span class="ruby-operator">+=</span> <span class="ruby-value">7</span> <span class="ruby-operator">*</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">h</span> <span class="ruby-operator">*</span> <span class="ruby-value">4</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">i</span>)) <span class="ruby-operator">+</span>
|
|
156
|
+
<span class="ruby-value">32</span> <span class="ruby-operator">*</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">h</span> <span class="ruby-operator">*</span> (<span class="ruby-value">4</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>))) <span class="ruby-operator">+</span>
|
|
157
|
+
<span class="ruby-value">12</span> <span class="ruby-operator">*</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">h</span> <span class="ruby-operator">*</span> (<span class="ruby-value">4</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span>))) <span class="ruby-operator">+</span>
|
|
158
|
+
<span class="ruby-value">32</span> <span class="ruby-operator">*</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">h</span> <span class="ruby-operator">*</span> (<span class="ruby-value">4</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">3</span>))) <span class="ruby-operator">+</span>
|
|
159
|
+
<span class="ruby-value">7</span> <span class="ruby-operator">*</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">h</span> <span class="ruby-operator">*</span> (<span class="ruby-value">4</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">4</span>)))
|
|
160
|
+
<span class="ruby-keyword">end</span>
|
|
161
|
+
<span class="ruby-keyword">return</span> (<span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">h</span>) <span class="ruby-operator">/</span> <span class="ruby-value">45.0</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">part</span>
|
|
162
|
+
<span class="ruby-keyword">end</span></pre>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
<div id="method-c-midpoint" class="method-detail ">
|
|
174
|
+
|
|
175
|
+
<div class="method-heading">
|
|
176
|
+
<span class="method-name">midpoint</span><span
|
|
177
|
+
class="method-args">(a,b,n) { |a| ... }</span>
|
|
178
|
+
|
|
179
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
180
|
+
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
<div class="method-description">
|
|
185
|
+
|
|
186
|
+
<p>Implementation of midpoint method</p>
|
|
187
|
+
<ul><li>
|
|
188
|
+
<p>*<strong>argument</strong>*: left range value</p>
|
|
189
|
+
</li><li>
|
|
190
|
+
<p>*<strong>argument</strong>*: right range value</p>
|
|
191
|
+
</li><li>
|
|
192
|
+
<p>*<strong>argument</strong>*: number of integration points</p>
|
|
193
|
+
</li><li>
|
|
194
|
+
<p>*<strong>returns</strong>*: result of the operation (Numeric)</p>
|
|
195
|
+
</li></ul>
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
<div class="method-source-code" id="midpoint-source">
|
|
201
|
+
<pre><span class="ruby-comment"># File lib/linmeric/Integrators.rb, line 38</span>
|
|
202
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">midpoint</span>(<span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span>,<span class="ruby-identifier">n</span>)
|
|
203
|
+
<span class="ruby-identifier">parz</span> = <span class="ruby-value">0</span>
|
|
204
|
+
<span class="ruby-identifier">h</span> = (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">to_f</span>
|
|
205
|
+
<span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> <span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">n</span>
|
|
206
|
+
<span class="ruby-identifier">f1</span> = <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">0.5</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">h</span>)
|
|
207
|
+
<span class="ruby-identifier">parz</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">f1</span>
|
|
208
|
+
<span class="ruby-keyword">end</span>
|
|
209
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">h</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">parz</span>
|
|
210
|
+
<span class="ruby-keyword">end</span></pre>
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
<div id="method-c-rettdx" class="method-detail ">
|
|
222
|
+
|
|
223
|
+
<div class="method-heading">
|
|
224
|
+
<span class="method-name">rettdx</span><span
|
|
225
|
+
class="method-args">(a,b,n) { |a| ... }</span>
|
|
226
|
+
|
|
227
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
228
|
+
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
<div class="method-description">
|
|
233
|
+
|
|
234
|
+
<p>Implementation of right rectangles method</p>
|
|
235
|
+
<ul><li>
|
|
236
|
+
<p>*<strong>argument</strong>*: left range value</p>
|
|
237
|
+
</li><li>
|
|
238
|
+
<p>*<strong>argument</strong>*: right range value</p>
|
|
239
|
+
</li><li>
|
|
240
|
+
<p>*<strong>argument</strong>*: number of integration points</p>
|
|
241
|
+
</li><li>
|
|
242
|
+
<p>*<strong>returns</strong>*: result of the operation (Numeric)</p>
|
|
243
|
+
</li></ul>
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
<div class="method-source-code" id="rettdx-source">
|
|
249
|
+
<pre><span class="ruby-comment"># File lib/linmeric/Integrators.rb, line 94</span>
|
|
250
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">rettdx</span>(<span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span>,<span class="ruby-identifier">n</span>)
|
|
251
|
+
<span class="ruby-identifier">h</span> = (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">to_f</span>
|
|
252
|
+
<span class="ruby-identifier">area</span> = <span class="ruby-value">0</span>
|
|
253
|
+
<span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> <span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">n</span>
|
|
254
|
+
<span class="ruby-identifier">area</span> <span class="ruby-operator">+=</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">h</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">i</span>)) <span class="ruby-operator">*</span> <span class="ruby-identifier">h</span>
|
|
255
|
+
<span class="ruby-keyword">end</span>
|
|
256
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">area</span>
|
|
257
|
+
<span class="ruby-keyword">end</span></pre>
|
|
258
|
+
</div>
|
|
259
|
+
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
</div>
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
<div id="method-c-rettsx" class="method-detail ">
|
|
269
|
+
|
|
270
|
+
<div class="method-heading">
|
|
271
|
+
<span class="method-name">rettsx</span><span
|
|
272
|
+
class="method-args">(a,b,n) { |a| ... }</span>
|
|
273
|
+
|
|
274
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
275
|
+
|
|
276
|
+
</div>
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
<div class="method-description">
|
|
280
|
+
|
|
281
|
+
<p>Implementation of left rectangles method</p>
|
|
282
|
+
<ul><li>
|
|
283
|
+
<p>*<strong>argument</strong>*: left range value</p>
|
|
284
|
+
</li><li>
|
|
285
|
+
<p>*<strong>argument</strong>*: right range value</p>
|
|
286
|
+
</li><li>
|
|
287
|
+
<p>*<strong>argument</strong>*: number of integration points</p>
|
|
288
|
+
</li><li>
|
|
289
|
+
<p>*<strong>returns</strong>*: result of the operation (Numeric)</p>
|
|
290
|
+
</li></ul>
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
<div class="method-source-code" id="rettsx-source">
|
|
296
|
+
<pre><span class="ruby-comment"># File lib/linmeric/Integrators.rb, line 79</span>
|
|
297
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">rettsx</span>(<span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span>,<span class="ruby-identifier">n</span>)
|
|
298
|
+
<span class="ruby-identifier">h</span> = (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">to_f</span>
|
|
299
|
+
<span class="ruby-identifier">area</span> = <span class="ruby-value">0</span>
|
|
300
|
+
<span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> <span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">n</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
|
|
301
|
+
<span class="ruby-identifier">area</span> <span class="ruby-operator">+=</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">h</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">i</span>)) <span class="ruby-operator">*</span> <span class="ruby-identifier">h</span>
|
|
302
|
+
<span class="ruby-keyword">end</span>
|
|
303
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">area</span>
|
|
304
|
+
<span class="ruby-keyword">end</span></pre>
|
|
305
|
+
</div>
|
|
306
|
+
|
|
307
|
+
</div>
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
</div>
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
<div id="method-c-simpson" class="method-detail ">
|
|
316
|
+
|
|
317
|
+
<div class="method-heading">
|
|
318
|
+
<span class="method-name">simpson</span><span
|
|
319
|
+
class="method-args">(a,b,n) { |xa| ... }</span>
|
|
320
|
+
|
|
321
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
322
|
+
|
|
323
|
+
</div>
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
<div class="method-description">
|
|
327
|
+
|
|
328
|
+
<p>Implementation of Simpson's method</p>
|
|
329
|
+
<ul><li>
|
|
330
|
+
<p>*<strong>argument</strong>*: left range value</p>
|
|
331
|
+
</li><li>
|
|
332
|
+
<p>*<strong>argument</strong>*: right range value</p>
|
|
333
|
+
</li><li>
|
|
334
|
+
<p>*<strong>argument</strong>*: number of integration points</p>
|
|
335
|
+
</li><li>
|
|
336
|
+
<p>*<strong>returns</strong>*: result of the operation (Numeric)</p>
|
|
337
|
+
</li></ul>
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
<div class="method-source-code" id="simpson-source">
|
|
343
|
+
<pre><span class="ruby-comment"># File lib/linmeric/Integrators.rb, line 54</span>
|
|
344
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">simpson</span>(<span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span>,<span class="ruby-identifier">n</span>)
|
|
345
|
+
<span class="ruby-identifier">hs</span> = (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">/</span> (<span class="ruby-identifier">n</span> <span class="ruby-operator">*</span> <span class="ruby-value">2.0</span>)
|
|
346
|
+
<span class="ruby-identifier">intSA</span> = <span class="ruby-value">0</span>
|
|
347
|
+
<span class="ruby-identifier">intSB</span> = <span class="ruby-value">0</span>
|
|
348
|
+
<span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> <span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">n</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
|
|
349
|
+
<span class="ruby-identifier">xa</span> = <span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">i</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">hs</span>
|
|
350
|
+
<span class="ruby-identifier">intSA</span> <span class="ruby-operator">+=</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">xa</span>)
|
|
351
|
+
<span class="ruby-keyword">end</span>
|
|
352
|
+
|
|
353
|
+
<span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> <span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">n</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
|
|
354
|
+
<span class="ruby-identifier">xb</span> = <span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">hs</span>
|
|
355
|
+
<span class="ruby-identifier">intSB</span> <span class="ruby-operator">+=</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">xb</span>)
|
|
356
|
+
<span class="ruby-keyword">end</span>
|
|
357
|
+
<span class="ruby-identifier">fa</span> = <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span>)
|
|
358
|
+
<span class="ruby-identifier">fb</span> = <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">b</span>)
|
|
359
|
+
<span class="ruby-identifier">intS</span> = <span class="ruby-identifier">hs</span> <span class="ruby-operator">/</span> <span class="ruby-value">3.0</span> <span class="ruby-operator">*</span> (<span class="ruby-identifier">fa</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">fb</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">intSA</span> <span class="ruby-operator">+</span> <span class="ruby-value">4</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">intSB</span>)
|
|
360
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">intS</span>
|
|
361
|
+
<span class="ruby-keyword">end</span></pre>
|
|
362
|
+
</div>
|
|
363
|
+
|
|
364
|
+
</div>
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
</div>
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
<div id="method-c-trapezi" class="method-detail ">
|
|
373
|
+
|
|
374
|
+
<div class="method-heading">
|
|
375
|
+
<span class="method-name">trapezi</span><span
|
|
376
|
+
class="method-args">(a,b,n) { |a| ... }</span>
|
|
377
|
+
|
|
378
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
379
|
+
|
|
380
|
+
</div>
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
<div class="method-description">
|
|
384
|
+
|
|
385
|
+
<p>Implementation of trapezes method</p>
|
|
386
|
+
<ul><li>
|
|
387
|
+
<p>*<strong>argument</strong>*: left range value</p>
|
|
388
|
+
</li><li>
|
|
389
|
+
<p>*<strong>argument</strong>*: right range value</p>
|
|
390
|
+
</li><li>
|
|
391
|
+
<p>*<strong>argument</strong>*: number of integration points</p>
|
|
392
|
+
</li><li>
|
|
393
|
+
<p>*<strong>returns</strong>*: result of the operation (Numeric)</p>
|
|
394
|
+
</li></ul>
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
<div class="method-source-code" id="trapezi-source">
|
|
400
|
+
<pre><span class="ruby-comment"># File lib/linmeric/Integrators.rb, line 17</span>
|
|
401
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">trapezi</span>(<span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span>,<span class="ruby-identifier">n</span>)
|
|
402
|
+
<span class="ruby-identifier">h</span> = (<span class="ruby-identifier">b</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">a</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">to_f</span>
|
|
403
|
+
<span class="ruby-identifier">int_parz</span> = <span class="ruby-value">0</span>
|
|
404
|
+
<span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> <span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">n</span>
|
|
405
|
+
<span class="ruby-comment"># Calculating first addend = f(x_i)</span>
|
|
406
|
+
<span class="ruby-identifier">f1</span> = <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">h</span>)
|
|
407
|
+
<span class="ruby-comment"># calculating second addend = f(X_{i+1})</span>
|
|
408
|
+
<span class="ruby-identifier">f2</span> = <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">a</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">h</span>)
|
|
409
|
+
<span class="ruby-comment"># Calculating trapeze area</span>
|
|
410
|
+
<span class="ruby-identifier">trap</span> = <span class="ruby-value">0.5</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">h</span> <span class="ruby-operator">*</span> (<span class="ruby-identifier">f1</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">f2</span>)
|
|
411
|
+
<span class="ruby-identifier">int_parz</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">trap</span>
|
|
412
|
+
<span class="ruby-keyword">end</span>
|
|
413
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">int_parz</span>
|
|
414
|
+
<span class="ruby-keyword">end</span></pre>
|
|
415
|
+
</div>
|
|
416
|
+
|
|
417
|
+
</div>
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
</div>
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
</section>
|
|
426
|
+
|
|
427
|
+
</section>
|
|
428
|
+
</main>
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
<footer id="validator-badges" role="contentinfo">
|
|
432
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
|
433
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
|
434
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
|
435
|
+
</footer>
|
|
436
|
+
|