SHOGUN
v2.0.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2011 Shashwat Lal Das 00008 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society 00009 */ 00010 #include <shogun/features/streaming/StreamingDotFeatures.h> 00011 00012 using namespace shogun; 00013 00014 CStreamingDotFeatures::CStreamingDotFeatures() : CStreamingFeatures() 00015 { 00016 init(); 00017 set_property(FP_STREAMING_DOT); 00018 } 00019 00020 CStreamingDotFeatures::CStreamingDotFeatures(CStreamingFile* file, bool is_labelled, 00021 int32_t size) : CStreamingFeatures() 00022 { 00023 init(file, is_labelled, size); 00024 set_property(FP_STREAMING_DOT); 00025 } 00026 00027 CStreamingDotFeatures::CStreamingDotFeatures(CDotFeatures* dot_features, 00028 float64_t* lab) 00029 { 00030 SG_NOTIMPLEMENTED; 00031 return; 00032 } 00033 00034 CStreamingDotFeatures::~CStreamingDotFeatures() 00035 { 00036 } 00037 00038 void CStreamingDotFeatures::dense_dot_range(float32_t* output, float32_t* alphas, 00039 float32_t* vec, int32_t dim, float32_t b, int32_t num_vec) 00040 { 00041 ASSERT(num_vec>=0); 00042 00043 int32_t counter=0; 00044 start_parser(); 00045 while (get_next_example()) 00046 { 00047 if (alphas) 00048 output[counter]=alphas[counter]*dense_dot(vec, dim)+b; 00049 else 00050 output[counter]=dense_dot(vec, dim)+b; 00051 00052 release_example(); 00053 00054 counter++; 00055 if ((counter>=num_vec) && (num_vec>0)) 00056 break; 00057 } 00058 end_parser(); 00059 } 00060 00061 void CStreamingDotFeatures::expand_if_required(float32_t*& vec, int32_t &len) 00062 { 00063 int32_t dim = get_dim_feature_space(); 00064 if (dim > len) 00065 { 00066 vec = SG_REALLOC(float32_t, vec, dim); 00067 memset(&vec[len], 0, (dim-len) * sizeof(float32_t)); 00068 len = dim; 00069 } 00070 } 00071 00072 void CStreamingDotFeatures::expand_if_required(float64_t*& vec, int32_t &len) 00073 { 00074 int32_t dim = get_dim_feature_space(); 00075 if (dim > len) 00076 { 00077 vec = SG_REALLOC(float64_t, vec, dim); 00078 memset(&vec[len], 0, (dim-len) * sizeof(float64_t)); 00079 len = dim; 00080 } 00081 } 00082 00083 void* CStreamingDotFeatures::get_feature_iterator() 00084 { 00085 SG_NOTIMPLEMENTED; 00086 return NULL; 00087 } 00088 00089 int32_t CStreamingDotFeatures::get_nnz_features_for_vector() 00090 { 00091 SG_NOTIMPLEMENTED; 00092 return -1; 00093 } 00094 00095 bool CStreamingDotFeatures::get_next_feature(int32_t& index, float32_t& value, void* iterator) 00096 { 00097 SG_NOTIMPLEMENTED; 00098 return false; 00099 } 00100 00101 void CStreamingDotFeatures::free_feature_iterator(void* iterator) 00102 { 00103 SG_NOTIMPLEMENTED; 00104 return; 00105 } 00106 00107 void CStreamingDotFeatures::init() 00108 { 00109 } 00110 00111 void CStreamingDotFeatures::init(CStreamingFile *file, bool is_labelled, int32_t size) 00112 { 00113 }