Example #1
0
/*
        void ContactDynamics::updateBasisMatrix() {
            mB = MatrixXd::Zero(getNumTotalDofs(), getNumContacts() * getNumContactDirections());
            for (int i = 0; i < getNumContacts(); i++) {
                ContactPoint& c = mCollisionChecker->getContact(i);
                Vector3d p = c.point;
                int skelID1 = mBodyIndexToSkelIndex[c.bdID1];
                int skelID2 = mBodyIndexToSkelIndex[c.bdID2];

                MatrixXd B21;
                MatrixXd B12;
                if (!mSkels[skelID1]->getImmobileState()) {
                    int index1 = mIndices[skelID1];
                    int NDOF1 = c.bd1->getSkel()->getNumDofs();
                    B21 = getTangentBasisMatrix(p, c.normal);
                    MatrixXd J21 = getJacobian(c.bd1, p);

                    mB.block(index1, i * getNumContactDirections(), NDOF1, getNumContactDirections()) = J21.transpose() * B21;

                    //  cout << "B21: " << B21 << endl;
                }

                if (!mSkels[skelID2]->getImmobileState()) {
                    int index2 = mIndices[skelID2];
                    int NDOF2 = c.bd2->getSkel()->getNumDofs();
                    if (B21.rows() == 0)
                        B12 = getTangentBasisMatrix(p, -c.normal);
                    else
                        B12 = -B21;
                    MatrixXd J12 = getJacobian(c.bd2, p);
                    mB.block(index2, i * getNumContactDirections(), NDOF2, getNumContactDirections()) = J12.transpose() * B12;

                    //  cout << "B12: " << B12 << endl;

                }
            }
            return;
        }
        */
MatrixXd ContactDynamics::getContactMatrix() const {
    int numDir = getNumContactDirections();
    MatrixXd E(MatrixXd::Zero(getNumContacts() * numDir, getNumContacts()));
    MatrixXd column(MatrixXd::Ones(numDir, 1));
    for (int i = 0; i < getNumContacts(); i++) {
        E.block(i * numDir, i, numDir, 1) = column;
    }
    //        return E / (mDt * mDt);
    return E;
}
Example #2
0
void BindEnum::handleViewResponse(const QVariantMap& values)
{
	Q_ASSERT( mViewer && mEditor );
	Q_ASSERT( values.contains(column()) );

	QVariant data = values.value(column());

	Q_ASSERT( data.canConvert<int>() );

	int index = data.toInt();
	index = mEditor->findData(index);
	if(index == -1)
		index = mEditor->findData(mDefaultValue);

	Q_ASSERT(index != -1);

	mEditor->setCurrentIndex(index);
	mViewer->setText( mEditor->itemText(index) );
}
Example #3
0
/*
 * Obleeperate characters in hardcopy
 * open with \'s.
 */
void
bleep(int i, char *cp)
{

	i -= column(cp);
	do
		ex_putchar('\\' | QUOTE);
	while (--i >= 0);
	rubble = 1;
}
void Launcher::List::Columns::Save(Configuration& cfg) const
{
    if (const uint n=selected.Size())
    {
        Configuration::Section column( cfg["launcher"]["view"]["columns"]["column"] );

        for (uint i=0; i < n; ++i)
            column[i].Str() = cfgStrings[selected[i]];
    }
}
Example #5
0
            typename filtered_matrix_nonzero_helper<Matrix>::nz
            dereference() const 
            { 
				typename impl::filtered_matrix_nonzero_helper<Matrix>::s r,c;

				r = (*_fm)[row(*_i,*_m)]-1;
				c = (*_fm)[column(*_i,*_m)]-1;
				
            	return boost::make_tuple(r, c, value(*_i,*_m));
            }
Example #6
0
math::Vector<2> TransformationMatrix::prod(math::const_VectorRef<2> vec) const
{
	math::Vector<2> result;
	for (std::size_t c = 0; c < 2; c++) {
		math::const_VectorRef<2> col = column(c).ptr();
		for (std::size_t r = 0; r < 2; r++)
			result(r) += col(r) * vec(c);
	}
	return result;
}
Example #7
0
 void assign_attributes(RecordPtr<Record> ptr, const wayward::data_franca::Spectator& data) {
   auto record_type = get_type<Record>();
   for (size_t i = 0; i < record_type->num_properties(); ++i) {
     auto prop = record_type->property_at(i);
     auto col = prop->column();
     if (data.has_key(col)) {
       prop->deserialize(*ptr, data[col]);
     }
   }
 }
QVariant KexiComboBoxBase::value()
{
    KexiTableViewData *relData = column() ? column()->relatedData() : 0;
    KexiDB::LookupFieldSchema *lookupFieldSchema = 0;
    if (relData) {
        if (m_internalEditorValueChanged) {
            //we've user-entered text: look for id
//TODO: make error if matching text not found?
            int rowToHighlight;
            return valueForString(m_userEnteredValue.toString(), &rowToHighlight, 1, 0, true/*allowNulls*/);
        } else {
            //use 'related table data' model
            KexiDB::RecordData *record = popup() ? popup()->tableView()->selectedItem() : 0;
            return record ? record->at(0) : origValue();
        }
    } else if ((lookupFieldSchema = this->lookupFieldSchema())) {
        if (lookupFieldSchema->boundColumn() == -1)
            return origValue();
        KexiDB::RecordData *record = popup() ? popup()->tableView()->selectedItem() : 0;
        if (/*!record &&*/ m_internalEditorValueChanged && !m_userEnteredValue.toString().isEmpty()) { //
            //try to select a row using the user-entered text
            if (!popup()) {
                QVariant prevUserEnteredValue = m_userEnteredValue;
                createPopup(false);
                m_userEnteredValue = prevUserEnteredValue;
            }
            record = selectItemForEnteredValueInLookupTable(m_userEnteredValue);
        }
        return record ? record->at(lookupFieldSchema->boundColumn()) : QVariant();
    } else if (popup()) {
        //use 'enum hints' model
        const int row = popup()->tableView()->currentRow();
        if (row >= 0)
            return QVariant(row);
    }

    if (valueFromInternalEditor().toString().isEmpty())
        return QVariant();
    /*! \todo don't return just 1st row, but use autocompletion feature
          and: show message box if entered text does not match! */
    return origValue(); //unchanged
}
Example #9
0
TableViewImpl * TableViewImpl::clone() const
{
    auto result = std::make_unique<TableViewImpl>(getParentHandle(),getControlData());    
    ListView_SetExtendedListViewStyle(result->hWnd,ListView_GetExtendedListViewStyle(hWnd));
    result->imageListImpl = imageListImpl;
    for( int c = 0; c != colCount; ++c ) {
        result->addColumn(column(c));
    }
    result->setRows(rowCount);
    return result.release();
}
QString KDReports::ErrorDetails::message() const
{
    if ( !hasError() )
        return QString();

    if ( d->m_line != -1 )
        return QObject::tr("Error on line %1, column %2: %3").arg(line()).arg(column()).arg(driverMessage());

    else
        return driverMessage();
}
Example #11
0
void createUI(NVGcontext *vg, float w, float h)
{
    int col;

    uiClear();

    {
        int root = uiItem(); 
        // position root element
        uiSetLayout(root,UI_LEFT|UI_TOP);
        uiSetMargins(root,50,50,0,0);
        uiSetSize(root,250,400);
    }

    col = column(0);
    uiSetLayout(col, UI_TOP|UI_HFILL);

    button(col, __LINE__, BND_ICONID(6,3), "Item 1", demohandler);
    button(col, __LINE__, BND_ICONID(6,3), "Item 2", demohandler);

    {
        int h = hgroup(col);
        radio(h, __LINE__, BND_ICONID(6,3), "Item 3.0", &enum1);
        radio(h, __LINE__, BND_ICONID(0,10), NULL, &enum1);
        radio(h, __LINE__, BND_ICONID(1,10), NULL, &enum1);
        radio(h, __LINE__, BND_ICONID(6,3), "Item 3.3", &enum1);
    }

    {
        int colr;
        int rows = row(col);
        int coll = vgroup(rows);
        label(coll, -1, "Items 4.0:");
        coll = vgroup(coll);
        button(coll, __LINE__, BND_ICONID(6,3), "Item 4.0.0", demohandler);
        button(coll, __LINE__, BND_ICONID(6,3), "Item 4.0.1", demohandler);
        colr = vgroup(rows);
        uiSetFrozen(colr, option1);
        label(colr, -1, "Items 4.1:");
        colr = vgroup(colr);
        slider(colr, __LINE__, "Item 4.1.0", &progress1);
        slider(colr,__LINE__, "Item 4.1.1", &progress2);
    }

    button(col, __LINE__, BND_ICONID(6,3), "Item 5", NULL);

    check(col, __LINE__, "Frozen", &option1);
    check(col, __LINE__, "Item 7", &option2);
    check(col, __LINE__, "Item 8", &option3);

    textbox(col, (UIhandle)textbuffer, textbuffer, 32);

    uiLayout();
}
Example #12
0
int
lindent(line *addr)
{
	register int i;
	char *swcurs = wcursor;
	line *swdot = wdot;

again:
	if (addr > one) {
		register char *cp;
		register int cnt = 0;

		addr--;
		getline(*addr);
		for (cp = linebuf; *cp; cp++)
			if (*cp == '(')
				cnt++;
			else if (*cp == ')')
				cnt--;
		cp = vpastwh(linebuf);
		if (*cp == 0)
			goto again;
		if (cnt == 0)
			return (whitecnt(linebuf));
		addr++;
	}
	wcursor = linebuf;
	linebuf[0] = 0;
	wdot = addr;
	dir = -1;
	llimit = one;
	lf = (void (*)(int))lindent;
	if (!lskipbal("()"))
		i = 0;
	else if (wcursor == linebuf)
		i = 2;
	else {
		register char *wp = wcursor;

		dir = 1;
		llimit = wdot;
		if (!lnext() || !ltosolid() || !lskipatom()) {
			wcursor = wp;
			i = 1;
		} else
			i = 0;
		i += column(wcursor) - 1;
		if (!inopen)
			i--;
	}
	wdot = swdot;
	wcursor = swcurs;
	return (i);
}
Example #13
0
SquareMatrix SqMRO_InverseLUDecomp::operator()() const {

	SquareMatrix inv(*m_thisMatrix);
	RowVector indices(getRows()), column(getRows());
	unsigned int i, j;
	double sign;

	inv.luDecomposition(indices, &sign);

	for (j = 0; j < getColumns(); j++) {
		column.zero();
		column(j) = 1;
		inv.luBackSubstitution(indices, column);
		for (i = 0; i < getRows(); i++) {
			inv(i,j) = column(i);
		}
	}

	return inv;
}
Example #14
0
/*
 * Compute the column position implied by the cursor at ``nc'',
 * and move the cursor there.
 */
void
vsetcurs(register char *nc)
{
	register int col;

	col = column(nc);
	if (linebuf[0])
		col--;
	vgotoCL(col);
	cursor = vcolbp;
}
//------------------------------------------------------------------------------
void DbMySQLTableEditorIndexPage::index_cursor_changed() {
  Gtk::TreeModel::Path path;
  Gtk::TreeView::Column *column(0);

  _indexes_tv->get_cursor(path, column);

  bec::NodeId node = _indexes_model->get_node_for_path(path);

  _index_node = node;
  update_index_details();
}
Example #16
0
void StarPuzzle::applyChanges() {
    std::map<int, int>::iterator iter = m_changes.begin();
    int newPos;
    for (; iter != m_changes.end(); iter++) {
    	newPos = iter->first;
        m_stars[newPos] = m_stars[iter->second];
        m_stars[iter->second] = NULL;
        m_stars[newPos]->moveTo(m_left + column(newPos) * STAR_WIDTH, m_bottom + row(newPos) * STAR_HEIGHT);
    }
    m_changes.clear();
}
Example #17
0
inline void softlist_parser::parse_error(Format &&fmt, Params &&... args)
{
	// always start with filename(line.column):
	util::stream_format(m_errors, "%s(%d.%d): ", m_filename, line(), column());

	// append the remainder of the string
	util::stream_format(m_errors, std::forward<Format>(fmt), std::forward<Params>(args)...);

	// append a newline at the end
	m_errors.put('\n');
}
Example #18
0
double Matrix::getColSum(int n) const
{
   Matrix column(getCol(n));
   double sum = 0;
   
   for (int i=0; i<column.height; i++)
   {
      sum += column.get(i,0);
   }
   return sum;
}
Example #19
0
    QVariant BsonTableModelProxy::headerData(int section, Qt::Orientation orientation, int role) const
    {
        if(role != Qt::DisplayRole)
            return QVariant();

        if(orientation == Qt::Horizontal && role == Qt::DisplayRole){
            return column(section); 
        }else{
            return QString("%1").arg( section + 1 ); 
        }
    }
Example #20
0
int KexiComboBoxTableEdit::widthForValue(const QVariant &val, const QFontMetrics &fm)
{
    KexiDB::TableViewData *relData = column() ? column()->relatedData() : 0;
    if (lookupFieldSchema() || relData) {
        // in 'lookupFieldSchema' or  or 'related table data' model
        // we're assuming val is already the text, not the index
//! @todo ok?
        return qMax(KEXITV_MINIMUM_COLUMN_WIDTH, fm.width(val.toString()));
    }
    //use 'enum hints' model
    QVector<QString> hints = field()->enumHints();
    bool ok;
    int idx = val.toInt(&ok);
    if (!ok || idx < 0 || idx > int(hints.size() - 1))
        return KEXITV_MINIMUM_COLUMN_WIDTH;
    QString txt = hints.value(idx);
    if (txt.isEmpty())
        return KEXITV_MINIMUM_COLUMN_WIDTH;
    return fm.width(txt);
}
Example #21
0
 inline Matrix4T<T>& Matrix4T<T>::operator *= (const Matrix4T<T>& that)
 {
   for(int i = 0; i < columns(); i++)
     {
   const Vector4T<T> t = column(i);
   m[0][i] = ::dot(that[0],t);
   m[1][i] = ::dot(that[1],t);
   m[2][i] = ::dot(that[2],t);
   m[3][i] = ::dot(that[3],t);
     }
   return *this;
 }
Example #22
0
VectorType
cholesky_solve(MatrixType a, const VectorType& y)
{
    // set up Ax = y
    MatrixType y1(linalg::size(y), 1, 0);
    column(y1, 0) = y;

    // solve
    posv(a, y1);

    return linalg::column(y1, 0);
}
Example #23
0
bool Lexer::tokenizeIdentifier()
{
	Token token(Token::tok_identifier, line(), column());

	while(m_begin != m_end && isIdentifier(*m_begin)) {
		*(token.value) += *m_begin;
		++m_begin;
	}

	m_tokens.push_back(token);
	return true;
}
void MatrixTest::test_set_column(void)
{
   message += "test_set_column\n";

   Matrix<double> m(1,1);

   Vector<double> column(1, 1.0);

   m.set_column(0, column);

   assert_true(m.arrange_column(0) == column, LOG);
}
Example #25
0
void EigenProblemsTest::testGeev2()
{
  std::cout << "--> Test: geev2." <<std::endl;
  // Compute only left eigenvectors.
  complex_matrix fake(1,1), leftV(size,size);
  complex_vector eigenval(size);
  Siconos::eigenproblems::geev(*A, eigenval, leftV, fake, true, false);
  complex_vector error(size);
  for( unsigned int i = 0; i < size; ++i ) error(i) = 0.0;
  for( unsigned int i = 0; i < size; ++i )
  {
    error.plus_assign(ublas::prod(conj(column(leftV, i)), *A->dense() ));
    error.minus_assign(eigenval(i)*conj(column(leftV,i)));
  }
  // Check ...
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testGeev2 1: ", norm_2(error) < 10 * std::numeric_limits< double >::epsilon() , true);
  // Check if A has not been modified
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testGeev2 2: ", (*A) == (*Aref) , true);

  std::cout << "--> geev1 test ended with success." <<std::endl;
}
Example #26
0
// ============================================================================
StatusCode Tuples::TupleObj::column ( const std::string&   name  ,
                                      const unsigned long  value ,
                                      const unsigned long  minv  ,
                                      const unsigned long  maxv  )
{
  Warning( "'unsigned long' has different sizes on 32/64 bit systems. Casting '" +
           name + "' to 'unsigned long long'", StatusCode::SUCCESS ).ignore();
  return column( name, 
                 (unsigned long long)value, 
                 (unsigned long long)minv, 
                 (unsigned long long)maxv );
}
Example #27
0
QString KWQQuizModel::kbAnswer()
{
    int col = column(m_list.at(m_currentQuestion));
    QString result;

    if (col == 0)
        return headerData(0, Qt::Horizontal, KWQTableModel::KeyboardLayoutRole).toString();
    if (col == 1)
        return headerData(1, Qt::Horizontal, KWQTableModel::KeyboardLayoutRole).toString();

    return result;
}
Example #28
0
void SparseMatrix<CoeffType>::sort() {
	if(rows_are_stored_) {
		for(unsigned int i=0; i<m_; i++) {
			row(i).sort() ;
		}
	}
	if(columns_are_stored_) {
		for(unsigned int j=0; j<n_; j++) {
			column(j).sort() ;
		}
	}
}
//------------------------------------------------------------------------------
void ListModelWrapper::handle_popup(const int x, const int y, const int time, GdkEventButton* evb) {
  Gtk::TreeModel::Path path;
  Gtk::TreeView::Column* column(0);
  int cell_x(-1);
  int cell_y(-1);

  ListModelWrapper::NodeIdArray list = get_selection();

  bool there_is_path_at_pos = false;
  if (_treeview)
    there_is_path_at_pos = _treeview->get_path_at_pos(x, y, path, column, cell_x, cell_y);
  else if (_iconview) {
    path = _iconview->get_path_at_pos(x, y);
    there_is_path_at_pos = path.gobj() && !path.empty();
  }

  if (there_is_path_at_pos) {
    // Check that @path is on selection, otherwise add @path to selection
    bec::NodeId node = get_node_for_path(path);
    // list stores current selection
    bool path_at_pos_is_in_selection = false;
    for (int i = list.size() - 1; i >= 0; --i) {
      if (node == list[i]) {
        path_at_pos_is_in_selection = true;
        break;
      }
    }

    if (!path_at_pos_is_in_selection) {
      // Add it, if user holds Ctrl while clicking right mouse btn
      // Otherwise clear selection, and select only @path
      const bool clear_selection = evb ? (!(evb->state & GDK_CONTROL_MASK)) : false;
      if (clear_selection) {
        if (_treeview)
          _treeview->get_selection()->unselect_all();
        if (_iconview)
          _iconview->unselect_all();
      }

      if (_treeview)
        _treeview->get_selection()->select(path);
      if (_iconview)
        _iconview->select_path(path);

      list = get_selection();
    }
  }
  if (!_context_menu)
    _context_menu = new Gtk::Menu();

  run_menu_and_forward_action((*_tm)->get_popup_items_for_nodes(list), x, y, time, *_tm, list, _fe_menu_handler,
                              _context_menu);
}
bool TableCatalogDelegate::getIndexScheme(catalog::Table const& catalogTable,
                                          catalog::Index const& catalogIndex,
                                          TupleSchema const* schema,
                                          TableIndexScheme* scheme) {
    std::vector<int> index_columns;
    std::vector<ValueType> column_types;

    // The catalog::Index object now has a list of columns that are to be
    // used
    if (catalogIndex.columns().size() == (size_t) 0) {
        VOLT_ERROR("Index '%s' in table '%s' does not declare any columns"
                   " to use",
                   catalogIndex.name().c_str(),
                   catalogTable.name().c_str());
        return false;
    }

    auto indexedExpressions = TableIndex::simplyIndexColumns();
    std::string const& expressionsAsText = catalogIndex.expressionsjson();
    if (expressionsAsText.length() != 0) {
        ExpressionUtil::loadIndexedExprsFromJson(indexedExpressions, expressionsAsText);
    }

    // Since the columns are not going to come back in the proper order from
    // the catalogs, we'll use the index attribute to make sure we put them
    // in the right order
    index_columns.resize(catalogIndex.columns().size());
    std::map<std::string, catalog::ColumnRef*>::const_iterator colrefIterator;
    for (colrefIterator = catalogIndex.columns().begin();
         colrefIterator != catalogIndex.columns().end();
         colrefIterator++) {
        auto catalogColref = colrefIterator->second;
        assert(catalogColref->index() >= 0);
        index_columns[catalogColref->index()] = catalogColref->column()->index();
    }
    // partial index predicate
    std::string const& predicateAsText  = catalogIndex.predicatejson();
    AbstractExpression* predicate = NULL;
    if (!predicateAsText.empty()) {
        predicate = ExpressionUtil::loadExpressionFromJson(predicateAsText);
    }
    *scheme = TableIndexScheme(catalogIndex.name(),
                               (TableIndexType)catalogIndex.type(),
                               index_columns,
                               indexedExpressions,
                               predicate,
                               catalogIndex.unique(),
                               catalogIndex.countable(),
                               expressionsAsText,
                               predicateAsText,
                               schema);
    return true;
}