// File: /workspace/github_cpp_makefile_star2_O3/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 $0x348, %rsp            # imm = 0x348
leaq 0x148(%rsp), %r14
movq %r14, %rdi
callq 0x21b0
movl $0xf, %eax
leaq 0x7c4f(%rip), %r15      # 0xa038
leaq 0x128(%rsp), %r12
leaq 0x138(%rsp), %rbp
movl %eax, 0xc4(%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, 0x110(%rsp)
movl %r13d, %r15d
negl %r15d
xorpd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
xorl %ebx, %ebx
movsd %xmm0, 0x10(%rsp)
movsd %xmm0, 0x30(%rsp)
movsd %xmm0, 0x28(%rsp)
movsd %xmm0, 0x80(%rsp)
movsd %xmm0, 0x78(%rsp)
movsd %xmm0, 0x98(%rsp)
movsd %xmm0, 0x90(%rsp)
movsd %xmm0, 0x88(%rsp)
movsd %xmm0, 0xa8(%rsp)
movsd %xmm0, 0xa0(%rsp)
movsd %xmm0, 0xb0(%rsp)
movq %r13, 0xb8(%rsp)
movl %ebx, 0xc(%rsp)
callq 0x20c0
movq %rax, %r14
movq %r12, %rdi
movl $0x64, %esi
callq 0x821c
leaq 0x118(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8ea1
movq %r12, %rdi
movq %rbx, %rsi
callq 0x896e
movq %rbx, %rdi
callq 0x82b2
movq %rbx, %rdi
movl $0x64, %esi
movl $0x64, %edx
callq 0x2ec8
leaq 0xc8(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3edd
movq %rbx, %rdi
movq %r12, %rsi
callq 0x35a8
movq %r12, %rdi
callq 0x2f50
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3148
movq %rbp, %rdi
movl $0x64, %esi
movl $0x64, %edx
callq 0x2ec8
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x35a8
testl %r13d, %r13d
jle 0x25ea
movl $0x1, %r12d
xorps %xmm0, %xmm0
cvtsi2ss %r12d, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x110(%rsp), %xmm0
addsd 0x7a83(%rip), %xmm0     # 0xa020
movsd %xmm0, 0x20(%rsp)
movl $0x1, %ebx
movq %rbp, %rdi
movl %r12d, %esi
movl %ebx, %edx
callq 0x2f90
movsd (%rax), %xmm0
mulsd 0x20(%rsp), %xmm0
movq %rbp, %rdi
movl %r12d, %esi
movl %ebx, %edx
callq 0x3934
leal (%r15,%rbx), %eax
incl %eax
movl %ebx, %ecx
incl %ecx
movl %ecx, %ebx
cmpl $0x1, %eax
jne 0x25a8
leal 0x1(%r12), %eax
cmpl %r13d, %r12d
movl %eax, %r12d
jne 0x2580
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0xc8(%rsp), %rdx
callq 0x37dc
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x35a8
movq %rbx, %rdi
callq 0x2f50
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x128(%rsp), %rdx
callq 0x3949
callq 0x20c0
subq %r14, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x79e8(%rip), %xmm0     # 0xa028
movsd %xmm0, 0x20(%rsp)
movl $0x7, %edx
movq 0xb97e(%rip), %rbx      # 0xdfd0
movq %rbx, %rdi
leaq 0x79de(%rip), %rsi      # 0xa03a
callq 0x2160
movq %rbx, %rdi
movl %r13d, %esi
callq 0x21d0
movq %rax, %rbx
movl $0x10, %edx
movq %rax, %rdi
leaq 0x79c4(%rip), %rsi      # 0xa042
callq 0x2160
movq %rbx, %rdi
movsd 0x20(%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, 0x8(%rsp)
callq 0x20c0
movq %rax, %rbx
movl %r14d, 0x8(%rsp)
leaq 0x38(%rsp), %rdi
movq %rbp, %rsi
leaq 0x58(%rsp), %r14
movq %r14, %rdx
leaq 0x8(%rsp), %r12
movq %r12, %rcx
callq 0x7156
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x7923(%rip), %xmm0     # 0xa028
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x8(%rsp), %xmm0
movsd %xmm0, 0x108(%rsp)
callq 0x20c0
movq %rax, %rbx
movl $0x0, 0x8(%rsp)
leaq 0x48(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x73f0
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0x896e
movq %r13, %rdi
callq 0x82b2
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x78b8(%rip), %xmm0     # 0xa028
movsd %xmm0, 0x100(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x8(%rsp), %xmm0
movsd %xmm0, 0xf8(%rsp)
callq 0x20c0
movq %rax, %rbx
movl $0x0, 0x8(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
leaq 0x58(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x78d1
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0x896e
movq %r13, %rdi
callq 0x82b2
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x784b(%rip), %xmm0     # 0xa028
movsd %xmm0, 0xf0(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x8(%rsp), %xmm0
movsd %xmm0, 0xe8(%rsp)
callq 0x20c0
movq %rax, %rbx
movq %r13, %rdi
movq %rbp, %rsi
leaq 0x58(%rsp), %rdx
callq 0x494d
leaq 0x38(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x896e
movq %r13, %rdi
callq 0x82b2
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x77e8(%rip), %xmm0     # 0xa028
movsd %xmm0, 0xe0(%rsp)
movq %r13, %rdi
movq %r14, %rsi
leaq 0x128(%rsp), %r12
movq %r12, %rdx
callq 0x845c
movq %r13, %rdi
movl $0x2, %esi
callq 0x8d9c
movsd %xmm0, 0xd8(%rsp)
movq %r13, %rdi
callq 0x82b2
cmpl $0xc7, 0xb8(%rsp)
jg 0x29ce
callq 0x20c0
movq %rax, %rbx
movq %r13, %rdi
movq %rbp, %rsi
leaq 0x58(%rsp), %rdx
callq 0x56d3
leaq 0x38(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x896e
movq %r13, %rdi
callq 0x82b2
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x7752(%rip), %xmm0     # 0xa028
movsd %xmm0, 0x70(%rsp)
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x845c
movq %r13, %rdi
movl $0x2, %esi
callq 0x8d9c
movq %r13, %rdi
movsd %xmm0, 0x68(%rsp)
callq 0x82b2
movsd 0x28(%rsp), %xmm0
addsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x30(%rsp), %xmm0
addsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
cmpl $0x63, 0xb8(%rsp)
jg 0x29e0
callq 0x20c0
movq %rax, %rbx
movq %r13, %rdi
movq %rbp, %rsi
leaq 0x58(%rsp), %rdx
callq 0x4d52
leaq 0x38(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x896e
movq %r13, %rdi
callq 0x82b2
callq 0x20c0
subq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x76a9(%rip), %xmm0     # 0xa028
movsd %xmm0, 0x70(%rsp)
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x845c
movq %r13, %rdi
movl $0x2, %esi
callq 0x8d9c
movsd %xmm0, 0x68(%rsp)
movq %r13, %rdi
callq 0x82b2
movsd 0x10(%rsp), %xmm0
addsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
addsd 0x68(%rsp), %xmm0
jmp 0x29ea
xorpd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
movsd %xmm0, 0x28(%rsp)
jmp 0x29e4
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd %xmm0, 0x18(%rsp)
leaq 0x38(%rsp), %rdi
movl 0xc(%rsp), %ebx
movsd 0xa0(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
movsd %xmm0, 0xa0(%rsp)
movsd 0xb0(%rsp), %xmm0
addsd 0x108(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
movsd 0x88(%rsp), %xmm0
addsd 0x100(%rsp), %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0xa8(%rsp), %xmm0
addsd 0xf8(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
movsd 0x98(%rsp), %xmm0
addsd 0xf0(%rsp), %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0x90(%rsp), %xmm0
addsd 0xe8(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0x78(%rsp), %xmm0
addsd 0xe0(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0x80(%rsp), %xmm0
addsd 0xd8(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
callq 0x82b2
leaq 0x58(%rsp), %rdi
callq 0x82b2
movq %rbp, %rdi
callq 0x2f50
leaq 0xc8(%rsp), %rdi
callq 0x2f50
leaq 0x118(%rsp), %rdi
callq 0x2f50
movq %r12, %rdi
callq 0x82b2
incl %ebx
cmpl $0xb, %ebx
movq 0xb8(%rsp), %r13
jne 0x24d6
leaq 0x148(%rsp), %r14
movq %r14, %rdi
leaq 0x752d(%rip), %rsi      # 0xa053
movl $0x1, %edx
callq 0x2050
leaq 0x7501(%rip), %r15      # 0xa038
movsd 0xb0(%rsp), %xmm0
divsd 0x74e8(%rip), %xmm0     # 0xa030
movq %r14, %rdi
callq 0x21a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0xa0(%rsp), %xmm0
divsd 0x74bc(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0xa8(%rsp), %xmm0
divsd 0x7493(%rip), %xmm0     # 0xa030
movq %r14, %rdi
callq 0x21a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x88(%rsp), %xmm0
divsd 0x7467(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x90(%rsp), %xmm0
divsd 0x743e(%rip), %xmm0     # 0xa030
movq %r14, %rdi
callq 0x21a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x98(%rsp), %xmm0
divsd 0x7412(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x78(%rsp), %xmm0
divsd 0x73ec(%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 0x73c0(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x28(%rsp), %xmm0
divsd 0x739a(%rip), %xmm0     # 0xa030
movq %r14, %rdi
callq 0x21a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x30(%rsp), %xmm0
divsd 0x7371(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movsd 0x10(%rsp), %xmm0
divsd 0x734b(%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 0x7322(%rip), %xmm0     # 0xa030
movq %rbx, %rdi
callq 0x21a0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
movq 0x148(%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 0xc4(%rsp), %eax
incl %eax
cmpl $0x33, %eax
jne 0x23f9
movq 0xb24d(%rip), %rax      # 0xdfc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x150(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x148(%rsp,%rcx)
callq 0x2120
leaq 0x240(%rsp), %rdi
callq 0x2070
movl $0x1, %eax
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2ddd
jmp 0x2df0
jmp 0x2ddd
jmp 0x2df0
jmp 0x2ddd
jmp 0x2ddd
jmp 0x2df0
jmp 0x2df0
jmp 0x2ddd
jmp 0x2ddd
jmp 0x2df0
jmp 0x2e42
jmp 0x2ddd
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x82b2
jmp 0x2df3
jmp 0x2df0
jmp 0x2df0
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x82b2
jmp 0x2e45
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x2f50
jmp 0x2e54
jmp 0x2e51
jmp 0x2e51
jmp 0x2e33
jmp 0x2e38
jmp 0x2e3d
jmp 0x2e51
jmp 0x2e2e
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x82b2
jmp 0x2e7b
movq %rax, %rbx
jmp 0x2e7b
movq %rax, %rbx
jmp 0x2e6e
movq %rax, %rbx
jmp 0x2e61
movq %rax, %rbx
jmp 0x2e88
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x82b2
jmp 0x2e54
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x2f50
leaq 0xc8(%rsp), %rdi
callq 0x2f50
leaq 0x118(%rsp), %rdi
callq 0x2f50
leaq 0x128(%rsp), %rdi
callq 0x82b2
movq 0xb139(%rip), %rax      # 0xdfc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x150(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x148(%rsp,%rcx)
callq 0x2120
leaq 0x240(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x21f0