void ListController::didBecomeFirstResponder() { if (selectedRow() == -1) { selectCellAtLocation(0, 0); } else { selectCellAtLocation(selectedColumn(), selectedRow()); } if (selectedRow() >= numberOfRows()) { selectCellAtLocation(selectedColumn(), numberOfRows()-1); } footer()->setSelectedButton(-1); app()->setFirstResponder(selectableTableView()); }
Vector Matrix::column(const index &j) const { if (j < 0 || j >= numberOfColumns()) { throw std::out_of_range("Matrix::column(const index &j): Column index out of range"); } Vector column(numberOfRows()); #pragma omp parallel for for (node i = 0; i < numberOfRows(); ++i) { column[i] = graph.weight(i,j); } return column; }
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { willDisplayCellAtLocationWithDisplayMode(cell, i, j, PrintFloat::Mode::Default); if (cellAtLocationIsEditable(i, j)) { return; } // The cell is not a title cell and not editable if (j > 0 && i > 0) { char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; // Special case: last row if (j == numberOfRows() - 1) { int numberOfIntervalElements = m_interval->numberOfElements(); if (numberOfIntervalElements < Interval::k_maxNumberOfElements) { buffer[0] = 0; EvenOddBufferTextCell * myValueCell = (EvenOddBufferTextCell *)cell; myValueCell->setText(buffer); return; } } // The cell is a value cell EvenOddBufferTextCell * myValueCell = (EvenOddBufferTextCell *)cell; double x = m_interval->element(j-1); PrintFloat::convertFloatToText<double>(evaluationOfAbscissaAtColumn(x, i), buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); myValueCell->setText(buffer); } }
RMatrix& RMatrix::attachRows (const RMatrix& A) { //! \todo zcopy_ verwenden const LongInt n = numberOfColumns(); const LongInt m1 = numberOfRows(); const LongInt m2 = A.numberOfRows(); const LongInt m = m1+m2; RMatrix temp((*this)); setDimension(m,n); for(LongInt j=0; j<n; j++) { LongInt i; for(i=0; i<m1; i++) { (*this)(i,j) = temp(i,j); } for(i=0; i<m2; i++) { (*this)(i+m1,j) = A(i,j); } } return (*this); }
RMatrix& RMatrix::isInverseOf(const AMatrix& s, AMatrix& w) { const AMatrixType theMatrixS = s.type(); const AMatrixType theMatrixW = w.type(); if(theMatrixS==isRMatrix && theMatrixW==isRMatrix) { const RMatrix& S = (const RMatrix&)s; const RMatrix& W = (const RMatrix&)w; (*this) = S; integer m = numberOfRows(); integer n = numberOfColumns(); integer lda = MAX(1,m); integer dim = MIN(m,n); integer info = 0; integer lwork = m*n; integer* ipiv = new integer[dim]; // dgetrf (&m, &n, (LongReal*) &_pelm[0], &lda, ipiv, &info); // dgetri (&m, (LongReal*) &_pelm[0], &lda, ipiv, (LongReal*) &W(0,0), &lwork, &info); info = TensorCalculus::Lapack<double>::getrf (m, n, &_pelm[0], lda, ipiv); info = TensorCalculus::Lapack<double>::getri (m, &_pelm[0], lda, ipiv, &W(0,0), lwork); delete [] ipiv; } else { throw SimpleException(IString("Warning In RMatrix::isInverseOf(const AMatrix& s, const AMatrix& w), Bad Type!!!")); } return (*this); }
int TableViewDataSource::indexFromCumulatedHeight(KDCoordinate offsetY) { int result = 0; int j = 0; while (result < offsetY && j < numberOfRows()) { result += rowHeight(j++); } return (result < offsetY || offsetY == 0) ? j : j - 1; }
void HistogramParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { if (index == numberOfRows()-1) { return; } MessageTableCellWithEditableText * myCell = (MessageTableCellWithEditableText *)cell; I18n::Message labels[k_numberOfCells] = {I18n::Message::RectangleWidth, I18n::Message::BarStart}; myCell->setMessage(labels[index]); FloatParameterController::willDisplayCellForIndex(cell, index); }
void IntervalParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { if (index == numberOfRows()-1) { return; } MessageTableCellWithEditableText * myCell = (MessageTableCellWithEditableText *)cell; I18n::Message labels[k_totalNumberOfCell] = {I18n::Message::NStart, I18n::Message::NEnd, I18n::Message::Step}; myCell->setMessage(labels[index]); FloatParameterController::willDisplayCellForIndex(cell, index); }
double Matrix::operator()(const index &i, const index &j) const { if (i < 0 || i >= numberOfRows()) { throw std::out_of_range("Matrix(i,j): Row index out of range"); } else if (j< 0 || j >= numberOfColumns()) { throw std::out_of_range("Matrix(i,j): Column index out of range"); } return graph.weight(i,j); }
RMatrix& RMatrix::addMatrix (const AMatrix& A, const LongInt& rowIndex, const LongInt& colIndex) { const AMatrixType theMatrixA = A.type(); LongInt m = numberOfRows(); LongInt n = numberOfColumns(); LongInt m1 = A.numberOfRows(); LongInt n1 = A.numberOfColumns(); if(theMatrixA==isRkRMatrix) { const RkRMatrix& R = (const RkRMatrix&)A; LongInt k = R.rank(); LongInt mR = R.numberOfRows(); LongInt nR = R.numberOfColumns(); LongReal mike = 1.0; // dgemm ( ¬ConjTrans, &conjTrans, &MIN(m,mR), &MIN(n,nR), &k, (LongReal*) &(Complex::complexUnit), // (LongReal*) &(R.attr_A(rowIndex, 0)), &mR, // (LongReal*) &(R.attr_B(colIndex, 0)), &nR, (LongReal*) &(Complex::complexUnit), // (LongReal*) &(*this)(0, 0), &m); TensorCalculus::Blas<double>::gemm (notConjTrans, conjTrans, MIN(m,mR), MIN(n,nR), k, 1.0, &(R.attr_A(rowIndex, 0)), mR, &(R.attr_B(colIndex, 0)), nR, 1.0, &(*this)(0, 0), m); } else if(theMatrixA==isRMatrix) { const RMatrix& C = (const RMatrix&)A; int ic = 1; for(LongInt i=0; i<n; i++) { // daxpy (&m, (LongReal*) &(Complex::complexUnit), (LongReal*) &C(rowIndex, colIndex+i), // &ic, (LongReal*) &(*this)(0, i), &ic); TensorCalculus::Blas<double>::axpy (m, 1.0, &C(rowIndex, colIndex+i), ic, &(*this)(0, i), ic); } } else if(theMatrixA==isHMatrixInterface) { RMatrix C(m1, n1); C.isConversionOf(A); addMatrix(C, rowIndex, colIndex); } else { throw SimpleException(IString("Warning In RMatrix::addMatrix (const AMatrix& A, const LongInt& rowIndex, const LongInt& colIndex), Type Not Implemented !!!")); } return (*this); }
Matrix& Matrix::operator-=(const Matrix &other) { if (numberOfRows() != other.numberOfRows() || numberOfColumns() != other.numberOfColumns()) { throw std::runtime_error("Matrix::operator-=(const Matrix &other): Dimensions of matrices do not match"); } other.parallelForNonZeroElementsInRowOrder([&](node i, node j, double value) { graph.increaseWeight(i, j, -value); }); return *this; }
void Matrix::setValue(const index &i, const index &j, const double &value) { if (i < 0 || i >= numberOfRows()) { throw std::out_of_range("Matrix::setValue(const index &i, const index &j, const double &value): " "Row index out of range"); } else if (j< 0 || j >= numberOfColumns()) { throw std::out_of_range("Matrix::setValue(const index &i, const index &j, const double &value): " "Column index out of range"); } graph.setWeight(i, j, value); }
RMatrix& RMatrix::addIdentityScaledBy (const LongReal& z) { const LongInt dim = MIN(numberOfRows(),numberOfColumns()); for(LongInt i=0; i<dim; i++) { (*this)(i,i) += z; } return(*this); }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> const ListControl::Row& ListControl::rowAt(unsigned int pos) const { if(pos >= numberOfRows()) THROW("Tried to access the row of a ListControl with an invalid index"); Rows::const_iterator it = rows_.begin(); std::advance(it, pos); return *it; }
int RangeParameterController::typeAtLocation(int i, int j) { if (j == numberOfRows()-1) { return 0; } if (j >= 0 && j < 2) { return 1; } if (j == 2) { return 2; } return 3; }
void GoToParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { if (index == numberOfRows()-1) { return; } MessageTableCellWithEditableText * myCell = (MessageTableCellWithEditableText *) cell; if (m_xPrediction) { myCell->setMessage(I18n::Message::X); } else { myCell->setMessage(I18n::Message::Y); } FloatParameterController::willDisplayCellForIndex(cell, index); }
Vector Matrix::row(const index &i) const { if (i < 0 || i >= numberOfRows()) { throw std::out_of_range("Matrix::row(const index &i): Row index out of range"); } Vector row(numberOfColumns(), 0.0, true); graph.forEdgesOf(i, [&](node i, node j, double value) { row[j] = value; }); return row; }
Matrix Matrix::operator*(const Matrix &other) const { if (numberOfColumns() != other.numberOfRows()) { throw std::runtime_error("Matrix::operator*(const Matrix &other): Dimensions of matrices do not match"); } Matrix result(numberOfRows(), other.numberOfColumns()); SparseAccumulator spa(numberOfRows()); for (index r = 0; r < numberOfRows(); ++r) { graph.forNeighborsOf(r, [&](node v, double w1){ other.graph.forNeighborsOf(v, [&](node u, double w2){ double value = w1 * w2; spa.scatter(value, u); }); }); spa.gather([&](node row, node column, double value){ result.graph.addEdge(row, column, value); }); spa.increaseRow(); } return result; }
Vector Matrix::operator*(const Vector &vector) const { if (vector.isTransposed() && numberOfColumns() != 1) { throw std::runtime_error("operator*(const Vector &vector): Vector is not transposed correctly"); } else if (numberOfColumns() != vector.getDimension()) { throw std::runtime_error("operator*(const Vector &vector): Dimensions of matrix and vector do not match"); } Vector result(numberOfRows(), 0.0); parallelForNonZeroElementsInRowOrder([&](node i, node j, double value) { result[i] += value * vector[j]; }); return result; }
bool ValuesController::handleEvent(Ion::Events::Event event) { if (event == Ion::Events::Down) { if (selectedRow() == -1) { header()->setSelectedButton(-1); selectableTableView()->selectCellAtLocation(0,0); app()->setFirstResponder(selectableTableView()); return true; } return false; } if (event == Ion::Events::Up) { if (selectedRow() == -1) { header()->setSelectedButton(-1); app()->setFirstResponder(tabController()); return true; } selectableTableView()->deselectTable(); header()->setSelectedButton(0); return true; } if (event == Ion::Events::Backspace && selectedRow() > 0 && (selectedRow() < numberOfRows()-1 || m_interval->numberOfElements() == Interval::k_maxNumberOfElements)) { m_interval->deleteElementAtIndex(selectedRow()-1); selectableTableView()->reloadData(); return true; } if (event == Ion::Events::OK || event == Ion::Events::EXE) { if (selectedRow() == -1) { return header()->handleEvent(event); } if (selectedRow() == 0) { if (selectedColumn() == 0) { configureAbscissa(); return true; } configureFunction(); return true; } return false; } if (selectedRow() == -1) { return header()->handleEvent(event); } return false; }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ListControl& ListControl::removeRowAt(unsigned int pos) { Rows::iterator it; unsigned int counter = 0; for(it = rows_.begin(); it != rows_.end(); ++it) { if(counter == pos) break; counter++; } if(counter < numberOfRows()) rows_.erase(it); onContentsChanged(); return *this; }
bool ListController::handleEvent(Ion::Events::Event event) { if (event == Ion::Events::Up && selectedRow() == -1) { footer()->setSelectedButton(-1); selectableTableView()->selectCellAtLocation(0, numberOfRows()-1); app()->setFirstResponder(selectableTableView()); return true; } if (event == Ion::Events::Down) { if (selectedRow() == -1) { return false; } selectableTableView()->deselectTable(); footer()->setSelectedButton(0); return true; } return handleEventOnExpression(event); }
void RangeParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { if (index == numberOfRows()-1) { return; } if (index == 2) { SwitchView * switchView = (SwitchView *)m_yAutoCell->accessoryView(); switchView->setState(m_interactiveRange->yAuto()); return; } MessageTableCellWithEditableText * myCell = (MessageTableCellWithEditableText *)cell; I18n::Message labels[k_numberOfTextCell+1] = {I18n::Message::XMin, I18n::Message::XMax, I18n::Message::Default, I18n::Message::YMin, I18n::Message::YMax}; myCell->setMessage(labels[index]); KDColor yColor = m_interactiveRange->yAuto() ? Palette::GreyDark : KDColorBlack; KDColor colors[k_numberOfTextCell+1] = {KDColorBlack, KDColorBlack, KDColorBlack, yColor, yColor}; myCell->setTextColor(colors[index]); FloatParameterController::willDisplayCellForIndex(cell, index); }
bool RMatrix::partialEvaluateTransposeAt (const LongInt& i, RVector& w, const LongInt& j, const RVector& v) const { bool value = true; integer incx = 1; integer n = numberOfRows(); integer m = numberOfColumns(); integer lda = n; // dgemv ( &trans, &n, &m, (LongReal*) &(Complex::complexUnit), (LongReal*) (&_pelm[0]), // &lda, (LongReal*) &v(j), &incx, (LongReal*) &(Complex::complexUnit), // (LongReal*)&w(i), &incx // ); TensorCalculus::Blas<double>::gemv(trans, n, m, 1.0, (&_pelm[0]), lda, &v(j), incx, 1.0, &w(i), incx); return value; }
FWTestTableManager::FWTestTableManager(const std::vector<std::string>& iColumns, const std::vector<std::string>& iData): m_columns(iColumns), m_content(iData), m_rowChecked(m_content.size(),false), m_renderer( new FWTextTableCellRenderer), m_rowHeaderRenderer( new FWCheckedTextTableCellRenderer), m_selectedRow(-1), m_lastRequestedRow(-1) { assert(0== m_content.size()%m_columns.size()); unsigned int nRows = numberOfRows(); m_sortOrder.reserve(nRows); for(unsigned int i = 0; i < nRows; ++i) { m_sortOrder.push_back(i); } m_rowHeaderRenderer->Connect("checkBoxClicked()","FWTestTableManager",this,"checkBoxClicked()"); }
bool RMatrix::operator () (const LongInt& i, RVector& w, const LongInt& j, const RVector& v) { bool value = true; integer incx = 1; integer m = numberOfRows(); integer n = numberOfColumns(); integer lda = m; // dgemv ( correctChar(), &m, &n, (LongReal*) &(Complex::complexUnit), (LongReal*) (&_pelm[0]), // &lda, (LongReal*) &v(j), &incx, (LongReal*) &(Complex::complexUnit), // (LongReal*) &w(i), &incx // ); TensorCalculus::Blas<double>::gemv(*correctChar(), m, n, 1.0, &_pelm[0], lda, &v(j), incx, 1.0, &w(i), incx); clearTranspose(); return value; }
RMatrix& RMatrix::invert() { integer m = numberOfRows(); integer n = numberOfColumns(); integer lda = MAX(1,m); integer dim = MIN(m,n); integer info = 0; integer* ipiv = new integer[dim]; // dgetrf (&m, &n, (LongReal*) &_pelm[0], &lda, ipiv, &info); info = TensorCalculus::Lapack<double>::getrf(m, n, &_pelm[0], lda, ipiv); integer lwork = m*n; RVector work(lwork); // dgetri (&m, (LongReal*) &_pelm[0], &lda, ipiv, (LongReal*) &work(0), &lwork, &info); info = TensorCalculus::Lapack<double>::getri(m, &_pelm[0], lda, ipiv, &work(0), lwork); delete [] ipiv; return (*this); }
RMatrix& RMatrix::attachColumns (const RMatrix& A) { const LongInt m = numberOfRows(); const LongInt n1 = numberOfColumns(); const LongInt n2 = A.numberOfColumns(); const LongInt n = n1+n2; RMatrix temp((*this)); setDimension(m, n); integer dim1 = m*n1; integer nx = 1; // dcopy (&dim1, (LongReal*)(&temp._pelm[0]), &nx, (LongReal*)(&_pelm[0]), &nx); TensorCalculus::Blas<double>::copy (dim1, (&temp._pelm[0]), nx, (&_pelm[0]), nx); integer dim2 = m*n2; // dcopy (&dim2, (LongReal*)(&A._pelm[0]), &nx, (LongReal*)(&_pelm[dim1]), &nx); TensorCalculus::Blas<double>::copy (dim2, (&A._pelm[0]), nx, (&_pelm[dim1]), nx); return (*this); }
void FWTestTableManager::implSort(int col, bool sortOrder) { if(col >-1 && col < m_columns.size()) { std::vector<std::pair<std::string,unsigned int> > toSort; int nRows = numberOfRows(); toSort.reserve(nRows); for(int row=0; row< nRows; ++row) { toSort.push_back( std::make_pair<std::string, unsigned int>(m_content[col+row*numberOfColumns()],row)); } if(sortOrder) { std::sort(toSort.begin(),toSort.end(),std::greater<std::pair<std::string,unsigned int> >()); } else { std::sort(toSort.begin(),toSort.end(),std::less<std::pair<std::string,unsigned int> >()); } std::vector<unsigned int>::iterator itSort = m_sortOrder.begin(); for(std::vector<std::pair<std::string,unsigned int> >::iterator it = toSort.begin(), itEnd=toSort.end(); it != itEnd; ++it,++itSort) { *itSort = it->second; } } }
void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { if (i == 0 && j == 0) { return; } EvenOddCell * myCell = (EvenOddCell *)cell; myCell->setEven(j%2 == 0); myCell->setHighlighted(i == selectedColumn() && j == selectedRow()); // Calculation title if (i == 0) { if (j == numberOfRows()-1) { EvenOddExpressionCell * myCell = static_cast<EvenOddExpressionCell *>(cell); myCell->setExpressionLayout(m_r2Layout); return; } MarginEvenOddMessageTextCell * myCell = (MarginEvenOddMessageTextCell *)cell; myCell->setAlignment(1.0f, 0.5f); I18n::Message titles[k_totalNumberOfRows-1] = {I18n::Message::Mean, I18n::Message::Sum, I18n::Message::SquareSum, I18n::Message::StandardDeviation, I18n::Message::Deviation, I18n::Message::NumberOfDots, I18n::Message::Covariance, I18n::Message::Sxy, I18n::Message::Regression, I18n::Message::A, I18n::Message::B, I18n::Message::R, I18n::Message::Default}; myCell->setMessage(titles[j-1]); return; } int seriesNumber = m_store->indexOfKthNonEmptySeries(i - 1); assert(i >= 0 && seriesNumber < DoublePairStore::k_numberOfSeries); // Coordinate and series title if (j == 0 && i > 0) { ColumnTitleCell * myCell = (ColumnTitleCell *)cell; char buffer[] = {'X', static_cast<char>('1' + seriesNumber), 0}; myCell->setFirstText(buffer); buffer[0] = 'Y'; myCell->setSecondText(buffer); myCell->setColor(Palette::DataColor[seriesNumber]); return; } // Calculation cell if (i > 0 && j > 0 && j <= k_totalNumberOfDoubleBufferRows) { ArgCalculPointer calculationMethods[k_totalNumberOfDoubleBufferRows] = {&Store::meanOfColumn, &Store::sumOfColumn, &Store::squaredValueSumOfColumn, &Store::standardDeviationOfColumn, &Store::varianceOfColumn}; double calculation1 = (m_store->*calculationMethods[j-1])(seriesNumber, 0); double calculation2 = (m_store->*calculationMethods[j-1])(seriesNumber, 1); EvenOddDoubleBufferTextCellWithSeparator * myCell = (EvenOddDoubleBufferTextCellWithSeparator *)cell; char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; PrintFloat::convertFloatToText<double>(calculation1, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); myCell->setFirstText(buffer); PrintFloat::convertFloatToText<double>(calculation2, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); myCell->setSecondText(buffer); return; } if (i > 0 && j == 9) { SeparatorEvenOddBufferTextCell * myCell = (SeparatorEvenOddBufferTextCell *)cell; myCell->setText("ax+b"); return; } if (i > 0 && j > k_totalNumberOfDoubleBufferRows) { assert(j != 9); CalculPointer calculationMethods[k_totalNumberOfRows-k_totalNumberOfDoubleBufferRows] = {&Store::doubleCastedNumberOfPairsOfSeries, &Store::covariance, &Store::columnProductSum, nullptr, &Store::slope, &Store::yIntercept, &Store::correlationCoefficient, &Store::squaredCorrelationCoefficient}; double calculation = (m_store->*calculationMethods[j-k_totalNumberOfDoubleBufferRows-1])(seriesNumber); SeparatorEvenOddBufferTextCell * myCell = (SeparatorEvenOddBufferTextCell *)cell; char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; PrintFloat::convertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); myCell->setText(buffer); return; } }