Uzupełnienie materiałów do lab. 1

This commit is contained in:
Paweł Skórzewski 2021-03-19 19:33:27 +01:00
parent a9ee16e88b
commit 663c79ba3c
2 changed files with 1686 additions and 1634 deletions

View File

@ -728,7 +728,9 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 32, "execution_count": 32,
"metadata": {}, "metadata": {
"scrolled": true
},
"outputs": [ "outputs": [
{ {
"data": { "data": {
@ -1556,48 +1558,111 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 57, "execution_count": 158,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "name": "stdout",
"text/plain": [ "output_type": "stream",
"array([[1, 2, 3],\n", "text": [
" [4, 5, 6],\n", "[[1 2 3]\n",
" [7, 8, 9]])" " [4 5 6]\n",
" [7 8 9]]\n"
] ]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [ "source": [
"x = np.array([1,2,3,4,5,6,7,8,9]).reshape(3,3)\n", "x = np.array([1,2,3,4,5,6,7,8,9]).reshape(3,3)\n",
"x" "print(x)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 58, "execution_count": 159,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "name": "stdout",
"text/plain": [ "output_type": "stream",
"matrix([[1, 2, 3],\n", "text": [
" [4, 5, 6],\n", "[[4 6 3]\n",
" [7, 8, 9]])" " [8 7 1]\n",
" [3 0 3]]\n"
] ]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
} }
], ],
"source": [
"y = np.array([4,6,3,8,7,1,3,0,3]).reshape(3,3)\n",
"print(y)"
]
},
{
"cell_type": "code",
"execution_count": 160,
"metadata": {},
"outputs": [],
"source": [ "source": [
"X = np.matrix(x)\n", "X = np.matrix(x)\n",
"X" "Y = np.matrix(y)"
]
},
{
"cell_type": "code",
"execution_count": 161,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 4 12 9]\n",
" [32 35 6]\n",
" [21 0 27]]\n"
]
}
],
"source": [
"print(x * y) # Tablice np.array mnożone są element po elemencie"
]
},
{
"cell_type": "code",
"execution_count": 162,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 29 20 14]\n",
" [ 74 59 35]\n",
" [119 98 56]]\n"
]
}
],
"source": [
"print(X * Y) # Macierze np.matrix mnożone są macierzowo"
]
},
{
"cell_type": "code",
"execution_count": 164,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 29 20 14]\n",
" [ 74 59 35]\n",
" [119 98 56]]\n"
]
}
],
"source": [
"print(np.matmul(x, y))"
] ]
}, },
{ {

File diff suppressed because it is too large Load Diff