2012-07-30 4 views
0

SFS 알고리즘 pages 11-12this 문서로 구현하려고합니다.SFS (Sequential Forward Selection) 알고리즘

내가 지금까지 C++에있는 것은 다음

#include "stdafx.h" 
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <iterator> 
using namespace std; 

struct Features 
{ 
    int m_f1; 
    int m_f2; 
    int m_f3; 
    int m_f4; 

    Features(int a, int b, int c, int d) : 
     m_f1(a), 
     m_f2(b), 
     m_f3(c), 
     m_f4(d) 
    { 

    } 
}; 

int criterionFunction(Features const& features) 
{ 
    return -2 * features.m_f1 * features.m_f2 + 
      3 * features.m_f3 + 
      5 * features.m_f4 + 
      -2 * features.m_f1 * features.m_f2 * features.m_f3 + 
      7 * features.m_f3 + 
      4 * features.m_f4 + 
      -2 * features.m_f1 * features.m_f2 * features.m_f3 * features.m_f4; 
} 

int main(){ 

    Features feature, 
    vector<Features> listOfFeatures(4); 

    listOfFeatures.push_back(Features(1,0,0,0)); 
    listOfFeatures.push_back(Features(0,1,0,0)); 
    listOfFeatures.push_back(Features(0,0,1,0)); 
    listOfFeatures.push_back(Features(0,0,0,1)); 

    vector<int> listOfCriterion; 

} 

내 질문

은 다음과 같습니다

- 이제까지 전달 기능 같은 것을 criterionFunction()로 전화를 걸 수있는 방법은 무엇입니까 (예 : ; m_f1)의 값은 1이고 전달되지 않은 값은 0입니까?

는 - 여기, 내가 제일 three 기능의 조합을 (내 출력)을 선택합니다. 어떻게해야합니까?

+0

남자, 나는 정직합니다. 저는 게으른 프로그래머입니다 ... 언제든지'매트릭스 곱셈/합산/시퀀스 또는 확률'을 볼 수 있습니다. Matlab에서 똑바로 생각하고'C++ '또는'Java'로 시작하려고하지 않습니다. 해야 해. 당신은 당신의 과제를 성취하기 위해'Matlab'을 고려 했습니까? – cybertextron

+0

가능한 중복 [값을 전달하면 "1"이되고, 그렇지 않으면 "0"이됩니다. 당신은 어떻게 생각합니까?] (http://stackoverflow.com/questions/11713452/if-i-pass-a-value-i-want-it-1-otherwise-i-want-it-0-what-do - 너 - 생각해) – Blastfurnace

답변

3

그것은 당신의 요구 사항은 그러나 일반적인 대답은 아르마 같은 C++ 선형 대수 라이브러리를 사용하는 것, 질문에서 무엇을 나에게 완전히 분명하지 않다 :

http://arma.sourceforge.net/

이것은 당신에게 줄 것이다 MATLAB과 유사한 인터페이스를 사용하여 행렬 클래스 및 관련 연산을 처리합니다.