Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mutalibcs committed Jul 28, 2023
1 parent 04f9906 commit 93252dc
Show file tree
Hide file tree
Showing 14 changed files with 1,264 additions and 180 deletions.
446 changes: 446 additions & 0 deletions 1-sinusoid.ipynb

Large diffs are not rendered by default.

46 changes: 16 additions & 30 deletions 4-DSPL_Divide _ Conquer(1_6_23).ipynb → 10-Divide _ Conquer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"id": "6a749398",
"metadata": {},
"outputs": [],
Expand All @@ -13,8 +13,8 @@
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f8f59a71",
"execution_count": 3,
"id": "7fb2cb10",
"metadata": {},
"outputs": [
{
Expand All @@ -35,21 +35,13 @@
"M = 3\n",
"x = np.array([4,2,0,5,7,2,4,9,1,2,3,8,0,2,3])\n",
"np.shape(x)\n",
"y = x.reshape(L,M, order='F')\n",
"y = x.reshape(L,M,order='F')\n",
"print(y)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7fb2cb10",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"id": "222ce56e",
"metadata": {},
"outputs": [],
Expand All @@ -65,8 +57,8 @@
},
{
"cell_type": "code",
"execution_count": 4,
"id": "4bf3e133",
"execution_count": 9,
"id": "fb11ddff",
"metadata": {},
"outputs": [
{
Expand All @@ -83,17 +75,19 @@
}
],
"source": [
"F = np.zeros((L,M),dtype = 'complex_')\n",
"F = np.zeros((L,M), dtype= 'complex_')\n",
"print(np.shape(F))\n",
"\n",
"for l in range(L):\n",
" F[l] = DFT(y[l,:],M) #row\n",
" #np.shape(F)\n",
" print(F[l])"
" F[l] = DFT(y[l,:],M) # for Row\n",
" # np.shape(F)\n",
" print(F[l])\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 12,
"id": "37f26696",
"metadata": {},
"outputs": [
Expand All @@ -119,7 +113,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 14,
"id": "971059df",
"metadata": {},
"outputs": [
Expand All @@ -144,7 +138,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 16,
"id": "b563a847",
"metadata": {},
"outputs": [
Expand All @@ -161,14 +155,6 @@
"source": [
"print(abs(np.fft.fft(x,N)))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "53bef6ec",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
159 changes: 159 additions & 0 deletions 11-MovingAverage.ipynb

Large diffs are not rendered by default.

157 changes: 157 additions & 0 deletions 2-signal.ipynb

Large diffs are not rendered by default.

111 changes: 111 additions & 0 deletions 3-convolution.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"id": "3693637f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 1. 4. 8. 8. 3. -2. -1.]\n"
]
}
],
"source": [
"#convulation sum EX: 2.3.2\n",
"#1st method\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"x = [1, 2, 3, 1]\n",
"h = [1, 2, 1, -1]\n",
"lx = len(x)\n",
"lh = len(h)\n",
"y = np.zeros(lx+lh-1)\n",
"\n",
"for m in range(lx):\n",
" for n in range(lh):\n",
" y[m+n] = y[m+n] + x[m]*h[n]\n",
"print(y)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "a84b4ef8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 1 4 8 8 3 -2 -1]\n"
]
}
],
"source": [
"#2nd method relates with 1st\n",
"z = np.convolve(x, h, 'full')\n",
"print(z)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "b78f4be2",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 1 4 8 8 3 -2 -1]\n"
]
}
],
"source": [
"#3rd method indivitual\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"x = [1, 2, 3, 1]\n",
"h = [1, 2, 1, -1]\n",
"\n",
"z = np.convolve(x, h, 'full')\n",
"print(z)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "58064ae7",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
158 changes: 158 additions & 0 deletions 4-Convolution-np.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"def conv(x, h):\n",
" lx = len(x)\n",
" lh = len(h)\n",
" y = np.zeros(lx+lh-1)\n",
" \n",
" for m in range(lx):\n",
" for n in range(lh):\n",
" y[m+n] = y[m+n] + x[m]*h[n]\n",
" return y\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 1. 4. 8. 8. 3. -2. -1.]\n",
"[ 2. 8. 18. 22. 16. 4. 0.]\n"
]
}
],
"source": [
"x = [1,2,3,1]\n",
"h = [1, 2, 1, -1]\n",
"\n",
"y = conv(x, h)\n",
"print(y)\n",
"\n",
"\n",
"\n",
"yd2 = conv(x, h) + conv(x, h2)\n",
"print(yd2)\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1. 2. 3. 1.]\n"
]
}
],
"source": [
"d = np.zeros(1)\n",
"d[0] = 1\n",
"\n",
"#identity law\n",
"yi = conv(x, d)\n",
"print(yi)\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 1. 4. 8. 8. 3. -2. -1.]\n"
]
}
],
"source": [
"\n",
"#communitative property\n",
"yc = conv(h, x)\n",
"print(yc) \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 1. 6. 19. 37. 47. 36. 12. -5. -5. -1.]\n",
"[ 1. 6. 19. 37. 47. 36. 12. -5. -5. -1.]\n"
]
}
],
"source": [
"#assosiative law \n",
"h2 = [1,2 ,3, 1]\n",
"ya = conv(yc, h2)\n",
"print(ya) \n",
"yb = conv(h2, yc)\n",
"print(yb)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 1. 4. 8. 8. 4. 2. 9. 14. 13. 6. 1.]\n"
]
}
],
"source": [
"\n",
"#distributive law \n",
"yd1 = conv(x, h + h2)\n",
"print(yd1)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 93252dc

Please sign in to comment.