blob: 89c7fc126d76417843c43545465697b347ac1ca9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*
* MiraFeatureVector.h
* kbmira - k-best Batch MIRA
*
* An alternative to the existing SparseVector
* and FeatureDataItem combo. Should be as memory
* efficient, and a little more time efficient,
* and should save me from constantly hacking
* SparseVector
*/
#ifndef MERT_MIRA_FEATURE_VECTOR_H
#define MERT_MIRA_FEATURE_VECTOR_H
#include <vector>
#include <iostream>
#include "FeatureDataIterator.h"
typedef FeatureStatsType ValType;
class MiraFeatureVector {
public:
MiraFeatureVector(const FeatureDataItem& vec);
MiraFeatureVector(const MiraFeatureVector& other);
MiraFeatureVector(const std::vector<ValType>& dense,
const std::vector<std::size_t>& sparseFeats,
const std::vector<ValType>& sparseVals);
ValType val(std::size_t index) const;
std::size_t feat(std::size_t index) const;
std::size_t size() const;
ValType sqrNorm() const;
friend MiraFeatureVector operator-(const MiraFeatureVector& a,
const MiraFeatureVector& b);
friend std::ostream& operator<<(std::ostream& o, const MiraFeatureVector& e);
private:
std::vector<ValType> m_dense;
std::vector<std::size_t> m_sparseFeats;
std::vector<ValType> m_sparseVals;
};
#endif // MERT_FEATURE_VECTOR_H
// --Emacs trickery--
// Local Variables:
// mode:c++
// c-basic-offset:2
// End:
|