SHOGUN
v3.2.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 set_property(FP_STREAMING_DOT); 00017 } 00018 00019 CStreamingDotFeatures::CStreamingDotFeatures(CDotFeatures* dot_features, 00020 float64_t* lab) 00021 { 00022 SG_NOTIMPLEMENTED 00023 return; 00024 } 00025 00026 CStreamingDotFeatures::~CStreamingDotFeatures() 00027 { 00028 } 00029 00030 void CStreamingDotFeatures::dense_dot_range(float32_t* output, float32_t* alphas, 00031 float32_t* vec, int32_t dim, float32_t b, int32_t num_vec) 00032 { 00033 ASSERT(num_vec>=0) 00034 00035 int32_t counter=0; 00036 start_parser(); 00037 while (get_next_example()) 00038 { 00039 if (alphas) 00040 output[counter]=alphas[counter]*dense_dot(vec, dim)+b; 00041 else 00042 output[counter]=dense_dot(vec, dim)+b; 00043 00044 release_example(); 00045 00046 counter++; 00047 if ((counter>=num_vec) && (num_vec>0)) 00048 break; 00049 } 00050 end_parser(); 00051 } 00052 00053 void CStreamingDotFeatures::expand_if_required(float32_t*& vec, int32_t &len) 00054 { 00055 int32_t dim = get_dim_feature_space(); 00056 if (dim > len) 00057 { 00058 vec = SG_REALLOC(float32_t, vec, len, dim); 00059 memset(&vec[len], 0, (dim-len) * sizeof(float32_t)); 00060 len = dim; 00061 } 00062 } 00063 00064 void CStreamingDotFeatures::expand_if_required(float64_t*& vec, int32_t &len) 00065 { 00066 int32_t dim = get_dim_feature_space(); 00067 if (dim > len) 00068 { 00069 vec = SG_REALLOC(float64_t, vec, len, dim); 00070 memset(&vec[len], 0, (dim-len) * sizeof(float64_t)); 00071 len = dim; 00072 } 00073 } 00074 00075 void* CStreamingDotFeatures::get_feature_iterator() 00076 { 00077 SG_NOTIMPLEMENTED 00078 return NULL; 00079 } 00080 00081 int32_t CStreamingDotFeatures::get_nnz_features_for_vector() 00082 { 00083 SG_NOTIMPLEMENTED 00084 return -1; 00085 } 00086 00087 bool CStreamingDotFeatures::get_next_feature(int32_t& index, float32_t& value, void* iterator) 00088 { 00089 SG_NOTIMPLEMENTED 00090 return false; 00091 } 00092 00093 void CStreamingDotFeatures::free_feature_iterator(void* iterator) 00094 { 00095 SG_NOTIMPLEMENTED 00096 return; 00097 }