#include <field.h>
Definition at line 40 of file field.h.
Public Methods | |
| Field (void) | |
| Field (const unsigned n) | |
| Field (const Field &a) | |
| Field (const unsigned n, DataNode *a, FieldStruct st, HashTable *ht=0) | |
| ~Field (void) | |
| Field & | resize (const unsigned n) |
| Field & | resize (const unsigned n, DataNode *a) |
| const Field & | operator= (const Field &a) |
| Field & | operator+= (const Field &a) |
| Field & | operator-= (const Field &a) |
| Field & | operator *= (const Field &a) |
| Field & | operator/= (const Field &a) |
| Field & | operator+= (const double s) |
| Field & | operator-= (const double s) |
| Field & | operator *= (const double s) |
| Field & | operator/= (const double s) |
| DataNode & | operator() (const unsigned i) |
| DataNode & | operator[] (const unsigned i) |
| Field | operator! (void) const |
| Field | operator- (void) const |
| Field & | operator+ (void) |
| Vector< bool > | operator== (const Field &a) const |
| Vector< bool > | operator== (const double x) const |
| Vector< bool > | operator< (const Field &a) const |
| Vector< bool > | operator> (const Field &a) const |
| Vector< bool > | operator!= (const Field &a) const |
| Vector< bool > | operator<= (const Field &a) const |
| Vector< bool > | operator>= (const Field &a) const |
| void | value_for_missing (const double vm) |
| void | out_to_stream (std::ostream &stream, const int ic) const |
| void | save (const std::string &ffname, const int io_mode=std::ios::out) const |
| void | display (const std::string &meg="", const int ic=0) const |
| void | set_missing (const unsigned k) |
| void | pretend_missing (const unsigned k) |
| void | recover_missing (const unsigned k) |
| Field | map (double(*f)(double)) const |
| Field | sub (const int i1, const int i2) const |
| Field & | zeros (void) |
| Field & | ones (void) |
| Field & | sort (void) |
| DataNode | max (void) const |
| DataNode | min (void) const |
| DataNode | sum (void) const |
| DataNode | sumsq (void) const |
| DataNode | product (void) const |
| DataNode | mean (const int flag=1) |
| DataNode | covariance (const Field *B=0) const |
| DataNode | elem (const unsigned i) const |
| unsigned | len (void) const |
| unsigned | size (void) const |
| void | release (void) |
| void | index (const unsigned k) |
| void | nlevel (const unsigned k) |
| void | nmiss (const unsigned k) |
| void | count_miss (const int k) |
| void | classi (const char c) |
| void | type (const char c) |
| void | name (const std::string &n) |
| unsigned | index (void) const |
| unsigned | nlevel (void) const |
| unsigned | nmiss (void) const |
| char | classi (void) const |
| char | type (void) const |
| const std::string | name (void) const |
Public Attributes | |
| FieldStruct | col_struct |
Protected Methods | |
| void | copyfrom (const Field &a) |
Protected Attributes | |
| unsigned | ne |
| DataNode | mean_value |
| DataNode * | dat_vec |
| HashTable * | hashtable |
Friends | |
| class | Data |
| Vector< bool > | operator== (const double a, const Field &b) |
| Vector< bool > | operator< (const Field &a, const double b) |
| Vector< bool > | operator< (const double a, const Field &b) |
| Vector< bool > | operator!= (const Field &a, const double b) |
| Vector< bool > | operator!= (const double a, const Field &b) |
| Vector< bool > | operator> (const Field &a, const double b) |
| Vector< bool > | operator> (const double a, const Field &b) |
| Vector< bool > | operator<= (const Field &a, const double b) |
| Vector< bool > | operator<= (const double a, const Field b) |
| Vector< bool > | operator>= (const Field &a, const double b) |
| Vector< bool > | operator>= (const double a, const Field &b) |
| Field | operator+ (const Field &a, const Field &b) |
| Field | operator+ (const Field &a, const double b) |
| Field | operator+ (const double b, const Field &a) |
| Field | operator- (const Field &a, const Field &b) |
| Field | operator- (const Field &a, const double b) |
| Field | operator- (const double b, const Field &a) |
| Field | operator/ (const Field &a, const Field &b) |
| Field | operator/ (const Field &a, const double s) |
| Field | operator/ (const double s, const Field &b) |
| Field | operator * (const Field &a, const Field &b) |
| Field | operator * (const Field &a, const double b) |
| Field | operator * (const double a, const Field &b) |
| std::ostream & | operator<< (std::ostream &stream, const Field &a) |
| Field | sin (Field &a) |
| Field | asin (Field &a) |
| Field | cos (Field &a) |
| Field | acos (Field &a) |
| Field | tan (Field &a) |
| Field | atan (Field &a) |
| Field | ceil (Field &a) |
| Field | floor (Field &a) |
| Field | log (Field &a) |
| Field | log10 (Field &a) |
| Field | exp (Field &a) |
| Field | sqrt (Field &a) |
| Field | abs (Field &a) |
| Field | erf (Field &a) |
| Field | erfc (Field &a) |
|
|
Definition at line 180 of file field.h. Referenced by map(), and sub().
|
|
|
Definition at line 183 of file field.h.
|
|
|
Definition at line 40 of file field.cpp.
|
|
||||||||||||||||||||
|
Definition at line 33 of file field.cpp. References col_struct, dat_vec, hashtable, and ne.
00033 {
00034 ne = n;
00035 dat_vec = a;
00036 col_struct = st;
00037 hashtable = ht;
00038 }
|
|
|
Definition at line 58 of file field.h. References release().
00058 {release();} // Destructor
|
|
|
Definition at line 172 of file field.h. References matvec::FieldStruct::classi().
00172 {return col_struct.classi();}
|
|
|
Definition at line 166 of file field.h. References matvec::FieldStruct::classi(). Referenced by matvec::Model::hashxact(), matvec::Model::prepare_data(), matvec::Model::re_hash_data(), matvec::Model::save(), matvec::GLMM::save(), matvec::Model::save_pos_val(), and matvec::Model::trait_effect_level().
00166 {col_struct.classi(c);}
|
|
|
Definition at line 53 of file field.cpp. References col_struct, dat_vec, hashtable, ne, and resize(). Referenced by operator=().
00054 {
00055 if (this == &A) return;
00056 resize(A.ne);
00057 memcpy(dat_vec,A.dat_vec,sizeof(DataNode)*ne);
00058 col_struct = A.col_struct;
00059 if (A.hashtable) {
00060 if (hashtable) {
00061 delete hashtable;
00062 hashtable=0;
00063 }
00064 hashtable = new HashTable;
00065 *hashtable = *(A.hashtable);
00066 }
00067 }
|
|
|
Definition at line 165 of file field.h. References matvec::FieldStruct::count_miss(). Referenced by matvec::Data::input(), and matvec::Model::save_pos_val().
00165 {col_struct.count_miss(k);}
|
|
|
Definition at line 910 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), matvec::DataNode::missing, ne, matvec::FieldStruct::type(), and matvec::Vector< T >::variance(). Referenced by matvec::Data::stat().
00911 {
00912 if (B) throw exception("Field::covariance(B): not yet implemented");
00913 DataNode retval;
00914 retval.missing = 1;
00915
00916 if (col_struct.type() != 'S') {
00917 unsigned i,k;
00918 for (k=0,i=0; i<ne; i++) if (!dat_vec[i].missing) k++;
00919 if (k >= 2) {
00920 Vector<double> tmp(k);
00921 for (k=0,i=0; i<ne; i++) {
00922 if (!dat_vec[i].missing) tmp[k++] = dat_vec[i].double_val();
00923 }
00924 retval.double_val(tmp.variance());
00925 retval.missing = 0;
00926 }
00927 }
00928 return retval;
00929 }
|
|
||||||||||||
|
Definition at line 1057 of file field.cpp. References out_to_stream().
01058 {
01059 if (msg != "") std::cout <<"\n " << msg << "\n";
01060 this->out_to_stream(std::cout,ic);
01061 }
|
|
|
Definition at line 201 of file field.h. References ne. Referenced by matvec::Data::newcol().
|
|
|
Definition at line 169 of file field.h. References matvec::FieldStruct::index().
00169 {return col_struct.index();}
|
|
|
Definition at line 162 of file field.h. References matvec::FieldStruct::index(). Referenced by matvec::Data::field_index(), matvec::Data::input(), and matvec::Model::prepare_data().
00162 {col_struct.index(k);}
|
|
|
Definition at line 158 of file field.h. References ne. Referenced by operator<(), matvec::Data::operator=(), operator==(), and operator>().
00158 {return ne;}
|
|
|
Definition at line 703 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), Field(), matvec::DataNode::missing, ne, matvec::FieldStruct::type(), and matvec::warning(). Referenced by matvec::abs(), matvec::acos(), matvec::asin(), matvec::atan(), matvec::ceil(), matvec::cos(), matvec::erf(), matvec::erfc(), matvec::exp(), matvec::floor(), matvec::log(), matvec::log10(), matvec::sin(), matvec::sqrt(), and matvec::tan().
00704 {
00705 if (col_struct.type()=='S') {
00706 warning("Field:map(): failed for string column");
00707 return Field();
00708 }
00709 DataNode *temp;
00710 if(ne>0){
00711 temp = new DataNode [ne];
00712 }
00713 else {
00714 temp = 0;
00715 }
00716 for (unsigned i=0; i<ne; i++) {
00717 if (dat_vec[i].missing) {temp[i].missing = 1; }
00718 else { temp[i].double_val((*f)(dat_vec[i].double_val())); }
00719 }
00720 return Field(ne,temp,col_struct);
00721 }
|
|
|
Definition at line 778 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), matvec::DataNode::missing, ne, and matvec::FieldStruct::type(). Referenced by matvec::Data::stat().
00779 {
00780 DataNode retval;
00781 retval.missing = 1;
00782
00783 if (col_struct.type() != 'S') {
00784 unsigned i,k=0;
00785 while (dat_vec[k].missing) k++;
00786 double y,mx = dat_vec[k].double_val();
00787 for (i=k; i<ne; i++) {
00788 if (!dat_vec[i].missing) {
00789 y = dat_vec[i].double_val();
00790 if ( y > mx) mx = y;
00791 }
00792 }
00793 if (k < ne) {
00794 retval.missing = 0;
00795 retval.double_val(mx);
00796 }
00797 }
00798 return retval;
00799 }
|
|
|
Definition at line 889 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), mean_value, matvec::DataNode::missing, ne, and matvec::FieldStruct::type(). Referenced by matvec::Model::save_pos_val(), and matvec::Data::stat().
00890 {
00891 if (flag == 0 || col_struct.type()=='S') return mean_value;
00892
00893 unsigned i,k;
00894 double x;
00895 for (x=0.0,k=0,i=0; i<ne; i++) {
00896 if (!dat_vec[i].missing) {
00897 k++;
00898 x += dat_vec[i].double_val();
00899 }
00900 }
00901 if (k >=1 ) {
00902 x /= k;
00903 mean_value.missing = 0;
00904 mean_value.double_val(x);
00905 }
00906 return mean_value;
00907 }
|
|
|
Definition at line 801 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), matvec::DataNode::missing, ne, and matvec::FieldStruct::type(). Referenced by matvec::Data::stat().
00802 {
00803 DataNode retval;
00804 retval.missing = 1;
00805
00806 if (col_struct.type() != 'S') {
00807 unsigned i, k=0;
00808 while (dat_vec[k].missing) k++;
00809 double y,mx = dat_vec[k].double_val();
00810 for (i=k; i<ne; i++) {
00811 if (!dat_vec[i].missing) {
00812 y = dat_vec[i].double_val();
00813 if ( y < mx) mx = y;
00814 }
00815 }
00816 if (k < ne) {
00817 retval.missing = 0;
00818 retval.double_val(mx);
00819 }
00820 }
00821 return retval;
00822 }
|
|
|
Definition at line 174 of file field.h. References matvec::FieldStruct::name().
00174 {return col_struct.name();}
|
|
|
Definition at line 168 of file field.h. References matvec::FieldStruct::name(). Referenced by matvec::Data::field_index(), matvec::Data::input(), matvec::Model::save(), matvec::GLMM::save(), matvec::Data::stat(), and matvec::Model::trait_effect_level().
00168 {col_struct.name(n);}
|
|
|
Definition at line 170 of file field.h. References matvec::FieldStruct::nlevel().
00170 {return col_struct.nlevel();}
|
|
|
Definition at line 163 of file field.h. References matvec::FieldStruct::nlevel(). Referenced by matvec::Data::input(), matvec::Model::prepare_data(), matvec::Model::re_hash_data(), and matvec::Model::save_pos_val().
00163 {col_struct.nlevel(k);}
|
|
|
Definition at line 171 of file field.h. References matvec::FieldStruct::nmiss().
00171 {return col_struct.nmiss();}
|
|
|
Definition at line 164 of file field.h. References matvec::FieldStruct::nmiss(). Referenced by matvec::Data::input(), matvec::Model::prepare_data(), and matvec::Data::stat().
00164 {col_struct.nmiss(k);}
|
|
|
Definition at line 213 of file field.h. References matvec::DataNode::double_val(), and ne.
|
|
|
Definition at line 207 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::data, ne, matvec::FieldStruct::type(), and matvec::warning().
00208 {
00209 if (col_struct.type() == 'S') {
00210 warning("Field *= s: failed for string column");
00211 }
00212 else {
00213 for (unsigned i=0; i<ne; i++) {
00214 dat_vec[i].data.double_value *= s;
00215 }
00216 }
00217 return *this;
00218 }
|
|
|
Definition at line 146 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::data, matvec::DataNode::missing, ne, matvec::FieldStruct::type(), and matvec::warning().
00147 {
00148 if (ne == a.ne ) {
00149 if (col_struct.type() == 'S') {
00150 warning("Field *= Field: string column");
00151 }
00152 else {
00153 for (unsigned i=0; i<ne; i++) {
00154 if (!a.dat_vec[i].missing) {
00155 dat_vec[i].data.double_value *= a.dat_vec[i].data.double_value;
00156 }
00157 }
00158 }
00159 }
00160 else {
00161 warning("operator *=, Fields not conformable");
00162 }
00163 return *this;
00164 }
|
|
|
Definition at line 679 of file field.cpp. References matvec::DataNode::double_val(), matvec::DataNode::missing, and matvec::warning().
00680 {
00681 if (col_struct.type()=='S') {
00682 warning("!Field: failed for string column");
00683 return Field();
00684 }
00685 DataNode *temp;
00686 if(ne>0){
00687 temp = new DataNode [ne];
00688 }
00689 else {
00690 temp = 0;
00691 }
00692 for (unsigned i=0; i<ne; i++) {
00693 if (dat_vec[i].missing) {
00694 temp[i].missing = 1;
00695 }
00696 else {
00697 temp[i].double_val(-(dat_vec[i].double_val()));
00698 }
00699 }
00700 return Field(ne,temp,col_struct);
00701 }
|
|
|
Definition at line 271 of file field.cpp.
00271 {return !(*this == a);}
|
|
|
Definition at line 195 of file field.h. References ne.
|
|
|
Definition at line 80 of file field.h.
00080 {return *this;}; //unary plus
|
|
|
Definition at line 186 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::data, ne, matvec::FieldStruct::type(), and matvec::warning().
00187 {
00188 if (col_struct.type() == 'S') {
00189 warning("Field += s: failed for string column");
00190 }
00191 else {
00192 for (unsigned i=0; i<ne; i++) dat_vec[i].data.double_value += s;
00193 }
00194 return *this;
00195 }
|
|
|
Definition at line 106 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::data, matvec::DataNode::missing, ne, matvec::FieldStruct::type(), and matvec::warning().
00107 {
00108 if (ne == a.ne ) {
00109 if (col_struct.type() == 'S') {
00110 warning("Field += Field: string column");
00111 }
00112 else {
00113 for (unsigned i=0; i<ne; i++) {
00114 if (!a.dat_vec[i].missing) {
00115 dat_vec[i].data.double_value += a.dat_vec[i].data.double_value;
00116 }
00117 }
00118 }
00119 }
00120 else {
00121 warning("operator +=, size not conformable");
00122 }
00123 return *this;
00124 }
|
|
|
|
|
|
Definition at line 196 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::data, ne, matvec::FieldStruct::type(), and matvec::warning().
00197 {
00198 if (col_struct.type() == 'S') {
00199 warning("Field -= s: failed for string column");
00200 }
00201 else {
00202 for (unsigned i=0; i<ne; i++) dat_vec[i].data.double_value -= s;
00203 }
00204 return *this;
00205 }
|
|
|
Definition at line 126 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::data, matvec::DataNode::missing, ne, matvec::FieldStruct::type(), and matvec::warning().
00127 {
00128 if (ne == a.ne ) {
00129 if (col_struct.type() == 'S') {
00130 warning("Field -= Field: string column");
00131 }
00132 else {
00133 for (unsigned i=0; i<ne; i++) {
00134 if (!a.dat_vec[i].missing) {
00135 dat_vec[i].data.double_value -= a.dat_vec[i].data.double_value;
00136 }
00137 }
00138 }
00139 }
00140 else {
00141 warning("operator -=, Fields not conformable");
00142 }
00143 return *this;
00144 }
|
|
|
Definition at line 220 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::data, ne, matvec::FieldStruct::type(), and matvec::warning().
00221 {
00222 if (col_struct.type() == 'S') {
00223 warning("Field /= s: failed for string column");
00224 }
00225 else {
00226 for (unsigned i=0; i<ne; i++) dat_vec[i].data.double_value /= s;
00227 }
00228 return *this;
00229 }
|
|
|
Definition at line 166 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::data, matvec::DataNode::missing, ne, matvec::FieldStruct::type(), and matvec::warning().
00167 {
00168 if (ne != a.ne ) {
00169 if (col_struct.type() == 'S') {
00170 warning("Field /= Field: string column");
00171 }
00172 else {
00173 for (unsigned i=0; i<ne; i++) {
00174 if (!a.dat_vec[i].missing) {
00175 dat_vec[i].data.double_value /= a.dat_vec[i].data.double_value;
00176 }
00177 }
00178 }
00179 }
00180 else {
00181 warning("operator /=, Fields not conformable");
00182 }
00183 return *this;
00184 }
|
|
|
Definition at line 275 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), matvec::HashTable::find(), hashtable, len(), matvec::DataNode::missing, ne, matvec::FieldStruct::nlevel(), matvec::FieldStruct::type(), and matvec::warning().
00276 {
00277 Vector<bool> temp(ne);
00278 if (ne != a.len() ) {
00279 warning("A==B, two Fields are not conformable");
00280 return temp;
00281 }
00282
00283 if (col_struct.type() != a.col_struct.type() ) return temp;
00284 if (col_struct.nlevel() != a.col_struct.nlevel()) return temp;
00285
00286 if (col_struct.type() == 'S') {
00287 char *str, *a_str;
00288 for (unsigned i=0; i<ne; i++) {
00289 if (!dat_vec[i].missing && !a.dat_vec[i].missing) {
00290 str = (char *)hashtable->find(dat_vec[i].unsigned_val());
00291 a_str = (char *)a.hashtable->find(dat_vec[i].unsigned_val());
00292 if (strcmp(str,a_str) < 0) temp[i] = true;
00293 }
00294 }
00295 }
00296 else if (col_struct.type() == 'F') {
00297 for (unsigned i=0; i<ne; i++) {
00298 if (dat_vec[i].double_val()<a.dat_vec[i].double_val()) temp[i]= true;
00299 }
00300 }
00301 return temp;
00302
00303 }
|
|
|
Definition at line 272 of file field.cpp.
00272 {return !(*this > a);}
|
|
|
Definition at line 69 of file field.cpp. References copyfrom().
00070 {
00071 copyfrom(a);
00072 return *this;
00073 }
|
|
|
Definition at line 260 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), ne, and matvec::FieldStruct::type().
00261 {
00262 Vector<bool> temp(ne);
00263
00264 if (col_struct.type() == 'S') return temp;
00265 for (unsigned i=0; i<ne; i++) {
00266 if (dat_vec[i].double_val()==x) temp[i] = true;
00267 }
00268 return temp;
00269 }
|
|
|
Definition at line 231 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), matvec::HashTable::find(), hashtable, len(), matvec::DataNode::missing, ne, matvec::FieldStruct::nlevel(), matvec::FieldStruct::type(), and matvec::warning().
00232 {
00233 Vector<bool> temp(ne);
00234 if (ne != a.len() ) {
00235 warning("Field::operator==(), size not conformable");
00236 return temp;
00237 }
00238
00239 if (col_struct.type() != a.col_struct.type() ) return temp;
00240 if (col_struct.nlevel() != a.col_struct.nlevel()) return temp;
00241
00242 if (col_struct.type() == 'S') {
00243 char *str, *a_str;
00244 for (unsigned i=0; i<ne; i++) {
00245 if (!dat_vec[i].missing && !a.dat_vec[i].missing) {
00246 str = (char *)hashtable->find(dat_vec[i].unsigned_val());
00247 a_str = (char *)a.hashtable->find(dat_vec[i].unsigned_val());
00248 if (strcmp(str,a_str)==0) temp[i] = true;
00249 }
00250 }
00251 }
00252 else if (col_struct.type() == 'F') {
00253 for (unsigned i=0; i<ne; i++) {
00254 if (dat_vec[i].double_val()==a.dat_vec[i].double_val()) temp[i]= true;
00255 }
00256 }
00257 return temp;
00258 }
|
|
|
Definition at line 305 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), matvec::HashTable::find(), hashtable, len(), matvec::DataNode::missing, ne, matvec::FieldStruct::nlevel(), matvec::FieldStruct::type(), and matvec::warning().
00306 {
00307 Vector<bool> temp(ne);
00308 if (ne != a.len() ) {
00309 warning("A==B, two Fields are not conformable");
00310 return temp;
00311 }
00312
00313 if (col_struct.type() != a.col_struct.type() ) return temp;
00314 if (col_struct.nlevel() != a.col_struct.nlevel()) return temp;
00315
00316 if (col_struct.type() == 'S') {
00317 char *str, *a_str;
00318 for (unsigned i=0; i<ne; i++) {
00319 if (!dat_vec[i].missing && !a.dat_vec[i].missing) {
00320 str = (char *)hashtable->find(dat_vec[i].unsigned_val());
00321 a_str = (char *)a.hashtable->find(dat_vec[i].unsigned_val());
00322 if (strcmp(str,a_str) > 0) temp[i] = true;
00323 }
00324 }
00325 }
00326 else if (col_struct.type() == 'F') {
00327 for (unsigned i=0; i<ne; i++) {
00328 if (dat_vec[i].double_val()>a.dat_vec[i].double_val()) temp[i]= true;
00329 }
00330 }
00331 return temp;
00332 }
|
|
|
Definition at line 273 of file field.cpp.
00273 {return !(*this < a);}
|
|
|
Definition at line 76 of file field.h.
00076 {return dat_vec[i];}
|
|
||||||||||||
|
Definition at line 1001 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), matvec::HashTable::find(), hashtable, matvec::DataNode::missing, ne, and matvec::FieldStruct::type(). Referenced by display(), matvec::operator<<(), and save().
01002 {
01003 stream << "\n";
01004 unsigned i,k;
01005 stream.precision(6);
01006 unsigned W = 6+6;
01007 char ch;
01008
01009 if (col_struct.type()=='S') {
01010 for (k=23,i=0; i<ne; i++) {
01011 if (ic && i>=k) {
01012 k += 23;
01013 stream << " more ... [q for quit] ";
01014 std::cin.get(ch);
01015 std::cin.seekg(0L,std::ios::beg);
01016 if (ch == 'q') break;
01017 }
01018 if (dat_vec[i].missing) {
01019 stream << " " << std::setw(W) << ".";
01020 }
01021 else {
01022 stream << " " << std::setw(W)
01023 << (char *)hashtable->find(dat_vec[i].unsigned_val());
01024 }
01025 stream << "\n";
01026 }
01027 }
01028 else {
01029 for (k=23,i=0; i<ne; i++) {
01030 if (ic && i>=k) {
01031 k += 23;
01032 stream << " more ... [q for quit] ";
01033 std::cin.get(ch);
01034 std::cin.seekg(0L,std::ios::beg);
01035 if (ch == 'q') break;
01036 }
01037 if (dat_vec[i].missing) {
01038 stream << " " << std::setw(W) << ".";
01039 }
01040 else {
01041 stream << " " << std::setw(W) << dat_vec[i].double_val();
01042 }
01043 stream << "\n";
01044 }
01045 }
01046 }
|
|
|
Definition at line 950 of file field.cpp. References col_struct, matvec::FieldStruct::count_miss(), dat_vec, matvec::DataNode::missing, and ne.
00951 {
00952 if (k >= ne) throw exception("Field::pretend_missing(): out of range");
00953 dat_vec[k].missing++;
00954 col_struct.count_miss(1);
00955 }
|
|
|
Definition at line 868 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), matvec::DataNode::missing, ne, and matvec::FieldStruct::type().
00869 {
00870 DataNode retval;
00871 retval.missing = 1;
00872 if (col_struct.type() != 'S') {
00873 unsigned i,k=0;
00874 double x;
00875 for (x=1.0,k=0,i=0; i<ne; i++) {
00876 if (!dat_vec[i].missing) {
00877 k++;
00878 x *= dat_vec[i].double_val();
00879 }
00880 }
00881 if (k) {
00882 retval.missing = 0;
00883 retval.double_val(x);
00884 }
00885 }
00886 return retval;
00887 }
|
|
|
Definition at line 957 of file field.cpp. References col_struct, matvec::FieldStruct::count_miss(), dat_vec, matvec::DataNode::missing, ne, and matvec::warning().
00958 {
00959 if (k >= ne) throw exception("Field::recover_missing(): out of range");
00960 if (dat_vec[k].missing <= 0) {
00961 warning("recover::recover_missing(): can't recover from missing");
00962 }
00963 else {
00964 dat_vec[k].missing--;
00965 col_struct.count_miss(-1);
00966 }
00967 }
|
|
|
Definition at line 46 of file field.cpp. References dat_vec, hashtable, and ne. Referenced by ~Field().
|
|
||||||||||||
|
Definition at line 94 of file field.cpp.
|
|
|
Definition at line 75 of file field.cpp. References dat_vec, hashtable, and ne. Referenced by copyfrom(), matvec::Data::input_datasheet(), matvec::Data::release_datasheet(), and matvec::Data::resize().
00076 {
00077 if (ne == n) return *this;
00078 if (dat_vec) {
00079 delete [] dat_vec;
00080 dat_vec=0;
00081 }
00082 ne = n;
00083 if (ne>0){
00084 dat_vec = new DataNode [ne];
00085 }
00086 else {
00087 dat_vec = 0;
00088 }
00089
00090 if (hashtable) {delete hashtable; hashtable = 0;}
00091 return *this;
00092 }
|
|
||||||||||||
|
Definition at line 1048 of file field.cpp. References out_to_stream().
01049 {
01050 std::ofstream ofs;
01051 ofs.open(fname.c_str(),(OpenModeType)io_mode);
01052 if (!ofs) throw exception("Field::save(): cannot open file");
01053 this->out_to_stream(ofs,0);
01054 ofs.close();
01055 }
|
|
|
Definition at line 943 of file field.cpp. References col_struct, matvec::FieldStruct::count_miss(), dat_vec, matvec::DataNode::missing, and ne.
00944 {
00945 if (k >= ne) throw exception("Field::set_missing(): out of range");
00946 if (!dat_vec[k].missing) col_struct.count_miss(1);
00947 dat_vec[k].missing = 1;
00948 }
|
|
|
Definition at line 159 of file field.h. References ne. Referenced by matvec::Data::newcol().
00159 {return ne;}
|
|
|
Definition at line 995 of file field.cpp. References matvec::compare_DataNode(), dat_vec, and ne.
00996 {
00997 qsort((DataNode*)dat_vec,ne,sizeof(DataNode),compare_DataNode);
00998 return *this;
00999 }
|
|
||||||||||||
|
Definition at line 723 of file field.cpp. References col_struct, dat_vec, Field(), matvec::HashTable::find(), hashtable, matvec::HashTable::insert(), ne, matvec::FieldStruct::nlevel(), matvec::HashTable::resize(), matvec::HashTable::size(), matvec::FieldStruct::type(), matvec::DataNode::unsigned_val(), and matvec::warning().
00724 {
00725 if (ne == 0) return Field();
00726 int newne = i2 - i1 + 1;
00727 if ( newne >ne || i2 > ne) {
00728 warning("Field::s(), subscript out of range");
00729 return Field();
00730 }
00731 unsigned id,i,k;
00732 HashTable *tmp_hashtable = 0;
00733 FieldStruct tmp_struct = col_struct;
00734
00735 DataNode *temp;
00736 if(newne>0){
00737 temp = new DataNode [newne];
00738 }
00739 else {
00740 temp = 0;
00741 }
00742 if (col_struct.type()=='S') {
00743 tmp_hashtable = new HashTable;
00744 tmp_hashtable->resize(col_struct.nlevel());
00745 for (i=i1-1; i<i2; i++) {
00746 tmp_hashtable->insert((char *)hashtable->find(i+1));
00747 }
00748 id = tmp_hashtable->size();
00749 tmp_struct.nlevel(id);
00750 tmp_hashtable->resize(id);
00751 for (k=0,i=i1-1; i<i2; i++) {
00752 id = tmp_hashtable->insert((char *)hashtable->find(i+1));
00753 temp[k++].unsigned_val(id);
00754 }
00755 }
00756 else {
00757 memcpy(temp,&dat_vec[i1-1],sizeof(DataNode)*newne);
00758 }
00759 return Field(newne,temp,tmp_struct,tmp_hashtable);
00760 }
|
|
|
Definition at line 824 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), matvec::DataNode::missing, ne, and matvec::FieldStruct::type(). Referenced by matvec::doubleMatrix::norm().
00825 {
00826 DataNode retval;
00827 retval.missing = 1;
00828
00829 if (col_struct.type() != 'S') {
00830 unsigned i,k;
00831 double x;
00832 for (x=0.0, k=0,i=0; i<ne; i++) {
00833 if (!dat_vec[i].missing) {
00834 k++;
00835 x += dat_vec[i].double_val();
00836 }
00837 }
00838 if (k) {
00839 retval.missing = 0;
00840 retval.double_val(x);
00841 }
00842 }
00843 return retval;
00844 }
|
|
|
Definition at line 846 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), matvec::DataNode::missing, ne, and matvec::FieldStruct::type().
00847 {
00848 DataNode retval;
00849 retval.missing = 1;
00850 if (col_struct.type() !='S') {
00851 unsigned i,k;
00852 double y,x;
00853 for (x=0.0, k=0,i=0; i<ne; i++) {
00854 if (!dat_vec[i].missing) {
00855 k++;
00856 y = dat_vec[i].double_val();
00857 x += y*y;
00858 }
00859 }
00860 if (k) {
00861 retval.missing = 0;
00862 retval.double_val(x);
00863 }
00864 }
00865 return retval;
00866 }
|
|
|
Definition at line 173 of file field.h. References matvec::FieldStruct::type().
00173 {return col_struct.type();}
|
|
|
Definition at line 167 of file field.h. References matvec::FieldStruct::type(). Referenced by matvec::Data::input(), matvec::Population::input_markerData(), matvec::Data::mat(), matvec::Data::newcol(), matvec::Model::prepare_data(), matvec::Data::print(), matvec::Model::re_hash_data(), and matvec::Data::stat().
00167 {col_struct.type(c);}
|
|
|
Definition at line 931 of file field.cpp. References col_struct, dat_vec, matvec::DataNode::double_val(), matvec::DataNode::missing, ne, matvec::FieldStruct::type(), and matvec::warning(). Referenced by matvec::Model::prepare_data(), and matvec::Data::value_for_missing().
00932 {
00933 if (col_struct.type() == 'F') {
00934 for (unsigned i=0; i<ne; i++) {
00935 if (dat_vec[i].missing) dat_vec[i].double_val(vm);
00936 }
00937 }
00938 else {
00939 warning("Field::value_for_missing(): won't work for string column");
00940 }
00941 }
|
|
|
Definition at line 207 of file field.h. References matvec::DataNode::double_val(), and ne.
|
|
|
Definition at line 774 of file field.cpp.
00774 {return a.map(std::fabs);}
|
|
|
Definition at line 765 of file field.cpp.
00765 {return a.map(std::acos);}
|
|
|
Definition at line 763 of file field.cpp.
00763 {return a.map(std::asin);}
|
|
|
Definition at line 767 of file field.cpp.
00767 {return a.map(std::atan);}
|
|
|
Definition at line 768 of file field.cpp.
00768 {return a.map(std::ceil);}
|
|
|
Definition at line 764 of file field.cpp.
00764 {return a.map(std::cos);}
|
|
|
|
|
|
Definition at line 775 of file field.cpp.
00775 {return a.map(::erf);}
|
|
|
Definition at line 776 of file field.cpp.
00776 {return a.map(::erfc);}
|
|
|
Definition at line 772 of file field.cpp.
00772 {return a.map(std::exp);}
|
|
|
Definition at line 769 of file field.cpp.
00769 {return a.map(std::floor);}
|
|
|
Definition at line 770 of file field.cpp.
00770 {return a.map(std::log);}
|
|
|
Definition at line 771 of file field.cpp.
00771 {return a.map(std::log10);}
|
|
||||||||||||
|
Definition at line 632 of file field.cpp.
00633 {
00634 if (B.col_struct.type()=='S') {
00635 warning("s * Field: failed for string column");
00636 return Field();
00637 }
00638 DataNode *temp;
00639 if(B.ne>0){
00640 temp = new DataNode [B.ne];
00641 }
00642 else {
00643 temp = 0;
00644 }
00645 for (unsigned i=0; i<B.ne; i++) {
00646 if (B.dat_vec[i].missing) {
00647 temp[i].missing = 1;
00648 }
00649 else {
00650 temp[i].double_val( s * B.dat_vec[i].double_val());
00651 }
00652 }
00653 return Field(B.ne,temp,B.col_struct);
00654 }
|
|
||||||||||||
|
Definition at line 536 of file field.cpp.
00537 {
00538 if (A.col_struct.type()=='S') {
00539 warning("Field * s: failed for string column");
00540 return Field();
00541 }
00542 DataNode *temp;
00543 if(A.ne>0){
00544 temp = new DataNode [A.ne];
00545 }
00546 else {
00547 temp = 0;
00548 }
00549 for (unsigned i=0; i<A.ne; i++) {
00550 if (A.dat_vec[i].missing) {
00551 temp[i].missing = 1;
00552 }
00553 else {
00554 temp[i].double_val(A.dat_vec[i].double_val() * s);
00555 }
00556 }
00557 return Field(A.ne,temp,A.col_struct);
00558 }
|
|
||||||||||||
|
Definition at line 428 of file field.cpp.
00429 {
00430 unsigned n = A.ne;
00431 if (n != B.ne) {
00432 warning("Col * Col: size not conformable");
00433 return Field();
00434 }
00435 if (A.col_struct.type()=='S' || B.col_struct.type()=='S') {
00436 warning("Col * Field: failed for string column");
00437 return Field();
00438 }
00439 DataNode *temp;
00440 if(n>0){
00441 temp = new DataNode [n];
00442 }
00443 else {
00444 temp = 0;
00445 }
00446 for (unsigned i=0; i<n; i++) {
00447 if (A.dat_vec[i].missing || B.dat_vec[i].missing) {
00448 temp[i].missing = 1;
00449 }
00450 else {
00451 temp[i].double_val(A.dat_vec[i].double_val()*
00452 B.dat_vec[i].double_val());
00453 }
00454 }
00455 return Field(n,temp,A.col_struct);
00456 }
|
|
||||||||||||
|
Definition at line 336 of file field.cpp.
00336 {return !(b==a); }
|
|
||||||||||||
|
Definition at line 335 of file field.cpp.
00335 {return !(a==b);}
|
|
||||||||||||
|
Definition at line 584 of file field.cpp.
00585 {
00586 if (B.col_struct.type()=='S') {
00587 warning("s + Field: failed for string column");
00588 return Field();
00589 }
00590 DataNode *temp;
00591 if(B.ne>0){
00592 temp = new DataNode [B.ne];
00593 }
00594 else {
00595 temp = 0;
00596 }
00597 for (unsigned i=0; i<B.ne; i++) {
00598 if (B.dat_vec[i].missing) {
00599 temp[i].missing = 1;
00600 }
00601 else {
00602 temp[i].double_val(s + B.dat_vec[i].double_val());
00603 }
00604 }
00605 return Field(B.ne,temp,B.col_struct);
00606 }
|
|
||||||||||||
|
Definition at line 488 of file field.cpp.
00489 {
00490 if (A.col_struct.type()=='S') {
00491 warning("Field + s: failed for string column");
00492 return Field();
00493 }
00494 DataNode *temp;
00495 if(A.ne>0){
00496 temp = new DataNode [A.ne];
00497 }
00498 else {
00499 temp = 0;
00500 }
00501 for (unsigned i=0; i<A.ne; i++) {
00502 if (A.dat_vec[i].missing) {
00503 temp[i].missing = 1;
00504 }
00505 else {
00506 temp[i].double_val(A.dat_vec[i].double_val() + s);
00507 }
00508 }
00509 return Field(A.ne,temp,A.col_struct);
00510 }
|
|
||||||||||||
|
Definition at line 368 of file field.cpp.
00369 {
00370 unsigned n = A.ne;
00371 if (n != B.ne) {
00372 warning("Col + Col: size not conformable");
00373 return Field();
00374 }
00375 if (A.col_struct.type()=='S' || B.col_struct.type()=='S') {
00376 warning("Col + Col: failed for string column");
00377 return Field();
00378 }
00379 DataNode *temp;
00380 if(n>0){
00381 temp = new DataNode [n];
00382 }
00383 else {
00384 temp = 0;
00385 }
00386 for (unsigned i=0; i<n; i++) {
00387 if (A.dat_vec[i].missing || B.dat_vec[i].missing) {
00388 temp[i].missing = 1;
00389 }
00390 else {
00391 temp[i].double_val(A.dat_vec[i].double_val() +
00392 B.dat_vec[i].double_val());
00393 }
00394 }
00395 return Field(n,temp,A.col_struct);
00396 }
|
|
||||||||||||
|
Definition at line 608 of file field.cpp.
00609 {
00610 if (B.col_struct.type()=='S') {
00611 warning("s - Field: failed for string column");
00612 return Field();
00613 }
00614 DataNode *temp;
00615 if(B.ne>0){
00616 temp = new DataNode [B.ne];
00617 }
00618 else {
00619 temp = 0;
00620 }
00621 for (unsigned i=0; i<B.ne; i++) {
00622 if (B.dat_vec[i].missing) {
00623 temp[i].missing = 1;
00624 }
00625 else {
00626 temp[i].double_val(s - B.dat_vec[i].double_val());
00627 }
00628 }
00629 return Field(B.ne,temp,B.col_struct);
00630 }
|
|
||||||||||||
|
Definition at line 512 of file field.cpp.
00513 {
00514 if (A.col_struct.type()=='S') {
00515 warning("Field - s: failed for string column");
00516 return Field();
00517 }
00518 DataNode *temp;
00519 if(A.ne>0){
00520 temp = new DataNode [A.ne];
00521 }
00522 else {
00523 temp = 0;
00524 }
00525 for (unsigned i=0; i<A.ne; i++) {
00526 if (A.dat_vec[i].missing) {
00527 temp[i].missing = 1;
00528 }
00529 else {
00530 temp[i].double_val(A.dat_vec[i].double_val() - s);
00531 }
00532 }
00533 return Field(A.ne,temp,A.col_struct);
00534 }
|
|
||||||||||||
|
Definition at line 398 of file field.cpp.
00399 {
00400 unsigned n = A.ne;
00401 if (n != B.ne) {
00402 warning("Col - Col: size not conformable");
00403 return Field();
00404 }
00405 if (A.col_struct.type()=='S' || B.col_struct.type()=='S') {
00406 warning("Col - Field: failed for string column");
00407 return Field();
00408 }
00409 DataNode *temp;
00410 if(n>0){
00411 temp = new DataNode [n];
00412 }
00413 else {
00414 temp = 0;
00415 }
00416 for (unsigned i=0; i<n; i++) {
00417 if (A.dat_vec[i].missing || B.dat_vec[i].missing) {
00418 temp[i].missing = 1;
00419 }
00420 else {
00421 temp[i].double_val(A.dat_vec[i].double_val()-
00422 B.dat_vec[i].double_val());
00423 }
00424 }
00425 return Field(n,temp,A.col_struct);
00426 }
|
|
||||||||||||
|
Definition at line 655 of file field.cpp.
00656 {
00657 if (B.col_struct.type()=='S') {
00658 warning("s / Col: failed for string column");
00659 return Field();
00660 }
00661 DataNode *temp;
00662 if(B.ne>0){
00663 temp = new DataNode [B.ne];
00664 }
00665 else {
00666 temp = 0;
00667 }
00668 for (unsigned i=0; i<B.ne; i++) {
00669 if (B.dat_vec[i].missing) {
00670 temp[i].missing = 1;
00671 }
00672 else {
00673 temp[i].double_val(s / B.dat_vec[i].double_val());
00674 }
00675 }
00676 return Field(B.ne,temp,B.col_struct);
00677 }
|
|
||||||||||||
|
Definition at line 560 of file field.cpp.
00561 {
00562 if (A.col_struct.type()=='S') {
00563 warning("Field / s: failed for string column");
00564 return Field();
00565 }
00566 DataNode *temp;
00567 if(A.ne>0){
00568 temp = new DataNode [A.ne];
00569 }
00570 else {
00571 temp = 0;
00572 }
00573 for (unsigned i=0; i<A.ne; i++) {
00574 if (A.dat_vec[i].missing) {
00575 temp[i].missing = 1;
00576 }
00577 else {
00578 temp[i].double_val(A.dat_vec[i].double_val() / s);
00579 }
00580 }
00581 return Field(A.ne,temp,A.col_struct);
00582 }
|
|
||||||||||||
|
Definition at line 458 of file field.cpp.
00459 {
00460 unsigned n = A.ne;
00461 if (n != B.ne) {
00462 warning("Col / Col: size not conformable");
00463 return Field();
00464 }
00465 if (A.col_struct.type()=='S' || B.col_struct.type()=='S') {
00466 warning("Field / Field: failed for string column");
00467 return Field();
00468 }
00469 DataNode *temp;
00470 if(n>0){
00471 temp = new DataNode [n];
00472 }
00473 else {
00474 temp = 0;
00475 }
00476 for (unsigned i=0; i<n; i++) {
00477 if (A.dat_vec[i].missing || B.dat_vec[i].missing){
00478 temp[i].missing = 1;
00479 }
00480 else {
00481 temp[i].double_val(A.dat_vec[i].double_val()/
00482 B.dat_vec[i].double_val());
00483 }
00484 }
00485 return Field(n,temp,A.col_struct);
00486 }
|
|
||||||||||||
|
Definition at line 356 of file field.cpp.
00357 {
00358 unsigned n = A.ne;
00359 Vector<bool> temp(n);
00360
00361 if (A.col_struct.type() == 'S') return temp;
00362 for (unsigned i=0; i<n; i++) {
00363 if (x < A.dat_vec[i].double_val()) temp[i] = true;
00364 }
00365 return temp;
00366 }
|
|
||||||||||||
|
Definition at line 344 of file field.cpp.
00345 {
00346 unsigned n = A.ne;
00347 Vector<bool> temp(n);
00348
00349 if (A.col_struct.type() == 'S') return temp;
00350 for (unsigned i=0; i<n; i++) {
00351 if (A.dat_vec[i].double_val() < x) temp[i] = true;
00352 }
00353 return temp;
00354 }
|
|
||||||||||||
|
Definition at line 1063 of file field.cpp.
01064 {
01065 V.out_to_stream(stream,1);
01066 return stream;
01067 }
|
|
||||||||||||
|
|
|
||||||||||||
|
Definition at line 339 of file field.cpp.
00339 {return !(b<a);}
|
|
||||||||||||
|
Definition at line 334 of file field.cpp.
00334 {return (b==a);}
|
|
||||||||||||
|
Definition at line 338 of file field.cpp.
00338 {return (b<a);}
|
|
||||||||||||
|
Definition at line 337 of file field.cpp.
00337 {return (b<a);}
|
|
||||||||||||
|
Definition at line 342 of file field.cpp.
00342 {return !(a<b);}
|
|
||||||||||||
|
Definition at line 341 of file field.cpp.
00341 {return !(a<b);}
|
|
|
Definition at line 762 of file field.cpp.
00762 {return a.map(std::sin);}
|
|
|
Definition at line 773 of file field.cpp.
00773 {return a.map(std::sqrt);}
|
|
|
Definition at line 766 of file field.cpp.
00766 {return a.map(std::tan);}
|
|
|
Definition at line 51 of file field.h. Referenced by copyfrom(), covariance(), Field(), matvec::Population::input_data(), matvec::Population::input_markerData(), map(), max(), mean(), min(), matvec::Data::newcol(), matvec::operator *(), operator *=(), matvec::operator+(), operator+=(), matvec::operator-(), operator-=(), matvec::operator/(), operator/=(), matvec::operator<(), operator<(), operator==(), operator>(), out_to_stream(), pretend_missing(), product(), recover_missing(), set_missing(), sub(), sum(), sumsq(), and value_for_missing(). |
|
|
Definition at line 45 of file field.h. Referenced by matvec::Data::col(), copyfrom(), covariance(), Field(), map(), matvec::Data::mat(), max(), mean(), min(), matvec::operator *(), operator *=(), matvec::operator+(), operator+=(), matvec::operator-(), operator-=(), matvec::operator/(), operator/=(), matvec::operator<(), operator<(), operator==(), operator>(), out_to_stream(), pretend_missing(), matvec::Data::print(), product(), matvec::Data::rawcol(), recover_missing(), release(), resize(), set_missing(), sort(), sub(), sum(), sumsq(), and value_for_missing(). |
|
|
Definition at line 46 of file field.h. Referenced by copyfrom(), Field(), operator<(), matvec::Data::operator=(), operator==(), operator>(), out_to_stream(), release(), resize(), and sub(). |
|
|
Definition at line 44 of file field.h. Referenced by mean(). |
|
|
Definition at line 43 of file field.h. Referenced by copyfrom(), covariance(), elem(), Field(), len(), map(), max(), mean(), min(), ones(), matvec::operator *(), operator *=(), operator()(), matvec::operator+(), operator+=(), matvec::operator-(), operator-=(), matvec::operator/(), operator/=(), matvec::operator<(), operator<(), operator==(), operator>(), out_to_stream(), pretend_missing(), product(), recover_missing(), release(), resize(), set_missing(), size(), sort(), sub(), sum(), sumsq(), value_for_missing(), and zeros(). |
1.2.16