Пример #1
0
void refine_offset(void *l,double *out_t,double *out_x)
{
	int i;
	imgLocRec *loc=(imgLocRec *)l;
	
	loc->offT=0.0,loc->offX=0.0;
	errorVsTimeAz(loc->offT,loc);
	errorVsTimeRng(loc->offX,loc);
	printPosError(loc);
	
#ifndef CHECK_OFFSET
	for (i=0;i<20;i++)
	{
		loc->offT = minimize((minFunc)errorVsTimeAz,(void *)loc,loc->offT,0.0001);
		loc->offX = minimize((minFunc)errorVsTimeRng,(void *)loc,loc->offX,1.0);
		printf("Offsets: Time=%f s; Slant Range=%f m\n",loc->offT,loc->offX);
	}
	
	errorVsTimeAz(loc->offT,loc);
	errorVsTimeRng(loc->offX,loc);
	printPosError(loc);
#endif
	*out_t=loc->offT;
	*out_x=loc->offX;
}
Пример #2
0
bool RecordEnumerator::doBacktrack(Solver& s, uint32 bl) {
	assert(bl >= s.rootLevel());
	if (!projectionEnabled()) {
		addSolution(s);
	}
	bl = std::min(bl, assertionLevel(s));
	if (s.backtrackLevel() > 0) {
		// must clear backtracking level;
		// not needed to guarantee redundancy-freeness
		// and may inadvertently bound undoUntil()
		s.setBacktrackLevel(0);
	}
	s.undoUntil(bl);
	if (solution_.empty()) {
		assert(minimize() && minimize()->mode() == MinimizeConstraint::compare_less);
		return true;
	}
	bool r = true;
	if (solution_.size() < 4) {
		r = solution_.end();
	}
	else {
		Literal x;
		if (s.isFalse(solution_[solution_.secondWatch()])) {
			x = solution_[0];
		}
		LearntConstraint* c = Clause::newLearntClause(s, solution_.lits(), Constraint_t::learnt_conflict, solution_.secondWatch());
		nogoods_.push_back((Clause*)c);
		r = s.force(x, c);
	}
	return r || s.resolveConflict();
}
Пример #3
0
    bool IntersectRayAABB(const Ray& r, const AABB& a, float* out_tmin, float3* out_pos, float3* out_nor)
    {
        const float3& p = r.pos;
        const float3& d = r.direction;
        float tmin = -FLT_MAX;
        float tmax = FLT_MAX;
        float3 minNorm, maxNorm;
        
        // check vs. all three 'slabs' of the aabb
        for(int i = 0; i < 3; ++i)
        {
            if(abs(d[i]) < Epsilon) 
            {   // ray is parallel to slab, no hit if origin not within slab
                if(p[i] < a.Min()[i] || p[i] > a.Max()[i] )
                {
                    return false;
                }
            }
            else
            {
                // compute intersection t values of ray with near and far plane of slab
                float ood = 1.0f / d[i];
                float t1 = (a.Min()[i] - p[i]) * ood;
                float t2 = (a.Max()[i] - p[i]) * ood;
                tmin = maximize(tmin, minimize(t1, t2));
                tmax = minimize(tmax, maximize(t1, t2));

                // exit with no collision as soon as slab intersection becomes empty
                if(tmin > tmax) 
                {
                    return false;
                }
            }
        }
        
        if(tmax < 0.f)
        {
            // entire bounding box is behind us
            return false;
        }
        else if(tmin < 0.f)
        {
            // we are inside the bounding box
            *out_tmin = 0.f;
            *out_pos = p;
            *out_nor = normalize(a.GetCenter() - (*out_pos)); // use 'sphere' type normal calculation to approximate.
            return true;
        }
        else
        {
            // ray intersects all 3 slabs. return point and normal of intersection
            *out_tmin = tmin;
            *out_pos = p + d * tmin;
            *out_nor = normalize(a.GetCenter() - (*out_pos)); // use 'sphere' type normal calculation to approximate.
            return true;
        }
    }
