// File: yukimasano[P]cpp_matrix/Matrix.cpp
// Function: momentum(Matrix&, Vector&, int&, double, double)
Vector momentum(Matrix& A, Vector& v, int& count,double lambda,double mu){
	assert(nrows(A) == ncols(A));
	int m =nrows(A);
	// we want a square system

	// INITIALISATION
	Vector x= v;
	double tol = 1.e-12;
	Vector r = A*x;
	r= r-v;
	Vector temp(m);
	//std::cout<<" before the while loop "<<(A*x -c).norm() << std::endl<<std::flush;
	while ((A*x -v).norm() > tol){
		count+=1;
    temp = mu*temp - lambda*r;
		x = x + temp;
		r = v - A*x;
	}
   //	std::cout<<count<<std::endl<<std::flush;

	return x;
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x20(%rsp)
movq %rdi, %rax
movq %rax, 0x28(%rsp)
movq %rdi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
movq %rdx, 0x120(%rsp)
movq %rcx, 0x118(%rsp)
movsd %xmm0, 0x110(%rsp)
movsd %xmm1, 0x108(%rsp)
movq 0x128(%rsp), %rdi
callq 0x3ac0
movl %eax, 0x34(%rsp)
movq 0x128(%rsp), %rdi
callq 0x3ad0
movl %eax, %ecx
movl 0x34(%rsp), %eax
cmpl %ecx, %eax
jne 0xcb70
jmp 0xcb8f
leaq 0x279b(%rip), %rdi      # 0xf312
leaq 0x25cb(%rip), %rsi      # 0xf149
movl $0x3b3, %edx            # imm = 0x3B3
leaq 0x28fe(%rip), %rcx      # 0xf488
callq 0x2090
movq 0x128(%rsp), %rdi
callq 0x3ac0
movq 0x20(%rsp), %rdi
movl %eax, 0x104(%rsp)
movb $0x0, 0x103(%rsp)
movq 0x120(%rsp), %rsi
callq 0xd0d0
movq 0x20(%rsp), %rdx
movabsq $0x3d719799812dea11, %rax # imm = 0x3D719799812DEA11
movq %rax, 0xf8(%rsp)
movq 0x128(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
callq 0x4800
jmp 0xcbeb
movq 0x120(%rsp), %rdx
leaq 0xc8(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0xd470
jmp 0xcc0a
leaq 0xe8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xdc70
jmp 0xcc21
leaq 0xc8(%rsp), %rdi
callq 0xd170
movl 0x104(%rsp), %esi
leaq 0xb8(%rsp), %rdi
callq 0xd040
jmp 0xcc44
jmp 0xcc46
movq 0x20(%rsp), %rdx
movq 0x128(%rsp), %rsi
leaq 0x98(%rsp), %rdi
callq 0x4800
jmp 0xcc62
movq 0x120(%rsp), %rdx
leaq 0xa8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0xd470
jmp 0xcc81
leaq 0xa8(%rsp), %rdi
movl $0x2, %esi
callq 0xe320
movsd %xmm0, 0x18(%rsp)
jmp 0xcc9b
movsd 0xf8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xd170
leaq 0x98(%rsp), %rdi
callq 0xd170
movsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xcf8e
movq 0x118(%rsp), %rax
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
leaq 0x78(%rsp), %rdi
leaq 0x108(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0xd910
jmp 0xcd04
leaq 0x68(%rsp), %rdi
leaq 0x110(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0xd910
jmp 0xcd20
leaq 0x88(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0xd470
jmp 0xcd39
leaq 0xb8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xdc70
jmp 0xcd50
leaq 0x88(%rsp), %rdi
callq 0xd170
leaq 0x68(%rsp), %rdi
callq 0xd170
leaq 0x78(%rsp), %rdi
callq 0xd170
movq 0x20(%rsp), %rsi
leaq 0x58(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0xd1a0
jmp 0xcd8a
movq 0x20(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0xdc70
jmp 0xcd9b
leaq 0x58(%rsp), %rdi
callq 0xd170
movq 0x20(%rsp), %rdx
movq 0x120(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x128(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x4800
jmp 0xcdcb
movq 0x8(%rsp), %rsi
leaq 0x48(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0xd470
jmp 0xcde1
leaq 0xe8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xdc70
jmp 0xcdf5
leaq 0x48(%rsp), %rdi
callq 0xd170
leaq 0x38(%rsp), %rdi
callq 0xd170
jmp 0xcc46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0xcfef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0xcfc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0xd170
jmp 0xcfc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0xcfbc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0xceb6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xd170
leaq 0x98(%rsp), %rdi
callq 0xd170
jmp 0xcfbc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0xcf1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0xcf15
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x88(%rsp), %rdi
callq 0xd170
leaq 0x68(%rsp), %rdi
callq 0xd170
leaq 0x78(%rsp), %rdi
callq 0xd170
jmp 0xcfbc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xd170
jmp 0xcfbc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
jmp 0xcf82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x48(%rsp), %rdi
callq 0xd170
leaq 0x38(%rsp), %rdi
callq 0xd170
jmp 0xcfbc
movb $0x1, 0x103(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0xd170
leaq 0xe8(%rsp), %rdi
callq 0xd170
testb $0x1, 0x103(%rsp)
jne 0xcfe2
jmp 0xcfd8
leaq 0xb8(%rsp), %rdi
callq 0xd170
leaq 0xe8(%rsp), %rdi
callq 0xd170
jmp 0xcfef
movq 0x20(%rsp), %rdi
callq 0xd170
movq 0x28(%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
retq
movq 0x20(%rsp), %rdi
callq 0xd170
movq 0xe0(%rsp), %rdi
callq 0x21e0
nopw %cs:(%rax,%rax)