Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 178 additions & 0 deletions Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"A=np.array([[12,12,12,12,12],[12,12,12,12,12],[12,12,12,12,12],[12,12,12,12,12],[12,12,12,12,12]])\n",
"B=np.array([[1,1],[1,1]])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4\n"
]
}
],
"source": [
"m=(A.shape[0]-B.shape[0]+1)\n",
"print m\n",
"C=np.zeros((m,m))\n",
"def fun(B,D):\n",
" sum=0\n",
" if(B.shape[0]==B.shape[0]):\n",
" for i in range(B.shape[0]):\n",
" for ix in range(B.shape[0]):\n",
" #for ixx in range(B.shape[0]):\n",
" sum+=(B[i][ix]*D[i][ix])\n",
" \n",
" return sum\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"j=0\n",
"k=B.shape[0]\n",
"\n",
"for ixxx in range(m):\n",
" l=0\n",
" n=B.shape[0]\n",
" for ixxxx in range(m):\n",
" \n",
" #print('.........',j,k,'.....',l,n)\n",
" \n",
" D=np.array(A[j:k,l:n])\n",
" \n",
" C[ixxx][ixxxx]=fun(B,D)\n",
" l+=1\n",
" n+=1\n",
" j+=1\n",
" k+=1"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[48., 48., 48., 48.],\n",
" [48., 48., 48., 48.],\n",
" [48., 48., 48., 48.],\n",
" [48., 48., 48., 48.]])"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"C"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}