// File: /workspace/github_cpp_makefile_star2_O2/KokiKishimoto[P]cp_decomposition/testcp.cpp
// Function: TestCP::test_inv()
void test_inv() {
		double total = (double)testData.triples.size() * 2;
		double mrr = 0.0, mrr_filter = 0.0;
		double rank_1 = 0.0, rank_1_filter = 0.0;
		double rank_3 = 0.0, rank_3_filter = 0.0;
		double rank_5 = 0.0, rank_5_filter = 0.0;
		double rank_10 = 0.0, rank_10_filter = 0.0;
		int j=0;
		
		for (Triple& test_tuple : testData.triples) {
			if (test_tuple.flag) {
				total = total - 2;
				continue;
			}
			pre_score_inv(test_tuple.subj, test_tuple.relation, test_tuple.relation_rev, test_tuple.obj);
			for (int entity = 0; entity<trainData.entity_counter; ++entity) {
				RankScore& r1 = scores_subj[entity]; 
				r1.set(entity, innerProductSubj(entity, outVec2) + innerProductObj(entity, outVec3_inv));
				RankScore& r2 = scores_obj[entity];
				r2.set(entity, innerProductObj(entity, outVec3) + innerProductSubj(entity, outVec2_inv));
			}
			generate_rank(scores_subj, test_tuple.relation, test_tuple.subj, test_tuple.obj, subjSet, rank1, rank_filter_1);
			generate_rank(scores_obj, test_tuple.relation, test_tuple.obj, test_tuple.subj, objSet, rank2, rank_filter_2);

		}
		rank_1 = calculate_ranking(rank1, rank2, 1);
		rank_3 = calculate_ranking(rank1, rank2, 3);
		rank_5 = calculate_ranking(rank1, rank2, 5);
		rank_10 = calculate_ranking(rank1, rank2, 10);
		mrr = calate_mrr(rank1, rank2);

		rank_1_filter = calculate_ranking(rank_filter_1, rank_filter_2, 1);
		rank_3_filter = calculate_ranking(rank_filter_1, rank_filter_2, 3);
		rank_5_filter = calculate_ranking(rank_filter_1, rank_filter_2, 5);
		rank_10_filter = calculate_ranking(rank_filter_1, rank_filter_2, 10);
		mrr_filter = calate_mrr(rank_filter_1, rank_filter_2);

		std::cout << "Raw Rank1: " << (rank_1 / total) << "\n";
		std::cout << "Raw Rank3: " << (rank_3 / total) << "\n";
		std::cout << "Raw Rank5: " << (rank_5 / total) << "\n";
		std::cout << "Raw Rank10: " << (rank_10 / total) << "\n";
		std::cout << "Raw MRR: " << (mrr / total) << "\n";
		
		std::cout << "Filtered Rank1: " << (rank_1_filter / total) << "\n";
		std::cout << "Filtered Rank3: " << (rank_3_filter / total) << "\n";
		std::cout << "Filtered Rank5: " << (rank_5_filter / total) << "\n";
		std::cout << "Filtered Rank10: " << (rank_10_filter / total) << "\n";
		std::cout << "Filtered MRR: " << (mrr_filter / total) << "\n";
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movq 0x148(%rdi), %r14
movq 0x150(%rdi), %rsi
movq %rsi, %rax
subq %r14, %rax
pushq $0x14
popq %rcx
cqto
idivq %rcx
movq %rax, %xmm0
punpckldq 0x4e0e(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x4e16(%rip), %xmm0     # 0x8020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd %xmm1, %xmm1
movapd %xmm1, (%rsp)
leaq 0x298(%rdi), %rax
movq %rax, 0x60(%rsp)
leaq 0x2f8(%rdi), %rax
movq %rax, 0x58(%rsp)
leaq 0x18(%rdi), %rax
movq %rax, 0x40(%rsp)
leaq 0x2b0(%rdi), %r15
leaq 0x2e0(%rdi), %r12
leaq 0x318(%rdi), %rax
movq %rax, 0x38(%rsp)
leaq 0x380(%rdi), %rax
movq %rax, 0x28(%rsp)
leaq 0x3b0(%rdi), %rax
movq %rax, 0x70(%rsp)
leaq 0x348(%rdi), %rax
movq %rax, 0x30(%rsp)
leaq 0x398(%rdi), %rax
movq %rax, 0x20(%rsp)
leaq 0x3c8(%rdi), %rax
movq %rax, 0x68(%rsp)
movq %rsi, 0x48(%rsp)
cmpq %rsi, %r14
je 0x33c9
cmpb $0x1, 0x10(%r14)
jne 0x32c2
movapd (%rsp), %xmm0
addsd 0x4d88(%rip), %xmm0     # 0x8040
movapd %xmm0, (%rsp)
jmp 0x33c0
movl 0x8(%r14), %edx
movl 0xc(%r14), %ecx
movl (%r14), %esi
movq %r14, 0x50(%rsp)
movl 0x4(%r14), %r8d
movq %rbx, %rdi
callq 0x65a2
pushq $0x8
popq %rbp
xorl %r13d, %r13d
movslq 0x30(%rbx), %rax
cmpq %rax, %r13
jge 0x336a
movq (%rbx), %r14
movq %rbx, %rdi
movl %r13d, %esi
movq 0x60(%rsp), %rdx
callq 0x668a
movsd %xmm0, 0x18(%rsp)
movq %rbx, %rdi
movl %r13d, %esi
movq 0x58(%rsp), %rdx
callq 0x66a4
addsd 0x18(%rsp), %xmm0
movl %r13d, (%r14,%rbp)
movsd %xmm0, -0x8(%r14,%rbp)
movq 0x18(%rbx), %r14
movq %rbx, %rdi
movl %r13d, %esi
movq %r15, %rdx
callq 0x66a4
movsd %xmm0, 0x18(%rsp)
movq %rbx, %rdi
movl %r13d, %esi
movq %r12, %rdx
callq 0x668a
addsd 0x18(%rsp), %xmm0
movl %r13d, (%r14,%rbp)
movsd %xmm0, -0x8(%r14,%rbp)
incq %r13
addq $0x10, %rbp
jmp 0x32e4
movq 0x50(%rsp), %r14
movl 0x8(%r14), %edx
movl (%r14), %ecx
movl 0x4(%r14), %r8d
movq %rbx, %rdi
movq %rbx, %rsi
movq 0x38(%rsp), %r9
pushq 0x70(%rsp)
pushq 0x30(%rsp)
callq 0x66be
popq %rax
popq %rcx
movl 0x8(%r14), %edx
movl (%r14), %r8d
movl 0x4(%r14), %ecx
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
movq 0x30(%rsp), %r9
pushq 0x68(%rsp)
pushq 0x28(%rsp)
callq 0x66be
popq %rax
popq %rcx
movq 0x48(%rsp), %rsi
addq $0x14, %r14
jmp 0x329b
pushq $0x1
popq %rcx
movq %rbx, %rdi
movq 0x28(%rsp), %r13
movq %r13, %rsi
movq 0x20(%rsp), %rbp
movq %rbp, %rdx
callq 0x67bc
movsd %xmm0, 0x30(%rsp)
pushq $0x3
popq %r14
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl %r14d, %ecx
callq 0x67bc
movsd %xmm0, 0x38(%rsp)
pushq $0x5
popq %r15
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl %r15d, %ecx
callq 0x67bc
movsd %xmm0, 0x40(%rsp)
pushq $0xa
popq %r12
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl %r12d, %ecx
callq 0x67bc
movsd %xmm0, 0x48(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x6826
movsd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
movq 0x70(%rsp), %r13
movq %r13, %rsi
movq 0x68(%rsp), %rbp
movq %rbp, %rdx
pushq $0x1
popq %rcx
callq 0x67bc
movsd %xmm0, 0x28(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl %r14d, %ecx
callq 0x67bc
movsd %xmm0, 0x50(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl %r15d, %ecx
callq 0x67bc
movsd %xmm0, 0x58(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl %r12d, %ecx
callq 0x67bc
movsd %xmm0, 0x60(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x6826
movsd %xmm0, 0x18(%rsp)
movq 0x8b08(%rip), %rbx      # 0xbfd8
leaq 0x4c1d(%rip), %rsi      # 0x80f4
movq %rbx, %rdi
callq 0x21b0
movsd 0x30(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x2280
leaq 0x4c07(%rip), %r14      # 0x8100
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
leaq 0x4bf7(%rip), %rsi      # 0x8102
movq %rbx, %rdi
callq 0x21b0
movsd 0x38(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
leaq 0x4bd6(%rip), %rsi      # 0x810e
movq %rbx, %rdi
callq 0x21b0
movsd 0x40(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
leaq 0x4bb5(%rip), %rsi      # 0x811a
movq %rbx, %rdi
callq 0x21b0
movsd 0x48(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
leaq 0x4b95(%rip), %rsi      # 0x8127
movq %rbx, %rdi
callq 0x21b0
movsd 0x20(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
leaq 0x4b72(%rip), %rsi      # 0x8131
movq %rbx, %rdi
callq 0x21b0
movsd 0x28(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
leaq 0x4b56(%rip), %rsi      # 0x8142
movq %rbx, %rdi
callq 0x21b0
movsd 0x50(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
leaq 0x4b3a(%rip), %rsi      # 0x8153
movq %rbx, %rdi
callq 0x21b0
movsd 0x58(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
leaq 0x4b1e(%rip), %rsi      # 0x8164
movq %rbx, %rdi
callq 0x21b0
movsd 0x60(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
callq 0x21b0
leaq 0x4b03(%rip), %rsi      # 0x8176
movq %rbx, %rdi
callq 0x21b0
movsd 0x18(%rsp), %xmm0
divsd (%rsp), %xmm0
movq %rax, %rdi
callq 0x2280
movq %rax, %rdi
movq %r14, %rsi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21b0
nop