// File: /workspace/github_cpp_makefile_star2_O2/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), %rbx
movq %rbx, %rdi
callq 0x2190
pushq $0xf
popq %rax
leaq 0x6c81(%rip), %r15      # 0x9038
leaq 0xc8(%rsp), %rbp
pushq $0x64
popq %r12
leaq 0x148(%rsp), %r14
cmpl $0x33, %eax
je 0x2ca7
movl %eax, 0xbc(%rsp)
cvtsi2sd %eax, %xmm1
movsd 0x6c21(%rip), %xmm0     # 0x9008
callq 0x21c0
addsd 0x6c1c(%rip), %xmm0     # 0x9010
cvttsd2si %xmm0, %esi
movq %rbx, %rdi
movq %rsi, 0x30(%rsp)
callq 0x21b0
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movq 0x30(%rsp), %r15
cvtsi2sd %r15d, %xmm1
leal -0x1(%r15), %eax
cvtsi2ss %eax, %xmm0
addsd 0x6bee(%rip), %xmm1     # 0x9018
cvtss2sd %xmm0, %xmm0
xorl %eax, %eax
testl %r15d, %r15d
movl $0x0, %ecx
cmovgl %r15d, %ecx
divsd %xmm0, %xmm1
movsd %xmm1, 0x140(%rsp)
incl %ecx
movl %ecx, 0xc4(%rsp)
negl %r15d
xorpd %xmm0, %xmm0
movsd %xmm0, 0xa8(%rsp)
movsd %xmm0, 0xb0(%rsp)
movsd %xmm0, 0x90(%rsp)
movsd %xmm0, 0x98(%rsp)
movsd %xmm0, 0xa0(%rsp)
movsd %xmm0, 0x78(%rsp)
movsd %xmm0, 0x80(%rsp)
movsd %xmm0, 0x88(%rsp)
movsd %xmm0, 0x20(%rsp)
movsd %xmm0, 0x28(%rsp)
movsd %xmm0, 0x70(%rsp)
movsd %xmm0, 0x18(%rsp)
cmpl $0xb, %eax
je 0x2abf
movl %eax, 0xc0(%rsp)
callq 0x20c0
movq %rax, %rbx
movq %rbp, %rdi
movl %r12d, %esi
callq 0x80b4
leaq 0xe8(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x8a2d
movq %rbp, %rdi
movq %r13, %rsi
callq 0x85e8
movq %r13, %rdi
callq 0x8150
movq %r13, %rdi
movl %r12d, %esi
movl %r12d, %edx
callq 0x2da4
leaq 0xd8(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3cfe
movq %r13, %rdi
movq %rbp, %rsi
callq 0x341a
movq %rbp, %rdi
callq 0x2e36
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2fd2
movq %r14, %rdi
movl %r12d, %esi
movl %r12d, %edx
callq 0x2da4
movq %r14, %rdi
leaq 0xe8(%rsp), %rsi
callq 0x341a
pushq $0x1
popq %rbp
cmpl 0xc4(%rsp), %ebp
je 0x25c3
cvtsi2ss %ebp, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x140(%rsp), %xmm0
addsd 0x6a9f(%rip), %xmm0     # 0x9020
movsd %xmm0, 0x10(%rsp)
pushq $0x1
popq %rax
movl %eax, %r13d
leal (%r15,%r13), %eax
cmpl $0x1, %eax
je 0x25bf
movq %r14, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0x2e6c
movsd (%rax), %xmm0
mulsd 0x10(%rsp), %xmm0
movq %r14, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0x3766
incl %r13d
jmp 0x258d
incl %ebp
jmp 0x255f
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
leaq 0xd8(%rsp), %rdx
callq 0x3620
movq %r14, %rdi
movq %r13, %rsi
callq 0x341a
movq %r13, %rdi
callq 0x2e36
movq %r13, %rdi
movq %r14, %rsi
leaq 0xc8(%rsp), %rdx
callq 0x377b
callq 0x20c0
subq %rbx, %rax
cvtsi2sd %rax, %xmm0
divsd 0x6a12(%rip), %xmm0     # 0x9028
movsd %xmm0, 0x10(%rsp)
movq 0xa9ad(%rip), %rdi      # 0xcfd0
leaq 0x6a10(%rip), %rsi      # 0x903a
callq 0x2130
movq %rax, %rdi
movq 0x30(%rsp), %rsi
callq 0x21b0
movq %rax, %rdi
leaq 0x69fc(%rip), %rsi      # 0x9042
callq 0x2130
movq %rax, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x2180
movq %rax, %rdi
callq 0x2080
andl $0x0, 0xc(%rsp)
callq 0x20c0
movq %rax, %rbx
andl $0x0, 0xc(%rsp)
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
leaq 0x58(%rsp), %r13
movq %r13, %rdx
leaq 0xc(%rsp), %rbp
movq %rbp, %rcx
callq 0x709b
callq 0x20c0
subq %rbx, %rax
cvtsi2sd %rax, %xmm0
divsd 0x6983(%rip), %xmm0     # 0x9028
movsd %xmm0, 0x138(%rsp)
cvtsi2sdl 0xc(%rsp), %xmm0
movsd %xmm0, 0x130(%rsp)
callq 0x20c0
movq %rax, %rbx
andl $0x0, 0xc(%rsp)
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x7331
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x85e8
movq %r12, %rdi
callq 0x8150
callq 0x20c0
subq %rbx, %rax
cvtsi2sd %rax, %xmm0
divsd 0x691e(%rip), %xmm0     # 0x9028
movsd %xmm0, 0x128(%rsp)
cvtsi2sdl 0xc(%rsp), %xmm0
movsd %xmm0, 0x120(%rsp)
callq 0x20c0
movq %rax, %rbx
andl $0x0, 0xc(%rsp)
movq %r12, %rdi
movq %r14, %rsi
leaq 0x58(%rsp), %rdx
leaq 0xc(%rsp), %rcx
callq 0x7807
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x85e8
movq %r12, %rdi
callq 0x8150
callq 0x20c0
subq %rbx, %rax
cvtsi2sd %rax, %xmm0
divsd 0x68ba(%rip), %xmm0     # 0x9028
movsd %xmm0, 0x118(%rsp)
cvtsi2sdl 0xc(%rsp), %xmm0
movsd %xmm0, 0x110(%rsp)
callq 0x20c0
movq %rax, %rbx
movq %r12, %rdi
movq %r14, %rsi
leaq 0x58(%rsp), %rdx
callq 0x4796
leaq 0x38(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x85e8
movq %r12, %rdi
callq 0x8150
callq 0x20c0
subq %rbx, %rax
cvtsi2sd %rax, %xmm0
divsd 0x685d(%rip), %xmm0     # 0x9028
movsd %xmm0, 0x108(%rsp)
movq %r12, %rdi
movq %r13, %rsi
leaq 0xc8(%rsp), %rdx
callq 0x8284
movq %r12, %rdi
pushq $0x2
popq %rsi
callq 0x8966
movsd %xmm0, 0x100(%rsp)
movq %r12, %rdi
callq 0x8150
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
cmpl $0xc7, 0x30(%rsp)
jg 0x2962
callq 0x20c0
movq %rax, %rbx
movq %r12, %rdi
movq %r14, %rsi
leaq 0x58(%rsp), %rdx
callq 0x55af
leaq 0x38(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x85e8
movq %r12, %rdi
callq 0x8150
callq 0x20c0
subq %rbx, %rax
cvtsi2sd %rax, %xmm0
divsd 0x67c8(%rip), %xmm0     # 0x9028
movsd %xmm0, 0x68(%rsp)
movq %r12, %rdi
movq %r13, %rsi
leaq 0xc8(%rsp), %rbp
movq %rbp, %rdx
callq 0x8284
movq %r12, %rdi
pushq $0x2
popq %rsi
callq 0x8966
movq %r12, %rdi
movsd %xmm0, 0xf8(%rsp)
callq 0x8150
movsd 0x20(%rsp), %xmm0
addsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x28(%rsp), %xmm0
addsd 0xf8(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
cmpl $0x63, 0x30(%rsp)
jg 0x2987
callq 0x20c0
movq %rax, %rbx
movq %r12, %rdi
movq %r14, %rsi
leaq 0x58(%rsp), %rdx
callq 0x4ba1
leaq 0x38(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x85e8
movq %r12, %rdi
callq 0x8150
callq 0x20c0
subq %rbx, %rax
cvtsi2sd %rax, %xmm0
divsd 0x6719(%rip), %xmm0     # 0x9028
movsd %xmm0, 0x10(%rsp)
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x8284
movq %r12, %rdi
pushq $0x2
popq %rsi
callq 0x8966
movsd %xmm0, 0x68(%rsp)
movq %r12, %rdi
callq 0x8150
movsd 0x70(%rsp), %xmm1
addsd 0x10(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
addsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd %xmm1, 0x10(%rsp)
jmp 0x2991
movsd %xmm0, 0x28(%rsp)
movsd %xmm0, 0x20(%rsp)
movsd %xmm0, 0x18(%rsp)
pushq $0x64
popq %r12
leaq 0x38(%rsp), %rdi
leaq 0xc8(%rsp), %rbp
jmp 0x299a
xorpd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x38(%rsp), %rdi
pushq $0x64
popq %r12
movsd 0xb0(%rsp), %xmm0
addsd 0x138(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
movsd 0xa8(%rsp), %xmm0
addsd 0x130(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
movsd 0x98(%rsp), %xmm0
addsd 0x128(%rsp), %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0x90(%rsp), %xmm0
addsd 0x120(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0x78(%rsp), %xmm0
addsd 0x118(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0xa0(%rsp), %xmm0
addsd 0x110(%rsp), %xmm0
movsd %xmm0, 0xa0(%rsp)
movsd 0x80(%rsp), %xmm0
addsd 0x108(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x88(%rsp), %xmm0
addsd 0x100(%rsp), %xmm0
movsd %xmm0, 0x88(%rsp)
callq 0x8150
leaq 0x58(%rsp), %rdi
callq 0x8150
movq %r14, %rdi
callq 0x2e36
leaq 0xd8(%rsp), %rdi
callq 0x2e36
leaq 0xe8(%rsp), %rdi
callq 0x2e36
movq %rbp, %rdi
callq 0x8150
movl 0xc0(%rsp), %eax
incl %eax
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
jmp 0x24b6
leaq 0x158(%rsp), %rbx
movq %rbx, %rdi
leaq 0x6582(%rip), %rsi      # 0x9053
pushq $0x1
popq %rdx
callq 0x2040
leaq 0x6558(%rip), %r15      # 0x9038
movsd 0xa8(%rsp), %xmm0
divsd 0x653f(%rip), %xmm0     # 0x9030
movq %rbx, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movsd 0xb0(%rsp), %xmm0
divsd 0x651b(%rip), %xmm0     # 0x9030
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movsd 0x90(%rsp), %xmm0
divsd 0x64f7(%rip), %xmm0     # 0x9030
movq %rbx, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movsd 0x98(%rsp), %xmm0
divsd 0x64d3(%rip), %xmm0     # 0x9030
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movsd 0xa0(%rsp), %xmm0
divsd 0x64af(%rip), %xmm0     # 0x9030
movq %rbx, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movsd 0x78(%rsp), %xmm0
divsd 0x648e(%rip), %xmm0     # 0x9030
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movsd 0x80(%rsp), %xmm0
divsd 0x646a(%rip), %xmm0     # 0x9030
movq %rbx, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movsd 0x88(%rsp), %xmm0
divsd 0x6446(%rip), %xmm0     # 0x9030
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movsd 0x20(%rsp), %xmm0
divsd 0x6425(%rip), %xmm0     # 0x9030
movq %rbx, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movsd 0x28(%rsp), %xmm0
divsd 0x6404(%rip), %xmm0     # 0x9030
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movsd 0x70(%rsp), %xmm0
divsd 0x63e3(%rip), %xmm0     # 0x9030
movq %rbx, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movsd 0x18(%rsp), %xmm0
divsd 0x63c2(%rip), %xmm0     # 0x9030
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
movq %rbx, %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x2150
movl 0xbc(%rsp), %eax
incl %eax
jmp 0x23cb
leaq 0x158(%rsp), %rdi
callq 0x2160
pushq $0x1
popq %rax
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2cee
jmp 0x2ce7
jmp 0x2cee
jmp 0x2ce7
jmp 0x2ce7
jmp 0x2ce7
jmp 0x2cee
jmp 0x2cee
jmp 0x2d32
jmp 0x2ce7
jmp 0x2cee
jmp 0x2ce7
jmp 0x2cee
jmp 0x2ce7
jmp 0x2cee
movq %rax, %rbx
jmp 0x2cfb
jmp 0x2d48
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x8150
leaq 0x38(%rsp), %rdi
callq 0x8150
jmp 0x2d4b
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x2e36
jmp 0x2d5a
jmp 0x2d57
jmp 0x2d57
jmp 0x2d57
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x8150
jmp 0x2d81
jmp 0x2d3e
jmp 0x2d43
movq %rax, %rbx
jmp 0x2d8e
jmp 0x2d39
movq %rax, %rbx
jmp 0x2d74
movq %rax, %rbx
jmp 0x2d67
movq %rax, %rbx
jmp 0x2d81
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x8150
jmp 0x2d5a
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x2e36
leaq 0xd8(%rsp), %rdi
callq 0x2e36
leaq 0xe8(%rsp), %rdi
callq 0x2e36
leaq 0xc8(%rsp), %rdi
callq 0x8150
leaq 0x158(%rsp), %rdi
callq 0x2160
movq %rbx, %rdi
callq 0x21d0
nop