121 lines
2.3 KiB
Plaintext
121 lines
2.3 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 26,
|
||
|
"id": "da1135f1",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import numpy as np\n",
|
||
|
"\n",
|
||
|
"arr = np.array([4.,7.,2.,6.]).reshape(2,2)\n",
|
||
|
"mat = np.matrix(arr)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "0108e1d6",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Macierze "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 27,
|
||
|
"id": "19ba64f7",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[[4. 7.]\n",
|
||
|
" [2. 6.]]\n",
|
||
|
"[[4. 7.]\n",
|
||
|
" [2. 6.]]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# obiekty array i matrix wyświetlają się tak samo\n",
|
||
|
"\n",
|
||
|
"print(arr)\n",
|
||
|
"print(mat)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 30,
|
||
|
"id": "3f697dfd",
|
||
|
"metadata": {
|
||
|
"scrolled": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[[0.25 0.14285714]\n",
|
||
|
" [0.5 0.16666667]]\n",
|
||
|
"[[ 0.6 -0.7]\n",
|
||
|
" [-0.2 0.4]]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# jednak dla działania **-1 wynik wychodzi zupełnie inny\n",
|
||
|
"# dla obiektu array działanie **-1 powoduję odwrócenie każdej liczby w tablicy\n",
|
||
|
"# dla obiektu matrix działanie **-1 powoduję odwrócenie całej macierzy tak że 'mat * mat^-1 = 1'\n",
|
||
|
"\n",
|
||
|
"print(arr**-1)\n",
|
||
|
"print(mat**-1)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 31,
|
||
|
"id": "ea293b68",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[[ 0.6 -0.7]\n",
|
||
|
" [-0.2 0.4]]\n",
|
||
|
"[[ 0.6 -0.7]\n",
|
||
|
" [-0.2 0.4]]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(mat**-1)\n",
|
||
|
"print(np.linalg.inv(mat))"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"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.8.10"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 5
|
||
|
}
|