[LA] sympy로 Reduced Row Echelon Matrix 구하기.

2022. 9. 1. 13:53·.../Math
728x90
728x90

David C. Lay의 Linear Algebra에서 1.2장의 Example 3에 sympy적용.

  • RREF는 unique하기 때문에 sympy에서 지원함.

import numpy as np
import sympy as sp

# ----------------------------------
# colab에서 sympy의 값을 latex 지원하여 출력하기 위해 정의
def custom_latex_printer(exp, **options):
    from google.colab.output._publish import javascript
    url = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/latest.js?config=default"
    javascript(url=url)
    return sp.printing.latex(exp, **options)

sp.init_printing(use_latex="mathjax", latex_printer=custom_latex_printer)
# end ----------------------------------


A = np.array([
    [0 , 3, -6, 6, 4,-5],
    [3 ,-7 , 8,-5, 8, 9],
    [3 ,-9 ,12,-9, 6,15]
], dtype=float)

A = sp.Matrix(A)
rref_A = A.rref()
rref_A # rref and pivot columns

결과는 다음과 같음.
$$\displaystyle \left( \left[\begin{matrix}1 & 0 & -2.0 & 3.0 & 0 & -24.0\\0 & 1 & -2.0 & 2.0 & 0 & -7.0\\0 & 0 & 0 & 0 & 1 & 4.0\end{matrix}\right], \ \left( 0, \ 1, \ 4\right)\right)$$

References

https://gist.github.com/dsaint31x/72fa6d150b869c561eded8f745004913

 

LA_Ch01_02_Ex03.ipynb

LA_Ch01_02_Ex03.ipynb. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

 

'... > Math' 카테고리의 다른 글

[LA] Signal Space : Vector Space  (0) 2022.09.30
[LA] Set of Real-valued Functions defined on a set of real number : Vector Space  (1) 2022.09.30
[LA] tf.linalg.solve 로 linear system 의 solution 구하기.  (0) 2022.09.01
[LA] Data Types (or The Types of Variable)  (0) 2022.09.01
[LA] Introduction of Linear Algebra  (0) 2022.09.01
'.../Math' 카테고리의 다른 글
  • [LA] Signal Space : Vector Space
  • [LA] Set of Real-valued Functions defined on a set of real number : Vector Space
  • [LA] tf.linalg.solve 로 linear system 의 solution 구하기.
  • [LA] Data Types (or The Types of Variable)
dsaint31x
dsaint31x
    반응형
    250x250
  • dsaint31x
    Dsaint31's blog
    dsaint31x
  • 전체
    오늘
    어제
    • 분류 전체보기 (738)
      • Private Life (13)
      • Programming (186)
        • DIP (104)
        • ML (26)
      • Computer (118)
        • CE (52)
        • ETC (33)
        • CUDA (3)
        • Blog, Markdown, Latex (4)
        • Linux (9)
      • ... (349)
        • Signals and Systems (103)
        • Math (170)
        • Linear Algebra (33)
        • Physics (42)
        • 인성세미나 (1)
      • 정리필요. (54)
        • 의료기기의 이해 (6)
        • PET, MRI and so on. (1)
        • PET Study 2009 (1)
        • 방사선 장해방호 (4)
        • 방사선 생물학 (3)
        • 방사선 계측 (9)
        • 기타 방사능관련 (3)
        • 고시 (9)
        • 정리 (18)
      • RI (0)
      • 원자력,방사능 관련법 (2)
  • 블로그 메뉴

    • Math
    • Programming
    • SS
    • DIP
  • 링크

    • Convex Optimization For All
  • 공지사항

    • Test
    • PET Study 2009
    • 기타 방사능관련.
  • 인기 글

  • 태그

    인허가제도
    opencv
    fourier transform
    Vector
    SS
    SIGNAL
    검사
    math
    Programming
    signal_and_system
    function
    random
    Python
    Convolution
    Probability
    signals_and_systems
    linear algebra
    numpy
    Optimization
    Term
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
dsaint31x
[LA] sympy로 Reduced Row Echelon Matrix 구하기.
상단으로

티스토리툴바