Beispiel #1
0
/* Function: render_scene
	Scene should be assembled here. TODO: rework

	Parameters:
		counter - pointer to snapshot's point counter
*/
void render_scene(float y, float p, Snapshot *snap, uint32_t *counter) 
{
	uint32_t i;
	uint32_t cnt = *counter;
	clear_zbuffer(); 
	clear_img(CLEAR_COLOR); 
	yaw = y; 
	pitch = p;
	compute_yp(); 
	
	/* render here */
	render_cloud(&cloud,0,0,0,1); 
	
	/* end */
		
	for (i=0; i<WIDTH*HEIGHT; i++) { 
		if (img[i] != CLEAR_COLOR) {
		snap->x[cnt] = shrink(Xbuf[i], shrink_val); 
		snap->y[cnt] = shrink(Ybuf[i], shrink_val); 
		snap->z[cnt] = shrink(Zbuf[i], shrink_val); 
		snap->nx[cnt] = NXbuf[i];
		snap->ny[cnt] = NYbuf[i]; 
		snap->nz[cnt] = NZbuf[i];
		snap->sh[cnt] = SHbuf[i];
		snap->c[cnt] = true2high(img[i]); 
		cnt++; }
	}
	*counter = cnt;
}
Beispiel #2
0
void GrResizeGrayMap(unsigned char *map,int pitch,int ow,int oh,int nw,int nh)
{
	if(ow != nw) {
	    unsigned char *ptr = map;
	    int	  cnt = oh;
	    if((unsigned int)ow > (unsigned int)nw) do {
		shrink(ptr,1,ow,nw);
		ptr += pitch;
	    } while(--cnt > 0);
	    else do {
		grow(ptr,1,ow,nw);
		ptr += pitch;
	    } while(--cnt > 0);
	}
	if(oh != nh) {
	    int cnt = nw;
	    if((unsigned int)oh > (unsigned int)nh) do {
		shrink(map,pitch,oh,nh);
		map++;
	    } while(--cnt > 0);
	    else do {
		grow(map,pitch,oh,nh);
		map++;
	    } while(--cnt > 0);
	}
}
Beispiel #3
0
/**
 * im_shrink:
 * @in: input image
 * @out: output image
 * @xshrink: horizontal shrink
 * @yshrink: vertical shrink
 *
 * Shrink @in by a pair of factors with a simple box filter.
 *
 * You will get aliasing for non-integer shrinks. In this case, shrink with
 * this function to the nearest integer size above the target shrink, then
 * downsample to the exact size with im_affinei() and your choice of
 * interpolator.
 *
 * im_rightshift_size() is faster for factors which are integer powers of two.
 *
 * See also: im_rightshift_size(), im_affinei().
 *
 * Returns: 0 on success, -1 on error
 */
