Go to the documentation of this file.00001
00002
00003 #include "SparseEntry.h"
00004
00005 bool SparseEntry::hasOnlyZeroUI() {
00006
00007 for (unsigned int i = 0; i < uniqueIndex.size(); i++) {
00008 if (fabs(uniqueIndex[i].value) > 0.000001)
00009 return false;
00010 }
00011 return true;
00012 }
00013
00014 bool SparseEntry::operator==(const SparseEntry &rhs) const {
00015
00016 vector<UniqueIndex> a_ui = this->uniqueIndex;
00017 vector<UniqueIndex> b_ui = rhs.uniqueIndex;
00018
00019 for (unsigned int i = 0; i < a_ui.size(); i++) {
00020 if (a_ui[i].index != b_ui[i].index)
00021 return false;
00022 }
00023 return true;
00024 }
00025
00026 bool SparseEntry::operator<(const SparseEntry &rhs) const {
00027
00028 vector<UniqueIndex> a_ui = this->uniqueIndex;
00029 vector<UniqueIndex> b_ui = rhs.uniqueIndex;
00030
00031 for (unsigned int i = 0; i < a_ui.size(); i++) {
00032 if (a_ui[i].index < b_ui[i].index)
00033 return true;
00034 if (a_ui[i].index > b_ui[i].index)
00035 return false;
00036 }
00037 return false;
00038 }
00039
00040 std::ostream& SparseEntry::write(std::ostream& out) {
00041 out << "Unique Index: " << endl;
00042 for (unsigned int i = 0; i < uniqueIndex.size(); i++) {
00043 out << uniqueIndex[i].index << "=" << uniqueIndex[i].value << " ";
00044 }
00045 out << endl;
00046 return out;
00047 }
00048