/
RealFileFeatures.h
111 lines (96 loc) · 2.45 KB
/
RealFileFeatures.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 1999-2009 Soeren Sonnenburg
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
*/
#ifndef _DREALFILEFEATURES__H__
#define _DREALFILEFEATURES__H__
#include <shogun/lib/common.h>
#include <shogun/features/DenseFeatures.h>
namespace shogun
{
/** @brief The class RealFileFeatures implements a dense double-precision floating
* point matrix <b>from a file</b>.
*
* It inherits its functionality from CDenseFeatures, which should be
* consulted for further reference.
*/
class CRealFileFeatures: public CDenseFeatures<float64_t>
{
public:
/** default constructor */
CRealFileFeatures();
/** constructor
*
* @param size cache size
* @param file file to load features from
*/
CRealFileFeatures(int32_t size, FILE* file);
/** constructor
*
* @param size cache size
* @param filename filename to load features from
*/
CRealFileFeatures(int32_t size, char* filename);
/** copy constructor */
CRealFileFeatures(const CRealFileFeatures& orig);
virtual ~CRealFileFeatures();
/** load feature matrix
*
* @return loaded feature matrix
*/
virtual float64_t* load_feature_matrix();
/** get label at given index
*
* @param idx index to look at
* @return label at given index
*/
int32_t get_label(int32_t idx);
/** @return object name */
virtual const char* get_name() const { return "RealFileFeatures"; }
protected:
/** compute feature vector for sample num
* len is returned by reference
*
* @param num num
* @param len len
* @param target target
*/
virtual float64_t* compute_feature_vector(
int32_t num, int32_t& len, float64_t* target=NULL);
/** load base data
*
* @return if loading was successful
*/
bool load_base_data();
private:
/** initialises members */
void init();
protected:
/** working file */
FILE* working_file;
/** working filename */
char* working_filename;
/** status */
bool status;
/** labels */
int32_t* labels;
/** intlen */
uint8_t intlen;
/** doublelen */
uint8_t doublelen;
/** endian */
uint32_t endian;
/** fourcc */
uint32_t fourcc;
/** preprocd */
uint32_t preprocd;
/** filepos */
int64_t filepos;
};
}
#endif