00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef MATVEC_DATA_H
00023 #define MATVEC_DATA_H
00024
00025 #include "datanode.h"
00026 #include "field.h"
00027
00028 namespace matvec {
00029 class doubleMatrix;
00030
00031
00032
00033
00034
00035
00036 class Data {
00037 protected:
00038 int data_on_disk, data_in_memory;
00039 unsigned numcol,new_col,maxnumcol, numrec;
00040 std::string tdfname;
00041
00042 void copyfrom(Data& A);
00043
00044 public:
00045 HashTable **hashtable;
00046 Field *datasheet;
00047
00048 Data(void);
00049 Data(Data& D);
00050 ~Data(void){release();}
00051
00052 const Data& operator=(Data& A);
00053 const Data& operator=(const Field& V);
00054
00055 Data& resize(const unsigned nr,const unsigned nc,const unsigned mc=0);
00056 friend std::ostream& operator<<(std::ostream& stream, Data& A);
00057
00058 int in_memory(void) const {return data_in_memory;}
00059 int in_disk(void) const {return data_on_disk;}
00060 int field_index(const std::string &colname) const;
00061 void field_index_vec(Vector<int> &intvec,const std::string &fdname="");
00062 void value_for_missing(const double vm);
00063
00064 void input(const std::string & fname,const std::string & recfmt);
00065 void save_datasheet(const int relse=1);
00066 void input_datasheet(void);
00067 void release_datasheet(void);
00068 void release(void);
00069 void print(std::ostream& stream,const Vector<int> intvec, const int ic=0);
00070 void save(const std::string &fname,
00071 const int io_mode = std::ios::out);
00072 void display(const std::string &fieldnames="",const int ic=0);
00073 void newcol(const std::string &cname,const Field& col);
00074 void row(const unsigned i,DataNode* recd);
00075 Field col(const std::string &cname);
00076 Data& newcol(const std::string & cname);
00077 Data& stack(Data& b);
00078 Data& adjoin(Data& b);
00079
00080 DataNode* cell(const unsigned r,const unsigned c);
00081 DataNode* rawcol(unsigned c);
00082 DataNode* rawcol(const std::string &cname);
00083 unsigned size(void) const {return numrec;}
00084 unsigned num_cols(void) const {return numcol;}
00085 unsigned num_rows(void) const {return numrec;}
00086 Field mean(const std::string &cname = "");
00087 Field variance(const std::string &cname = "");
00088 Field sum(const std::string &cname = "");
00089 Field sumsq(const std::string &cname = "");
00090 Field product(const std::string &cname = "");
00091 Field max(const std::string &cname = "");
00092 Field min(const std::string &cname = "");
00093 void stat(void);
00094 doubleMatrix mat(void);
00095 };
00096 }
00097
00098 #endif