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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1282f00fc5f4e28e4e8a8a1070b9dbe7901b56f4
|
|
4
|
+
data.tar.gz: e9a17c5fb317d7ee863952408f281256a718200a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 03082a05f5d02d883060c4320dbd4da93cf3467ce08cd9e2dd6e85922765aec7fd2d4626144ef2c42ef93962ab7346213c714c0153ea33e38ed66fd276fc8ac0
|
|
7
|
+
data.tar.gz: 8de488ffb8ad277452c109829fbabf154c68e1ba19edf6ded763030ce9a8148cff1894009c9af07b08daf13440a50a0e8e6605f58bf555075388592b0bd3a7ec
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 TODO: Write your name
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Linmeric
|
|
2
|
+
|
|
3
|
+
This simple numeric calulator provides an easy command line user interface to make operations
|
|
4
|
+
with matrices and functions (integration)
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
rom the command line type:
|
|
9
|
+
```sh
|
|
10
|
+
$ sudo gem install linmeric
|
|
11
|
+
```
|
|
12
|
+
or click here to go to the linmeric rubygems page and download the .gem file. Then open the directory where the .gem file is saved on the commend line and type:
|
|
13
|
+
```sh
|
|
14
|
+
$ sudo gem install ./linmeric-<version>.gem
|
|
15
|
+
```
|
|
16
|
+
`<version>` must be replaced by the version number of the gem you downloaded
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
Instructions are available on the [linmeric page](https://max-codeware.github.io/linmeric/) or you can use the following commands
|
|
20
|
+
to display the guides:
|
|
21
|
+
|
|
22
|
+
### Displaying the command line guide:
|
|
23
|
+
|
|
24
|
+
From the command line type:
|
|
25
|
+
```sh
|
|
26
|
+
$ linmeric -h
|
|
27
|
+
```
|
|
28
|
+
or
|
|
29
|
+
```sh
|
|
30
|
+
$ linmeric --help
|
|
31
|
+
```
|
|
32
|
+
and a quick help menu will be runned. Choose the option you’re most interested in!
|
|
33
|
+
|
|
34
|
+
### Viewing the linmeric guide on gedit:
|
|
35
|
+
From the command line type:
|
|
36
|
+
```sh
|
|
37
|
+
$ linguide <lang>
|
|
38
|
+
```
|
|
39
|
+
to open the user guide on gedit. `<lang>` must be replaced by the language you want. The supported languages are:
|
|
40
|
+
* en (English)
|
|
41
|
+
* it (Italian)
|
|
42
|
+
|
|
43
|
+
Linguide is also provided by a `-h` command to view its help guide
|
|
44
|
+
|
|
45
|
+
## Contributing
|
|
46
|
+
|
|
47
|
+
Bug and mistake reports and pull requests are absolutely welcomed! To report any bug in the code or a mistake in the provided guides or in this website, please email me at max.codeware@gmail.com or on [GitHub](https://github.com/max-codeware/linmeric/) to pull requests too.
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/help/Help.rb
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require_relative "Help_inst.rb"
|
|
4
|
+
|
|
5
|
+
##
|
|
6
|
+
# Help menu module -user interface
|
|
7
|
+
#
|
|
8
|
+
# Author:: Massimiliano Dal Mas (mailto:max.codeware@gmail.com0)
|
|
9
|
+
# License:: Distributed under MIT license
|
|
10
|
+
module Help
|
|
11
|
+
MENU = [
|
|
12
|
+
"[0] Variable assignment",
|
|
13
|
+
"[1] Variable displaying",
|
|
14
|
+
"[2] Comparisons",
|
|
15
|
+
"[3] Creating a function",
|
|
16
|
+
"[4] Creating a matrix",
|
|
17
|
+
"[5] Operations on matrices",
|
|
18
|
+
"[6] Function intagration",
|
|
19
|
+
"[7] LU factorization",
|
|
20
|
+
"[8] Wrinting values and datas on files",
|
|
21
|
+
"[9] Symbols",
|
|
22
|
+
"[10] exit"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
MATRIX_OP = [
|
|
26
|
+
"[a] Transposition",
|
|
27
|
+
"[b] Norm",
|
|
28
|
+
"[c] Determinant",
|
|
29
|
+
"[d] to return to main menu"
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
NUMBER = /[0-9]/
|
|
33
|
+
LETTER = /[a-d]/
|
|
34
|
+
|
|
35
|
+
SINGLE_NUMBER = ("0".."9").map do |n|
|
|
36
|
+
n
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
SINGLE_LETTER = ("a".."d").map do |l|
|
|
40
|
+
l
|
|
41
|
+
end
|
|
42
|
+
def self.ask
|
|
43
|
+
puts MENU
|
|
44
|
+
print ">> "
|
|
45
|
+
cmd = STDIN.gets.downcase.chomp
|
|
46
|
+
while cmd != "10" do
|
|
47
|
+
case cmd
|
|
48
|
+
when NUMBER then menu(cmd)
|
|
49
|
+
self.clrscr
|
|
50
|
+
puts MENU
|
|
51
|
+
end
|
|
52
|
+
print ">> "
|
|
53
|
+
cmd = STDIN.gets.downcase.chomp
|
|
54
|
+
end
|
|
55
|
+
exit 0
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.menu(choice)
|
|
59
|
+
if SINGLE_NUMBER.include? choice then
|
|
60
|
+
self.send("_#{choice}_")
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.matrix_op(choice)
|
|
65
|
+
if SINGLE_LETTER.include? choice then
|
|
66
|
+
self.send("_#{cmd}_")
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.clrscr
|
|
71
|
+
print "\e[H\e[2J"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def self.back_to_menu
|
|
75
|
+
puts
|
|
76
|
+
print "[m] to return to menu >> "
|
|
77
|
+
key = STDIN.gets.downcase.chomp
|
|
78
|
+
while key != "m"
|
|
79
|
+
print "[m] to return to menu >> "
|
|
80
|
+
key = STDIN.gets.downcase.chomp
|
|
81
|
+
end
|
|
82
|
+
# self.clrscr
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def self.back_to_sub_menu
|
|
86
|
+
puts
|
|
87
|
+
print "[s] to return to sub menu >> "
|
|
88
|
+
key = STDIN.gets.downcase.chomp
|
|
89
|
+
while key != "s"
|
|
90
|
+
print "[s] to return to sub menu >> "
|
|
91
|
+
key = STDIN.gets.downcase.chomp
|
|
92
|
+
end
|
|
93
|
+
# self.clrscr
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def self._0_
|
|
97
|
+
self.clrscr
|
|
98
|
+
self.var_assign
|
|
99
|
+
self.back_to_menu
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def self._1_
|
|
103
|
+
self.clrscr
|
|
104
|
+
self.var_displaying
|
|
105
|
+
self.back_to_menu
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def self._2_
|
|
109
|
+
self.clrscr
|
|
110
|
+
self.comparisons
|
|
111
|
+
self.back_to_menu
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def self._3_
|
|
115
|
+
self.clrscr
|
|
116
|
+
self.function
|
|
117
|
+
self.back_to_menu
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def self._4_
|
|
121
|
+
self.clrscr
|
|
122
|
+
self.matrix
|
|
123
|
+
self.back_to_menu
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def self._5_
|
|
127
|
+
self.clrscr
|
|
128
|
+
puts MATRIX_OP
|
|
129
|
+
print "*>> "
|
|
130
|
+
cmd = STDIN.gets.downcase.chomp
|
|
131
|
+
while cmd != "d" do
|
|
132
|
+
if SINGLE_LETTER.include? cmd
|
|
133
|
+
self.send(cmd)
|
|
134
|
+
self.clrscr
|
|
135
|
+
puts MATRIX_OP
|
|
136
|
+
end
|
|
137
|
+
print "*>> "
|
|
138
|
+
cmd = STDIN.gets.downcase.chomp
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def self.a
|
|
143
|
+
self.clrscr
|
|
144
|
+
self.matrix_tr
|
|
145
|
+
self.back_to_sub_menu
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def self.b
|
|
149
|
+
self.clrscr
|
|
150
|
+
self.matrix_norm
|
|
151
|
+
self.back_to_sub_menu
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def self.c
|
|
155
|
+
self.clrscr
|
|
156
|
+
self.matrix_det
|
|
157
|
+
self.back_to_sub_menu
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def self._6_
|
|
161
|
+
self.clrscr
|
|
162
|
+
self.integration
|
|
163
|
+
self.back_to_menu
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def self._7_
|
|
167
|
+
self.clrscr
|
|
168
|
+
self.lu
|
|
169
|
+
self.back_to_menu
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def self._8_
|
|
173
|
+
self.clrscr
|
|
174
|
+
self.data_writing
|
|
175
|
+
self.back_to_menu
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def self._9_
|
|
179
|
+
self.clrscr
|
|
180
|
+
self.symbols
|
|
181
|
+
self.back_to_menu
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
end
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
##
|
|
5
|
+
# Help menu module -instructions
|
|
6
|
+
#
|
|
7
|
+
# Author:: Massimiliano Dal Mas (mailto:max.codeware@gmail.com0)
|
|
8
|
+
# License:: Distributed under MIT license
|
|
9
|
+
module Help
|
|
10
|
+
|
|
11
|
+
def self.write(syntax,example)
|
|
12
|
+
["SINTAX",syntax,"","EXAMPLES",example].each do |el|
|
|
13
|
+
puts el
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
VAR_ASSIGNMENT = [
|
|
17
|
+
" <variable_name> = <value>",
|
|
18
|
+
"",
|
|
19
|
+
" <variable_name> = <expression>"
|
|
20
|
+
]
|
|
21
|
+
VAR_ASSIGN_EG = [
|
|
22
|
+
" v1 = 13 #=> 13",
|
|
23
|
+
"",
|
|
24
|
+
" v2 = 3*4^2 #=> 48",
|
|
25
|
+
"",
|
|
26
|
+
" v3 = v1+v2 #=> 61",
|
|
27
|
+
"",
|
|
28
|
+
"(Allowed operations: +,-,*,/,^)",
|
|
29
|
+
"",
|
|
30
|
+
"This interpreter sees as different uppercase and lowercase",
|
|
31
|
+
"letters in variable definition. (A1 <> a1)"
|
|
32
|
+
]
|
|
33
|
+
def self.var_assign
|
|
34
|
+
self.write(VAR_ASSIGNMENT,VAR_ASSIGN_EG)
|
|
35
|
+
end
|
|
36
|
+
VAR_DISPLAYING = [
|
|
37
|
+
" shw: <variable_name> // displays <variable_name>",
|
|
38
|
+
"",
|
|
39
|
+
" <variable_name> // displays <variable_name>",
|
|
40
|
+
"",
|
|
41
|
+
" shwvar: // displays all the variables in memory",
|
|
42
|
+
" no argument required"
|
|
43
|
+
]
|
|
44
|
+
VAR_DISPLAY_EG = [
|
|
45
|
+
" # v1 = 13, v2 = 6",
|
|
46
|
+
" shw: v1 #=> 13",
|
|
47
|
+
"",
|
|
48
|
+
" v1 #=> 13",
|
|
49
|
+
"",
|
|
50
|
+
" shwvar: #=> 13; #=> 6"
|
|
51
|
+
]
|
|
52
|
+
def self.var_displaying
|
|
53
|
+
self.write(VAR_DISPLAYING,VAR_DISPLAY_EG)
|
|
54
|
+
end
|
|
55
|
+
COMPARISONS = [
|
|
56
|
+
" <expression> = <expression>"
|
|
57
|
+
]
|
|
58
|
+
COMPARISONS_EG = [
|
|
59
|
+
" 12+7 = 10+9 #=> true",
|
|
60
|
+
"",
|
|
61
|
+
" 12*8 = 20^123 #=> false",
|
|
62
|
+
"",
|
|
63
|
+
" a/b = c*f #=> true/false"
|
|
64
|
+
]
|
|
65
|
+
def self.comparisons
|
|
66
|
+
self.write(COMPARISONS,COMPARISONS_EG)
|
|
67
|
+
end
|
|
68
|
+
FUNCTION_DEF = [
|
|
69
|
+
" <function_name> = f: \"<function_definition>\""
|
|
70
|
+
]
|
|
71
|
+
FUNCTION_DEF_E = [
|
|
72
|
+
" fx = f: \"x*log(x)\" #=> x*log(x)",
|
|
73
|
+
"",
|
|
74
|
+
" gx = f: \"y^z\" #=> y^z",
|
|
75
|
+
"",
|
|
76
|
+
"At the moment, the following algebric functions are supported:",
|
|
77
|
+
" log, sin, cos, exp, tan",
|
|
78
|
+
"Constants: PI (PI = 3,14...)",
|
|
79
|
+
"",
|
|
80
|
+
"Restriction: parameters must be composed by only one letter (x,y,k,a...)",
|
|
81
|
+
"",
|
|
82
|
+
"Warning: this interpreter uses ruby methods to solve functions.",
|
|
83
|
+
"Therefore, divisions with numbers return a number in the format",
|
|
84
|
+
"corresponding to the one of the denominator.",
|
|
85
|
+
"Example: 1/2 #=> 0 (integer => integer)",
|
|
86
|
+
" 1/2.0 #=> 0.5 (float => float)"
|
|
87
|
+
]
|
|
88
|
+
def self.function
|
|
89
|
+
self.write(FUNCTION_DEF,FUNCTION_DEF_E)
|
|
90
|
+
end
|
|
91
|
+
MATRIX_CREATE = [
|
|
92
|
+
"// Matrix inserted by hand:",
|
|
93
|
+
"",
|
|
94
|
+
" <matrix_name> = mx: \"<rows>,<columns>\"",
|
|
95
|
+
"",
|
|
96
|
+
"// Matrix according to a certain function rows-columns (or number):",
|
|
97
|
+
"",
|
|
98
|
+
" <matrix_name> = mx: \"<rows>,<columns>\" as: \"<function_definition>\"",
|
|
99
|
+
"",
|
|
100
|
+
" <matrix_name> = mx: \"<rows>,<columns>\" as: <function_name>",
|
|
101
|
+
"",
|
|
102
|
+
"// Matrix from a .csv file:",
|
|
103
|
+
"",
|
|
104
|
+
" <matrix_name> = mx: from: \"<file_path>\"",
|
|
105
|
+
"",
|
|
106
|
+
"// Identity matrix:",
|
|
107
|
+
"",
|
|
108
|
+
" <matrix_name> = id_mx: <size>"
|
|
109
|
+
]
|
|
110
|
+
MATRIX_EXAMPLE = [
|
|
111
|
+
" m1 = mx: \"4,4\" // it creates a 4x4 matrix with values inserted",
|
|
112
|
+
" by the user",
|
|
113
|
+
"",
|
|
114
|
+
" m2 = mx: \"4,4\" as: \"r*c\" // it creates a 4x4 matrix in which each element is",
|
|
115
|
+
" given by the product row_number*column_number",
|
|
116
|
+
"",
|
|
117
|
+
" # kx = f: \"r*c\"",
|
|
118
|
+
" m4 = mx: \"4,4\" as: kx // equals to the previous example",
|
|
119
|
+
"",
|
|
120
|
+
" m5 = mx: from: \"/home/usr/Desktop/matrix.csv\" // it loads the matrix written",
|
|
121
|
+
" in the .csv file",
|
|
122
|
+
"",
|
|
123
|
+
" id = id_mx: 5 // it creates an identity 5x5 matrix",
|
|
124
|
+
"",
|
|
125
|
+
"Allowed operations: +, -, *",
|
|
126
|
+
"/ (Matrix-number) It divides each element for the given number",
|
|
127
|
+
"^ (Matrix-number) It elevates each element at the given exponent",
|
|
128
|
+
"",
|
|
129
|
+
"It is possible to insert as value simple operations as 3/4, 10^5..."
|
|
130
|
+
]
|
|
131
|
+
def self.matrix
|
|
132
|
+
self.write(MATRIX_CREATE,MATRIX_EXAMPLE)
|
|
133
|
+
end
|
|
134
|
+
MATRIX_OP_TR = [" t: <matrix_name>"]
|
|
135
|
+
MATRIX_OP_EG = [
|
|
136
|
+
" # m1: // 4x7 matrix",
|
|
137
|
+
" t: m1 #=> 7x4 matrix ",
|
|
138
|
+
"",
|
|
139
|
+
"Results can be stored in a variable"]
|
|
140
|
+
def self.matrix_tr
|
|
141
|
+
self.write(MATRIX_OP_TR,MATRIX_OP_EG)
|
|
142
|
+
end
|
|
143
|
+
MATRIX_OP_NORM = [" norm: <matrix_name>"]
|
|
144
|
+
MATRIX_NORM_EG = [
|
|
145
|
+
" norm: m1 // sqrt (sum (m1[r,c]^2))",
|
|
146
|
+
"",
|
|
147
|
+
"Results can be stored in a variable"
|
|
148
|
+
]
|
|
149
|
+
def self.matrix_norm
|
|
150
|
+
self.write(MATRIX_OP_NORM,MATRIX_NORM_EG)
|
|
151
|
+
end
|
|
152
|
+
MATRIX_OP_DET = [" det: <matrix_name>"]
|
|
153
|
+
MATRIX_DET_EG = [
|
|
154
|
+
" # m0 // 6,6 matrix",
|
|
155
|
+
" det: m0",
|
|
156
|
+
"",
|
|
157
|
+
"Results can be stored in a variable"
|
|
158
|
+
]
|
|
159
|
+
def self.matrix_det
|
|
160
|
+
self.write(MATRIX_OP_DET,MATRIX_DET_EG)
|
|
161
|
+
end
|
|
162
|
+
FUNCT_INTEG = [
|
|
163
|
+
" integ: \"<function_definitio>\" \"<range>\" <number_of_points> (\"<method>\")",
|
|
164
|
+
"",
|
|
165
|
+
"It is possible to replace the function definition with a variable containing",
|
|
166
|
+
"the function itself.",
|
|
167
|
+
"Results can be stored in a variable."
|
|
168
|
+
]
|
|
169
|
+
FUNCT_INTEG_EG = [
|
|
170
|
+
" integ: \"x*log(x^2)\" \"3,10\" 50 // integration of 'x*log(x^2)'",
|
|
171
|
+
" from 3 to 10 on 50 points",
|
|
172
|
+
" integ: \"x*log(x^2)\" \"3,10\" 50 \"midpoint\" // integration method specified",
|
|
173
|
+
"",
|
|
174
|
+
" # sx = f: \"x*log(x^2)\"",
|
|
175
|
+
" integ: sx \"3,10\" 50",
|
|
176
|
+
"",
|
|
177
|
+
"Available integration methods:",
|
|
178
|
+
" * trapezes // trapezes method",
|
|
179
|
+
" * rectl // left-rectangles method",
|
|
180
|
+
" * rectr // right-rectangles method",
|
|
181
|
+
" * midpoint // middle-rectangles method",
|
|
182
|
+
" * simpson // simpson method (default)",
|
|
183
|
+
" * boole // boole method"
|
|
184
|
+
]
|
|
185
|
+
def self.integration
|
|
186
|
+
self.write(FUNCT_INTEG,FUNCT_INTEG_EG)
|
|
187
|
+
end
|
|
188
|
+
LU_FACT = [
|
|
189
|
+
" solve: <matrix_name> ~ <solution_matrix_name>",
|
|
190
|
+
"",
|
|
191
|
+
" solve: <expression_with_matrices> ~ <expression_with_matrices>"
|
|
192
|
+
]
|
|
193
|
+
LU_FACT_EG = [
|
|
194
|
+
" # a,b,c // 3x3 matrices",
|
|
195
|
+
" # d // 3x1 matrix",
|
|
196
|
+
"",
|
|
197
|
+
" solve: a ~ d // returns the x-matrix containing the solution",
|
|
198
|
+
" of the system (d: known system values matrix)",
|
|
199
|
+
" solve: a*b ~ c*d // returns the x-matrix solution of the matrix",
|
|
200
|
+
" returned by a*b",
|
|
201
|
+
"",
|
|
202
|
+
"LU factorization with direct matrix creation:",
|
|
203
|
+
" solve: (mx: \"4,4\") ~ (mx: \"4,1\")",
|
|
204
|
+
"",
|
|
205
|
+
"L and U matrices are saved as variables with their default names (L,U)"
|
|
206
|
+
]
|
|
207
|
+
def self.lu
|
|
208
|
+
self.write(LU_FACT,LU_FACT_EG)
|
|
209
|
+
end
|
|
210
|
+
DATA_WRITING = [
|
|
211
|
+
" <value> > \"<file_path>\"",
|
|
212
|
+
"",
|
|
213
|
+
" <expression> > \"<file_path>\"",
|
|
214
|
+
"",
|
|
215
|
+
" <variable_name> > \"<file_path>\""
|
|
216
|
+
]
|
|
217
|
+
DATA_WRITING_E = [
|
|
218
|
+
" 23 > \"home/usr/Desktop/val.txt\" // the number 23 will be written",
|
|
219
|
+
" in val.txt. If the file does not exist,",
|
|
220
|
+
" it will be created",
|
|
221
|
+
" s*q0+1 > \"home/usr/Desktop/val.txt\" // the result of 's*q0+1' will be",
|
|
222
|
+
" written in val.txt (s,q0 are variables)",
|
|
223
|
+
" # mk // 8x8 matrix",
|
|
224
|
+
"mk > \"home/usr/Desktop/matrx.csv\" // Matrix 'mk' will be written in matrix.csv"
|
|
225
|
+
]
|
|
226
|
+
def self.data_writing
|
|
227
|
+
self.write(DATA_WRITING ,DATA_WRITING_E)
|
|
228
|
+
end
|
|
229
|
+
SYMBOLS = [
|
|
230
|
+
"Symbols used in this help menu:",
|
|
231
|
+
" <text> : kind of argument to replace",
|
|
232
|
+
" #=> : output of the program",
|
|
233
|
+
" // : comments",
|
|
234
|
+
" # : specifications",
|
|
235
|
+
" <> : different"
|
|
236
|
+
]
|
|
237
|
+
def self.symbols
|
|
238
|
+
puts SYMBOLS
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
data/bin/linguide
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
path = File.expand_path(__FILE__)
|
|
4
|
+
dir = File.dirname(path)
|
|
5
|
+
|
|
6
|
+
case ARGV[0]
|
|
7
|
+
when "en"
|
|
8
|
+
exec( "cd
|
|
9
|
+
cd #{dir}
|
|
10
|
+
cd ..
|
|
11
|
+
cd doc
|
|
12
|
+
gedit Instructions_en.txt")
|
|
13
|
+
when "it"
|
|
14
|
+
exec( "cd
|
|
15
|
+
cd #{dir}
|
|
16
|
+
cd ..
|
|
17
|
+
cd doc
|
|
18
|
+
gedit Instructions_it.txt")
|
|
19
|
+
when "-h"
|
|
20
|
+
puts "supported languages:\n * en type: linguide en\n * it type: linguide it"
|
|
21
|
+
else
|
|
22
|
+
exit 0
|
|
23
|
+
end
|