HW8 Complete

This commit is contained in:
2020-03-25 22:08:20 -06:00
parent 117ffcb5fb
commit 02d74cfd9a
4003 changed files with 1124519 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,24 @@
import numpy as np
def threeDivideConcur(n, P, Q):
PQ = np.zeros((2*n))
if n == 1:
PQ[0] = P[0] * Q[0]
return PQ
half = int(n/2)
PQ_LL = threeDivideConcur(half, P[0:half], Q[0:half])
PQ_HH = threeDivideConcur(half, P[half:], Q[half:])
P0 = [0] * half
Q0 = [0] * half
for i in range(half):
P0[i] = P[i] + P[i+half]
Q0[i] = Q[i] + Q[i+half]
S0 = threeDivideConcur(half, P0, Q0)
S0 = S0 - PQ_LL - PQ_HH
for i in range(0, n):
PQ[i] += PQ_LL[i]
PQ[i+half] += S0[i]
PQ[i+half] += PQ_HH[i]
return PQ

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -2,6 +2,7 @@ import time
import problemGenerator
import highSchool
import divideConcur
import ThreeDivideConcur
def main():
count = 32
@@ -11,6 +12,8 @@ def main():
dcTime = 0
highTimeStart = 0
dcTimeStart = 0
tpTimeStart = 0
tpTime = 0
for i in range(0, 10):
P = problemGenerator.GenerateProblem(count)
Q = problemGenerator.GenerateProblem(count)
@@ -22,11 +25,16 @@ def main():
divideConcur.DivideConcur(count, P, Q)
dcTime += (time.time()-dcTimeStart)
saveArray = [count, highTime, dcTime]
tpTimeStart = time.time()
ThreeDivideConcur.threeDivideConcur(count, P, Q)
tpTime += (time.time()-tpTimeStart)
saveArray = [count, highTime, dcTime, tpTime]
with open("results.txt", "a") as myfile:
print(str(saveArray), file=myfile)
myfile.flush()
count += count
print("done")
myfile.close()
main()

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -0,0 +1,8 @@
[32, 0.013394355773925781, 0.14917540550231934, 0.042598724365234375]
[64, 0.04674863815307617, 0.40509557723999023, 0.0937509536743164]
[128, 0.15992140769958496, 1.4650187492370605, 0.2788808345794678]
[256, 0.7615325450897217, 7.662258863449097, 0.9368202686309814]
[512, 2.826767683029175, 25.519383668899536, 2.65547776222229]
[1024, 11.587654829025269, 112.63592147827148, 8.038672924041748]
[2048, 42.060240745544434, 378.21464252471924, 22.36816930770874]
[4096, 167.49772214889526, 1508.2569563388824, 66.42253613471985]

BIN
PolyMultiplication/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB