Commit bbb48d24 authored by geobumac's avatar geobumac

demo

parent be8ff03f
......@@ -900,48 +900,23 @@
},
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[1. 0. 0.]\n",
" [0. 1. 0.]\n",
" [0. 0. 1.]]\n",
"-----\n",
"[[ 5 6 7]\n",
" [ 0 1 2]\n",
" [10 11 12]]\n",
"-------------\n",
"+++++++\n",
"[0 1 2]\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"
"[[1. 0. 0. 0. 0.]\n",
" [0. 1. 0. 0. 0.]\n",
" [0. 0. 1. 0. 0.]\n",
" [0. 0. 0. 1. 0.]\n",
" [0. 0. 0. 0. 1.]]\n",
"[[ 0 0 2 -1 2]\n",
" [ 0 2 -3 4 5]\n",
" [ 1 0 1 0 -3]\n",
" [ 3 0 0 1 -2]\n",
" [ 2 0 0 0 6]]\n"
]
}
],
......@@ -956,8 +931,13 @@
" auxrow = np.copy(matriz[row1]);\n",
" self.matriz[row1] = self.matriz[row2]\n",
" self.matriz[row2] = auxrow\n",
" print(\"-----\")\n",
" print(self.matriz)\n",
" identity = self.identity\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",
" def solver(self):\n",
" matriz = self.matriz\n",
......@@ -967,29 +947,25 @@
" print(\"no singular\")\n",
" else:\n",
" self.identity = np.eye(shapem[0])\n",
" \n",
" print(self.identity)\n",
" if matriz[0][0] == 0:\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",
" for fila_pivote in range(shapem[0] - 1):\n",
" for fila_pivote_mas1 in range(fila_pivote + 1, shapem[0]):\n",
" print(\"-------------\")\n",
" #print(matriz[fila_pivote_mas1][fila_pivote])\n",
" #print(matriz[fila_pivote][fila_pivote])\n",
" multiplicador = matriz[fila_pivote_mas1][fila_pivote]/matriz[fila_pivote][fila_pivote]\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",
"#a = np.floor(10*np.random.random((3,4)))\n",
"gaus = Gaus([[0, 2, -3, 4, 5],\n",
" [0, 0, 2, -1, 2],\n",
" [1, 1, 0, 2, -1],\n",
" [2, 0, -1, 1, 1],\n",
" [0, 1, 0, 1, 8]])\n",
"gaus.solver()"
]
},
......@@ -4082,7 +4058,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.7.1"
}
},
"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