// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/dimreduction.c
// Function: dimension_reduction_lda
Instanceptr dimension_reduction_lda(Datasetptr d, Instanceptr traindata, void* parameters, Datasetptr* new_dataset, char* new_dataset_name)
{
 /*!Last Changed 16.01.2008*/
 int howmany = 0, reversed;
 matrix eigenvectors, sw, sb, W;
 double *eigenvalues;
 Pca_parameterptr ppca = (Pca_parameterptr) parameters;
 Instanceptr newlist;
 sw = within_class_matrix(traindata);
 reversed = matrix_inverse(&sw);
 if (!reversed)
   printf("Matrix inverse problem\n");
 sb = between_class_matrix(traindata);
 W = matrix_multiply(sw, sb);
 matrix_free(sw);
 matrix_free(sb);
 switch (ppca->reduction_type)
  {
   case REDUCTION_TYPE_FEATURE :if (is_symmetric(W))
                                  eigenvalues = find_eigenvalues_eigenvectors_symmetric(&eigenvectors, W);
                                else
                                  eigenvalues = find_eigenvalues_eigenvectors_unsymmetric(&eigenvectors, W);
                                if (ppca->featurecount > d->classno - 1)
                                  howmany = d->classno - 1;
                                else
                                  howmany = ppca->featurecount;
                                break;
   case REDUCTION_TYPE_VARIANCE:if (is_symmetric(W))
                                  eigenvalues = find_eigenvalues_eigenvectors(&eigenvectors, W, &howmany, ppca->variance_explained);
                                else
                                  eigenvalues = find_eigenvalues_eigenvectors_unsymmetric(&eigenvectors, W);
                                break;
  }
 safe_free(eigenvalues);
 newlist = reduce_dimension_of_instancelist(traindata, howmany, eigenvectors);
 *new_dataset = dimension_reduced_dataset(d, howmany + 1, newlist, new_dataset_name);
 matrix_free(eigenvectors);
 matrix_free(W);
 return newlist;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
callq 0x18fd0
movq %rax, -0x98(%rbp)
movq %rdx, -0x90(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x5c470
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x2b90b
leaq 0xb8ce9(%rip), %rdi     # 0xe45ed
movb $0x0, %al
callq 0x4030
movq -0x10(%rbp), %rdi
callq 0x1a570
movq %rax, -0xa8(%rbp)
movq %rdx, -0xa0(%rbp)
movups -0xa8(%rbp), %xmm0
movaps %xmm0, -0x60(%rbp)
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq -0x58(%rbp), %rcx
callq 0x59fe0
movq %rax, -0xb8(%rbp)
movq %rdx, -0xb0(%rbp)
movups -0xb8(%rbp), %xmm0
movaps %xmm0, -0x70(%rbp)
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x59ea0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x59ea0
movq -0x80(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0xbc(%rbp)
testl %eax, %eax
je 0x2b998
jmp 0x2b988
movl -0xbc(%rbp), %eax
subl $0x1, %eax
je 0x2ba04
jmp 0x2ba51
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x5a680
cmpl $0x0, %eax
je 0x2b9c1
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0x5fb50
movq %rax, -0x78(%rbp)
jmp 0x2b9d6
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0x5fa30
movq %rax, -0x78(%rbp)
movq -0x80(%rbp), %rax
movl (%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x10(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x2b9f9
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2ba02
movq -0x80(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x2ba51
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x5a680
cmpl $0x0, %eax
je 0x2ba3a
movq -0x80(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
leaq -0x40(%rbp), %rdi
leaq -0x2c(%rbp), %rcx
callq 0x5fba0
movq %rax, -0x78(%rbp)
jmp 0x2ba4f
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0x5fa30
movq %rax, -0x78(%rbp)
jmp 0x2ba51
movq -0x78(%rbp), %rdi
callq 0x52e80
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x2c810
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
addl $0x1, %esi
movq -0x88(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x1e1d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x59ea0
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x59ea0
movq -0x88(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)