# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
# Basics of Linear Algebra for Machine Learning
## Types of Matrices
## Diagonal Matrix
## Ch10, Page 74
# -

from numpy import array
from numpy import diag
# define 5x3  matrix
A = array([
    [1, 2, 3],
    [2, 1, 2],
    [3, 2, 1],
    [1, 2, 3],
    [2, 1, 2]
])
print(A)
# get diagonal vector
d = diag(A)
print(d)
# get diagonal matrix from vector
D = diag(d)
print(D)

StarcoderdataJupyterScriptsDedupFiltered