int
im_shrink( IMAGE *in, IMAGE *out, double xshrink, double yshrink )
{
    if( im_check_noncomplex( "im_shrink", in ) ||
            im_check_coding_known( "im_shrink", in ) ||
            im_piocheck( in, out ) )
        return( -1 );
    if( xshrink < 1.0 || yshrink < 1.0 ) {
        im_error( "im_shrink",
                  "%s", _( "shrink factors should be >= 1" ) );
        return( -1 );
    }

    if( xshrink == 1 && yshrink == 1 ) {
        return( im_copy( in, out ) );
    }
    else if( in->Coding == IM_CODING_LABQ ) {
        IMAGE *t[2];

        if( im_open_local_array( out, t, 2, "im_shrink:1", "p" ) ||
                im_LabQ2LabS( in, t[0] ) ||
                shrink( t[0], t[1], xshrink, yshrink ) ||
                im_LabS2LabQ( t[1], out ) )
            return( -1 );
    }
    else if( shrink( in, out, xshrink, yshrink ) )
        return( -1 );

    return( 0 );
}
/* Takes an open file and adds all words from the file to words. */
int addWords(FILE* f, char** words) {
  int p, q;
  long long int num_words = 0;
  char buffer[BUFFERSIZE+1];
  int concat = 0;
  int size, len;
  unsigned long long int threshold = 4 * STARTTHRESHOLD;
  int threshold_hit = 0;

  while (!feof(f)) {
#ifdef SHRINK
    if (num_words > threshold) { /* Whenever we've got more than THRESHOLD words */
      /* fprintf(stderr, " *********************** Mini Shrinking, Threshold: %llu ***********************\n\n", threshold); */
      num_words = shrink(words, num_words); /* Eliminate duplicates */
      threshold_hit++;
      if (threshold_hit > 2) {
        threshold *= 2;
        threshold_hit = 0;
      }
    }
#endif
    if (fgets(buffer, BUFFERSIZE, f) != NULL) {
      size = strlen(buffer)+1;
      /* printf("%s\n", buffer); */
      /* Insert each word into words */
      p = q = 0;
      while (p < size-1) {
        while (q < size && isalnum(buffer[q++]));
        /* printf("q: %d\n", q); */
        if (q < size) {     /* A non-alfanumeric char was found before end of buffer. */
          buffer[q-1] = '\0';       /* Signal that the word ends at q */
        }
        if (!concat) {
          len = insert(words, &num_words, buffer, p);
          /* printf("Adicionada: %s\n", words[num_words-1]); */
        }
        else {
          strcat(words[num_words-1], buffer+p);
          /* printf("Concatenada: %s\n", words[num_words-1]); */
          concat = 0;
        }
        if (q >= size && !len) {  /* This means that '\0' was at the end off buffer, possible split word */
          concat = 1;
          p = q;
        }
        else {
          while (q < size && !isalnum(buffer[q++]));
          p = q-1;
          q--;
        }
      }
    }
  }
#ifdef SHRINK
  num_words = shrink(words, num_words); /* Eliminate duplicates */
#endif
  return num_words;
}
Beispiel #5
0
tex::spec_t::spec_t(box_base_t *p)
	{
	stretch_order(this) = stretch_order(p);
	shrink_order(this) = shrink_order(p);
	glue_ref_count(this) = 0;
	glue_width(this) = glue_width(p);
	stretch(this) = stretch(p);
	shrink(this) = shrink(p);
	}
Beispiel #6
0
void tex::print_spec(ptr p, str s)
	{
	print_scaled(glue_width(p));
	print(s);
	if (stretch(p) != 0) {
		print(" plus ");
		print_glue(stretch(p), stretch_order(p), s);
		}
	if (shrink(p) != 0) {
		print(" minus ");
		print_glue(shrink(p), shrink_order(p), s);
		}
	}
Beispiel #7
0
void burnDialog::on_FlashLoadButton_clicked()
{
  QString fileName;

  ui->BurnFlashButton->setDisabled(true);
  ui->FWFileName->clear();
  ui->DateField->clear();
  ui->versionField->clear();
  ui->ModField->clear();
  ui->FramFWInfo->hide();
  ui->SplashFrame->hide();
  ui->BurnFlashButton->setDisabled(true);
  ui->EEbackupCB->hide();
  QTimer::singleShot(0, this, SLOT(shrink()));
  if (hexType==FLASH_FILE_TYPE) {
    fileName = QFileDialog::getOpenFileName(this, tr("Open Firmware File"), g.flashDir(), FLASH_FILES_FILTER);
    if(fileName.isEmpty())
      return;
    checkFw(fileName);
  }
  else {
    QString fileName = QFileDialog::getOpenFileName(this,tr("Choose Radio Backup file"), g.eepromDir(), tr(EXTERNAL_EEPROM_FILES_FILTER));
    if (checkeEprom(fileName)) {
      if (burnraw==false) {
        ui->BurnFlashButton->setEnabled(true);
        ui->profile_label->show();
        ui->patchcalib_CB->show();
        ui->patchhw_CB->show();
        if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
          ui->EEpromCB->show();
        }
        else {
          ui->EEpromCB->setChecked(false);
        }
      }
      else {
        ui->BurnFlashButton->setEnabled(true);
        ui->profile_label->hide();
        ui->patchcalib_CB->setChecked(false);
        ui->patchhw_CB->setChecked(false);
        ui->patchhw_CB->hide();
        ui->patchcalib_CB->hide();        
      }
      QTimer::singleShot(0, this, SLOT(shrink()));
    }
  }
  updateUI();
}
Beispiel #8
0
void Heap::destroy()
{
    JSLock lock(SilenceAssertionsOnly);

    if (!m_globalData)
        return;

    ASSERT(!m_globalData->dynamicGlobalObject);
    ASSERT(m_operationInProgress == NoOperation);
    
    // The global object is not GC protected at this point, so sweeping may delete it
    // (and thus the global data) before other objects that may use the global data.
    RefPtr<JSGlobalData> protect(m_globalData);

#if ENABLE(JIT)
    m_globalData->jitStubs->clearHostFunctionStubs();
#endif

    delete m_markListSet;
    m_markListSet = 0;

    clearMarks();
    m_handleHeap.finalizeWeakHandles();
    m_globalData->smallStrings.finalizeSmallStrings();

#if !ENABLE(JSC_ZOMBIES)
    shrink();
    ASSERT(!size());
#endif

    m_globalData = 0;
}
Beispiel #9
0
 static inline float
 sample(T scorefn, float x0, float w, common::rng_t &rng, unsigned m=10000, unsigned ntries=100)
 {
   const float y = logf(distributions::sample_unif01(rng)) + scorefn(x0);
   const auto p = interval(scorefn, x0, y, w, rng, m);
   return shrink(scorefn, x0, y, p.first, p.second, rng, ntries);
 }
Beispiel #10
0
Main::Main(QGraphicsScene& c, QWidget* parent, const char* name, Qt::WindowFlags f) :
    Q3MainWindow(parent,name,f),
    canvas(c)
{
    editor = new FigureEditor(canvas,this);
    QMenuBar* menu = menuBar();

    Q3PopupMenu* file = new Q3PopupMenu( menu );
    file->insertItem("&Fill canvas", this, SLOT(init()), Qt::CTRL+Qt::Key_F);
    file->insertItem("&Erase canvas", this, SLOT(clear()), Qt::CTRL+Qt::Key_E);
    file->insertItem("&New view", this, SLOT(newView()), Qt::CTRL+Qt::Key_N);
    file->insertSeparator();
    file->insertItem("&Print...", this, SLOT(print()), Qt::CTRL+Qt::Key_P);
    file->insertSeparator();
    file->insertItem("E&xit", qApp, SLOT(quit()), Qt::CTRL+Qt::Key_Q);
    menu->insertItem("&File", file);

    Q3PopupMenu* edit = new Q3PopupMenu( menu );
    edit->insertItem("Add &Circle", this, SLOT(addCircle()), Qt::ALT+Qt::Key_C);
    edit->insertItem("Add &Hexagon", this, SLOT(addHexagon()), Qt::ALT+Qt::Key_H);
    edit->insertItem("Add &Polygon", this, SLOT(addPolygon()), Qt::ALT+Qt::Key_P);
    edit->insertItem("Add Spl&ine", this, SLOT(addSpline()), Qt::ALT+Qt::Key_I);
    edit->insertItem("Add &Text", this, SLOT(addText()), Qt::ALT+Qt::Key_T);
    edit->insertItem("Add &Line", this, SLOT(addLine()), Qt::ALT+Qt::Key_L);
    edit->insertItem("Add &Rectangle", this, SLOT(addRectangle()), Qt::ALT+Qt::Key_R);
    edit->insertItem("Add &Sprite", this, SLOT(addSprite()), Qt::ALT+Qt::Key_S);
    edit->insertItem("Create &Mesh", this, SLOT(addMesh()), Qt::ALT+Qt::Key_M );
    edit->insertItem("Add &Alpha-blended image", this, SLOT(addButterfly()), Qt::ALT+Qt::Key_A);
    menu->insertItem("&Edit", edit);

    Q3PopupMenu* view = new Q3PopupMenu( menu );
    view->insertItem("&Enlarge", this, SLOT(enlarge()), Qt::SHIFT+Qt::CTRL+Qt::Key_Plus);
    view->insertItem("Shr&ink", this, SLOT(shrink()), Qt::SHIFT+Qt::CTRL+Qt::Key_Minus);
    view->insertSeparator();
    view->insertItem("&Rotate clockwise", this, SLOT(rotateClockwise()), Qt::CTRL+Qt::Key_PageDown);
    view->insertItem("Rotate &counterclockwise", this, SLOT(rotateCounterClockwise()), Qt::CTRL+Qt::Key_PageUp);
    view->insertItem("&Zoom in", this, SLOT(zoomIn()), Qt::CTRL+Qt::Key_Plus);
    view->insertItem("Zoom &out", this, SLOT(zoomOut()), Qt::CTRL+Qt::Key_Minus);
    view->insertItem("Translate left", this, SLOT(moveL()), Qt::CTRL+Qt::Key_Left);
    view->insertItem("Translate right", this, SLOT(moveR()), Qt::CTRL+Qt::Key_Right);
    view->insertItem("Translate up", this, SLOT(moveU()), Qt::CTRL+Qt::Key_Up);
    view->insertItem("Translate down", this, SLOT(moveD()), Qt::CTRL+Qt::Key_Down);
    view->insertItem("&Mirror", this, SLOT(mirror()), Qt::CTRL+Qt::Key_Home);
    menu->insertItem("&View", view);

    menu->insertSeparator();

    Q3PopupMenu* help = new Q3PopupMenu( menu );
    help->insertItem("&About", this, SLOT(help()), Qt::Key_F1);
    help->setItemChecked(dbf_id, TRUE);
    menu->insertItem("&Help",help);

    statusBar();

    setCentralWidget(editor);

    printer = 0;

    init();
}
   void step()
    {
     ulen ind=random.select(Len);

     if( ind<rec_len )
       {
        check(rec[ind]);

        switch( random.select(3) )
          {
           case 0 :
            {
             free(ind);
            }
           break;

           case 1 :
            {
             extend(rec[ind]);
            }
           break;

           case 2 :
            {
             shrink(rec[ind]);
            }
           break;
          }
       }
     else
       {
        alloc(random.select(0,MaxAllocLen));
       }
    }
Beispiel #12
0
/* returns 0 if the function was successful, or -1 if there was an error */
int erase(vector* list, int first, int last) {
  if ((first < 0) || (last <= 0)) {
#ifdef VECTOR_DEBUG
    fprintf(stderr, "Error: index can't be negative.\n");
#endif
    return -1;
  }
  if (first >= last) {
#ifdef VECTOR_DEBUG
    fprintf(stderr, "Error: first index is higher than or equal to last index.\n");
#endif
    return -1;
  }
  if ((first > list->elements) || (last > list->elements)) {
#ifdef VECTOR_DEBUG
    fprintf(stderr, "Error: one of the arguments is too large.\n");
#endif
    return -1;
  }

  int remove_length = last - first;
  int new_size = list->elements - (last - first); // remove(0, 5) should remove 0..4, so 5 elements total

  for (int i = first; i < new_size; i++) {
    list->data[i] = list->data[i+remove_length];
  }

  if (new_size < (list->array_size) / 4) {
    shrink(list);
  }
  list->elements = new_size;
  return 0;
}
Beispiel #13
0
static void pop(const gulong p)
{
	--qnum;
	if(qnum == 0) {
		qstart = 0;
		qend = -1;
	} else if(p == qstart)
		qstart = (qstart + 1) % qsz;
	else {
		gulong pi;
		if((p >= qstart && p < qstart + qnum / 2) || (p < qstart && p < (qstart + qnum / 2) % qsz)) {
			pi = p;
			while(pi != qstart) {
				const gulong pi_next = (pi == 0 ? qsz - 1 : pi - 1);
				q[pi] = q[pi_next];
				pi = pi_next;
			}
			qstart = (qstart + 1) % qsz;
		} else {
			pi = p;
			while(pi != qend) {
				const gulong pi_next = (pi + 1) % qsz;
				q[pi] = q[pi_next];
				pi = pi_next;
			}
			qend = (qend == 0 ? qsz - 1 : qend - 1);
		}
	}
	shrink();
}
Beispiel #14
0
int
ymempool_shrink(struct ymempool *mp, int margin) {
	lock(mp);
	shrink(mp, margin);
	unlock(mp);
	return 0;
}
int SrsConsumer::get_packets(int max_count, SrsSharedPtrMessage**& pmsgs, int& count)
{
	int ret = ERROR_SUCCESS;
	
	if (msgs.empty()) {
		return ret;
	}

	if (paused) {
		if ((int)msgs.size() >= PAUSED_SHRINK_SIZE) {
			shrink();
		}
		return ret;
	}
	
	if (max_count == 0) {
		count = (int)msgs.size();
	} else {
		count = srs_min(max_count, (int)msgs.size());
	}
	
	pmsgs = new SrsSharedPtrMessage*[count];
	
	for (int i = 0; i < count; i++) {
		pmsgs[i] = msgs[i];
	}
	
	if (count == (int)msgs.size()) {
		msgs.clear();
	} else {
		msgs.erase(msgs.begin(), msgs.begin() + count);
	}
	
	return ret;
}
Beispiel #16
0
void WInputDialog::initialize() {
/*******************************/

    WPoint avg;
    WPoint max;
    textMetrics( avg, max );
    int sp = max.x();

    int x = WSystemMetrics::dialogFrameWidth();
    int y = WSystemMetrics::dialogFrameHeight();

    int p_w = 0;
    int p_h = 0;
    updateExtents( _promptText, &p_w, &p_h );
    p_w += avg.x() / 2;
    p_h += avg.y() / 2;
    int r_w = 32 * avg.x();
    int r_h = max.y() + 2*max.y() / 3;
    updateExtents( *_reply, &r_w, &r_h );

    _prompt = new WText( this, WRect( x, y + (r_h - p_h)/2, p_w, p_h ), _promptText );
    _prompt->show();
    _input = new WEditBox( this, WRect( x + p_w + sp, y, r_w, r_h ), *_reply );
    _input->show();
    y += p_h + max.y();

    int b_w = 0;
    int b_h = 0;
    updateExtents( BrowseText, &b_w, &b_h );
    updateExtents( CancelText, &b_w, &b_h );
    updateExtents( OKText, &b_w, &b_h );
    b_w += avg.x() * 2;
    b_h += avg.y() / 2;
    WDefPushButton *bOk = new WDefPushButton( this, WRect( x, y, b_w, b_h ),
                                              OKText );
    bOk->onClick( this, (cbw)&WInputDialog::okButton );
    bOk->show();
    x += b_w + max.x();

    WPushButton *bCancel = new WPushButton( this, WRect( x, y, b_w, b_h ),
                                            CancelText );
    bCancel->onClick( this, (cbw)&WInputDialog::cancelButton );
    bCancel->show();
    x += b_w + max.x();

    if( _browseDialog ) {
        WPushButton *bBrowse = new WPushButton( this,
                                                WRect( x, y, b_w, b_h ),
                                                BrowseText );
        bBrowse->onClick( this, (cbw)&WInputDialog::browseButton );
        bBrowse->show();
    }

    shrink();
    centre();

    _input->select();
    _input->setFocus();
    show();
}
Beispiel #17
0
void TupConfigurationArea::hideConfigurator()
{
    QWidget *widget = this->widget();

    if (widget && !isFloating ()) {
        // widget->setMinimumWidth(10);
        widget->setVisible(false);
        setFeatures(QDockWidget::NoDockWidgetFeatures);

        // =================

        QPalette pal = palette();
        pal.setBrush(QPalette::Background, pal.button());
        setPalette(pal);
        setAutoFillBackground(true);

        //==================

        for (int i = 0; i < 2; ++i) 
             qApp->processEvents();

        shrink();

        if (!k->toolTipShowed) {
            QToolTip::showText (k->mousePos, tr("Cursor here for expand"), this);
            k->toolTipShowed = true;
        }
    }

    k->mousePos = QCursor::pos();
}
Beispiel #18
0
BOOL CViewMsgDlg::OnInitDialog() 
{
	CMyDlg::OnInitDialog();

	m_msgEdit.AutoURLDetect(TRUE);
	m_msgEdit.SetBackgroundColor(FALSE, GetSysColor(COLOR_3DFACE));

	CRect rc;
	GetWindowRect(rc);
	wholeSize = rc.Size();

	shrink();

	SetDlgItemText(IDC_UIN, contact->qid.toString());
	SetDlgItemText(IDC_NICK, contact->nick.c_str());
	SetDlgItemText(IDC_EMAIL, contact->email.c_str());
	m_btnPic.SetIcon(getApp()->getLargeFace(contact->face));

	in_addr addr;
	addr.s_addr = htonl(contact->ip);
	SetDlgItemText(IDC_ADDR, inet_ntoa(addr));
	SetDlgItemInt(IDC_PORT, contact->port, FALSE);

	OnNextMsg();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #19
0
void burnDialog::checkFw(QString fileName)
{
  if (fileName.isEmpty()) {
    return;
  }

  if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
    ui->EEbackupCB->show();
  }
  else {
    ui->EEbackupCB->setChecked(false);
    *backup=false;
  }
  ui->FWFileName->setText(fileName);
  FlashInterface flash(fileName);
  if (flash.isValid()) {
    ui->FramFWInfo->show();
    ui->DateField->setText(flash.getDate() + " " + flash.getTime());
    ui->versionField->setText(flash.getVersion());
    ui->ModField->setText(flash.getEEprom());

    ui->SplashFrame->hide();
    if (flash.hasSplash()) {
      ui->SplashFrame->show();
      ui->imageLabel->setFixedSize(flash.getSplashWidth(), flash.getSplashHeight());
    }
  }
  else {
    QMessageBox::warning(this, tr("Warning"), tr("%1 may not be a valid firmware file").arg(fileName));
  }  
  ui->BurnFlashButton->setEnabled(true);
  QTimer::singleShot(0, this, SLOT(shrink()));
  g.flashDir( QFileInfo(fileName).dir().absolutePath() );
}
Beispiel #20
0
void Heap::collect(SweepToggle sweepToggle)
{
    ASSERT(globalData()->identifierTable == wtfThreadData().currentIdentifierTable());
    JAVASCRIPTCORE_GC_BEGIN();

    markRoots();
    m_handleHeap.finalizeWeakHandles();
    m_globalData->smallStrings.finalizeSmallStrings();

    JAVASCRIPTCORE_GC_MARKED();
    
    resetAllocator();

#if ENABLE(JSC_ZOMBIES)
    sweepToggle = DoSweep;
#endif

    if (sweepToggle == DoSweep) {
        sweep();
        shrink();
    }

    // To avoid pathological GC churn in large heaps, we set the allocation high
    // water mark to be proportional to the current size of the heap. The exact
    // proportion is a bit arbitrary. A 2X multiplier gives a 1:1 (heap size :
    // new bytes allocated) proportion, and seems to work well in benchmarks.
    size_t proportionalBytes = 2 * size();
    m_newSpace.setHighWaterMark(max(proportionalBytes, minBytesPerCycle));

    JAVASCRIPTCORE_GC_END();

    (*m_activityCallback)();
}
Beispiel #21
0
/**
 * Copies data from this buffer to the "dst" address. The buffer is
 * shrunk if possible. If the "dst" address is NULL, then the message
 * is dequeued but is not copied.
 */
