Search the Community
Showing results for tags 'linalg'.
-
Hi there! I have been learning linear algebra in my university for months. The subject was rather hard, I did't understand it much so I sent a email to my teacher to ask him. But I realized that typing a matrix by text was extremely hard. I don't want to make a LaTex function, save to a file, attach it to the mail, bla bla bla!!! It's complicated! So I spent 2 hours yesterday to make this tool. Just type the number of lines and columns and matrix values, it will generate a quite nice matrix in ASCII characters Enjoy! Notes: It will rearrage your numbers to straight columns. 1x1 will cause error. ConsoleWrite (@CRLF & '------------------------------------MATRIX TEST-----------------------------------------' &@CRLF) Dim $c = 6;column Dim $l = 4;line Dim $n = '1,6,2,4,b,a,7,6,6,0,44,4,6,3,6,2,6,8,9,6,6,1,2,logmein' $split = StringSplit ($n,',') If $c * $l <> $split[0] Then ConsoleWrite ('! Matrix values number do not match the columns and lines !' & @CRLF) Exit EndIf Dim $char[$l][$c], $len[$l][$c], $maxlen[$c][3] For $i = 0 To $l-1 For $u = 0 To $c -1 $v = $i*($c) + $u +1 $char[$i][$u] = $split[$v] $len[$i][$u] = StringLen ($split[$v]) If $len[$i][$u] > $maxlen[$u][0] Then $maxlen[$u][0] = $len[$i][$u] $maxlen[$u][1] = $i $maxlen[$u][2] = $u EndIf Next Next Local $finallen For $u = 0 To $c - 1 $finallen += $maxlen[$u][0] Next ConsoleWrite (' _' & _Repeat(' ',$finallen + $c) & '_' & @CRLF) For $i = 0 To $l-1;write lines For $u = 0 To $c-1;write columns $v = $i*($c) + $u +1 $char[$i][$u] = $split[$v] Switch $u Case 0; the first column If StringLen ($char[$i][$u])<$maxlen[$u][0] Then ConsoleWrite ('| ' & $char[$i][$u] & _Repeat(' ', $maxlen[$u][0]-StringLen ($char[$i][$u])+1)) Else ConsoleWrite ('| ' & $char[$i][$u] & ' ') EndIf Case 1 To $c-2 ;middle columns If $i > 0 Then If StringLen ($char[$i][$u]) < $maxlen[$u][0] Then ConsoleWrite ($char[$i][$u] & _Repeat(' ', $maxlen[$u][0]-StringLen ($char[$i][$u])+1)) Else ConsoleWrite ($char[$i][$u] & ' ' ) EndIf Else If StringLen ($char[$i][$u]) < $maxlen[$u][0] Then ConsoleWrite ($char[$i][$u] & _Repeat(' ', $maxlen[$u][0]-StringLen ($char[$i][$u])+1)) Else ConsoleWrite ($char[$i][$u] & ' ' ) EndIf EndIf Case Else ; the last column If StringLen ($char[$i][$u])<$maxlen[$u][0] Then ConsoleWrite ($char[$i][$u] & _Repeat(' ', $maxlen[$u][0]-StringLen ($char[$i][$u])+1) & ' |' & @CRLF) Else ConsoleWrite ($char[$i][$u] & ' |' & @CRLF) EndIf EndSwitch Next Next ConsoleWrite ('|_' & _Repeat(' ',$finallen + $c ) & '_|' & @CRLF) Func _Repeat($chars, $times);repeat a character in a specified time Local $rChar For $a = 1 To $times $rChar &= $chars Next Return $rChar EndFunc ;==>_Repeat