// File: /workspace/github_c_makefile_star2_O1/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, 0x50(%rsp)
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, 0x30(%rsp)
movl $0x0, 0x4(%rsp)
movq %rsi, %rdi
callq 0x11d36
leaq 0x38(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
callq 0x3f648
testl %eax, %eax
jne 0x1e097
leaq 0x8692b(%rip), %rdi     # 0xa49bd
callq 0x4090
movq %r12, %rdi
callq 0x12ad7
movq %rax, %r14
movq %rdx, %r15
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq %rax, %rdx
movq %r15, %rcx
callq 0x3dc8b
movq %rax, %r13
movq %rdx, %rbx
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x3dbad
movq %r14, %rdi
movq %r15, %rsi
callq 0x3dbad
movq %rbp, %r14
movl 0x10(%rbp), %ebp
movq %r13, 0x10(%rsp)
movq %r13, %rdi
movq %rbx, 0x8(%rsp)
movq %rbx, %rsi
callq 0x3e22c
testl %ebp, %ebp
je 0x1e11e
testl %eax, %eax
je 0x1e138
movsd 0x8(%r14), %xmm0
leaq 0x18(%rsp), %rdi
leaq 0x4(%rsp), %rcx
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x415a9
jmp 0x1e178
leaq 0x18(%rsp), %rdi
testl %eax, %eax
je 0x1e14e
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x41571
jmp 0x1e15d
leaq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x4148f
jmp 0x1e178
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x4148f
movl (%r14), %edx
movq 0x30(%rsp), %rsi
movl 0x10(%rsi), %ecx
cmpl %ecx, %edx
jge 0x1e172
movl %edx, 0x4(%rsp)
jmp 0x1e178
decl %ecx
movl %ecx, 0x4(%rsp)
movq %rax, %rdi
callq 0x39194
testq %r12, %r12
je 0x1e1cf
movl 0x4(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq 0x18(%rsp), %r15
movq 0x20(%rsp), %r13
xorl %ebx, %ebx
xorl %r14d, %r14d
movq %r12, %rdi
movl 0x2c(%rsp), %esi
movq %r15, %rdx
movq %r13, %rcx
callq 0x1ea3a
movq %rax, %rbp
testq %rbx, %rbx
je 0x1e1bd
movq %rax, 0x10(%r14)
movq %rbx, %rbp
movq 0x10(%r12), %r12
movq %rbp, %rbx
movq %rax, %r14
testq %r12, %r12
jne 0x1e19c
jmp 0x1e1d1
xorl %ebp, %ebp
movl 0x4(%rsp), %esi
incl %esi
movq 0x30(%rsp), %rdi
movq %rbp, %rdx
movq 0x48(%rsp), %rcx
callq 0x15357
movq 0x50(%rsp), %rcx
movq %rax, (%rcx)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x3dbad
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x3dbad
movq %rbp, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq