// File: /workspace/github_cpp_makefile_star2_O2/yukimasano[P]cpp_matrix/Matrix.cpp
// Function: Jacobi(Matrix&, Vector&, int&)
Vector Jacobi(Matrix& A, Vector& v, int& count){
	assert(nrows(A) == ncols(A));
	int m =nrows(A);
	// we want a square system

	// INITIALISATION
	Matrix T=A;
	for (int k=1; k<=m; k++){
		T.set_val(k,k, (1./A(k,k)));
	}
	Vector temp = ones(m);
	Matrix eye = diag(temp);
  Vector c = T*v;
	T =  (eye - T);
	double tol = 1.e-14*v.norm();
	Vector x=c;
	//std::cout<<" before the while loop "<<(A*x -c).norm() << std::endl<<std::flush;
  Vector r = (A*x -v);
	while (r.norm() > tol){
		count+=1;
		x = T*x + c;
    r = (A*x -v);
	//	std::cout<<(A*x -v).norm() << std::endl<<std::flush;
	}
  //	std::cout<<count<<std::endl<<std::flush;

	return x;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, 0x50(%rsp)
movq %rdx, (%rsp)
movl 0x8(%rsi), %ebp
cmpl 0xc(%rsi), %ebp
jne 0x5ff1
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3b80
xorl %r14d, %r14d
testl %ebp, %ebp
movl $0x0, %r15d
cmovgl %ebp, %r15d
cmpq %r14, %r15
je 0x5e4c
leal 0x1(%r14), %edx
movq %r12, %rdi
movl %edx, %esi
callq 0x2e20
movsd 0x31e4(%rip), %xmm0     # 0x9018
divsd (%rax), %xmm0
movq 0x20(%rsp), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
jmp 0x5e19
leaq 0x68(%rsp), %rdi
movl %ebp, %esi
callq 0x8995
leaq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3b09
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq (%rsp), %rdx
callq 0x372f
leaq 0x10(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x32b3
leaq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x33ce
leaq 0x10(%rsp), %rdi
callq 0x2dea
pushq $0x2
popq %rsi
movq (%rsp), %rdi
callq 0x891a
movsd %xmm0, 0x8(%rsp)
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x80b8
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x372f
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq (%rsp), %rdx
callq 0x8238
movsd 0x8(%rsp), %xmm0
mulsd 0x3199(%rip), %xmm0     # 0x9090
movsd %xmm0, 0x8(%rsp)
leaq 0x30(%rsp), %r13
movq %r13, %rdi
callq 0x8104
leaq 0x10(%rsp), %rbp
pushq $0x2
popq %r14
leaq 0x78(%rsp), %r15
movq %rbp, %rdi
movl %r14d, %esi
callq 0x891a
ucomisd 0x8(%rsp), %xmm0
jbe 0x5faa
movq 0x50(%rsp), %rax
incl (%rax)
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x372f
movq %r13, %rdi
movq %r15, %rsi
leaq 0x40(%rsp), %rdx
callq 0x8111
movq %rbx, %rdi
movq %r13, %rsi
callq 0x859c
movq %r13, %rdi
callq 0x8104
movq %r15, %rdi
callq 0x8104
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x372f
movq %r13, %rdi
movq %r15, %rsi
movq (%rsp), %rdx
callq 0x8238
movq %rbp, %rdi
movq %r13, %rsi
callq 0x859c
movq %r13, %rdi
callq 0x8104
movq %r15, %rdi
callq 0x8104
jmp 0x5f18
leaq 0x10(%rsp), %rdi
callq 0x8104
leaq 0x40(%rsp), %rdi
callq 0x8104
leaq 0x58(%rsp), %rdi
callq 0x2dea
leaq 0x68(%rsp), %rdi
callq 0x8104
leaq 0x20(%rsp), %rdi
callq 0x2dea
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3322(%rip), %rdi      # 0x931a
leaq 0x3152(%rip), %rsi      # 0x9151
leaq 0x33ab(%rip), %rcx      # 0x93b1
movl $0x29a, %edx            # imm = 0x29A
callq 0x20b0
movq %rax, %r14
leaq 0x30(%rsp), %rdi
jmp 0x6074
movq %rax, %r14
jmp 0x6079
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x2dea
jmp 0x6081
jmp 0x603c
movq %rax, %r14
jmp 0x608b
movq %rax, %r14
jmp 0x6095
jmp 0x6067
movq %rax, %r14
jmp 0x6081
jmp 0x606c
jmp 0x6047
jmp 0x6058
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x8104
jmp 0x605b
jmp 0x606c
movq %rax, %r14
leaq 0x78(%rsp), %rdi
callq 0x8104
jmp 0x606f
movq %rax, %r14
jmp 0x609f
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x8104
movq %rbx, %rdi
callq 0x8104
leaq 0x40(%rsp), %rdi
callq 0x8104
leaq 0x58(%rsp), %rdi
callq 0x2dea
leaq 0x68(%rsp), %rdi
callq 0x8104
leaq 0x20(%rsp), %rdi
callq 0x2dea
movq %r14, %rdi
callq 0x21d0