Пример #4
0
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
        switch (Msg) {
	case WM_USER:
		switch (lParam) {
		case WM_LBUTTONDBLCLK:
			ShowWindow(hWndDlg, SW_SHOW);
			return TRUE;
		}
		break;
		
	case WM_TERM:
		do_stop(hWndDlg);
		break;

	case WM_INITDIALOG:
		_hwnd = hWndDlg;
		do_init();
		do_stop(_hwnd);

		start_stop(hWndDlg); /* didn't we say on by default? ;D */
		break;

	case WM_SYSCOMMAND:
		if ((wParam & 0xfff0) == SC_MINIMIZE) {
			minimize(hWndDlg);
			return TRUE;
		}
		break;

        case WM_CLOSE:
		minimize(hWndDlg);
                return TRUE;

        case WM_COMMAND:
                switch(wParam) {
		case IDOK:
			start_stop(hWndDlg);
			return TRUE;
		case IDCANCEL:
			netstat();
			return TRUE;

		case IDC_BUTTON1:
			EndDialog(hWndDlg, 0);
			return TRUE;

		case IDC_BUTTON2:
			hof();
			return TRUE;
		}
		break;
	}

	return FALSE;
}
Пример #5
0
int main() {
    int test_count;
    scanf("%d", &test_count);
    while (test_count --) {
        scanf("%d%d", &n, &m);
        power = 1;
        for (int i = 0; i < m; ++ i) {
            power *= MAGIC;
        }

        std::vector <Hash> hashes;
        for (int i = 0; i < n; ++ i) {
            for (int j = 0; j < m; ++ j) {
                scanf("%d", a + j);
            }
            hashes.push_back(minimize());
        }

        std::sort(hashes.begin(), hashes.end());
        //int answer = n * (n - 1) / 2;
        for (int i = 0; i < n; ) {
            int j = i;
            while (j < n && hashes[i] == hashes[j]) {
                j ++;
            }
            //int s = j - i;
            //answer -= s * (s - 1) / 2;
            i = j;
        }
        printf("%d\n", (int)(std::unique(hashes.begin(), hashes.end()) - hashes.begin()));
        //printf("%d\n", answer);
    }
    return 0;
}
Пример #6
0
void RegExpTest::test6()	{
	RegExp<char> regexp;
	regexp.evaluate("a.a.b");
	std::cout << "test6 dfa:\n" << regexp.dfa() << std::endl;
	
	Nfa<char> nfa1 = to_nfa(regexp.dfa());
	std::cout << "test6 nfa1:\n" << nfa1 << std::endl;
	
	Nfa<char> nfa2 = nfa_reverse(nfa1);
	std::cout << "test6 nfa2:\n" << nfa2 << std::endl;

	Dfa<char> dfa2 = normalize(minimize(to_dfa(nfa2)));
	std::cout << "test6 dfa2:\n" << dfa2 << std::endl;
	
	CHECK(dfa2, s_, false);
	CHECK(dfa2, s_a, false);
	CHECK(dfa2, s_b, false);
	CHECK(dfa2, s_aa, false);
	CHECK(dfa2, s_bb, false);
	CHECK(dfa2, s_baa, true);


	

}
Пример #7
0
void CGenericLoss::Evaluate(CModel *model)
{
  TheMatrix &w = _model->GetW(); 
  double* dat = w.Data();

  Configuration &config = Configuration::GetInstance();
  string outFile = config.GetString("Data.labelOutput");
  FILE* f = fopen(outFile.c_str(), "w");

  {
    map<int,int> ybar;
    pair<int,double>* confidences = new pair<int,double> [data->nodeFeatures.size()];
    minimize(data->nodeFeatures, &(data->nodeLabels), data->edgeFeatures, dat, dat + data->nNodeFeatures, ybar, data->nNodeFeatures, data->nEdgeFeatures, data->lossPositive, data->lossNegative, data->indexEdge, confidences, 0, data->firstOrderResponses);

    printf("0/1 loss    = %f\n", LabelLoss(data->nodeLabels, ybar, data->lossPositive, data->lossNegative, ZEROONE));
    printf("scaled loss = %f\n", LabelLoss(data->nodeLabels, ybar, data->lossPositive, data->lossNegative, SCALED));
    printf("AvP = %f\n", AvP(confidences, data->nodeLabels));
    printf("loss = %f\n", LabelLoss(data->nodeLabels, ybar, data->lossPositive, data->lossNegative, LOSS));
    delete [] confidences;

    for (map<int,int>::iterator it = ybar.begin(); it != ybar.end(); it ++)
      if (it->second == 1)
        fprintf(f, "%ld\n", data->indexNode[it->first]);
  }
  
  fclose(f);
}
WeatherWidgetGraphicsView::WeatherWidgetGraphicsView()
{
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setWindowFlags(Qt::FramelessWindowHint);
	setAttribute(Qt::WA_TranslucentBackground,true);
	setAttribute(Qt::WA_ContentsPropagated,true);
    setCacheMode(CacheBackground);
    setViewportUpdateMode(FullViewportUpdate);
    setRenderHints(QPainter::Antialiasing | 
    			   QPainter::SmoothPixmapTransform | 
    		       QPainter::TextAntialiasing);

    // transparent background	
    QPalette palette = this->palette();
    palette.setBrush(QPalette::Base, Qt::transparent);
    setPalette(palette);
    setAttribute(Qt::WA_OpaquePaintEvent, false); // trasmit color 
	setFrameStyle(QFrame::NoFrame);
	
    iScene = new QGraphicsScene(this);
	setScene(iScene);
	resize(KWindowWidth+KExtraStrech,KWindowHeight+KExtraStrech);
	
	// Create main window which holds weather data
	iMainWindow = new WeatherGraphicsWindow(this);
	iScene->addItem(iMainWindow);
	iMainWindow->setZValue(0);
	iMainWindow->setObjectName("mainwindow");
	connect(iMainWindow,SIGNAL(minimize()),
			this,SLOT(on_mainwindow_minimize()));
	connect(iMainWindow,SIGNAL(temperatureUpdated(const QString&)),
			this,SLOT(setWindowTitle(const QString&)));
	
}
Пример #9
0
WindowManagerWindow::WindowManagerWindow( Window window ):
	_x11Window( window )
{
	_previousState = _state = Normal;

	_normalX = _normalY = 0;
	_normalWidth = _normalHeight = 600;

	_maximizedX = _maximizedY = 0;
	_maximizedWidth = XLibWrapper::getScreenWidth( XLibWrapper::getScreenForWindow(_x11Window) );
	_maximizedHeight = XLibWrapper::getScreenHeight( XLibWrapper::getScreenForWindow(_x11Window) );

	// init the titlebar
	_titleBar = new TitleBar();
	std::string windowName = XLibWrapper::getWindowName( _x11Window );
	_titleBar->setTitlebarText( windowName.c_str() );
	
	connect( _titleBar, SIGNAL(minimizeButton()), this, SLOT(minimize()) );
	connect( _titleBar, SIGNAL(maximizeButton()), this, SLOT(maximize()) );
	connect( _titleBar, SIGNAL(closeButton()), this, SLOT(close()) );
	connect( _titleBar, SIGNAL(titleDragged(int,int)), this, SLOT(move(int,int)) );

	// init the bottombar
	_bottomBar = new BottomBar();
	connect( _bottomBar, SIGNAL(reizeLeft(int,int)), this, SLOT(resizeLeft(int,int)) );	
	connect( _bottomBar, SIGNAL(reizeRight(int,int)), this, SLOT(resizeRight(int,int)) );	
}
Пример #10
0
void Geom::AABB::add( QVector<Vector3>& pnts )
{
	for (Point p : pnts) {
		bbmin = minimize(bbmin, p);
		bbmax = maximize(bbmax, p);
	} 
}
Пример #11
0
 typename VectorSpaceTraits<VectorSpace>::Vectors
 minimize(typename VectorSpaceTraits<VectorSpace>::Vectors& x, Function df,
          StepSizeRule& step_size_rule, UpdateRule update_rule,
          AbortCriterion abort_criterion)
 {
   minimize(x, df, step_size_rule, update_rule, abort_criterion, NullLogger());
 }
