17 #include "msdevstudio/MSconfig.h"
25 #define _GLIBCPP_USE_C99 1
46 #ifdef ITERATOR_MEMBER_DEFECT
50 using std::runtime_error;
55 using namespace hippodraw;
58 DataSource (
const std::string & name )
76 m_ds_name ( ds.m_ds_name ),
77 m_title( ds.m_title ),
78 m_labels ( ds.m_labels ),
80 m_shape ( ds.m_shape )
85 DataSource (
const std::vector < std::string > & labels )
86 : m_labels ( labels ),
101 : m_ds_name (
"null" ),
102 m_title (
"Not valid DataSource" ),
163 if ( i >=
m_labels.size() )
return false;
170 const vector <string> &
184 string what (
"DataSource: argument out of range" );
185 throw runtime_error ( what );
196 vector< string >::const_iterator first
200 #ifdef DISTANCE_DEFECT
203 index = distance (
m_labels.begin(), first );
215 if ( index >= size ) {
216 string what (
"DataSource: Index `" );
218 what +=
"' out of range 0 to ";
220 throw runtime_error ( what );
226 const vector < double > &
234 for (
unsigned int i = 0; i <
size; i++ ) {
241 const vector < double > &
247 const string what (
"DataSource: Attempt to get column whose label"
249 throw runtime_error ( what );
259 vector< string >::const_iterator first
271 if ( yes ==
false ) {
272 string what (
"DataSource: `" );
274 what +=
"' not found in this data source";
275 throw runtime_error ( what );
284 unsigned int cols = row.size ();
285 if ( size != cols ) {
286 string what (
"DataSource: Attempt to add row of size `" );
288 what +=
"' to DataSource with `";
291 throw runtime_error ( what );
311 const vector < unsigned int > &
323 shape.push_back (
rows () );
329 const std::string & label )
const
333 string what (
"DataSource: No column with label `" );
336 throw runtime_error ( what );
351 const std::vector < double > & array )
353 string what (
"DataSource: The type of data source does not support "
354 "replacing a column." );
355 throw runtime_error ( what );
361 const std::vector < double > & array )
366 string what (
"DataSource: Attempt to replace column `" );
368 what +=
"' which does not exist.";
369 throw runtime_error ( what );
379 const std::vector < double > &,
380 const std::vector < intptr_t > & )
382 string what (
"DataSource: This type of data source does not support"
383 " the notion of shape." );
384 throw runtime_error ( what );
391 const std::vector < double > & )
393 string what (
"DataSource: This type of data source does not support "
394 "adding a column." );
395 throw runtime_error ( what );
401 const std::vector < double > &,
402 const std::vector < intptr_t > & )
404 string what (
"DataSource: This type of data source does not support"
405 " the notion of shape." );
406 throw runtime_error ( what );
417 assert ( column <
columns () );
423 double min = DBL_MAX;
424 double max = DBL_MIN;
425 double pos = DBL_MAX;
426 for (
unsigned int i = 0; i <
size; i++ ) {
427 double x =
valueAt ( i, column );
429 if ( x != HUGE_VAL &&
431 isnan ( x ) ==
false ) {
432 min = std::min ( min, x );
433 max = std::max ( max, x );
434 if ( x > 0.0 ) pos = std::min ( pos, x );
441 if ( valid ==
true ) {
466 const std::vector< unsigned int > & )
478 assert ( column <
columns () );
481 unsigned int index = 0;
482 double m =
valueAt ( 0, column );
484 for (
unsigned int i = 1; i <
size; i++ ) {
485 double v =
valueAt ( i, column );
499 assert ( column <
columns () );
502 unsigned int index = 0;
503 double m =
valueAt ( 0, column );
505 for (
unsigned int i = 1; i <
size; i++ ) {
506 double v =
valueAt ( i, column );
520 assert ( column <
columns () );
525 for (
unsigned int i = 0; i <
size; i++ ) {
532 const vector < string > &
543 return valueAt ( row, column );
548 addRow (
const std::vector < double > & row )
550 string what (
"This data source is not capable of adding rows" );
551 throw runtime_error ( what );
558 string what (
"This data source is not capable of erasing rows" );
559 throw runtime_error ( what );
567 unsigned int ncolumns = source ->
columns ();
568 if ( ncolumns !=
columns () ) {
569 string what (
"DataSource: Number of columns of source (" );
571 what +=
") not equal to current (";
574 throw runtime_error ( what );
584 unsigned int size = source ->
rows ();
585 for (
unsigned int i = 0; i <
size; i++ ) {
586 const vector < double > & src_row = source ->
getRow ( i );
595 string what (
"DataSource: This data source is not capable of containing\n"
596 "an array in a column." );
597 throw runtime_error ( what );