linmeric 0.1.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.
@@ -0,0 +1,208 @@
1
+
2
+ LINMERIC: designed and developed by Massimiliano Dal Mas
3
+
4
+ Email: max.codeware@gmail.com
5
+
6
+ Requires 'io/console'
7
+
8
+ ## symbols used in this documentations: ##
9
+
10
+ <text> : kind of argument to be replaced
11
+ #=> : output of the program
12
+ // : specifications or comments
13
+ => : from..to
14
+ <> : different
15
+
16
+ ####################################
17
+ # INSTRUCTIONS #
18
+ ####################################
19
+ ________________________
20
+ #_VARIABLE ASSIGNMENT:_#
21
+ ************************
22
+
23
+ <variable_name> = <value>
24
+ or
25
+ <variable_name> = <expression>
26
+
27
+ Examples: v1 = 13
28
+ e1 = 3*4^2 #=> 48
29
+ e2 = a*b+c // a,b,c already defined
30
+
31
+ (allowed operations: +,-,*,/,^)
32
+
33
+ This interpreter sees as different uppercase and lowercase letters in variable definitions. (A1 <> a1)
34
+
35
+ ________________________
36
+ #_VARIABLE DISPLAYING:_#
37
+ ************************
38
+
39
+ shw: <variable_name> or simply typing <variable_name>
40
+
41
+ Examples: // v1 = 13
42
+ shw: v1 #=> 13
43
+ v1 #=> 13
44
+
45
+ Displaying all the inserted variables through the keyword 'shwvar:' (no argument required).
46
+
47
+ Example: // v1 = 13, v2 = 22
48
+ shwvar: #=> v1 = 13, #=> v2 = 22
49
+
50
+ ________________
51
+ #_COMPARISONS:_#
52
+ ****************
53
+
54
+ <expression> = <expression>
55
+
56
+ Examples: 12+7 = 10+9 #=> true
57
+ 12*8 = 20^123 #=> false
58
+
59
+ a/b = c*f #=> true/false
60
+
61
+ ________________________
62
+ #_CREATING A FUNCTION:_#
63
+ ************************
64
+
65
+ <function_name> = f: "<function_definition>"
66
+
67
+ Examples: fx = f: "x*log(x)"
68
+ gx = f: "y^z"
69
+
70
+ At the moment, the following algebric finctions are supported: log, sin, cos, exp, tan
71
+ Constants: PI (PI = 3,14...)
72
+
73
+ Restriction: parameters must be composed by only one letter (x,y,k,a...)
74
+
75
+ Warning: this interpreter uses ruby methods to solve functions.
76
+ Therefore, divisions with numbers return a number in the format corresponding to the one of the denominator.
77
+ Example: 1/2 #=> 0 (integer => integer); 1/2.0 #=> 0.5 (float => float)
78
+
79
+ ______________________
80
+ #_CREATING A MATRIX:_#
81
+ **********************
82
+
83
+ Matrix inserted by hand:
84
+
85
+ <matrix_name> = mx: "<rows>,<columns>"
86
+
87
+ Matrix according to a certain function rows-columns (or number)
88
+
89
+ <matrix_name> = mx: "<rows>,<columns>" as: "<function_definition>"
90
+
91
+ or
92
+
93
+ <matrix_name> = mx: "<rows>,<columns>" as: <function_name>
94
+
95
+ Matrix loaded from a file:
96
+
97
+ <matrix_name> = mx: from: "<file_path>"
98
+
99
+ Identity matrix:
100
+
101
+ <matrix_name> = id_mx: <size>
102
+
103
+ Examples: m1 = mx: "4,4" // it creates a 4x4 matrix with values inserted by the user
104
+ m2 = mx: "4,4" as: "r*c" // it creates a 4x4 matrix in which each element is given by the product row_number*column_number
105
+
106
+ // kx = f: "r*c"
107
+
108
+ m4 = mx: "4,4" as: kx // equals to the previous example
109
+ m5 = mx: from: "/home/usr/Desktop/matrice.csv" // it loads the matrix written in the .csv file
110
+ // the interpreter reads only .csv files
111
+ id = id_mx: 5 // it creates an identity 5x5 matrix
112
+
113
+ Allowed operations: +, -, *
114
+ / (Matrix-number) It divides each element of the specified matrix for the given number
115
+ ^ (Matrix-number) It elevates each element at the given exponent
116
+
117
+ It is possible to insert as value simple operations as 3/4, 10^5... Be careful: the conversion algorithm is not still strong,
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
120
+
121
+ __________________________
122
+ #_OPERATIONS ON MATRICES_#
123
+ **************************
124
+
125
+ Transposition: t: <matrix_name>
126
+ Example:
127
+ // m1: 4x7 matrix
128
+ t: m1 #=> 7x4 matrix
129
+
130
+ Norm: norm: <matrix_name>
131
+ Example:
132
+ norm: m1 // sqrt (sum (m1[r,c]^2))
133
+
134
+ Determinant: det: <matrix_name>
135
+ Example:
136
+ // m0: 6,6 matrix
137
+ det: m0
138
+
139
+ Results can be stored in a variable
140
+
141
+ ________________________
142
+ #_FUNCTION INTEGRATION_#
143
+ ************************
144
+
145
+
146
+ integ: "<function_definitio>" "<range>" <number_of_integration_points> ("<integration_method>")
147
+
148
+ It is possible to replace the function definition with a variable containing the function itself.
149
+ Results can be stored in a variable.
150
+
151
+ Examples: integ: "x*log(x^2)" "3,10" 50 // integration of 'x*log(x^2)' from 3 to 10 on 50 points
152
+ integ: "x*log(x^2)" "3,10" 50 "midpoint" // integration method specifyed
153
+ // sx = f: "x*log(x^2)"
154
+ integ: sx "3,10" 50
155
+
156
+ Available integration methods: trapezes // trapezes method
157
+ rectl // left-rectangles method
158
+ rectr // right-rectangles method
159
+ midpoint // middle-rectangles method
160
+ simpson // simpson method (default)
161
+ boole // boole method
162
+
163
+ ____________________
164
+ #_LU FACTORIZATION_#
165
+ ********************
166
+
167
+ solve: <matrix_name> ~ <solution_matrix_name>
168
+ or
169
+ solve: <expression_with_matrices> ~ <expression_with_matrices>
170
+
171
+ Examples:
172
+ a,b,c: 3x3 matrices
173
+ d : 3x1 matrix
174
+
175
+ solve: a ~ d // returns the x-matrix containing the solutions of the system (d: known system values matrix)
176
+ solve: a*b ~ c*d // returns the x-matrix solution of the matrix returned by a*b
177
+
178
+ LU factorization with direct matrix creation:
179
+
180
+ solve: (mx: "4,4") ~ (mx: "4,1")
181
+
182
+ L and U matrices are saved as variables with their default names (L,U)
183
+
184
+
185
+ _____________________________________
186
+ #_WRITING VALUES AND DATAS ON FILES_#
187
+ *************************************
188
+
189
+ <value> > "<file_path>"
190
+ or
191
+ <expression> > "<file_path>"
192
+ or
193
+ <variable_name> > "<file_path>"
194
+
195
+ Examples: 23 > "home/usr/Desktop/val.txt" // the number 23 will be written in val.txt. If the file does not exist, it will be created
196
+ 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
+ // mk: 8x8 matrix
198
+ mk > "home/usr/Desktop/matrx.csv" // Matrix 'mk' will be written in matrix.csv
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+