// File: /workspace/github_cpp_makefile_star2_O1/yukimasano[P]cpp_matrix/vary_kappa.cpp
// Function: main
int main()
{
	ofstream outfile;
	int i = 1;

	for (int j=15; j<=50; j+=1){

		/* format of output is
		# format    0 kappa , 1 SD Count, 2 SD Time, 3 CG Count, 4 CG time,
		#           5 CG_pre count 6 CG_pre time
		#           7 LU time, 8 LU delx, 9 QR time, 10 QR delx
		#						11 full QR time 12 full QR delx
		*/

		double sd_co =0.0;
		double sd_ti =0.0;
		double cg_co =0.0;
		double cg_ti =0.0;
		double cgp_co =0.0;
		double cgp_ti =0.0;
		double lu_ti =0.0;
		double lu_dx =0.0;
		double qr_ti =0.0;
		double qr_dx =0.0;
		double qre_ti =0.0;
		double qre_dx =0.0;
    i = pow(1.09,j)+8;
		outfile<<i<<",";



		// for loop to average measurements
	  for (int k=0;k<=10 ;k++){
			////VERSION Diff  KAPPA same size
			clock_t begin = clock();
			Vector x(100);
			x = randv(x);
			Matrix Q(100,100);
			Q = rand_basis_gs(Q);
			Matrix QT=Q.T();
			Matrix A(100,100);
			A = Q;
			double k0 = i;
			for (int jj=1; jj<=i;  jj++){
				double x = ((k0-1)/float(i-1))*float(jj) + 1.;
				for (int h =1; h<=i; h++){
					A.set_val(jj,h, A(jj,h)*x);
				}
			}
			A = A*QT;
			Vector b = A*x;

			clock_t end = clock();
			double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
			cout<<"cond = "<<i<<" time for prep: "<<elapsed_secs<<endl;
			// /////////////////////////////
			int count = 0;
	    //// code starts here /////////////////////////////////////
			begin = clock();
			count = 0;
			Vector x1 = SD(A,b, count);
			end = clock();
			elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
      sd_ti += elapsed_secs;
			sd_co += count;

			begin = clock();
			count = 0;
			x1 = CG(A,b, count);
			end = clock();
			elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
			cg_ti += elapsed_secs;
			cg_co += count;

			begin = clock();
			count = 0;
			x1 = CG_pre(A,b, count);
			end = clock();
			elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
			cgp_ti += elapsed_secs;
			cgp_co += count;

			////////////////// non-iterative solvers
			begin = clock();
			x1 = LUsolve(A,b);
			end = clock();
			elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
			double delx = (x1 - x).norm();
			lu_ti += elapsed_secs;
			lu_dx += delx;

			if (i<200){
				//cout<<"QR2"<<flush<<endl;
			  begin = clock();
				x1 = QRsolve2(A,b);
				end = clock();
				elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
				delx = (x1 - x).norm();
				qr_ti += elapsed_secs;
				qr_dx += delx;
			}
			else{
				qr_ti = 0;
				qr_dx = 0;
			}
			//cout<<"QRs"<<flush<<endl;
      if (i<100){
				begin = clock();
				x1 = QRsolve(A,b);
				end = clock();
				elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
				delx = (x1 - x).norm();
				qre_ti += elapsed_secs;
				qre_dx += delx;
			}
			else{
				qre_ti = 0;
				qre_dx = 0;
			}
		}
		//cout<<"done"<<flush<<endl;
		outfile.open("vary_kappa_N100.txt", fstream::app);
		outfile<< sd_co/10<<","<< sd_ti/10 << ",";
		outfile<< cg_co/10<<","<< cg_ti/10 << ",";
		outfile<< cgp_co/10<<","<< cgp_ti/10 << ",";
		outfile<< lu_ti/10<<","<< lu_dx/10 << ",";
		outfile<< qr_ti/10<<","<< qr_dx/10 << ",";
		outfile<< qre_ti/10<<","<< qre_dx/10<<",";
		outfile<<endl;
		outfile.flush();
		outfile.close();
	}

  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x358, %rsp            # imm = 0x358
leaq 0x158(%rsp), %r14
movq %r14, %rdi
callq 0x21b0
movl $0xf, %eax
leaq 0x7c4f(%rip), %r15      # 0xa038
leaq 0xb8(%rsp), %r12
leaq 0x148(%rsp), %rbp
movl %eax, 0xac(%rsp)
cvtsi2sd %eax, %xmm1
movsd 0x7bfc(%rip), %xmm0     # 0xa008
callq 0x21e0
addsd 0x7bf7(%rip), %xmm0     # 0xa010
cvttsd2si %xmm0, %r13d
movq %r14, %rdi
movl %r13d, %esi
callq 0x21d0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
addsd 0x7bcf(%rip), %xmm1     # 0xa018
leal -0x1(%r13), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
cvtss2sd %xmm0, %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0x130(%rsp)
movl %r13d, %r15d
negl %r15d
xorpd %xmm1, %xmm1
xorl %ebx, %ebx
xorps %xmm2, %xmm2
xorps %xmm3, %xmm3
xorps %xmm4, %xmm4
xorpd %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
movsd %xmm0, 0x70(%rsp)
movsd %xmm0, 0x68(%rsp)
movsd %xmm0, 0x60(%rsp)
movsd %xmm0, 0x80(%rsp)
movsd %xmm0, 0x78(%rsp)
movsd %xmm0, 0x90(%rsp)
movsd %xmm0, 0x88(%rsp)
movq %r13, 0xb0(%rsp)
movsd %xmm4, 0xe8(%rsp)
movsd %xmm3, 0x18(%rsp)
movsd %xmm2, 0xd8(%rsp)
movsd %xmm1, 0xe0(%rsp)
movl %ebx, 0x34(%rsp)
callq 0x20c0
movq %rax, %r14
movq %r12, %rdi
movl $0x64, %esi
callq 0x82b0
leaq 0x138(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8f4d
movq %r12, %rdi
movq %rbx, %rsi
callq 0x8a24
movq %rbx, %rdi
callq 0x8358
movq %rbx, %rdi
movl $0x64, %esi
movl $0x64, %edx
callq 0x2f00
leaq 0xc8(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3f29
movq %rbx, %rdi
movq %r12, %rsi
callq 0x35e8
movq %r12, %rdi
callq 0x2f94
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3188
movq %rbp, %rdi
movl $0x64, %esi
movl $0x64, %edx
callq 0x2f00
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x35e8
testl %r13d, %r13d
jle 0x25f4
movl $0x1, %r12d
xorps %xmm0, %xmm0
cvtsi2ss %r12d, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x130(%rsp), %xmm0
addsd 0x7a79(%rip), %xmm0     # 0xa020
movsd %xmm0, 0x10(%rsp)
movl $0x1, %ebx
movq %rbp, %rdi
movl %r12d, %esi
movl %ebx, %edx
callq 0x2fda
movsd (%rax), %xmm0
mulsd 0x10(%rsp), %xmm0
movq %rbp, %rdi
movl %r12d, %esi
movl %ebx, %edx
callq 0x3974
leal (%r15,%rbx), %eax
incl %eax
movl %ebx, %ecx
incl %ecx
movl %ecx, %ebx
cmpl $0x1, %eax
jne 0x25b2
leal 0x1(%r12), %eax
cmpl %r13d, %r12d
movl %eax, %r12d
jne 0x258a
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0xc8(%rsp), %rdx
callq 0x3820
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x35e8
movq %rbx, %rdi
callq 0x2f94
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0xb8(%rsp), %rdx
callq 0x3989
callq 0x20c0
subq %r14, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x79de(%rip), %xmm0     # 0xa028
movsd %xmm0, 0x10(%rsp)
movl $0x7, %edx
movq 0xb974(%rip), %rbx      # 0xdfd0
movq %rbx, %rdi
leaq 0x79d4(%rip), %rsi      # 0xa03a
callq 0x2160
movq %rbx, %rdi
movl %r13d, %esi
callq 0x21d0
movq %rax, %rbx
movl $0x10, %edx
movq %rax, %rdi
leaq 0x79ba(%rip), %rsi      # 0xa042
callq 0x2160
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x21a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
xorl %r14d, %r14d
movl %r14d, 0xc(%rsp)
callq 0x20c0
movq %rax, %rbx
movl %r14d, 0xc(%rsp)
leaq 0x98(%rsp), %rdi
movq %rbp, %rsi
leaq 0x48(%rsp), %r14
movq %r14, %rdx
leaq 0xc(%rsp), %r12
movq %r12, %rcx
callq 0x71ba
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x7916(%rip), %xmm0     # 0xa028
movsd %xmm0, 0x128(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0xc(%rsp), %xmm0
movsd %xmm0, 0x120(%rsp)
callq 0x20c0
movq %rax, %rbx
movl $0x0, 0xc(%rsp)
leaq 0x38(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x7454
leaq 0x98(%rsp), %rdi
movq %r13, %rsi
callq 0x8a24
movq %r13, %rdi
callq 0x8358
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x78a5(%rip), %xmm0     # 0xa028
movsd %xmm0, 0x118(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0xc(%rsp), %xmm0
movsd %xmm0, 0x110(%rsp)
callq 0x20c0
movq %rax, %rbx
movl $0x0, 0xc(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
leaq 0x48(%rsp), %rdx
leaq 0xc(%rsp), %rcx
callq 0x7935
leaq 0x98(%rsp), %rdi
movq %r13, %rsi
callq 0x8a24
movq %r13, %rdi
callq 0x8358
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x7835(%rip), %xmm0     # 0xa028
movsd %xmm0, 0x108(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0xc(%rsp), %xmm0
movsd %xmm0, 0x100(%rsp)
callq 0x20c0
movq %rax, %rbx
movq %r13, %rdi
movq %rbp, %rsi
leaq 0x48(%rsp), %rdx
callq 0x4996
leaq 0x98(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x8a24
movq %r13, %rdi
callq 0x8358
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x77cf(%rip), %xmm0     # 0xa028
movsd %xmm0, 0xf8(%rsp)
movq %r13, %rdi
movq %r14, %rsi
leaq 0xb8(%rsp), %r12
movq %r12, %rdx
callq 0x8510
movq %r13, %rdi
movl $0x2, %esi
callq 0x8e44
movsd %xmm0, 0xf0(%rsp)
movq %r13, %rdi
callq 0x8358
xorpd %xmm0, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd %xmm0, 0x28(%rsp)
movsd %xmm0, 0x10(%rsp)
movq 0xb0(%rsp), %rax
cmpl $0xc7, %eax
jg 0x2968
callq 0x20c0
movq %rax, %rbx
movq %r13, %rdi
movq %rbp, %rsi
leaq 0x48(%rsp), %rdx
callq 0x5718
leaq 0x98(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x8a24
movq %r13, %rdi
callq 0x8358
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x771e(%rip), %xmm0     # 0xa028
movsd %xmm0, 0x10(%rsp)
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x8510
movq %r13, %rdi
movl $0x2, %esi
callq 0x8e44
movq %r13, %rdi
movsd %xmm0, 0x28(%rsp)
callq 0x8358
movsd 0xe8(%rsp), %xmm1
addsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
addsd 0x28(%rsp), %xmm0
movsd %xmm1, 0x28(%rsp)
movsd %xmm0, 0x10(%rsp)
movq 0xb0(%rsp), %rax
xorpd %xmm0, %xmm0
cmpl $0x63, %eax
movq %rax, %r13
movl 0x34(%rsp), %ebx
jg 0x2a30
callq 0x20c0
movq %rax, %rbx
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
leaq 0x48(%rsp), %rdx
callq 0x4d99
leaq 0x98(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x8a24
movq %r12, %rdi
callq 0x8358
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x765c(%rip), %xmm0     # 0xa028
movsd %xmm0, 0x20(%rsp)
movq %r12, %rdi
movq %r14, %rsi
leaq 0xb8(%rsp), %rdx
callq 0x8510
movq %r12, %rdi
movl $0x2, %esi
callq 0x8e44
movq %r12, %rdi
movsd %xmm0, 0x18(%rsp)
callq 0x8358
movsd 0xd8(%rsp), %xmm1
addsd 0x20(%rsp), %xmm1
movsd 0xe0(%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
movsd %xmm1, 0x20(%rsp)
leaq 0xb8(%rsp), %r12
movl 0x34(%rsp), %ebx
movsd %xmm0, 0x18(%rsp)
movsd 0x90(%rsp), %xmm0
addsd 0x128(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0x88(%rsp), %xmm0
addsd 0x120(%rsp), %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x80(%rsp), %xmm0
addsd 0x118(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x78(%rsp), %xmm0
addsd 0x110(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x68(%rsp), %xmm0
addsd 0x108(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x60(%rsp), %xmm0
addsd 0x100(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x70(%rsp), %xmm0
addsd 0xf8(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x58(%rsp), %xmm0
addsd 0xf0(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x8358
leaq 0x48(%rsp), %rdi
callq 0x8358
movq %rbp, %rdi
callq 0x2f94
leaq 0xc8(%rsp), %rdi
callq 0x2f94
leaq 0x138(%rsp), %rdi
callq 0x2f94
movq %r12, %rdi
callq 0x8358
movsd 0x18(%rsp), %xmm1
incl %ebx
movsd 0x20(%rsp), %xmm2
movsd 0x10(%rsp), %xmm3
movsd 0x28(%rsp), %xmm4
cmpl $0xb, %ebx
jne 0x24bf
leaq 0x158(%rsp), %r14
movq %r14, %rdi
leaq 0x74ed(%rip), %rsi      # 0xa053
movl $0x1, %edx
callq 0x2050
leaq 0x74c1(%rip), %r15      # 0xa038
movsd 0x88(%rsp), %xmm0
divsd 0x74a8(%rip), %xmm0     # 0xa030
movq %r14, %rdi
callq 0x21a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x90(%rsp), %xmm0
divsd 0x747c(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x78(%rsp), %xmm0
divsd 0x7456(%rip), %xmm0     # 0xa030
movq %r14, %rdi
callq 0x21a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x80(%rsp), %xmm0
divsd 0x742a(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x60(%rsp), %xmm0
divsd 0x7404(%rip), %xmm0     # 0xa030
movq %r14, %rdi
callq 0x21a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x68(%rsp), %xmm0
divsd 0x73db(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x70(%rsp), %xmm0
divsd 0x73b5(%rip), %xmm0     # 0xa030
movq %r14, %rdi
callq 0x21a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x58(%rsp), %xmm0
divsd 0x738c(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x28(%rsp), %xmm0
divsd 0x7366(%rip), %xmm0     # 0xa030
movq %r14, %rdi
callq 0x21a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x10(%rsp), %xmm0
divsd 0x733d(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x20(%rsp), %xmm0
divsd 0x7317(%rip), %xmm0     # 0xa030
movq %r14, %rdi
callq 0x21a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x18(%rsp), %xmm0
divsd 0x72ee(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movq 0x158(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
movq %r14, %rdi
callq 0x20d0
movq %r14, %rdi
callq 0x2180
movl 0xac(%rsp), %eax
incl %eax
cmpl $0x33, %eax
jne 0x23f9
movq 0xb219(%rip), %rax      # 0xdfc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x160(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x158(%rsp,%rcx)
callq 0x2120
leaq 0x250(%rsp), %rdi
callq 0x2070
movl $0x1, %eax
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2e1a
jmp 0x2e1a
jmp 0x2e1a
jmp 0x2e1a
jmp 0x2e0f
jmp 0x2e0f
jmp 0x2e0f
jmp 0x2e0f
jmp 0x2e0f
jmp 0x2e0f
jmp 0x2e1a
jmp 0x2e0f
movq %rax, %rbx
jmp 0x2e27
jmp 0x2e79
jmp 0x2e1a
jmp 0x2e1a
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x8358
leaq 0x98(%rsp), %rdi
callq 0x8358
jmp 0x2e7c
jmp 0x2e88
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x2f94
jmp 0x2e8b
jmp 0x2e88
jmp 0x2e74
jmp 0x2e6a
jmp 0x2e88
jmp 0x2e63
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x8358
jmp 0x2eb2
movq %rax, %rbx
jmp 0x2eb2
jmp 0x2e6f
movq %rax, %rbx
jmp 0x2e98
movq %rax, %rbx
jmp 0x2ea5
movq %rax, %rbx
jmp 0x2ebf
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x8358
jmp 0x2e8b
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x2f94
leaq 0xc8(%rsp), %rdi
callq 0x2f94
leaq 0x138(%rsp), %rdi
callq 0x2f94
leaq 0xb8(%rsp), %rdi
callq 0x8358
movq 0xb102(%rip), %rax      # 0xdfc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x160(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x158(%rsp,%rcx)
callq 0x2120
leaq 0x250(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x21f0
nop