// File: /workspace/github_cpp_makefile_star2_O3/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), %r14d
cmpl 0xc(%rsi), %r14d
jne 0x6160
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3d86
testl %r14d, %r14d
jle 0x5fb7
leaq 0x1(%r14), %r13
movl $0x1, %r15d
movq %r12, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x2f5c
movsd 0x307e(%rip), %xmm0     # 0x9018
divsd (%rax), %xmm0
movq 0x20(%rsp), %rax
movq -0x8(%rax,%r15,8), %rax
movsd %xmm0, -0x8(%rax,%r15,8)
incq %r15
cmpq %r15, %r13
jne 0x5f84
leaq 0x68(%rsp), %rdi
movl %r14d, %esi
callq 0x8ded
leaq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3d0b
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq (%rsp), %rdx
callq 0x3915
leaq 0x10(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x3454
leaq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x3574
leaq 0x10(%rsp), %rdi
callq 0x2f1c
movq (%rsp), %rdi
movl $0x2, %esi
callq 0x8d68
movsd %xmm0, 0x8(%rsp)
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x822a
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x3915
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq (%rsp), %rdx
callq 0x8428
movsd 0x8(%rsp), %xmm0
mulsd 0x302b(%rip), %xmm0     # 0x9090
movsd %xmm0, 0x8(%rsp)
leaq 0x30(%rsp), %r13
movq %r13, %rdi
callq 0x827e
leaq 0x10(%rsp), %rbp
leaq 0x78(%rsp), %r14
leaq 0x40(%rsp), %r15
movq %rbp, %rdi
movl $0x2, %esi
callq 0x8d68
ucomisd 0x8(%rsp), %xmm0
jbe 0x6119
movq 0x50(%rsp), %rax
incl (%rax)
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x3915
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x828b
movq %rbx, %rdi
movq %r13, %rsi
callq 0x893a
movq %r13, %rdi
callq 0x827e
movq %r14, %rdi
callq 0x827e
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x3915
movq %r13, %rdi
movq %r14, %rsi
movq (%rsp), %rdx
callq 0x8428
movq %rbp, %rdi
movq %r13, %rsi
callq 0x893a
movq %r13, %rdi
callq 0x827e
movq %r14, %rdi
callq 0x827e
jmp 0x6087
leaq 0x10(%rsp), %rdi
callq 0x827e
leaq 0x40(%rsp), %rdi
callq 0x827e
leaq 0x58(%rsp), %rdi
callq 0x2f1c
leaq 0x68(%rsp), %rdi
callq 0x827e
leaq 0x20(%rsp), %rdi
callq 0x2f1c
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x31b3(%rip), %rdi      # 0x931a
leaq 0x2fe3(%rip), %rsi      # 0x9151
leaq 0x323c(%rip), %rcx      # 0x93b1
movl $0x29a, %edx            # imm = 0x29A
callq 0x20b0
movq %rax, %r14
leaq 0x30(%rsp), %rdi
jmp 0x61e3
movq %rax, %r14
jmp 0x61e8
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x2f1c
jmp 0x61f0
jmp 0x61ab
movq %rax, %r14
jmp 0x61fa
movq %rax, %r14
jmp 0x6204
jmp 0x61b0
movq %rax, %r14
jmp 0x61f0
movq %rax, %r14
jmp 0x620e
jmp 0x61db
jmp 0x61bb
jmp 0x61cc
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x827e
jmp 0x61cf
jmp 0x61db
movq %rax, %r14
leaq 0x78(%rsp), %rdi
callq 0x827e
jmp 0x61de
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x827e
movq %rbx, %rdi
callq 0x827e
leaq 0x40(%rsp), %rdi
callq 0x827e
leaq 0x58(%rsp), %rdi
callq 0x2f1c
leaq 0x68(%rsp), %rdi
callq 0x827e
leaq 0x20(%rsp), %rdi
callq 0x2f1c
movq %r14, %rdi
callq 0x21f0