Commit bbb48d24 authored by geobumac's avatar geobumac

demo

parent be8ff03f
...@@ -900,48 +900,23 @@ ...@@ -900,48 +900,23 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 43, "execution_count": 27,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"[[1. 0. 0.]\n", "[[1. 0. 0. 0. 0.]\n",
" [0. 1. 0.]\n", " [0. 1. 0. 0. 0.]\n",
" [0. 0. 1.]]\n", " [0. 0. 1. 0. 0.]\n",
"-----\n", " [0. 0. 0. 1. 0.]\n",
"[[ 5 6 7]\n", " [0. 0. 0. 0. 1.]]\n",
" [ 0 1 2]\n", "[[ 0 0 2 -1 2]\n",
" [10 11 12]]\n", " [ 0 2 -3 4 5]\n",
"-------------\n", " [ 1 0 1 0 -3]\n",
"+++++++\n", " [ 3 0 0 1 -2]\n",
"[0 1 2]\n", " [ 2 0 0 0 6]]\n"
"[[ 5 6 7]\n",
" [ 0 1 2]\n",
" [10 11 12]]\n",
"+++++++\n",
"[0 1 2]\n",
"[[ 5 6 7]\n",
" [ 0 1 2]\n",
" [10 11 12]]\n",
"-------------\n",
"+++++++\n",
"[ 2 11 12]\n",
"[[ 5 6 7]\n",
" [ 0 1 2]\n",
" [ 2 -1 12]]\n",
"+++++++\n",
"[ 2 -1 12]\n",
"[[ 5 6 7]\n",
" [ 0 1 2]\n",
" [ 2 -1 -2]]\n",
"-------------\n",
"+++++++\n",
"[ 2 -1 -2]\n",
"[[ 5 6 7]\n",
" [ 0 1 2]\n",
" [ 2 -1 0]]\n"
] ]
} }
], ],
...@@ -956,8 +931,13 @@ ...@@ -956,8 +931,13 @@
" auxrow = np.copy(matriz[row1]);\n", " auxrow = np.copy(matriz[row1]);\n",
" self.matriz[row1] = self.matriz[row2]\n", " self.matriz[row1] = self.matriz[row2]\n",
" self.matriz[row2] = auxrow\n", " self.matriz[row2] = auxrow\n",
" print(\"-----\")\n", " identity = self.identity\n",
" print(self.matriz)\n", " auxrow = np.copy(identity[row1])\n",
" self.identity[row1] = self.identity[row2]\n",
" self.identity[row2] = auxrow\n",
" \n",
" #print(\"-----swap\")\n",
" #print(self.matriz, self.identity)\n",
" \n", " \n",
" def solver(self):\n", " def solver(self):\n",
" matriz = self.matriz\n", " matriz = self.matriz\n",
...@@ -967,29 +947,25 @@ ...@@ -967,29 +947,25 @@
" print(\"no singular\")\n", " print(\"no singular\")\n",
" else:\n", " else:\n",
" self.identity = np.eye(shapem[0])\n", " self.identity = np.eye(shapem[0])\n",
" \n",
" print(self.identity)\n", " print(self.identity)\n",
" if matriz[0][0] == 0:\n", " if matriz[0][0] == 0:\n",
" self.swap(0,1)\n", " self.swap(0,1)\n",
" for z in range(shapem[0] - 1):\n",
" for x in range(1, shapem[0] - z):\n",
" if matriz[z][z] != 0:\n",
" d = matriz[x+z][z] / matriz[z][z]\n",
" for y in range(shapem[0]):\n",
" matriz[x+z][y] = matriz[x+z][y] - (matriz[z][y] * d)\n",
" self.identity[x+z] = self.identity[x+z] - (self.identity[z]*d)\n",
" print(matriz) \n",
" \n", " \n",
" for fila_pivote in range(shapem[0] - 1):\n", "#a = np.floor(10*np.random.random((3,4)))\n",
" for fila_pivote_mas1 in range(fila_pivote + 1, shapem[0]):\n", "gaus = Gaus([[0, 2, -3, 4, 5],\n",
" print(\"-------------\")\n", " [0, 0, 2, -1, 2],\n",
" #print(matriz[fila_pivote_mas1][fila_pivote])\n", " [1, 1, 0, 2, -1],\n",
" #print(matriz[fila_pivote][fila_pivote])\n", " [2, 0, -1, 1, 1],\n",
" multiplicador = matriz[fila_pivote_mas1][fila_pivote]/matriz[fila_pivote][fila_pivote]\n", " [0, 1, 0, 1, 8]])\n",
" matriz[fila_pivote_mas1][fila_pivote] = multiplicador\n",
" for col in range(fila_pivote + 1, shapem[0]):\n",
" print(\"+++++++\")\n",
" print(matriz[fila_pivote_mas1])\n",
" matriz[fila_pivote_mas1][col] = matriz[fila_pivote_mas1][col] - multiplicador*matriz[fila_pivote][col]\n",
" \n",
" print(matriz)\n",
" \n",
" \n",
"a = np.floor(10*np.random.random((3,4)))\n",
"gaus = Gaus([[0,1,2],\n",
" [ 5,6,7],\n",
" [10,11,12]])\n",
"gaus.solver()" "gaus.solver()"
] ]
}, },
...@@ -4082,7 +4058,7 @@ ...@@ -4082,7 +4058,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.7" "version": "3.7.1"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment