// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, 0x48(%rsp)
movq %rcx, 0x8(%rsp)
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, 0x20(%rsp)
movl $0x0, 0x4(%rsp)
movq %rsi, %rdi
callq 0x11cfe
leaq 0x28(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x409b7
testl %eax, %eax
jne 0x1e81b
leaq 0x891e7(%rip), %rdi     # 0xa79fd
callq 0x4090
movq %r12, %rdi
callq 0x12a17
movq %rax, %r14
movq %rdx, %r15
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq %rax, %rdx
movq %r15, %rcx
callq 0x3ee2f
movq %rax, %rbp
movq %rdx, %r13
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x3ed51
movq %r14, %rdi
movq %rbp, %r14
movq %r15, %rsi
callq 0x3ed51
movl 0x10(%rbx), %ebp
movq %r14, %rdi
movq %r13, %rsi
callq 0x3f4e7
testl %ebp, %ebp
je 0x1e893
testl %eax, %eax
je 0x1e8a9
movsd 0x8(%rbx), %xmm0
leaq 0x10(%rsp), %rdi
leaq 0x4(%rsp), %rcx
movq %r14, %rsi
movq %r13, %rdx
callq 0x42921
jmp 0x1e8da
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
testl %eax, %eax
je 0x1e8bb
callq 0x428e9
jmp 0x1e8c0
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x42814
jmp 0x1e8da
callq 0x42814
movl (%rbx), %edx
movq 0x20(%rsp), %rcx
movl 0x10(%rcx), %ecx
cmpl %ecx, %edx
jge 0x1e8d4
movl %edx, 0x4(%rsp)
jmp 0x1e8da
decl %ecx
movl %ecx, 0x4(%rsp)
movq 0x8(%rsp), %rbx
movq %rax, %rdi
callq 0x3a180
movl 0x4(%rsp), %esi
testq %r12, %r12
je 0x1e958
movq %r13, 0x38(%rsp)
movq %r14, 0x40(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x18(%rsp), %r13
xorl %r14d, %r14d
xorl %ebx, %ebx
movq %r12, %rdi
movl %esi, %r15d
movq 0x50(%rsp), %rdx
movq %r13, %rcx
callq 0x1f1cb
movq %rax, %rbp
testq %r14, %r14
je 0x1e930
movq %rax, 0x10(%rbx)
movq %r14, %rbp
movq 0x10(%r12), %r12
movq %rbp, %r14
movq %rax, %rbx
testq %r12, %r12
movl %r15d, %esi
jne 0x1e90e
movl 0x4(%rsp), %esi
movq 0x8(%rsp), %rbx
movq 0x40(%rsp), %r14
movq 0x38(%rsp), %r13
jmp 0x1e95a
xorl %ebp, %ebp
incl %esi
movq 0x20(%rsp), %rdi
movq %rbp, %rdx
movq 0x48(%rsp), %rcx
callq 0x153ec
movq %rax, (%rbx)
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x3ed51
movq %r14, %rdi
movq %r13, %rsi
callq 0x3ed51
movq %rbp, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq