void NumericToken::GetFloating(FPF &floatValue, int radix, char **ptr) { FPF fradix; fradix = radix; while (**ptr && Radix36(**ptr) < radix) { floatValue *= fradix; FPF temp; temp = Radix36(*(*ptr)++); floatValue += temp; } if (**ptr == '.') { (*ptr)++; GetFraction(radix, ptr, floatValue); intValue = 0; } if (**ptr == 'e' || **ptr == 'E' || **ptr == 'p' || **ptr== 'P') { (*ptr)++; int intValue = GetExponent(ptr); /* floating point too large goes to infinity... */ if (radix == 2) { floatValue.SetExp(floatValue.GetExp() + intValue); } else { floatValue.MultiplyPowTen(intValue); } } }
float LJStringUtil::StrToFloat(const string& str) { int n = str.size(); if(n == 0 || (str[0] == '.' && n == 1)) throw "Invalid Value"; bool neg = false; if(str[0] == '-') { neg = true; } string::size_type m = str.find_first_of('.'); if(m == string::npos) { return (float)GetWhole(str, 0, n-1); } if(neg) return -(GetWhole(str, 0, m-1) + GetFraction(str, m+1, n-1)); else return GetWhole(str, 0, m-1) + GetFraction(str, m+1, n-1); }
void scene::LightRight() { float fraction = GetFraction()*5; float dis[] = {this->eye[0] - this->vat[0], this->eye[1] - this->vat[1], this->eye[2] - this->vat[2]}; float normal[] = {dis[1]*this->vup[2] - dis[2]*this->vup[1], dis[2]*this->vup[0] - dis[0]*this->vup[2], dis[0]*this->vup[1] - dis[1]*this->vup[0]}; this->lights[0].x -= normal[0]*fraction; this->lights[0].y -= normal[1]*fraction; this->lights[0].z -= normal[2]*fraction; }
const std::string Clusterer::GetInfo() const { std::ostringstream os; oid_t cluster_itr; oid_t cluster_count; cluster_count = GetClusterCount(); for (cluster_itr = 0; cluster_itr < cluster_count; cluster_itr++) os << cluster_itr << " : " << GetFraction(cluster_itr) << " :: " << GetCluster(cluster_itr); return os.str(); }
bool CItem::DrawSubitem(int subitem, CDC *pdc, CRect rc, UINT state, int *width, int *focusLeft) const { if (subitem == COL_NAME) { return CTreeListItem::DrawSubitem(subitem, pdc, rc, state, width, focusLeft); } if (subitem != COL_SUBTREEPERCENTAGE) return false; bool showReadJobs = MustShowReadJobs(); if (showReadJobs && !GetOptions()->IsPacmanAnimation()) return false; if (showReadJobs && IsDone()) return false; if (width != NULL) { *width = GetSubtreePercentageWidth(); return true; } DrawSelection(GetTreeListControl(), pdc, rc, state); if (showReadJobs) { rc.DeflateRect(sizeDeflatePacman); DrawPacman(pdc, rc, GetTreeListControl()->GetItemSelectionBackgroundColor(this)); } else { rc.DeflateRect(2, 5); for (int i=0; i < GetIndent(); i++) rc.left += rc.Width() / 10; DrawPercentage(pdc, rc, GetFraction(), GetPercentageColor()); } return true; }
column_map_type Clusterer::GetPartitioning(oid_t tile_count) const { PL_ASSERT(tile_count >= 1); PL_ASSERT(tile_count <= sample_column_count_); std::map<double, oid_t> frequencies; oid_t cluster_itr = START_OID; oid_t cluster_count; cluster_count = GetClusterCount(); for (cluster_itr = 0; cluster_itr < cluster_count; cluster_itr++) { auto pair = std::make_pair(GetFraction(cluster_itr), cluster_itr); frequencies.insert(pair); } std::map<oid_t, oid_t> column_to_tile_map; oid_t tile_itr = START_OID; oid_t remaining_column_count = sample_column_count_; // look for most significant cluster for (auto entry = frequencies.rbegin(); entry != frequencies.rend(); ++entry) { LOG_TRACE(" %u :: %.3lf", entry->second, entry->first); // first, check if remaining columns less than tile count if (remaining_column_count <= tile_count) { oid_t column_itr; for (column_itr = 0; column_itr < sample_column_count_; column_itr++) { if (column_to_tile_map.count(column_itr) == 0) { column_to_tile_map[column_itr] = tile_itr; tile_itr++; } } } // otherwise, get its partitioning auto config = means_[entry->second]; auto config_tile = config.GetEnabledColumns(); for (auto column : config_tile) { if (column_to_tile_map.count(column) == 0) { column_to_tile_map[column] = tile_itr; remaining_column_count--; } } // check tile itr tile_itr++; if (tile_itr >= tile_count) tile_itr--; } // check if all columns are present in partitioning PL_ASSERT(column_to_tile_map.size() == sample_column_count_); // build partitioning column_map_type partitioning; std::map<oid_t, oid_t> tile_column_count_map; for (auto entry : column_to_tile_map) { auto column_id = entry.first; auto tile_id = entry.second; // figure out how many columns in given tile auto exists = tile_column_count_map.find(tile_id); if (exists == tile_column_count_map.end()) tile_column_count_map[tile_id] = 0; else tile_column_count_map[tile_id] += 1; // create an entry for the partitioning map auto partition_entry = std::make_pair(tile_id, tile_column_count_map[tile_id]); partitioning[column_id] = partition_entry; } return partitioning; }
int CItem::CompareSibling(const CTreeListItem *tlib, int subitem) const { CItem *other = (CItem *)tlib; int r=0; switch (subitem) { case COL_NAME: if (GetType() == IT_DRIVE) { ASSERT(other->GetType() == IT_DRIVE); r = signum(GetPath().CompareNoCase(other->GetPath())); } else { r = signum(m_name.CompareNoCase(other->m_name)); } break; case COL_SUBTREEPERCENTAGE: if (MustShowReadJobs()) r = signum(m_readJobs - other->m_readJobs); else r = signum(GetFraction() - other->GetFraction()); break; case COL_PERCENTAGE: r = signum(GetFraction() - other->GetFraction()); break; case COL_SUBTREETOTAL: r = signum(GetSize() - other->GetSize()); break; case COL_ITEMS: r = signum(GetItemsCount() - other->GetItemsCount()); break; case COL_FILES: r = signum(GetFilesCount() - other->GetFilesCount()); break; case COL_SUBDIRS: r = signum(GetSubdirsCount() - other->GetSubdirsCount()); break; case COL_LASTCHANGE: { if (m_lastChange < other->m_lastChange) return -1; else if (m_lastChange == other->m_lastChange) return 0; else return 1; } break; case COL_ATTRIBUTES: r = signum(GetSortAttributes() - other->GetSortAttributes()); break; default: ASSERT(false); break; } return r; }
CString CItem::GetText(int subitem) const { CString s; switch (subitem) { case COL_NAME: s = m_name; break; case COL_SUBTREEPERCENTAGE: if (IsDone()) { ASSERT(m_readJobs == 0); //s = "ok"; } else { if (m_readJobs == 1) s.LoadString(IDS_ONEREADJOB); else s.FormatMessage(IDS_sREADJOBS, FormatCount(m_readJobs)); } break; case COL_PERCENTAGE: if (GetOptions()->IsShowTimeSpent() && MustShowReadJobs() || IsRootItem()) { s.Format(_T("[%s s]"), FormatMilliseconds(GetTicksWorked())); } else { s.Format(_T("%s%%"), FormatDouble(GetFraction() * 100)); } break; case COL_SUBTREETOTAL: s = FormatBytes(GetSize()); break; case COL_ITEMS: if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN) s = FormatCount(GetItemsCount()); break; case COL_FILES: if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN) s = FormatCount(GetFilesCount()); break; case COL_SUBDIRS: if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN) s = FormatCount(GetSubdirsCount()); break; case COL_LASTCHANGE: if (GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN) { s = FormatFileTime(m_lastChange); } break; case COL_ATTRIBUTES: if (GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN && GetType() != IT_MYCOMPUTER && GetType() != IT_FILESFOLDER) { s = FormatAttributes(GetAttributes()); } break; default: ASSERT(0); break; } return s; }