// File: jingdao[P]PointCloudApp/descriptor.cpp
// Function: Descriptor::getPCA(double*, double*)
void Descriptor::getPCA(double* lambda_real,double* v) {
	double cov[9] = {}; //column major
	PCD::Quaternion center = pointcloud->getCentroid(NULL);
	for (int j=0;j<pointcloud->numPoints;j++) {
		float deltaP[3] = {
			pointcloud->float_data[j * 4] - center.i,
			pointcloud->float_data[j * 4 + 1] - center.j,
			pointcloud->float_data[j * 4 + 2] - center.k,
		};
		cov[0] += deltaP[0] * deltaP[0];
		cov[1] += deltaP[1] * deltaP[0];
		cov[2] += deltaP[2] * deltaP[0];
		cov[3] += deltaP[0] * deltaP[1];
		cov[4] += deltaP[1] * deltaP[1];
		cov[5] += deltaP[2] * deltaP[1];
		cov[6] += deltaP[0] * deltaP[2];
		cov[7] += deltaP[1] * deltaP[2];
		cov[8] += deltaP[2] * deltaP[2];
	}
	//compute PCA
	double lambda_imag[3];
	Normal::eigenvalue(3,cov,lambda_real,lambda_imag,v);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movq $0x0, -0x20(%rbp)
movq 0x10(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8a00
movlpd %xmm0, -0x70(%rbp)
movlpd %xmm1, -0x68(%rbp)
movl $0x0, -0x74(%rbp)
movq -0xa8(%rbp), %rcx
movl -0x74(%rbp), %eax
movq 0x10(%rcx), %rcx
cmpl 0x60(%rcx), %eax
jge 0x105d5
movq -0xa8(%rbp), %rax
movq 0x10(%rax), %rcx
movq 0x58(%rcx), %rcx
movl -0x74(%rbp), %edx
shll $0x2, %edx
movslq %edx, %rdx
movss (%rcx,%rdx,4), %xmm0
subss -0x6c(%rbp), %xmm0
movss %xmm0, -0x80(%rbp)
movq 0x10(%rax), %rcx
movq 0x58(%rcx), %rcx
movl -0x74(%rbp), %edx
shll $0x2, %edx
addl $0x1, %edx
movslq %edx, %rdx
movss (%rcx,%rdx,4), %xmm0
subss -0x68(%rbp), %xmm0
movss %xmm0, -0x7c(%rbp)
movq 0x10(%rax), %rax
movq 0x58(%rax), %rax
movl -0x74(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
subss -0x64(%rbp), %xmm0
movss %xmm0, -0x78(%rbp)
movss -0x80(%rbp), %xmm0
mulss -0x80(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movss -0x7c(%rbp), %xmm0
mulss -0x80(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movss -0x78(%rbp), %xmm0
mulss -0x80(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movss -0x80(%rbp), %xmm0
mulss -0x7c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movss -0x7c(%rbp), %xmm0
mulss -0x7c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movss -0x78(%rbp), %xmm0
mulss -0x7c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movss -0x80(%rbp), %xmm0
mulss -0x78(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movss -0x7c(%rbp), %xmm0
mulss -0x78(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movss -0x78(%rbp), %xmm0
mulss -0x78(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x1046b
leaq -0x60(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
movq -0x18(%rbp), %r8
movl $0x3, %edi
callq 0x11cd0
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)