// File: /workspace/github_cpp_makefile_star2_O3/IlanPrice[P]Linear-Algebra-Library-in-Cplusplus/Matrix.cpp
// Function: QR(Matrix const&)
std::pair <Matrix,Matrix> QR(const Matrix& A)
{
	int Rrows = A.mRows;
	int Rcolumns = A.mColumns;
	int t = std::min(Rrows,Rcolumns);
	Matrix R = A;
	Matrix Q = eye(Rrows);
	Vector u = R.getElements(1,Rrows,1,1,"Vector");
	Vector v(length(u));
	v(1) = norm(u,2);
	Vector w = u-v;
	Matrix H = eye(Rrows);
	if (norm(w,2)>1e-15)
		{
			Matrix temp = outer(w,w);
			H = H - (2/(w*w))*temp;
		}
	R = H*R;
	Q = Q*H;
	for (int i=2;i<t;i++)
	{
		Matrix B = R.getElements(i,Rrows,i, Rcolumns);
		Vector u2 = B.getElements(1,B.mRows,1,1,"Vector");
		Vector v2(length(u2));
		v2(1) = norm(u2,2);;
		Vector w2 = u2-v2;
		Matrix I2 = eye(B.mRows);
		Matrix temp2 = outer(w2,w2);
		Matrix H2 = eye(Rrows);
		if (norm(w2,2)>1e-15)
		{
		Matrix Hhat = I2 - (2/(w2*w2))*temp2;
		H2.setElements(i,Rrows,i,Rrows,Hhat);
		}
		R = H2*R;
		Q = Q*H2;
	}
	for (int i=1;i<=Rrows;i++)
	{
		for(int j=1;j<=Rcolumns;j++)
		{
			if (std::abs(R(i,j)) < 1e-14)
				{R(i,j) = 0;}
		}
	}
	std::pair<Matrix,Matrix> qr = std::make_pair(Q,R);
	return qr;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %r12
movl 0x8(%rsi), %r14d
movl 0xc(%rsi), %ebp
cmpl %r14d, %ebp
movl %r14d, %eax
cmovll %ebp, %eax
movl %eax, 0x24(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x3f2a
leaq 0x70(%rsp), %rdi
movl %r14d, %esi
movl %r14d, %edx
callq 0x3dd4
movabsq $0x3ff0000000000000, %rbx # imm = 0x3FF0000000000000
testl %r14d, %r14d
jle 0xa39b
movq 0x70(%rsp), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rbx, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %r14
jne 0xa38b
leaq 0x198(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2238(%rip), %rsi      # 0xc5e6
leaq 0x2237(%rip), %rdx      # 0xc5ec
leaq 0x188(%rsp), %rdi
callq 0x3c44
leaq 0xa0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl $0x1, %edx
movl %r14d, %ecx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x4398
movq 0x188(%rsp), %rdi
cmpq %r15, %rdi
je 0xa3fa
callq 0x2100
leaq 0xa0(%rsp), %rdi
callq 0x3461
leaq 0xd0(%rsp), %rdi
movl %eax, %esi
callq 0x28b8
leaq 0xa0(%rsp), %rdi
movl $0x2, %esi
callq 0x33e7
movsd %xmm0, 0x38(%rsp)
leaq 0xd0(%rsp), %rdi
movl $0x1, %esi
callq 0x3330
movsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rax)
leaq 0x80(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq 0x2af8
leaq 0x60(%rsp), %rdi
movl %r14d, %esi
movl %r14d, %edx
callq 0x3dd4
testl %r14d, %r14d
jle 0xa493
movq 0x60(%rsp), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rbx, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %r14
jne 0xa483
leaq 0x80(%rsp), %rdi
movl $0x2, %esi
callq 0x33e7
ucomisd 0x1e53(%rip), %xmm0     # 0xc300
jbe 0xa582
leaq 0x108(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x28fa
leaq 0xf8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x28fa
leaq 0x10(%rsp), %rdi
leaq 0x108(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
callq 0x692c
leaq 0xf8(%rsp), %rdi
callq 0x294e
leaq 0x108(%rsp), %rdi
callq 0x294e
leaq 0x80(%rsp), %rdi
movq %rdi, %rsi
callq 0x2c95
movsd 0x1def(%rip), %xmm1     # 0xc318
divsd %xmm0, %xmm1
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movapd %xmm1, %xmm0
callq 0x4e7a
leaq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x4dd5
leaq 0x60(%rsp), %rdi
leaq 0x50(%rsp), %r15
movq %r15, %rsi
callq 0x681a
movq %r15, %rdi
callq 0x3fe2
leaq 0x40(%rsp), %rdi
callq 0x3fe2
leaq 0x10(%rsp), %rdi
callq 0x3fe2
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x4ef7
movl %ebp, 0x20(%rsp)
movq %r12, 0xe0(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0x681a
movq %r15, %rdi
callq 0x3fe2
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x4ef7
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0x681a
movq %r15, %rdi
callq 0x3fe2
cmpl $0x3, 0x24(%rsp)
jl 0xa913
movl $0x2, %r15d
leaq 0x10(%rsp), %r13
leaq 0x28(%rsp), %rsi
movq %r13, %r12
movq %r13, %rdi
movl %r15d, %edx
movl %r14d, %ecx
movl %r15d, %r8d
movl 0x20(%rsp), %r9d
callq 0x412c
movl 0x18(%rsp), %r13d
leaq 0x128(%rsp), %rax
movq %rax, 0x118(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0x1fa4(%rip), %rsi      # 0xc5e6
leaq 0x1fa3(%rip), %rdx      # 0xc5ec
callq 0x3c44
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
movl $0x1, %edx
movl %r13d, %ecx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x4398
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0xa689
callq 0x2100
leaq 0x50(%rsp), %rdi
callq 0x3461
leaq 0x40(%rsp), %rdi
movl %eax, %esi
callq 0x28b8
leaq 0x50(%rsp), %rdi
movl $0x2, %esi
callq 0x33e7
movsd %xmm0, 0x38(%rsp)
leaq 0x40(%rsp), %rbp
movq %rbp, %rdi
movl $0x1, %esi
callq 0x3330
movsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rax)
leaq 0x90(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rbp, %rdx
callq 0x2af8
leaq 0xc0(%rsp), %rdi
movl %r13d, %esi
movl %r13d, %edx
callq 0x3dd4
testl %r13d, %r13d
jle 0xa717
movq 0xc0(%rsp), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rbx, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %r13
jne 0xa707
leaq 0x138(%rsp), %rdi
leaq 0x90(%rsp), %r13
movq %r13, %rsi
callq 0x28fa
leaq 0x178(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x28fa
leaq 0xe8(%rsp), %rdi
leaq 0x138(%rsp), %r12
movq %r12, %rsi
movq %rbp, %rdx
callq 0x692c
movq %rbp, %rdi
callq 0x294e
movq %r12, %rdi
callq 0x294e
leaq 0xb0(%rsp), %rdi
movl %r14d, %esi
movl %r14d, %edx
callq 0x3dd4
testl %r14d, %r14d
leaq 0x168(%rsp), %rbp
jle 0xa7a7
movq 0xb0(%rsp), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rbx, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %r14
jne 0xa797
leaq 0x90(%rsp), %rdi
movl $0x2, %esi
callq 0x33e7
ucomisd 0x1b3f(%rip), %xmm0     # 0xc300
jbe 0xa859
leaq 0x90(%rsp), %rdi
movq %rdi, %rsi
callq 0x2c95
leaq 0x158(%rsp), %r12
movsd 0x1b31(%rip), %xmm1     # 0xc318
divsd %xmm0, %xmm1
movq %r12, %rdi
movapd %xmm1, %xmm0
leaq 0xe8(%rsp), %rsi
callq 0x4e7a
movq %rbp, %rdi
leaq 0xc0(%rsp), %rsi
movq %r12, %rdx
callq 0x4dd5
movq %r12, %rdi
callq 0x3fe2
leaq 0x148(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3f2a
leaq 0xb0(%rsp), %rdi
movl %r15d, %esi
movl %r14d, %edx
movl %r15d, %ecx
movl %r14d, %r8d
movq %r12, %r9
callq 0x475c
movq %r12, %rdi
callq 0x3fe2
movq %rbp, %rdi
callq 0x3fe2
movq %rbp, %rdi
movq %rbp, %r13
leaq 0xb0(%rsp), %rbp
movq %rbp, %rsi
leaq 0x28(%rsp), %r12
movq %r12, %rdx
callq 0x4ef7
movq %r12, %rdi
movq %r13, %rsi
callq 0x681a
movq %r13, %rdi
callq 0x3fe2
movq %r13, %rdi
leaq 0x70(%rsp), %r12
movq %r12, %rsi
movq %rbp, %rdx
callq 0x4ef7
movq %r12, %rdi
movq %r13, %rsi
callq 0x681a
movq %r13, %rdi
callq 0x3fe2
movq %rbp, %rdi
callq 0x3fe2
leaq 0xe8(%rsp), %rdi
callq 0x3fe2
leaq 0xc0(%rsp), %rdi
callq 0x3fe2
leaq 0x90(%rsp), %rdi
callq 0x294e
leaq 0x40(%rsp), %rdi
callq 0x294e
leaq 0x50(%rsp), %rdi
callq 0x294e
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x3fe2
incl %r15d
cmpl 0x24(%rsp), %r15d
leaq 0x28(%rsp), %rsi
jne 0xa605
testl %r14d, %r14d
movl 0x20(%rsp), %ebp
jle 0xa993
movl %ebp, %r13d
negl %r13d
movl $0x1, %r15d
leaq 0x28(%rsp), %rbx
testl %ebp, %ebp
jle 0xa987
movl $0x1, %r12d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x5202
movsd (%rax), %xmm0
andpd 0x16ff(%rip), %xmm0     # 0xc050
movsd 0x19af(%rip), %xmm1     # 0xc308
ucomisd %xmm0, %xmm1
jbe 0xa974
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x5202
movq $0x0, (%rax)
leal (%r12,%r13), %eax
incl %eax
movl %r12d, %ecx
incl %ecx
movl %ecx, %r12d
cmpl $0x1, %eax
jne 0xa937
leal 0x1(%r15), %eax
cmpl %r14d, %r15d
movl %eax, %r15d
jne 0xa92d
leaq 0x70(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq 0xe0(%rsp), %rbx
movq %rbx, %rdi
callq 0xb0ea
leaq 0x60(%rsp), %rdi
callq 0x3fe2
leaq 0x80(%rsp), %rdi
callq 0x294e
leaq 0xd0(%rsp), %rdi
callq 0x294e
leaq 0xa0(%rsp), %rdi
callq 0x294e
leaq 0x70(%rsp), %rdi
callq 0x3fe2
leaq 0x28(%rsp), %rdi
callq 0x3fe2
movq %rbx, %rax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3fe2
jmp 0xab95
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x294e
jmp 0xaa2e
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x294e
jmp 0xaba4
jmp 0xaba1
jmp 0xaba1
jmp 0xaadb
jmp 0xaba1
movq %rax, %rbx
jmp 0xabae
jmp 0xaa91
movq %rax, %rbx
movq 0x188(%rsp), %rdi
cmpq %r15, %rdi
je 0xabd5
callq 0x2100
jmp 0xabd5
movq %rax, %rbx
jmp 0xabd5
movq %rax, %rbx
jmp 0xabdf
jmp 0xaba1
movq %rax, %rbx
jmp 0xabbb
movq %rax, %rbx
jmp 0xabc8
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
jmp 0xaacb
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x3fe2
jmp 0xaac3
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0x3fe2
jmp 0xab43
jmp 0xab40
jmp 0xab40
jmp 0xaba1
movq %rax, %rbx
jmp 0xab95
movq %rax, %rbx
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0xab95
callq 0x2100
jmp 0xab95
jmp 0xab7e
movq %rax, %rbx
jmp 0xab6a
movq %rax, %rbx
jmp 0xab5d
movq %rax, %rbx
jmp 0xab2a
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
callq 0x294e
leaq 0x138(%rsp), %rdi
callq 0x294e
jmp 0xab5d
movq %rax, %rbx
jmp 0xab50
jmp 0xab40
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x3fe2
leaq 0xe8(%rsp), %rdi
callq 0x3fe2
leaq 0xc0(%rsp), %rdi
callq 0x3fe2
leaq 0x90(%rsp), %rdi
callq 0x294e
jmp 0xab81
movq %rax, %rbx
jmp 0xab8b
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x294e
leaq 0x50(%rsp), %rdi
callq 0x294e
leaq 0x10(%rsp), %rdi
callq 0x3fe2
jmp 0xaba4
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3fe2
leaq 0x80(%rsp), %rdi
callq 0x294e
leaq 0xd0(%rsp), %rdi
callq 0x294e
leaq 0xa0(%rsp), %rdi
callq 0x294e
leaq 0x70(%rsp), %rdi
callq 0x3fe2
leaq 0x28(%rsp), %rdi
callq 0x3fe2
movq %rbx, %rdi
callq 0x21b0