// File: /workspace/github_cpp_makefile_star2_O1/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 0x3f5e
leaq 0x70(%rsp), %rdi
movl %r14d, %esi
movl %r14d, %edx
callq 0x3df8
movabsq $0x3ff0000000000000, %rbx # imm = 0x3FF0000000000000
testl %r14d, %r14d
jle 0xa3e6
movq 0x70(%rsp), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rbx, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %r14
jne 0xa3d6
leaq 0x198(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x21ed(%rip), %rsi      # 0xc5e6
leaq 0x21ec(%rip), %rdx      # 0xc5ec
leaq 0x188(%rsp), %rdi
callq 0x3c6e
leaq 0xa0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl $0x1, %edx
movl %r14d, %ecx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x43be
movq 0x188(%rsp), %rdi
cmpq %r15, %rdi
je 0xa445
callq 0x2110
leaq 0xa0(%rsp), %rdi
callq 0x3485
leaq 0xd0(%rsp), %rdi
movl %eax, %esi
callq 0x28c8
leaq 0xa0(%rsp), %rdi
movl $0x2, %esi
callq 0x340b
movsd %xmm0, 0x38(%rsp)
leaq 0xd0(%rsp), %rdi
movl $0x1, %esi
callq 0x3354
movsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rax)
leaq 0x80(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq 0x2b28
leaq 0x60(%rsp), %rdi
movl %r14d, %esi
movl %r14d, %edx
callq 0x3df8
testl %r14d, %r14d
jle 0xa4de
movq 0x60(%rsp), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rbx, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %r14
jne 0xa4ce
leaq 0x80(%rsp), %rdi
movl $0x2, %esi
callq 0x340b
ucomisd 0x1e08(%rip), %xmm0     # 0xc300
jbe 0xa5cd
leaq 0x108(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x2918
leaq 0xf8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x2918
leaq 0x10(%rsp), %rdi
leaq 0x108(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
callq 0x68fd
leaq 0xf8(%rsp), %rdi
callq 0x2970
leaq 0x108(%rsp), %rdi
callq 0x2970
leaq 0x80(%rsp), %rdi
movq %rdi, %rsi
callq 0x2cd3
movsd 0x1da4(%rip), %xmm1     # 0xc318
divsd %xmm0, %xmm1
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movapd %xmm1, %xmm0
callq 0x4e71
leaq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x4dca
leaq 0x60(%rsp), %rdi
leaq 0x50(%rsp), %r15
movq %r15, %rsi
callq 0x67e4
movq %r15, %rdi
callq 0x4016
leaq 0x40(%rsp), %rdi
callq 0x4016
leaq 0x10(%rsp), %rdi
callq 0x4016
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x4eee
movl %ebp, 0x20(%rsp)
movq %r12, 0xe0(%rsp)
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0x67e4
movq %r15, %rdi
callq 0x4016
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x4eee
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0x67e4
movq %r15, %rdi
callq 0x4016
cmpl $0x3, 0x24(%rsp)
jl 0xa95e
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 0x415c
movl 0x18(%rsp), %r13d
leaq 0x128(%rsp), %rax
movq %rax, 0x118(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0x1f59(%rip), %rsi      # 0xc5e6
leaq 0x1f58(%rip), %rdx      # 0xc5ec
callq 0x3c6e
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
movl $0x1, %edx
movl %r13d, %ecx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x43be
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0xa6d4
callq 0x2110
leaq 0x50(%rsp), %rdi
callq 0x3485
leaq 0x40(%rsp), %rdi
movl %eax, %esi
callq 0x28c8
leaq 0x50(%rsp), %rdi
movl $0x2, %esi
callq 0x340b
movsd %xmm0, 0x38(%rsp)
leaq 0x40(%rsp), %rbp
movq %rbp, %rdi
movl $0x1, %esi
callq 0x3354
movsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rax)
leaq 0x90(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rbp, %rdx
callq 0x2b28
leaq 0xc0(%rsp), %rdi
movl %r13d, %esi
movl %r13d, %edx
callq 0x3df8
testl %r13d, %r13d
jle 0xa762
movq 0xc0(%rsp), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rbx, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %r13
jne 0xa752
leaq 0x138(%rsp), %rdi
leaq 0x90(%rsp), %r13
movq %r13, %rsi
callq 0x2918
leaq 0x178(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2918
leaq 0xe8(%rsp), %rdi
leaq 0x138(%rsp), %r12
movq %r12, %rsi
movq %rbp, %rdx
callq 0x68fd
movq %rbp, %rdi
callq 0x2970
movq %r12, %rdi
callq 0x2970
leaq 0xb0(%rsp), %rdi
movl %r14d, %esi
movl %r14d, %edx
callq 0x3df8
testl %r14d, %r14d
leaq 0x168(%rsp), %rbp
jle 0xa7f2
movq 0xb0(%rsp), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rbx, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %r14
jne 0xa7e2
leaq 0x90(%rsp), %rdi
movl $0x2, %esi
callq 0x340b
ucomisd 0x1af4(%rip), %xmm0     # 0xc300
jbe 0xa8a4
leaq 0x90(%rsp), %rdi
movq %rdi, %rsi
callq 0x2cd3
leaq 0x158(%rsp), %r12
movsd 0x1ae6(%rip), %xmm1     # 0xc318
divsd %xmm0, %xmm1
movq %r12, %rdi
movapd %xmm1, %xmm0
leaq 0xe8(%rsp), %rsi
callq 0x4e71
movq %rbp, %rdi
leaq 0xc0(%rsp), %rsi
movq %r12, %rdx
callq 0x4dca
movq %r12, %rdi
callq 0x4016
leaq 0x148(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x3f5e
leaq 0xb0(%rsp), %rdi
movl %r15d, %esi
movl %r14d, %edx
movl %r15d, %ecx
movl %r14d, %r8d
movq %r12, %r9
callq 0x4768
movq %r12, %rdi
callq 0x4016
movq %rbp, %rdi
callq 0x4016
movq %rbp, %rdi
movq %rbp, %r13
leaq 0xb0(%rsp), %rbp
movq %rbp, %rsi
leaq 0x28(%rsp), %r12
movq %r12, %rdx
callq 0x4eee
movq %r12, %rdi
movq %r13, %rsi
callq 0x67e4
movq %r13, %rdi
callq 0x4016
movq %r13, %rdi
leaq 0x70(%rsp), %r12
movq %r12, %rsi
movq %rbp, %rdx
callq 0x4eee
movq %r12, %rdi
movq %r13, %rsi
callq 0x67e4
movq %r13, %rdi
callq 0x4016
movq %rbp, %rdi
callq 0x4016
leaq 0xe8(%rsp), %rdi
callq 0x4016
leaq 0xc0(%rsp), %rdi
callq 0x4016
leaq 0x90(%rsp), %rdi
callq 0x2970
leaq 0x40(%rsp), %rdi
callq 0x2970
leaq 0x50(%rsp), %rdi
callq 0x2970
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x4016
incl %r15d
cmpl 0x24(%rsp), %r15d
leaq 0x28(%rsp), %rsi
jne 0xa650
testl %r14d, %r14d
movl 0x20(%rsp), %ebp
jle 0xa9de
movl %ebp, %r13d
negl %r13d
movl $0x1, %r15d
leaq 0x28(%rsp), %rbx
testl %ebp, %ebp
jle 0xa9d2
movl $0x1, %r12d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x51ec
movsd (%rax), %xmm0
andpd 0x16b4(%rip), %xmm0     # 0xc050
movsd 0x1964(%rip), %xmm1     # 0xc308
ucomisd %xmm0, %xmm1
jbe 0xa9bf
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x51ec
movq $0x0, (%rax)
leal (%r12,%r13), %eax
incl %eax
movl %r12d, %ecx
incl %ecx
movl %ecx, %r12d
cmpl $0x1, %eax
jne 0xa982
leal 0x1(%r15), %eax
cmpl %r14d, %r15d
movl %eax, %r15d
jne 0xa978
leaq 0x70(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq 0xe0(%rsp), %rbx
movq %rbx, %rdi
callq 0xb12a
leaq 0x60(%rsp), %rdi
callq 0x4016
leaq 0x80(%rsp), %rdi
callq 0x2970
leaq 0xd0(%rsp), %rdi
callq 0x2970
leaq 0xa0(%rsp), %rdi
callq 0x2970
leaq 0x70(%rsp), %rdi
callq 0x4016
leaq 0x28(%rsp), %rdi
callq 0x4016
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 0x4016
jmp 0xabe0
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x2970
jmp 0xaa79
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x2970
jmp 0xabef
jmp 0xabec
jmp 0xabec
jmp 0xab26
jmp 0xabec
movq %rax, %rbx
jmp 0xabf9
jmp 0xaadc
movq %rax, %rbx
movq 0x188(%rsp), %rdi
cmpq %r15, %rdi
je 0xac20
callq 0x2110
jmp 0xac20
movq %rax, %rbx
jmp 0xac20
movq %rax, %rbx
jmp 0xac2a
jmp 0xabec
movq %rax, %rbx
jmp 0xac06
movq %rax, %rbx
jmp 0xac13
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
jmp 0xab16
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x4016
jmp 0xab0e
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
callq 0x4016
jmp 0xab8e
jmp 0xab8b
jmp 0xab8b
jmp 0xabec
movq %rax, %rbx
jmp 0xabe0
movq %rax, %rbx
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0xabe0
callq 0x2110
jmp 0xabe0
jmp 0xabc9
movq %rax, %rbx
jmp 0xabb5
movq %rax, %rbx
jmp 0xaba8
movq %rax, %rbx
jmp 0xab75
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
callq 0x2970
leaq 0x138(%rsp), %rdi
callq 0x2970
jmp 0xaba8
movq %rax, %rbx
jmp 0xab9b
jmp 0xab8b
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x4016
leaq 0xe8(%rsp), %rdi
callq 0x4016
leaq 0xc0(%rsp), %rdi
callq 0x4016
leaq 0x90(%rsp), %rdi
callq 0x2970
jmp 0xabcc
movq %rax, %rbx
jmp 0xabd6
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2970
leaq 0x50(%rsp), %rdi
callq 0x2970
leaq 0x10(%rsp), %rdi
callq 0x4016
jmp 0xabef
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x4016
leaq 0x80(%rsp), %rdi
callq 0x2970
leaq 0xd0(%rsp), %rdi
callq 0x2970
leaq 0xa0(%rsp), %rdi
callq 0x2970
leaq 0x70(%rsp), %rdi
callq 0x4016
leaq 0x28(%rsp), %rdi
callq 0x4016
movq %rbx, %rdi
callq 0x21c0