// File: 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:
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdi, 0x90(%rsp)
movq %rdi, %rax
movq %rax, 0x98(%rsp)
movq %rdi, 0x1f0(%rsp)
movq %rsi, 0x1e8(%rsp)
movq 0x1e8(%rsp), %rsi
leaq 0x1d8(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0xa130
movq 0xa0(%rsp), %rdi
movl $0x1, %esi
callq 0x3ee0
movq %rax, 0xa8(%rsp)
jmp 0x10703
movq 0xa8(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x80(%rsp)
leaq 0x1d8(%rsp), %rdi
movl $0x2, %esi
callq 0x3ee0
movq %rax, 0x88(%rsp)
jmp 0x10734
movsd 0x80(%rsp), %xmm0
movq 0x88(%rsp), %rax
ucomisd (%rax), %xmm0
jne 0x10752
jp 0x10752
jmp 0x108ac
movb $0x1, 0x17e(%rsp)
movl $0x40, %edi
callq 0x2070
movq %rax, 0x70(%rsp)
leaq 0x1a7(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x21c0
movq 0x78(%rsp), %rdx
leaq 0x1e9b(%rip), %rsi      # 0x12622
leaq 0x1a8(%rsp), %rdi
callq 0x2110
jmp 0x10796
leaq 0x17f(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x21c0
movq 0x68(%rsp), %rdx
leaq 0x1e7e(%rip), %rsi      # 0x12632
leaq 0x180(%rsp), %rdi
callq 0x2110
jmp 0x107c3
movq 0x70(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
leaq 0x180(%rsp), %rdx
callq 0x4d60
jmp 0x107df
movq 0x70(%rsp), %rdi
movb $0x0, 0x17e(%rsp)
leaq 0x55ad(%rip), %rsi      # 0x15da0
leaq -0xbaca(%rip), %rdx     # 0x4d30
callq 0x2180
jmp 0x10d6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0x10d53
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0x10884
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0x1086a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x2080
leaq 0x17f(%rsp), %rdi
callq 0x20f0
leaq 0x1a8(%rsp), %rdi
callq 0x2080
leaq 0x1a7(%rsp), %rdi
callq 0x20f0
testb $0x1, 0x17e(%rsp)
jne 0x1089d
jmp 0x108a7
movq 0x70(%rsp), %rdi
callq 0x20a0
jmp 0x10d53
movq 0x1e8(%rsp), %rsi
leaq 0x158(%rsp), %rdi
callq 0xf9d0
jmp 0x108c3
leaq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x50f0
jmp 0x108da
leaq 0x168(%rsp), %rsi
leaq 0x138(%rsp), %rdi
callq 0x50f0
jmp 0x108f1
leaq 0x148(%rsp), %rdi
callq 0x5410
jmp 0x10900
leaq 0x138(%rsp), %rdi
callq 0x5410
jmp 0x1090f
leaq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rsi
leaq 0x148(%rsp), %rdx
callq 0x6cc0
jmp 0x1092e
leaq 0x1d8(%rsp), %rdi
movl $0x1, %esi
callq 0x3ee0
movq %rax, 0x60(%rsp)
jmp 0x10947
movq 0x60(%rsp), %rax
cvttsd2si (%rax), %eax
movl %eax, 0x54(%rsp)
leaq 0x1d8(%rsp), %rdi
movl $0x2, %esi
callq 0x3ee0
movq %rax, 0x58(%rsp)
jmp 0x1096d
movl 0x54(%rsp), %esi
movq 0x58(%rsp), %rax
cvttsd2si (%rax), %edx
leaq 0x118(%rsp), %rdi
callq 0x4e80
jmp 0x10989
leaq 0x108(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x50f0
jmp 0x109a0
jmp 0x109a2
leaq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rsi
movq %rsi, 0x48(%rsp)
callq 0x9930
movq 0x48(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
callq 0xf9d0
jmp 0x109d0
leaq 0x158(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x10f40
jmp 0x109e7
leaq 0xe8(%rsp), %rdi
callq 0x10f10
leaq 0x148(%rsp), %rdi
movq %rdi, 0x40(%rsp)
leaq 0x158(%rsp), %rsi
callq 0x9930
leaq 0x168(%rsp), %rsi
leaq 0x138(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x9930
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
leaq 0xd8(%rsp), %rdi
callq 0x6cc0
jmp 0x10a41
leaq 0x128(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
movq %rsi, 0x30(%rsp)
callq 0x9930
movq 0x30(%rsp), %rdi
callq 0x5230
leaq 0xc8(%rsp), %rdi
leaq 0x108(%rsp), %rsi
leaq 0x148(%rsp), %rdx
callq 0x6cc0
jmp 0x10a84
leaq 0x108(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
movq %rsi, 0x28(%rsp)
callq 0x9930
movq 0x28(%rsp), %rdi
callq 0x5230
leaq 0x148(%rsp), %rdi
callq 0x5410
jmp 0x10ab7
leaq 0x108(%rsp), %rdi
callq 0x5410
jmp 0x10ac6
jmp 0x10ac8
leaq 0x118(%rsp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x96e0
movq %rax, 0x20(%rsp)
jmp 0x10ae3
movq 0x20(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x128(%rsp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x96e0
movq %rax, 0x18(%rsp)
jmp 0x10b0d
movsd 0x10(%rsp), %xmm0
movq 0x18(%rsp), %rax
movsd (%rax), %xmm1
subsd %xmm1, %xmm0
callq 0x10e30
movsd %xmm0, 0x8(%rsp)
jmp 0x10b2d
movsd 0x8(%rsp), %xmm0
movsd 0x1775(%rip), %xmm1     # 0x122b0
ucomisd %xmm1, %xmm0
ja 0x109a2
leaq 0xb8(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0xa570
jmp 0x10b5c
movq 0x90(%rsp), %rdi
movb $0x0, 0xb7(%rsp)
leaq 0xb8(%rsp), %rsi
leaq 0x108(%rsp), %rdx
callq 0x10f80
jmp 0x10b83
movb $0x1, 0xb7(%rsp)
testb $0x1, 0xb7(%rsp)
jne 0x10c8d
jmp 0x10c80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0x10d46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0x10d39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0x10d2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0x10d1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0x10d12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
jmp 0x10d05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x10f10
jmp 0x10d05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1d0(%rsp)
movl %eax, 0x1cc(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x2ea0
jmp 0x10d05
movq 0x90(%rsp), %rdi
callq 0x10fc0
leaq 0xb8(%rsp), %rdi
callq 0x2ea0
leaq 0x108(%rsp), %rdi
callq 0x5230
leaq 0x118(%rsp), %rdi
callq 0x5230
leaq 0x128(%rsp), %rdi
callq 0x5230
leaq 0x138(%rsp), %rdi
callq 0x5230
leaq 0x148(%rsp), %rdi
callq 0x5230
leaq 0x158(%rsp), %rdi
callq 0x10f10
leaq 0x1d8(%rsp), %rdi
callq 0x2ea0
movq 0x98(%rsp), %rax
addq $0x1f8, %rsp            # imm = 0x1F8
retq
leaq 0x108(%rsp), %rdi
callq 0x5230
leaq 0x118(%rsp), %rdi
callq 0x5230
leaq 0x128(%rsp), %rdi
callq 0x5230
leaq 0x138(%rsp), %rdi
callq 0x5230
leaq 0x148(%rsp), %rdi
callq 0x5230
leaq 0x158(%rsp), %rdi
callq 0x10f10
leaq 0x1d8(%rsp), %rdi
callq 0x2ea0
movq 0x1d0(%rsp), %rdi
callq 0x21b0
nopl (%rax)