기본 콘텐츠로 건너뛰기

10월, 2018의 게시물 표시

추천 게시물

[Go] 고루틴

런타임(Runtime) visual code에서 브라우저 실행 단축키: Alt+B Go runtime은 메모리 관리, 가비지 수집, 동시성을 포함하여 Go 프로그림의 실행을 관리하는 역할을 합니다. 이 문서에서는 Go runtime을 자세히 살펴보고 아키텍초, 특성과 장점을 살펴봅니다. Go Runtime Architecture Go runtime은 모듈식이고 유연하게 설계되었으며 개발자가 특정 요구사항에 따라 동작을 사용자 정의할 수 있는 계층적 아키텍쳐를 갖추고 있습니다. 런타임은 스케줄러(schedualer), 가비지 수집기(garbage collector), 메모리 할당자(memory alllocator) 및 스택관리(stack management)를 포함한 어려 핵심 구성 요소로 구성됩니다. Schedualer Go 런타임의 핵심은 고루틴의 실행을 관리하는 스케줄러입니다. 고루틴은 효율적인 동시성을 가능하게 하는 가벼운 스레드입니다. 스케줄러는 사용 가능한 스레드에 고루틴을 분산하고, 스레드 로컬 스토리지를 관리하고, I/O 작업을 조정하는 역할을 합니다. thread(스레드): 프로그램 내에서 실행되는 흐름의 단위로 동시에 여러 작업이나 프로그램을 실행하는 것입니다. 즉, 코드를 실행할 수 있는 각 단위를 스레드라고 합니다. 고루틴(goroutine): Go 언어로 동시에 실행되는 모든 활동을 의미합니다. 고루틴을 만드는 비용을 스레드에 비해 매우 적기 떄문에 경량 스레드라고 합니다. 모든 프로그램은 적어도 하나의 main() 함수라는 고루틴을 포함하고 고루틴은 항상 백그라운드에서 작동합니다. 메인함수가 종료되면 모든 고루틴은 종료됩니다. 그러므로 고루틴보다 main이 먼저 종료되는 것을 방지해야 합니다. Go 스케줄러는 매우 효율적이고 확장 가능하도록 설계되어 많은 수의 동시 고루틴을 손쉽게 처리할 수 있습니다. 스레드 간에 부하를 분산하여 경합을 최소화하고 성능을 개선하는 작업 훔치기 알고리즘을 사용합니다...

How to get solution of linear system?

$$\text{A}\overrightarrow{x}=\overrightarrow{b}\qquad \text{Eq.1}$$ A: m $\times$ n Matrix, Coefficient(Standard) Matrix x: Variable vector(column vector) b: Constant vector(column vector) Equation 1 is called a matrix equation or a linear combination system. The above relationship means that an appropriate solution exists. The solution of the matrix equation can be calculated by using the inverse matrix and by using the row echelon form matrix (RREF). 1. How to use inverse matrix Invertible matrix: matrix (M) in which the inverse matrix exists The basic conditions of this invertible matrix are as follows. 1) square matrix (number of rows = number of columns) 2) The determinant is not zero. $$det(M) \neq 0$$ The inverse matrix of the square matrix M is denoted by  $M^{-1}$ , and the product of these two matrices is the identity matrix (I). An identity matrix: a matrix with diagonal elements of 1 and all other elements of 0 >>> I2=np.eye(2);I2...

Linear combination

$R_n = \{\overrightarrow {v_1}, \overrightarrow {v_2}, ...., \overrightarrow {v_n}\}$ $\text{scalar} \; c=\{c_1, c_2,..., c_n\}$ For vector R and scalar c, if the following relationship Equation 7 is defined $$y=c_1 \overrightarrow {v_1} + c_2 \overrightarrow {v_2} + .... +c_n \overrightarrow {v_n},$$ This is called the linear combination of the vector R and the scalar (weight). 1. Are linear combinations in vectors a 1 , a 2 and vector b? Whether the relationship is established, $$x_1 a_1 +x_2 a_2 = b \quad x_1, x_2 : scalar(weight)$$ $$a_1 =\left[\begin{array}{r}1\\-2\\-5 \end{array}\right], \qquad a_2=\left[\begin{array}{r}2\\5\\6 \end{array}\right], \qquad b=\left[\begin{array}{r}7\\4\\3\end{array}\right]$$ $$x_1 \left[\begin{array}{r}1\\-2\\-5 \end{array}\right] + x_2 =a_2=\left[\begin{array}{r}2\\5\\6 \end{array}\right]=\left[\begin{array}{r}7\\4\\3\end{array}\right]$$ The above is arranged in the form of matrix product as follows. $$\left[\begin{array}{r}1&...

pivot position in rref

pivot position In matrix A, the pivot position is the position corresponding to leading 1 in the row echelon form matrix (rref) of the matrix. A pivot column is a column that contains a pivot position. The rref of matrix A is ? >>> from sympy import * >>> A=Matrix([[0, -3, -6,4, 9],[-1,-2,-1, 3, 1], [-2, -3, 0, 3, -1], [1, 4, 5, -9, -7]]) >>> A Matrix([ [ 0, -3, -6,  4,  9], [-1, -2, -1,  3,  1], [-2, -3,  0,  3, -1], [ 1,  4,  5, -9, -7]]) >>> A.rref() (Matrix([ [1, 0, -3, 0,  5], [0, 1,  2, 0, -3], [0, 0,  0, 1,  0], [0, 0,  0, 0,  0]]), (0, 1, 3)) In that rref, the columns containing the leading 1 are 1, 2, and 4 columns. $$\left[\begin{array}{rrrrr}1(pivot)&0&-3&0&5\\0&1(pivot)&2&0&-3\\0&0&0&1(pivot)&0 \\0&0&0&0&0\end{array}\right]$$ >>> from sympy import * >>> B=Matrix...