// File: /workspace/github_cpp_makefile_star2_O2/IlanPrice[P]Linear-Algebra-Library-in-Cplusplus/Matrix.cpp
// Function: eig(Matrix const&)
std::pair <Vector,Matrix> eig(const Matrix& A)
{
	Vector dim = size(A);
	if (dim(1) != dim(2)) {throw Exception("dimension error",
	"computing eig(), matrix supplied not square");}
	std::pair<Matrix, Matrix> qr = QR(A);
	Matrix Q = qr.first;
	Matrix R = qr.second;
	disp(Q);
	disp(R);
	Matrix Anew = R*Q;
	Matrix Atemp = Matrix(dim(1),dim(2));
	Matrix evecs = Q;
	do {
			Atemp = Anew;
			qr = QR(Anew);
			Q = qr.first;
			R = qr.second;
			Anew = R*Q;
			evecs = evecs*Q;
			disp(Q);
			disp(evecs);
		}while((std::abs(Atemp(1,1) - Anew(1,1))) > 1e-15);

	Vector evals = diag(Anew);
	std::pair<Vector,Matrix> eigs = std::make_pair(evals,evecs);
	return eigs;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x506c
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x2030
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x2030
movsd 0x10(%rsp), %xmm0
ucomisd (%rax), %xmm0
jne 0x8a8b
jp 0x8a8b
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
callq 0x8061
movq %rsp, %rdi
leaq 0x78(%rsp), %rsi
callq 0x29b2
leaq 0x88(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x29b2
movq %rsp, %rdi
callq 0x2b73
leaq 0x20(%rsp), %rdi
callq 0x2b73
leaq 0x60(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
callq 0x376b
leaq 0x30(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x2030
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
pushq $0x2
popq %rsi
callq 0x2030
cvttsd2si 0x10(%rsp), %esi
cvttsd2si (%rax), %edx
leaq 0x50(%rsp), %rdi
callq 0x285c
movq %r15, 0x70(%rsp)
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
callq 0x29b2
leaq 0x60(%rsp), %r12
leaq 0x98(%rsp), %r13
movq %rsp, %rbx
leaq 0x40(%rsp), %r15
pushq $0x1
popq %rbp
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
callq 0x4c1c
movq %r13, %rdi
movq %r12, %rsi
callq 0x8061
leaq 0x78(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x8bf2
movq %r13, %rdi
callq 0x8bdc
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4c1c
leaq 0x20(%rsp), %r14
movq %r14, %rdi
leaq 0x88(%rsp), %rsi
callq 0x4c1c
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x376b
movq %r12, %rdi
movq %r13, %rsi
callq 0x4c1c
movq %r13, %rdi
callq 0x2a78
movq %r13, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x376b
movq %r15, %rdi
movq %r13, %rsi
callq 0x4c1c
movq %r13, %rdi
callq 0x2a78
movq %rbx, %rdi
callq 0x2b73
movq %r15, %rdi
callq 0x2b73
leaq 0x50(%rsp), %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0x3a1a
movsd (%rax), %xmm0
movapd %xmm0, 0x10(%rsp)
movq %r12, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0x3a1a
movapd 0x10(%rsp), %xmm0
subsd (%rax), %xmm0
andpd 0x665(%rip), %xmm0      # 0x9050
ucomisd 0x8e5(%rip), %xmm0      # 0x92d8
ja 0x8913
leaq 0x98(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x528f
leaq 0x98(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movq 0x70(%rsp), %rbx
movq %rbx, %rdi
callq 0x8c68
leaq 0x98(%rsp), %rdi
callq 0x1908
leaq 0x40(%rsp), %rdi
callq 0x2a78
leaq 0x50(%rsp), %rdi
callq 0x2a78
leaq 0x60(%rsp), %rdi
callq 0x2a78
leaq 0x20(%rsp), %rdi
callq 0x2a78
movq %rsp, %rdi
callq 0x2a78
leaq 0x78(%rsp), %rdi
callq 0x8bdc
leaq 0x30(%rsp), %rdi
callq 0x1908
movq %rbx, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x40
popq %rdi
callq 0x1080
movq %rax, %r14
leaq 0xb95(%rip), %rsi       # 0x9632
leaq 0xd8(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x1060
leaq 0xb8c(%rip), %rsi       # 0x9642
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x1060
movb $0x1, %bpl
leaq 0xd8(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
movq %r14, %rdi
callq 0x2790
xorl %ebp, %ebp
leaq 0x52b1(%rip), %rsi      # 0xdda0
leaq -0x637c(%rip), %rdx     # 0x277a
movq %r14, %rdi
callq 0x1150
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x1070
jmp 0x8b16
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xd8(%rsp), %rdi
callq 0x1070
testb %bpl, %bpl
jne 0x8b30
jmp 0x8bb3
movq %rax, %rbx
movq %r14, %rdi
callq 0x10b0
jmp 0x8bb3
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x1908
jmp 0x8b79
jmp 0x8b76
movq %rax, %rbx
jmp 0x8b83
jmp 0x8b61
movq %rax, %rbx
jmp 0x8ba1
movq %rax, %rbx
jmp 0x8ba9
jmp 0x8b66
movq %rax, %rbx
jmp 0x8b97
movq %rax, %rbx
jmp 0x8bb3
movq %rax, %rbx
jmp 0x8b8d
jmp 0x8b76
jmp 0x8b76
jmp 0x8b76
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2a78
leaq 0x50(%rsp), %rdi
callq 0x2a78
leaq 0x60(%rsp), %rdi
callq 0x2a78
leaq 0x20(%rsp), %rdi
callq 0x2a78
movq %rsp, %rdi
callq 0x2a78
leaq 0x78(%rsp), %rdi
callq 0x8bdc
leaq 0x30(%rsp), %rdi
callq 0x1908
movq %rbx, %rdi
callq 0x1180
nop