Skip to content

Commit 8b9ebdf

Browse files
committed
Merge pull request #6 from jverzani/patch-2
modify *
2 parents 4ab8d1a + b6d2f98 commit 8b9ebdf

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Polynomials.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,17 @@ function -{T,S}(p1::Poly{T}, p2::Poly{S})
168168
Poly([p1[i] - p2[i] for i = 0:max(length(p1),length(p2))])
169169
end
170170

171+
171172
function *{T,S}(p1::Poly{T}, p2::Poly{S})
172173
if p1.var != p2.var
173174
error("Polynomials must have same variable")
174175
end
175176
R = promote_type(T,S)
176-
n = length(p1)
177-
m = length(p2)
178-
a = Poly(zeros(R,m+n+2))
179-
for i = 0:length(p1)
180-
for j = 0:length(p2)
177+
n = degree(p1)
178+
m = degree(p2)
179+
a = Poly(zeros(R,m+n+1))
180+
for i = 0:n
181+
for j = 0:m
181182
a[i+j] += p1[i] * p2[j]
182183
end
183184
end

0 commit comments

Comments
 (0)