Advertisement
ChristophX86

polynomial Division

Aug 23rd, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.41 KB | None | 0 0
  1. ; polynomialDivision
  2. ; Array[0] = Solution; Array[1] = Remainder
  3. Func polynomialDivision($p, $q)
  4.     Local $s[UBound($p,1)-UBound($q,1)+1], $i, $j
  5.     For $i = UBound($p,1)-1 To UBound($q,1)-1 Step -1
  6.         $s[$i-UBound($q,1)+1] = $p[$i] / $q[UBound($q,1)-1]
  7.         For $j = UBound($q,1)-1 To 0 Step -1
  8.             $p[$i-UBound($q,1)+1+$j] -= $s[$i-UBound($q,1)+1] * $q[$j]
  9.         Next
  10.     Next
  11.     Local $a[2] = [$s, $p]
  12.     Return $a
  13. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement