int AbstractTableView::scaleFromUint64ToScrollBarRange(dsint value) { if(mScrollBarAttributes.is64 == true) { dsint wValue = ((dsint)value) >> mScrollBarAttributes.rightShiftCount; dsint wValueMax = ((dsint)getRowCount() - 1) >> mScrollBarAttributes.rightShiftCount; if(value == ((dsint)getRowCount() - 1)) return (int)(verticalScrollBar()->maximum()); else return (int)((dsint)((dsint)verticalScrollBar()->maximum() * (dsint)wValue) / (dsint)wValueMax); }
// Returns the index of the new column void Tableau::addSlackColumn() { m_slackCount++; const int c = getSlackColumn(m_slackCount); if(getWidth() == m_table[0].m_a.size()) { for(int row = 0; row < getRowCount(); row++) { m_table[row].m_a.add(c,0); } } else { for(int row = 0; row < getRowCount(); row++) { m_table[row].m_a[c] = 0; } } }
void applyTanh() { for (int rowIndex = 0; rowIndex < getRowCount(); ++rowIndex) { for (int columnIndex = 0; columnIndex < getColumnCount(); ++columnIndex) { data[rowIndex][columnIndex] = tanh(data[rowIndex][columnIndex]); } } }
Variant HHVM_FUNCTION(mysql_num_rows, const Resource& result) { auto res = php_mysql_extract_result(result); if (res) { return res->getRowCount(); } return false; }
void applyScale(float scale) { for (int rowIndex = 0; rowIndex < getRowCount(); ++rowIndex) { for (int columnIndex = 0; columnIndex < getColumnCount(); ++columnIndex) { data[rowIndex][columnIndex] *= scale; } } }
CallerAliasDB::CallerAliasDB( const UtlString& name ) : mDatabaseName( name ) , mTableLoaded ( true ) { // Access the shared table databse SIPDBManager* pSIPDBManager = SIPDBManager::getInstance(); mpFastDB = pSIPDBManager->getDatabase(name); // If we are the first process to attach // then we need to load the DB int users = pSIPDBManager->getNumDatabaseProcesses(name); OsSysLog::add(FAC_SUPERVISOR, PRI_DEBUG, "CallerAliasDB::_ users = %d, mTableLoaded = %d", users, mTableLoaded); if ( users == 1 || ( users > 1 && mTableLoaded == false ) ) { OsSysLog::add(FAC_DB, PRI_DEBUG, "CallerAliasDB::_ about to load"); mTableLoaded = false; // Load the file implicitly if (this->load() == OS_SUCCESS) { mTableLoaded = true; OsSysLog::add(FAC_DB, PRI_DEBUG, "CallerAliasDB::_ table successfully loaded"); } } OsSysLog::add(FAC_SUPERVISOR, PRI_DEBUG, "CallerAliasDB::_ rows in table = %d", getRowCount()); }
bool CMatrix::checkSymmetric() const{ UINT Col = getColCount(), Row = getRowCount(); bool flag = true; if (Col == Row) { UINT i = 0, j; while ((i < Row) && flag) { j = i + 1; while (j < Col) { if ((*this)[i][j] != (*this)[j][i]){ flag = false; break; } j++; } // while (j < Col) i++; } // while ((i < Row) && flag) } else { flag = false; } return flag; }
Screen* ScreenMgr::getScreen(ResourceID id){ uint32_t row = GetRow(id); uint32_t col = GetCol(id); if ( row-1 >=0 && col-1 >=0 && row -1 < getRowCount() && col -1 < getColCount()){ return screens_[GetRow(id)-1][GetCol(id)-1]; }else return 0; }
ExecStreamResult LcsCountAggExecStream::execute( ExecStreamQuantum const &quantum) { if (pOutAccessor->hasPendingEOS() || pOutAccessor->getState() == EXECBUF_EOS) { return EXECRC_EOS; } ExecStreamResult rc = LcsRowScanExecStream::execute(quantum); if (rc != EXECRC_EOS) { return rc; } // Write out final row count. pOutAccessor->clear(); RecordNum nRows = getRowCount(); getProjOutputTupleData()[0].pData = reinterpret_cast<PConstBuffer>(&nRows); pOutputTupleAccessor->marshal( getProjOutputTupleData(), outputTupleBuffer.get()); pOutAccessor->provideBufferForConsumption( outputTupleBuffer.get(), outputTupleBuffer.get() + pOutputTupleAccessor->getCurrentByteCount()); pOutAccessor->markEOS(); return EXECRC_BUF_OVERFLOW; }
CMatrix CMatrix::operator * (const CMatrix &arg) { auto rows = getRowCount(), cols = arg.getColCount(), p = getColCount(), // = RowCount у второй матрицы p2 = arg.getRowCount(); /* избыточно, ввести обработчик */ if (p == p2) // ширина первой матрицы равна высоте второй? { CMatrix Res(rows, cols); for (auto i = 0; i < rows; i++) { for (auto j = 0; j < cols; j++) { for (auto k = 0; k < p; k++) { Res[i][j] += (*this)[i][k] * arg[k][j]; } } } return Res; } else // не равна { return CMatrix(rows, cols); // возвращаем нулевую матрицу } }
QVector<TextField*> SyntaxHighlighter::getRow(unsigned int rowIdx) { assert(rowIdx < getRowCount()); Row *row = m_rows[rowIdx]; return row->m_fields; }
Matrix<_Type> invert() { int size = getRowCount(); if (size != getColCount()){ throw MatrixException("Invalid size"); return *this; } Matrix<_Type> result(size, size, 0); _Type det = determinant(); if (det == 0) { throw MatrixException("Determinant = 0"); return *this; } _Type temp; bool _invert = false; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { temp = _invert ? 0 : 1; temp = minor(i, j); temp /= det; result.put(i, j, temp); _invert = !_invert; } } result = result.transposition(); return result; }
void ControlsTab::reSizeTo(RECT & rc) { TabBar::reSizeTo(rc); rc.left += marge; rc.top += marge; //-- We do those dirty things //-- because it's a "vertical" tab control if (_isVertical) { rc.right -= 40; rc.bottom -= 20; if (getRowCount() == 2) { rc.right -= 20; } } //-- end of dirty things rc.bottom -= 55; rc.right -= 20; (*_pWinVector)[_current]._dlg->reSizeTo(rc); (*_pWinVector)[_current]._dlg->redraw(); }
void applyDerivativeOfTanh() { for (int rowIndex = 0; rowIndex < getRowCount(); ++rowIndex) { for (int columnIndex = 0; columnIndex < getColumnCount(); ++columnIndex) { float v = tanh(data[rowIndex][columnIndex]); data[rowIndex][columnIndex] = 1 - v * v; } } }
TreePath FixedHeightTreeModelLayout::getPathClosestTo(const Pnt2f& Loc) const { //Determine the row UInt32 Row(osgMin<UInt32>(Loc.y()/getRowHeight(),getRowCount()-1)); //Get the Path for that row return getPathForRow(Row); }
void addBy(Matrix const& matrix) { for (int rowIndex = 0; rowIndex < getRowCount(); ++rowIndex) { for (int columnIndex = 0; columnIndex < getColumnCount(); ++columnIndex) { data[rowIndex][columnIndex] += matrix[rowIndex][columnIndex]; } } }
/** * @brief This method has been reimplemented. It repaints the table when the height changes. * * @param[in] event Resize event * * @return Nothing. */ void AbstractTableView::resizeEvent(QResizeEvent* event) { if(event->size().height() != event->oldSize().height()) { updateScrollBarRange(getRowCount()); mShouldReload = true; } QWidget::resizeEvent(event); }
bool SoapExecution::process() { if (lastOffset == 0) { LOG_DEBUG("process url = " << getUrl()->getUrl()); LOG_DEBUG("query: '" << getSql() << "'"); prepareQuery(); shared_ptr<Event> ev(new ExecutionStateChangeEvent(getId(),"CONNECTED")); fireEvent(ev); } auto source = getInPorts().at(0)->getResult(); uint64_t row; for (row = lastOffset; row < lastOffset + chunkSize; row++) { auto range = TableDataFactory::getInstance().range(source,row,chunkSize); xmlNodePtr result = inputTemplate.transform(range); string response = callServer(getUrl(),as_string(result)); auto rangeResult = outputTemplate.transform(response); if (!resultTable) { resultTable = TableDataFactory::getInstance().create("text",rangeResult->getColumns()); } for (uint64_t rrow = 0; rrow < rangeResult->getRowCount(); rrow++) { vector<string> rv; for (uint32_t rcol = 0; rcol < rangeResult->getColCount(); rcol++) { rv.push_back(rangeResult->getValue(rrow,rcol)); } resultTable->addRow(rv); } } shared_ptr<Event> rde(new ReceiveDataEvent(getId(),resultTable->getRowCount())); fireEvent(rde); if (row >= source->getRowCount()) { setResult("",resultTable); setState(QueryExecutionState::DONE); return true; } lastOffset = row; return false; }
template <class R> CMatrix<R> CMatrix<R>::getSubMatrix(int startRow, int rowCount, int startCol, int colCount) const { ASSERT((0 <= startRow) && (startRow + rowCount <= getRowCount())); ASSERT((0 <= startCol) && (startCol + colCount <= getColumnCount())); CMatrix<R> result = CMatrix<R>(colCount); for (int q = startRow; q < startRow + rowCount; q++) { result.addRow(rows[q]->getSubVector(startCol, colCount)); } return result; }
CMatrix CMatrix::flip(){ int Col = getColCount(), Row = getRowCount(); CMatrix Res(Col, Row); for (int i = 0; i < Col; i++) { for (int j = 0; j < Row; j++) { Res[i][j] = (*this)[j][i]; } } return Res; }
CMatrix CMatrix::operator * (const TYPE num){ UINT n = getRowCount(), m = getColCount(); CMatrix Res(n, m); for (UINT i = 0; i < n; i++) { for (UINT j = 0; j < m; j++) { Res[i][j] = (*this)[i][j] * num; } } return Res; }
/** * @brief This virtual method is called at the end of the vertSliderActionSlot(...) method. * It allows changing the table offset according to the action type, the old table offset * and delta between the old and the new table offset. * * @param[in] type Type of action (Refer to the QAbstractSlider::SliderAction enum) * @param[in] value Old table offset * @param[in] delta Scrollbar value delta compared to the previous state * * @return Return the value of the new table offset. */ dsint AbstractTableView::sliderMovedHook(int type, dsint value, dsint delta) { Q_UNUSED(type); dsint wValue = value + delta; dsint wMax = getRowCount() - getViewableRowsCount() + 1; // Bounding wValue = wValue > wMax ? wMax : wValue; wValue = wValue < 0 ? 0 : wValue; return wValue; }
CMatrix CMatrix::operator * (const TYPE num) { auto rows = getRowCount(), cols = getColCount(); CMatrix Res(rows, cols); for (auto i = 0; i < rows; i++) { for (auto j = 0; j < cols; j++) { Res[i][j] = (*this)[i][j] * num; } } return Res; }
void ExtendedTableData::init(vector<ColRef> colRefs) { assert(colRefs.size() > 0); this->colRefs = colRefs; setRowCount(colRefs[0].getTable()->getRowCount()); vector<ColDef> colDefs; for (auto& colRef:colRefs) { if (colRef.getTable()->getRowCount() != getRowCount()) { throw runtime_error("tables need same row count to be extendable"); } colDefs.push_back(colRef.getTable()->getColumns()[colRef.getColIdx()]); } setColumns(colDefs); }
CMatrix CMatrix::flip(){ UINT Col = getColCount(), Row = getRowCount(); CMatrix Res(Row, Col); for (UINT i = 0; i < Row; i++) { for (UINT j = 0; j < Col; j++) { Res[i][j] = (*this)[j][i]; } } return Res; }
Matrix& Matrix::gausRightTrianForEquation(Polynom & right) { if ((getCoding() == ON_LINE) && (getTrianType() == NONE)) { uint maxDigits = 0, row = getRowCount(); for (uint i = 0; i < row; i++) if (maxDigits < plMatrix[i]->getNumberDigits()) maxDigits = plMatrix[i]->getNumberDigits(); uint activeRow = 0; int activeCol = maxDigits - 1; while ((activeRow < row)&&(activeCol >= 0)) { uint max = 0, j = activeRow, digit; for (uint i = activeRow; i < row; i++) { digit = plMatrix[i]->getDigit(activeCol); if (max < digit) { max = digit; j = i; } } if (max) { uint r = degree(max); uint ar = 1<<r; if (plMatrix[activeRow]->getDigit((uint)activeCol) < ar) { plMatrix[activeRow]->Xor(*plMatrix[j], *plMatrix[activeRow]); right.setBit(activeRow, right.getBit(j)^right.getBit(activeRow)); } for (uint i = activeRow + 1; i < row; i++) { if (plMatrix[i]->getDigit((uint)activeCol) >= ar) { plMatrix[i]->Xor(*plMatrix[i], *plMatrix[activeRow]); right.setBit(i, right.getBit(i)^right.getBit(activeRow)); } } activeRow++; } else activeCol--; } setTrianType(RIGHT); } else throw new Exception("Матрица должна быть упакована по строкам и не приведена к треугольному виду"); return *this; }
// вычисление определителя матрицы по методу Гаусса TYPE CMatrix::detGauss() const{ if (checkSquare()) { CMatrix temp = *this; int n = getRowCount(); if (n == 1) { return temp[0][0]; // в случае, если матрица состоит из одного эл-та } for (int i = 0; i < n; i++) { if (temp[i][i] == 0) { int k = i + 1; if (k >= n) return 0; // последний элемент оказался нулевым while ((k < n) && (temp[k][i] == 0)) k++; if (temp[k][i] != 0) { for (int p = i; p < n; p++) temp[i][p] += temp[k][p]; } else { return 0; } } // проверили текущий диагональный элемент на 0 for (int j = n - 1; j >= i; j--) { for (int p = i + 1; p < n; p++) { temp[p][j] -= temp[i][j] * (temp[p][i] / temp[i][i]); } } } TYPE result = 1; for (int i = 0; i < n; i++) { result *= temp[i][i]; } return result; } // else return INFINITY; else return sizeof(TYPE); }
std::string CategoryController::getName(int index) const { assert(index >= 1 && index <= getRowCount()); std::vector<std::string> categories; for (int i = 1; i <= _gameController->getRowCount(); ++i) { if (std::find(categories.begin(), categories.end(), _gameController->getCategory(i)) == categories.end()) categories.push_back(_gameController->getCategory(i)); } return categories[index-1]; }
bool MySQLResult::seekRow(int64_t row) { if (row < 0 || row >= getRowCount()) { raise_warning("Unable to jump to row %" PRId64 " on MySQL result index %d", row, o_getId()); return false; } if (!m_localized) { mysql_data_seek(m_res, (my_ulonglong)row); } else { m_current_row = m_rows->begin(); for (int i = 0; i < row; i++) m_current_row++; m_row_ready = false; } return true; }
// определение положительно определённой матрицы bool CMatrix::PositiveDef() const{ bool flag = true; if (checkSymmetric()) { int n = getRowCount(); for (int i = 1; (i <= n) && (flag); i++) { CMatrix temp = *this; temp.setSize(i, i); if (temp.detGauss() <= 0) flag = false; // у нас неположительно определённая матрица } } else flag = false; return flag; }