void
circular_buffer::dequeue(void *dst) {
    assert(unit_sz > 0);
    assert(_unread >= unit_sz);
    assert(_unread <= _buffer_sz);
    assert(_buffer);

    KLOG(kernel, mem,
             "circular_buffer dequeue "
             "unread: %d, next: %d, buffer_sz: %d, unit_sz: %d",
             _unread, _next, _buffer_sz, unit_sz);

    assert(_next + unit_sz <= _buffer_sz);
    if (dst != NULL) {
        memcpy(dst, &_buffer[_next], unit_sz);
    }
    KLOG(kernel, mem, "shifted data from index %d", _next);
    _unread -= unit_sz;
    _next += unit_sz;
    if (_next == _buffer_sz) {
        _next = 0;
    }

    // Shrink if possible.
    if (_buffer_sz > initial_size() && _unread <= _buffer_sz / 4) {
        shrink();
    }
}
Beispiel #22
0
void rootisharraystack_clear(rootisharraystack_t* r) {

    assert((void *)r != NULL);

    r->length = 0;
    shrink(r);
}
Beispiel #23
0
void jacobi( cmattyp m, cvectyp lv, cmattyp h, cmattyp h1 )
{
  cmattyp subjac, subh, subh1;
  int i, k;

  for ( i = 0; i < 4; i++)
    for ( k = 0; k < 4; k++ )
      if ( blabs( m[i][k] ) < 1.0e-6 )
        m[i][k] = cero;
  for ( k = 0; k < 4 - 1; k++)
  {
    shrink( k, subjac, m);
    hsubjac( 4 - k, subjac, lv[k], subh);
    swell( k, subh);
    cmatcpy( subh1, subh );
    cmatinv( subh1 );
    if ( k == 0 )
    {
      cmatcpy( h, subh);
      cmatcpy( h1, subh1);
    }
    else
    {
      cmatmul( subh, h);
      cmatmul1( h1, subh1);
    }
    cmatmul1( m, subh1);
    cmatmul( subh, m);
  }
  for ( i = 1; i < 4; i++ )
    for ( k = 0; k < i; k++ )
      m[i][k] = cero;
}
Beispiel #24
0
void rootisharraystack_remove(rootisharraystack_t* r, size_t pos,
                              void* elem_out) {

    size_t i;
    void* tmp;

    assert((void *)r != NULL);
    assert(pos < r->length);

    tmp = malloc(r->elem_size);
    assert(tmp != NULL);

    if (elem_out != NULL)
        rootisharraystack_get(r, pos, elem_out);

    for (i = pos; i < r->length - 1; ++i) {
        rootisharraystack_get(r, i + 1, tmp);
        rootisharraystack_set(r, i, tmp, NULL);
    }

    --r->length;

    if (alloclen(r->b_length - 2) >= r->length)
        shrink(r);

    free(tmp);
}
Beispiel #25
0
void VAbout::initialize()
{
    int fw = WSystemMetrics::dialogFrameWidth();
    int fh = WSystemMetrics::dialogFrameHeight();
    int wid = 0;
    int yoff = fh;
    for( int i=0; _viperDesc[i] != NULL; i++ ) {
        int w = getTextExtentX( _viperDesc[i] );
        int h = getTextExtentY( _viperDesc[i] );
        if( w > 0 ) {
            if( wid < w ) wid = w;
            WText* t1 = new WText( this, WRect(fw, yoff, w, h), _viperDesc[i] );
//          WText* t1 = new WText( this, WRect(fw, yoff, w, h), _viperDesc[i], TextStyleCentre );
            yoff += h * 5/4;
            t1->show();
        }
    }
    wid += fw * 2;

    static const char ok[] = { "OK" };
    int w = getTextExtentX( ok ) * 3;
    int h = getTextExtentY( ok ) * 3/2;
    int xoff = (wid - w) / 2;
    WDefPushButton* bOk = new WDefPushButton( this, WRect( xoff, yoff, w, h), "OK" );
    yoff += h * 5/4;
    bOk->onClick( this, (cbw)&VAbout::okButton );
    bOk->show();

    shrink();
    centre();

    show();
    bOk->setFocus();
}
Beispiel #26
0
tlNum* tlNumMul(tlNum* lhs, tlNum* rhs) {
    int point = max(lhs->point, rhs->point);
    int ldiff = point - lhs->point;
    int rdiff = point - rhs->point;
    assert(point >= 0 && ldiff >= 0 && rdiff >= 0);
    int digits = lhs->digits + rhs->digits + max(ldiff, rdiff);
    tlNum* res = tlNumNewInternal(digits);

    for (int il = 0; il < lhs->digits + ldiff; il++) {
        int c = 0;
        for (int ir = 0; ir < rhs->digits + rdiff; ir++) {
            int li = il;// - ldiff;
            int ri = ir;// - rdiff;
            int l = (li >= 0 && li < lhs->digits)? lhs->data[li] : 0;
            int r = (ri >= 0 && ri < rhs->digits)? rhs->data[ri] : 0;
            int m = (res->data[il + ir] + l * r + c);
            //print("[%d] = %d (%d + %d * %d + %d", il + ir, m, res->data[il + ir], l, r, c);
            res->data[ir + il] = m % BASE;
            c = m / BASE;
        }
        res->data[rhs->digits + il] = res->data[rhs->digits + il] + c;
    }
    res->point = lhs->point + rhs->point;

    return shrink(res);
}
void DDockInternalWidget::setExpanded(bool v)
{
	QSettings config;
	config.beginGroup("DLSLib-"+objectName());
	
	if (m_visible)
	{
		config.setValue( "ViewWidth", m_position == DDockWindow::Bottom ? height() : width() );
	}
	
	m_widgetStack->setVisible(v);
	
	m_internalLayout->invalidate();
	
	m_visible = v;

	if ( ! v)
	{
		for (int i = 0; i < 2; ++i)
			qApp->processEvents();
		shrink();
		
		if ( m_toggledButton) m_toggledButton->setChecked(false);
	}
}
uint32_t   AUDMAudioFilterLimiter::fill(uint32_t max,float *output,AUD_Status *status)
{
  uint32_t len,i;
  
  shrink();
  fillIncomingBuffer(status);
  
  
  len=_tail-_head;
  if(len>max) len=max;
  if(len>=DELIM_WINDOW_SIZE) len=DELIM_WINDOW_SIZE-1;
  
  // Count in full sample  i.e. all channels
  len=len-(len%_wavHeader.channels);
  
  // Process..
  if (mLastLevel == 0.0) {
    int preSeed = mCircleSize;
    if (preSeed > len)
      preSeed = len;
    for(i=0; i<preSeed; i++)
      AvgCircle(_incomingBuffer[_head+i]);
  }
  
    for (i = 0; i < len; i++) {
      Follow(_incomingBuffer[_head+i], &follow[i], i);
    }

    for (i = 0; i < len; i++) {
      output[i] =DoCompression(_incomingBuffer[_head+i], follow[i]);
    }  
    _head+=len;
    return len;
}
Beispiel #29
0
void smoothMesh( Polyhedron & poly, unsigned int nTimes )
{
    int nV = poly.size_of_vertices();
    const double lambda = SMOOTHING_LAMBDA;
    const double mu	= SMOOTHING_MU;

    vector< Point3 > shrink  ( nV );
    vector< Point3 > expand  ( nV );

    for ( unsigned int k = 0; k < nTimes; ++k ) {
	// copy the vertex coordinates
	for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
	    shrink  [ vi->id() ] = vi->point();
	}
	// shrinking stage
	for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
	    moveVertex( vi, shrink[ vi->id() ], lambda );
	}
	// copy back the vertex coordinates
	for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
	    vi->point()		= shrink[ vi->id() ];
	    expand[ vi->id() ]	= shrink[ vi->id() ];
	}
	// expanding stage
	for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
	    moveVertex( vi, expand[ vi->id() ], mu );
	}
	// copy back the vertex coordinates
	for ( Vertex_iterator vi = poly.vertices_begin(); vi != poly.vertices_end(); ++vi ) {
	    vi->point()		= expand[ vi->id() ];
	}
    }
}
void*
hashtable_remove(struct hashtable* h, char* key, unsigned int keylen)
{
    assert(h != NULL);

    /* Compute the hash to index into array. */
    int index = hash(key, keylen) % h->arraysize;
    struct list* chain = h->vals[index];
    assert(chain != NULL);
    
    /* Build a kv_pair object with the query key. */
    struct kv_pair query_item;
    query_item.key = key;
    query_item.keylen = keylen;

    struct kv_pair* removed
        = (struct kv_pair*)list_remove(chain, &query_item, &key_comparator);
    if (removed == NULL) {
        /* Key does not exist. */
        return NULL;
    }

    /* Key value pair removed. */
    --h->size;
    if (h->arraysize > h->init_size &&
        compute_load(h->size - 1, h->arraysize) < h->load_factor) {
        /* Half the size of array. */
        shrink(h);
    }
    void* res = removed->val;
    free(removed);
    
    return res;
}