| 767 | } |
| 768 | |
| 769 | int smileSvmModel::buildFtSelMap(int n, const char * name) |
| 770 | { |
| 771 | if (name == NULL || n < 0) { |
| 772 | return -1; |
| 773 | } |
| 774 | if (ftSelMap == NULL) { |
| 775 | ftSelMap = (int *)malloc(sizeof(int) * vectorDim); |
| 776 | for (int i = 0; i < vectorDim; i++) { |
| 777 | ftSelMap[i] = -1; |
| 778 | } |
| 779 | } |
| 780 | int i = n; |
| 781 | int j = n - 1; |
| 782 | if (j >= vectorDim) { |
| 783 | j = vectorDim - 1; |
| 784 | } |
| 785 | do { |
| 786 | if (i < vectorDim) { |
| 787 | if (!strcmp(name, attributeNames[i])) { |
| 788 | ftSelMap[i] = n; |
| 789 | return i; |
| 790 | } |
| 791 | i++; |
| 792 | } else { |
| 793 | if (j < 0) { return -1; } |
| 794 | } |
| 795 | if (j >= 0) { |
| 796 | if (!strcmp(name, attributeNames[j])) { |
| 797 | ftSelMap[j] = n; |
| 798 | return j; |
| 799 | } |
| 800 | j--; |
| 801 | } else { |
| 802 | if (i >= vectorDim) { return -1; } |
| 803 | } |
| 804 | } while(1); |
| 805 | return -1; |
| 806 | } |
| 807 | |
| 808 | // Checks the feature selection map for missing features, |
| 809 | // after it has been fully built. |