Пример #12
0
void SysTrayIconPlugin::slotSysTrayActivated(QSystemTrayIcon::ActivationReason reason)
{
#ifdef Q_WS_MAC
  // on mac simple clic gives the menu; don't automatically activate window.
  if (reason == QSystemTrayIcon::Trigger)
    return;
#endif

  if (reason == QSystemTrayIcon::Trigger) {
    if ( ! _mainwin->isVisible() ) {
      restore();
    } else {
      if ( QApplication::activeWindow() != NULL ) {
	minimize();
      } else {
	restore();
      }
    }
  }
  if (reason == QSystemTrayIcon::DoubleClick) {
    latexFromClipboard();
  }
  if (reason == QSystemTrayIcon::MiddleClick) {
    // paste mouse selection
    latexFromClipboard(QClipboard::Selection);
  }
}
Пример #13
0
int minimize(int maxValue)
{
    if(maxValue%4==0)
    {
        int n1=0,n2=0,temp=maxValue;
        while(temp%10==0)
        {
            n1++;
            temp/=10;
        }
        temp=maxValue/4;
        while(temp%10==0)
        {
            n2++;
            temp/=10;
        }
        if(n1==n2)
            return minimize(maxValue/4);
        else
          return  maxValue;
    }
    else
        return maxValue;

}
Пример #14
0
bool SysTrayIconPlugin::eventFilter(QObject *obj, QEvent *e)
{
  if (obj == _systrayicon && e->type() == QEvent::ToolTip) {
    // works on X11 only
    if (_config->readValue("restoreonhover").toBool()) {
      restore();
    }
  }

  //#ifndef KLF_MAC_HIDE_INSTEAD ... well yes do this too, except by default disable this option
  if (obj == _mainwin && e->type() == QEvent::WindowStateChange) {
    if ( _mainwin->property("x11WindowShaded").toBool() )
      return false; // don't take action if the window is just shaded

    klfDbg("main win window state changed: oldState="<<((QWindowStateChangeEvent*)e)->oldState()
	   <<" new state="<<_mainwin->windowState()) ;
    if ( _config->readValue("systrayon").toBool() &&
	 _config->readValue("mintosystray").toBool() &&
	(_mainwin->windowState() & Qt::WindowMinimized) &&
	!(((QWindowStateChangeEvent*)e)->oldState() & Qt::WindowMinimized)
	) {
      // the user minimized the window, and we want to minimize it to system tray.
      QTimer::singleShot(20, this, SLOT(minimize()));
    }
  }
  //#endif // KLF_MAC_HIDE_INSTEAD

  return false;
}
Пример #15
0
int Form1::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: quit(); break;
        case 1: play(); break;
        case 2: musinfo(); break;
        case 3: stop(); break;
        case 4: slR(); break;
        case 5: slP(); break;
        case 6: opcje(); break;
        case 7: showplaylist(); break;
        case 8: timrefDo(); break;
        case 9: funkcje_opn(); break;
        case 10: info(); break;
        case 11: aWAV(); break;
        case 12: slAT((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 13: setVol((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 14: savMus(); break;
        case 15: nextB(); break;
        case 16: prevB(); break;
        case 17: AboutQMP(); break;
        case 18: NextXs(); break;
        case 19: volup(); break;
        case 20: voldown(); break;
        case 21: minimize(); break;
        case 22: seekP((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 23: setVolR((*reinterpret_cast< int*(*)>(_a[1]))); break;
        case 24: pwp(); break;
        case 25: pwl(); break;
        case 26: netA(); break;
        case 27: selA(); break;
        case 28: SoH(); break;
        case 29: mnuAct((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break;
        case 30: checkUpdatesButton(); break;
        case 31: checkUpdates(); break;
        case 32: updateQVis(); break;
        case 33: BTpause(); break;
        case 34: showEq(); break;
        case 35: volMnu(); break;
        case 36: setBothVolB(); break;
        case 37: TrayMessageClicked(); break;
        case 38: showMnuOpt(); break;
        case 39: miniQMP(); break;
        case 40: showTrayMnu(); break;
        case 41: setVolFromMiniQMP((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 42: opisQMP(); break;
        case 43: resetInfoWindow(); break;
        case 44: miniVersion(); break;
        case 45: copyTitleA(); break;
        case 46: fileChanged(); break;
        default: ;
        }
        _id -= 47;
    }
    return _id;
}
Пример #16
0
bool ofxGuiGroup::setValue(float mx, float my, bool bCheck){
    
	if( !isGuiDrawing() ){
		bGuiActive = false;
		return false;
	}


	if( bCheck ){
		if( b.inside(mx, my) ){
			bGuiActive = true;

			ofRectangle minButton(b.x+b.width-textPadding*3,b.y,textPadding*3,header);
			if(minButton.inside(mx,my)){
				minimized = !minimized;
				if(minimized){
					minimize();
				}else{
					maximize();
				}
				return true;
			}
        }
	}

	return false;
}
Пример #17
0
sequence_in_t TeacherBB::equivalenceQuery(const unique_ptr<DFSM>& conjecture) {
	_equivalenceQueryCounter++;
	auto tmp = _currState;
	auto model = FSMmodel::duplicateFSM(conjecture);
	if (!model->isReduced()) model->minimize();
	for (state_t extraStates = 0; extraStates < _maxExtraStates; extraStates++) {
		auto TS = _testingMethod(model, extraStates);
		for (const auto& test : TS) {
			auto bbOut = resetAndOutputQuery(test);
			_outputQueryCounter--;
			sequence_out_t modelOut;
			state_t state = 0;
			for (const auto& input : test) {
				auto ns = model->getNextState(state, input);
				if ((ns != NULL_STATE) && (ns != WRONG_STATE)) {
					modelOut.emplace_back(model->getOutput(state, input));
					state = ns;
				}
				else modelOut.emplace_back(WRONG_OUTPUT);
			}
			if (bbOut != modelOut) {
				_currState = tmp;
				return test;
			}
		}
	}
	_currState = tmp;
	return sequence_in_t();
}
Пример #18
0
// ------------------------------------------------------------------------------------------------
void Model::UpdateBounds()
{
    assert(m_constructed==true);
    const GeometryDict& geos = Geometries();
    if(geos.size()==0)
    {
        return;
    }

    float3 min = float3(FLT_MAX, FLT_MAX, FLT_MAX);
    float3 max = float3(-FLT_MAX, -FLT_MAX, -FLT_MAX);
    const NodeDict& nodes = Nodes();
    for(auto nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt)
    {
        Node* node = nodeIt->second;
        for(auto geoIt = node->geometries.begin(); geoIt != node->geometries.end(); ++geoIt)
        {
            Geometry * geo = (*geoIt);
            AABB bbox = geo->mesh->bounds;
            bbox.Transform(m_nodeTransforms[node->index]);
            min = minimize(min, bbox.Min());
            max = maximize(max, bbox.Max());
        }
    }
    // note: min & max already transformed by entire object world matrix
    m_bounds = AABB(min, max);
}
Пример #19
0
void EffectWindow::setMinimized(bool min)
{
    if (min) {
        minimize();
    } else {
        unminimize();
    }
}
Пример #20
0
static int phase2() {
  int j;
  jmax = n2;
  for (j = 0; j <= n; j++) {
    mpfr_set(a[0][j], c[j], GMP_RNDN);
  }

  return minimize();
}
Пример #21
0
//--------------------------------------------------------------
void ofxMuiWindow::toggleMaxMin()
{
	if(isMinimized) {
		maximize();		
	} else {
		minimize();
	}
	
}
Пример #22
0
void SysTrayIconPlugin::initialize(QApplication */*app*/, KLFMainWin *mainWin,
				   KLFPluginConfigAccess *rwconfig)
{
  _mainButtonBar = NULL;

  _mainwin = mainWin;
  _config = rwconfig;

  // set default settings
#ifdef Q_WS_MAC
  // Mac: offer to hide application by default
  _config->makeDefaultValue("systrayon", true);
#else
  // Win/Linux: disable sys tray icon by default
  _config->makeDefaultValue("systrayon", false);
#endif
  _config->makeDefaultValue("replacequitbutton", true);
#ifdef Q_WS_X11
  _config->makeDefaultValue("restoreonhover", true);
#endif
#ifndef KLF_MAC_HIDE_INSTEAD
  _config->makeDefaultValue("mintosystray", true);
#else
  _config->makeDefaultValue("mintosystray", false);
#endif

  QMenu *menu = new QMenu(mainWin);
  menu->addAction(tr("Minimize"), this, SLOT(minimize()));
  menu->addAction(tr("Restore"), this, SLOT(restore()));
  menu->addAction(QIcon(":/pics/paste.png"), tr("Paste From Clipboard"),
		  this, SLOT(latexFromClipboard()));
#ifdef Q_WS_X11
  menu->addAction(QIcon(":/pics/paste.png"), tr("Paste From Mouse Selection"),
		  this, SLOT(latexFromClipboardSelection()));
#endif
  menu->addAction(QIcon(":/pics/closehide.png"), tr("Quit"), mainWin, SLOT(quit()));

#ifndef KLF_MAC_HIDE_INSTEAD
  _systrayicon = new QSystemTrayIcon(QIcon(":/pics/klatexformula-32.png"), mainWin);
  _systrayicon->setToolTip("KLatexFormula");
  _systrayicon->setContextMenu(menu);
  _systrayicon->installEventFilter(this);
  connect(_systrayicon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
	  this, SLOT(slotSysTrayActivated(QSystemTrayIcon::ActivationReason)));
#else
  _systrayicon = NULL;
#endif

  _mainwin->installEventFilter(this);

  connect(_mainwin, SIGNAL(userActivity()), this, SLOT(restore()));

  apply();
}
Пример #23
0
void RecordEnumerator::addSolution(Solver& s) {
	solution_.clear(); solution_.setSolver(s);
	if (minimize() && minimize()->mode() == MinimizeConstraint::compare_less) return;
	solution_.start(Constraint_t::learnt_conflict);
	for (uint32 x = s.decisionLevel(); x != 0; --x) {
		solution_.add(~s.decision(x));
	}
	if (minimize() && minimize()->models() == 1) {
		ConstraintDB::size_type i, end, j = 0;
		for (i = 0, end = nogoods_.size(); i != end; ++i) {
			Clause* c = (Clause*)nogoods_[i];
			if (c->locked(s)) {
				nogoods_[j++] = c;
			}
			else {
				c->removeWatches(s);
				c->destroy();
			}
		}
		nogoods_.erase(nogoods_.begin()+j, nogoods_.end());
	}
}
Пример #24
0
// push Renderable nodes
//virtual
bool ControlPointGob::GetRenderables(RenderableNodeCollector* collector, RenderContext* context)
{
  
    Mesh* mesh = ShapeLibGetMesh(RenderShape::QuadLineStrip);
    m_localBounds = mesh->bounds;

    const float pointSize = 8; // control point size in pixels
    float upp = context->Cam().ComputeUnitPerPixel(float3(&m_world.M41),
        context->ViewPort().y);
    float scale = pointSize * upp;        
    Matrix scaleM = Matrix::CreateScale(scale);
    float3 objectPos = float3(m_world.M41,m_world.M42,m_world.M43);
    Matrix b = Matrix::CreateBillboard(objectPos,context->Cam().CamPos(),context->Cam().CamUp(),context->Cam().CamLook());
    Matrix billboard = scaleM * b;

    // calculate bounds for screen facing quad
    float3 transformed, min, max;
    transformed = mesh->pos[0];
    transformed.Transform(billboard);
    min = max = transformed;
    for (auto it = mesh->pos.begin(); it != mesh->pos.end(); ++it)
    {
        transformed = (*it);
        transformed.Transform(billboard);
        min = minimize(min, transformed);
        max = maximize(max, transformed);
    }
    m_bounds = AABB(min,max);

    // give it same color as curve
    int color = 0xFFFF0000;
    CurveGob* curve = (CurveGob*)m_parent;
    if(curve != NULL)
    {
        color = curve->GetColor();
    }

    // set renderable
    RenderableNode r;
    r.mesh = mesh;
    ConvertColor(color, &r.diffuse);
    r.objectId = GetInstanceId();
    r.bounds = m_bounds;
    r.WorldXform = billboard;
    r.SetFlag(RenderableNode::kTestAgainstBBoxOnly, true);
    r.SetFlag(RenderableNode::kShadowCaster, false);
    r.SetFlag(RenderableNode::kShadowReceiver, false);
    
    collector->Add(r, RenderFlags::None, Shaders::BasicShader);
    return true;
}
Пример #25
0
int getDeleteCount(Vert* vert, TableItem(*table)[MAX], int rootIndex){
	Edge* temp = vert[rootIndex].edge;
	TableItem usedForMinimize[MAX];
	int usedCount = 0;
	while (temp != NULL){
		TableItem item = getMemorize(vert, temp->to, rootIndex, table);
		usedForMinimize[usedCount++] = item;
		temp = temp->next;
	}
	if (usedCount == 1)
		return usedForMinimize[0].totalVertCount;
	int min = minimize(usedForMinimize, vert[rootIndex].edgeCount);
	return min;
}
Пример #26
0
//--------------------------------------------------------------
void ofxMuiWindow::update() {
    // not using events locally anymore. 
    if(minMaxButton->getValue()) {
        minimize();
    } else {
        maximize(); 
    }

    if(enableDisableButton->getValue()) {
        disable(); 
    } else {
        enable();   
    }
}
Пример #27
0
void solveCase(void)
{
    int num;
    scanf("%d",&num);
    max=num;
    int numofzeroes = countZeroes(num);

    if(numofzeroes == 0)
        printf("%d\n",num);
    else{
        //Now minimize the number
       printf( "%d\n",minimize(max));
    }
}
Пример #28
0
void memorize(Vert* vert, int rootIndex, int parent, TableItem(*table)[MAX]){
	int exceptVertCount = vert[rootIndex].edgeCount - 1;
	int needDeleteVertCount = 0;
	int totalVertCount = 0;
	if (exceptVertCount == 0){
		needDeleteVertCount = 0;
		totalVertCount = 1;
	}
	else if (exceptVertCount == 1){
		Edge* e = vert[rootIndex].edge;
		while (e != NULL){
			int to = e->to;
			if (to != parent){
				TableItem item = getMemorize(vert, e->to, rootIndex, table);
				needDeleteVertCount = item.totalVertCount;
				totalVertCount = item.totalVertCount + 1;
			}
			e = e->next;
		}
	}
	else if (exceptVertCount >= 2){
		TableItem usedForMinimize[MAX];
		int usedCount = 0;
		Edge* e = vert[rootIndex].edge;
		while (e != NULL){
			int to = e->to;
			if (to != parent){
				TableItem item = getMemorize(vert, to, rootIndex, table);
				usedForMinimize[usedCount++] = item;

				totalVertCount += item.totalVertCount;	//가지 정점의 개수
			}
			e = e->next;
		}
		int min = minimize(usedForMinimize, exceptVertCount);
		needDeleteVertCount = min;	//최소 삭제 개수
		totalVertCount += 1;	//자기자신 포함
	}
	//테이블에 결과 저장
	TableItem newItem;
	//newItem.parent = parent;
	//newItem.rootIndex = rootIndex;
	newItem.needDeleteVertCount = needDeleteVertCount;
	newItem.totalVertCount = totalVertCount;

	//테이블에 결과 저장
	table[rootIndex][parent] = newItem;
}
Пример #29
0
int main(int argc, char const *argv[])
{
	int n=3; /* number of parameters */
	int k=10; /* number of experimental data */
	int i;
	double* result=(double*)malloc(n*sizeof(double));
	double x[10]={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0};
	double y[10]={2.98, 6.03, 11.05, 17.99, 27.1, 39.05, 50.89, 67.1, 82.77, 103.2};
	result=minimize(x,y,n,k);
	for(i=0;i<n;i++)
	{
		printf("%.4f ",result[i]);
	}
	printf("\n");
	return 0;
}
Пример #30
0
void CGenericLoss::Evaluate(CModel *model)
{
	  TheMatrix &w = _model->GetW();
	  double* dat = w.Data();

	  Configuration &config = Configuration::GetInstance();
	  string outFile = config.GetString("Data.labelOutput");

	  FILE* f = fopen(outFile.c_str(), "w");

	  // 将预测的值confidences和gt一起写入一个文件,用于更详细的对比。
	  	  string predFile = config.GetString("Data.predOutput");
	  	  FILE* f_pred = fopen(predFile.c_str(), "w");

	  {
	    map<int,int> ybar;
	    pair<int,double>* confidences = new pair<int,double> [data->nodeFeatures.size()];
	    minimize(data->nodeFeatures, &(data->nodeLabels), data->edgeFeatures, dat, dat + data->nNodeFeatures, ybar, data->nNodeFeatures, data->nEdgeFeatures, data->lossPositive, data->lossNegative, data->indexEdge, confidences, 0, data->firstOrderResponses);

	    printf("0/1 loss    = %f\n", LabelLoss(data->nodeLabels, ybar, data->lossPositive, data->lossNegative, ZEROONE));
	    printf("scaled loss = %f\n", LabelLoss(data->nodeLabels, ybar, data->lossPositive, data->lossNegative, SCALED));
	    printf("AvP = %f\n", AvP(confidences, data->nodeLabels));
	    printf("loss = %f\n", LabelLoss(data->nodeLabels, ybar, data->lossPositive, data->lossNegative, LOSS));
	    delete [] confidences;

	    for (map<int,int>::iterator it = ybar.begin(); it != ybar.end(); it ++)
	      if (it->second == 1)
	        fprintf(f, "%ld\n", data->indexNode[it->first]);

		  double pred_value = 0;
		  int gt_value = 0;
		  for (int i = 0; i < (int) data->nodeLabels.size(); i ++)
		  {
			if (data->nodeLabels[i] == POSITIVE or data->nodeLabels[i] == NEGATIVE)
			{
			  gt_value = data->nodeLabels[i];
			  pred_value = confidences[i].second;
			  fprintf(f_pred, "%d %f\n", gt_value, pred_value);
			}
		  }


	  }

	  fclose(f);
	  fclose(f_pred);
}