// File: 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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
addq $0x148, %rdi            # imm = 0x148
callq 0x9e40
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movq %rcx, %xmm0
movaps 0x106e4(%rip), %xmm1    # 0x14020
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x106e8(%rip), %xmm1    # 0x14030
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x106a9(%rip), %xmm1    # 0x14008
mulsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x18(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
addq $0x148, %rax            # imm = 0x148
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x75b0
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0x75e0
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x7610
testb $0x1, %al
jne 0x39f9
jmp 0x3c7f
leaq -0x78(%rbp), %rdi
callq 0x7650
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
testb $0x1, 0x10(%rax)
je 0x3a31
movsd -0x10(%rbp), %xmm0
movsd 0x105e5(%rip), %xmm1    # 0x14008
subsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
jmp 0x3c71
movq -0xa8(%rbp), %rdi
movq -0x88(%rbp), %rax
movl (%rax), %esi
movq -0x88(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x88(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x88(%rbp), %rax
movl 0x4(%rax), %r8d
callq 0x117b0
movl $0x0, -0x8c(%rbp)
movq -0xa8(%rbp), %rcx
movl -0x8c(%rbp), %eax
cmpl 0x30(%rcx), %eax
jge 0x3bc7
movq -0xa8(%rbp), %rdi
movslq -0x8c(%rbp), %rsi
callq 0x11910
movq -0xa8(%rbp), %rdi
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xd8(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0xcc(%rbp)
movl -0x8c(%rbp), %esi
movq %rdi, %rdx
addq $0x298, %rdx            # imm = 0x298
callq 0x11960
movq -0xa8(%rbp), %rdi
movsd %xmm0, -0xc8(%rbp)
movl -0x8c(%rbp), %esi
movq %rdi, %rdx
addq $0x2f8, %rdx            # imm = 0x2F8
callq 0x119b0
movq -0xd8(%rbp), %rdi
movl -0xcc(%rbp), %esi
movaps %xmm0, %xmm1
movsd -0xc8(%rbp), %xmm0
addsd %xmm1, %xmm0
callq 0x11930
movq -0xa8(%rbp), %rdi
addq $0x18, %rdi
movslq -0x8c(%rbp), %rsi
callq 0x11910
movq -0xa8(%rbp), %rdi
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0x8c(%rbp), %esi
movq %rdi, %rdx
addq $0x2b0, %rdx            # imm = 0x2B0
callq 0x119b0
movq -0xa8(%rbp), %rdi
movsd %xmm0, -0xb0(%rbp)
movl -0x8c(%rbp), %esi
movq %rdi, %rdx
addq $0x2e0, %rdx            # imm = 0x2E0
callq 0x11960
movq -0xc0(%rbp), %rdi
movl -0xb4(%rbp), %esi
movaps %xmm0, %xmm1
movsd -0xb0(%rbp), %xmm0
addsd %xmm1, %xmm0
callq 0x11930
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x3a6f
movq -0xa8(%rbp), %rsi
movq -0x88(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x88(%rbp), %rax
movl (%rax), %ecx
movq -0x88(%rbp), %rax
movl 0x4(%rax), %r8d
movq %rsi, %r9
addq $0x318, %r9             # imm = 0x318
movq %rsi, %r10
addq $0x380, %r10            # imm = 0x380
movq %rsi, %rax
addq $0x3b0, %rax            # imm = 0x3B0
movq %rsi, %rdi
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x11a00
movq -0xa8(%rbp), %rdi
movq %rdi, %rsi
addq $0x18, %rsi
movq -0x88(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x88(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x88(%rbp), %rax
movl (%rax), %r8d
movq %rdi, %r9
addq $0x348, %r9             # imm = 0x348
movq %rdi, %r10
addq $0x398, %r10            # imm = 0x398
movq %rdi, %rax
addq $0x3c8, %rax            # imm = 0x3C8
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x11a00
leaq -0x78(%rbp), %rdi
callq 0x7700
jmp 0x39e3
movq -0xa8(%rbp), %rdi
movq %rdi, %rsi
addq $0x380, %rsi            # imm = 0x380
movq %rdi, %rdx
addq $0x398, %rdx            # imm = 0x398
movl $0x1, %ecx
callq 0x11b80
movq -0xa8(%rbp), %rdi
movsd %xmm0, -0x28(%rbp)
movq %rdi, %rsi
addq $0x380, %rsi            # imm = 0x380
movq %rdi, %rdx
addq $0x398, %rdx            # imm = 0x398
movl $0x3, %ecx
callq 0x11b80
movq -0xa8(%rbp), %rdi
movsd %xmm0, -0x38(%rbp)
movq %rdi, %rsi
addq $0x380, %rsi            # imm = 0x380
movq %rdi, %rdx
addq $0x398, %rdx            # imm = 0x398
movl $0x5, %ecx
callq 0x11b80
movq -0xa8(%rbp), %rdi
movsd %xmm0, -0x48(%rbp)
movq %rdi, %rsi
addq $0x380, %rsi            # imm = 0x380
movq %rdi, %rdx
addq $0x398, %rdx            # imm = 0x398
movl $0xa, %ecx
callq 0x11b80
movq -0xa8(%rbp), %rdi
movsd %xmm0, -0x58(%rbp)
movq %rdi, %rsi
addq $0x380, %rsi            # imm = 0x380
movq %rdi, %rdx
addq $0x398, %rdx            # imm = 0x398
callq 0x11c40
movq -0xa8(%rbp), %rdi
movsd %xmm0, -0x18(%rbp)
movq %rdi, %rsi
addq $0x3b0, %rsi            # imm = 0x3B0
movq %rdi, %rdx
addq $0x3c8, %rdx            # imm = 0x3C8
movl $0x1, %ecx
callq 0x11b80
movq -0xa8(%rbp), %rdi
movsd %xmm0, -0x30(%rbp)
movq %rdi, %rsi
addq $0x3b0, %rsi            # imm = 0x3B0
movq %rdi, %rdx
addq $0x3c8, %rdx            # imm = 0x3C8
movl $0x3, %ecx
callq 0x11b80
movq -0xa8(%rbp), %rdi
movsd %xmm0, -0x40(%rbp)
movq %rdi, %rsi
addq $0x3b0, %rsi            # imm = 0x3B0
movq %rdi, %rdx
addq $0x3c8, %rdx            # imm = 0x3C8
movl $0x5, %ecx
callq 0x11b80
movq -0xa8(%rbp), %rdi
movsd %xmm0, -0x50(%rbp)
movq %rdi, %rsi
addq $0x3b0, %rsi            # imm = 0x3B0
movq %rdi, %rdx
addq $0x3c8, %rdx            # imm = 0x3C8
movl $0xa, %ecx
callq 0x11b80
movq -0xa8(%rbp), %rdi
movsd %xmm0, -0x60(%rbp)
movq %rdi, %rsi
addq $0x3b0, %rsi            # imm = 0x3B0
movq %rdi, %rdx
addq $0x3c8, %rdx            # imm = 0x3C8
callq 0x11c40
movsd %xmm0, -0x20(%rbp)
movq 0x1b1b8(%rip), %rdi     # 0x1efd8
leaq 0x102bd(%rip), %rsi     # 0x140e4
callq 0x2210
movq %rax, %rdi
movsd -0x28(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
callq 0x23d0
movq %rax, %rdi
leaq 0x102a8(%rip), %rsi     # 0x140f0
callq 0x2210
movq 0x1b184(%rip), %rdi     # 0x1efd8
leaq 0x10297(%rip), %rsi     # 0x140f2
callq 0x2210
movq %rax, %rdi
movsd -0x38(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
callq 0x23d0
movq %rax, %rdi
leaq 0x10274(%rip), %rsi     # 0x140f0
callq 0x2210
movq 0x1b150(%rip), %rdi     # 0x1efd8
leaq 0x1026f(%rip), %rsi     # 0x140fe
callq 0x2210
movq %rax, %rdi
movsd -0x48(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
callq 0x23d0
movq %rax, %rdi
leaq 0x10240(%rip), %rsi     # 0x140f0
callq 0x2210
movq 0x1b11c(%rip), %rdi     # 0x1efd8
leaq 0x10247(%rip), %rsi     # 0x1410a
callq 0x2210
movq %rax, %rdi
movsd -0x58(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
callq 0x23d0
movq %rax, %rdi
leaq 0x1020c(%rip), %rsi     # 0x140f0
callq 0x2210
movq 0x1b0e8(%rip), %rdi     # 0x1efd8
leaq 0x10220(%rip), %rsi     # 0x14117
callq 0x2210
movq %rax, %rdi
movsd -0x18(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
callq 0x23d0
movq %rax, %rdi
leaq 0x101d8(%rip), %rsi     # 0x140f0
callq 0x2210
movq 0x1b0b4(%rip), %rdi     # 0x1efd8
leaq 0x101f6(%rip), %rsi     # 0x14121
callq 0x2210
movq %rax, %rdi
movsd -0x30(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
callq 0x23d0
movq %rax, %rdi
leaq 0x101a4(%rip), %rsi     # 0x140f0
callq 0x2210
movq 0x1b080(%rip), %rdi     # 0x1efd8
leaq 0x101d3(%rip), %rsi     # 0x14132
callq 0x2210
movq %rax, %rdi
movsd -0x40(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
callq 0x23d0
movq %rax, %rdi
leaq 0x10170(%rip), %rsi     # 0x140f0
callq 0x2210
movq 0x1b04c(%rip), %rdi     # 0x1efd8
leaq 0x101b0(%rip), %rsi     # 0x14143
callq 0x2210
movq %rax, %rdi
movsd -0x50(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
callq 0x23d0
movq %rax, %rdi
leaq 0x1013c(%rip), %rsi     # 0x140f0
callq 0x2210
movq 0x1b018(%rip), %rdi     # 0x1efd8
leaq 0x1018d(%rip), %rsi     # 0x14154
callq 0x2210
movq %rax, %rdi
movsd -0x60(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
callq 0x23d0
movq %rax, %rdi
leaq 0x10108(%rip), %rsi     # 0x140f0
callq 0x2210
movq 0x1afe4(%rip), %rdi     # 0x1efd8
leaq 0x1016b(%rip), %rsi     # 0x14166
callq 0x2210
movq %rax, %rdi
movsd -0x20(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
callq 0x23d0
movq %rax, %rdi
leaq 0x100d4(%rip), %rsi     # 0x140f0
callq 0x2210
addq $0xf0, %rsp
popq %rbp
retq
nopw (%rax,%rax)