Skip to content

Conversation

@TakshKamlesh
Copy link

def multiply(m1,m2):

ans=np.zeros((len(m1)-len(m2)+1,len(m1)-len(m2)+1))
for ix in range(len(m1)-len(m2)+1):
    for jx in range(len(m1)-len(m2)+1):
        patch=m1[ix:ix+len(m2),jx:jx+len(m2)]
        mlt=patch*m2
        mlt=mlt.sum()
        ans[ix][jx]=mlt
    
return ans

m1=np.array([[1 ,2, 3],[4, 5, 6],[7, 8, 9]])
m2=np.array([[5 ,6],[7 ,8]])
m3=multiply(m1,m2)
print(m3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant