Go to the documentation of this file.00001 #include <shogun/features/StreamingDotFeatures.h>
00002
00003 using namespace shogun;
00004
00005 CStreamingDotFeatures::CStreamingDotFeatures() : CStreamingFeatures()
00006 {
00007 init();
00008 set_property(FP_STREAMING_DOT);
00009 }
00010
00011 CStreamingDotFeatures::CStreamingDotFeatures(CStreamingFile* file, bool is_labelled,
00012 int32_t size) : CStreamingFeatures()
00013 {
00014 init(file, is_labelled, size);
00015 set_property(FP_STREAMING_DOT);
00016 }
00017
00018 CStreamingDotFeatures::CStreamingDotFeatures(CDotFeatures* dot_features,
00019 float64_t* lab)
00020 {
00021 SG_NOTIMPLEMENTED;
00022 return;
00023 }
00024
00025 CStreamingDotFeatures::~CStreamingDotFeatures()
00026 {
00027 }
00028
00029 void CStreamingDotFeatures::dense_dot_range(float32_t* output, float32_t* alphas,
00030 float32_t* vec, int32_t dim, float32_t b, int32_t num_vec)
00031 {
00032 ASSERT(num_vec>=0);
00033
00034 int32_t counter=0;
00035 start_parser();
00036 while (get_next_example())
00037 {
00038 if (alphas)
00039 output[counter]=alphas[counter]*dense_dot(vec, dim)+b;
00040 else
00041 output[counter]=dense_dot(vec, dim)+b;
00042
00043 release_example();
00044
00045 counter++;
00046 if ((counter>=num_vec) && (num_vec>0))
00047 break;
00048 }
00049 end_parser();
00050 }
00051
00052 void CStreamingDotFeatures::expand_if_required(float32_t*& vec, int32_t &len)
00053 {
00054 int32_t dim = get_dim_feature_space();
00055 if (dim > len)
00056 {
00057 vec = SG_REALLOC(float32_t, vec, dim);
00058 memset(&vec[len], 0, (dim-len) * sizeof(float32_t));
00059 len = dim;
00060 }
00061 }
00062
00063 void CStreamingDotFeatures::expand_if_required(float64_t*& vec, int32_t &len)
00064 {
00065 int32_t dim = get_dim_feature_space();
00066 if (dim > len)
00067 {
00068 vec = SG_REALLOC(float64_t, vec, dim);
00069 memset(&vec[len], 0, (dim-len) * sizeof(float64_t));
00070 len = dim;
00071 }
00072 }
00073
00074 void* CStreamingDotFeatures::get_feature_iterator()
00075 {
00076 SG_NOTIMPLEMENTED;
00077 return NULL;
00078 }
00079
00080 int32_t CStreamingDotFeatures::get_nnz_features_for_vector()
00081 {
00082 SG_NOTIMPLEMENTED;
00083 return -1;
00084 }
00085
00086 bool CStreamingDotFeatures::get_next_feature(int32_t& index, float32_t& value, void* iterator)
00087 {
00088 SG_NOTIMPLEMENTED;
00089 return false;
00090 }
00091
00092 void CStreamingDotFeatures::free_feature_iterator(void* iterator)
00093 {
00094 SG_NOTIMPLEMENTED;
00095 return;
00096 }
00097
00098 void CStreamingDotFeatures::init()
00099 {
00100 }
00101
00102 void CStreamingDotFeatures::init(CStreamingFile *file, bool is_labelled, int32_t size)
00103 {
00104 }