コード例 #1
0
ファイル: mesh.cpp プロジェクト: ipa-nhg/kukadu
void getEdgeNeighborsList(const Mesh& m, uintA& EV, uintA& Et, intA& ET) {
  intA Vt, VT;
  getVertexNeighorsList(m, Vt, VT);
  
  uint A=0, B=0, t, tt, i, r, k;
  //build edge list
  EV.resize(m.T.d0*3, 2);   EV=0;     //edge vert neighbors
  ET.resize(m.T.d0*3, 10);  ET=-1;    //edge tri neighbors
  Et.resize(m.T.d0*3); Et.setZero(); //#edge tri neighbors
  boolA done(m.T.d0); done=false;
  for(t=0, k=0; t<m.T.d0; t++) {
    for(r=0; r<3; r++) {
      if(r==0) { A=m.T(t, 0);  B=m.T(t, 1);  }
      if(r==1) { A=m.T(t, 1);  B=m.T(t, 2);  }
      if(r==2) { A=m.T(t, 2);  B=m.T(t, 0);  }
      
      //has AB already been taken care of?
      bool yes=false;
      for(i=0; i<(uint)Vt(A); i++) {
        tt=VT(A, i);
        if(m.T(tt, 0)==B || m.T(tt, 1)==B || m.T(tt, 2)==B) {
          if(done(tt)) yes=true;
        }
      }
      if(yes) continue;
      
      //if not, then do it
      EV(k, 0)=A;
      EV(k, 1)=B;
      for(i=0; i<(uint)Vt(A); i++) {
        tt=VT(A, i);
        if(m.T(tt, 0)==B || m.T(tt, 1)==B || m.T(tt, 2)==B) {
          ET(k, Et(k))=tt;
          Et(k)++;
        }
      }
      k++;
    }
    done(t)=true;
  }
  
  EV.resizeCopy(k, 2);
  ET.resizeCopy(k, 10);
  Et.resizeCopy(k);
  
  cout <<"\n#edges=" <<k
       <<"\nedge=\n" <<EV
       <<"\n@neighs=\n" <<Et
       <<"\nneighs=\n" <<ET <<endl;
}
コード例 #2
0
ファイル: mesh.cpp プロジェクト: ipa-nhg/kukadu
void getTriNeighborsList(const Mesh& m, uintA& Tt, intA& TT) {
  intA Vt, VT;
  getVertexNeighorsList(m, Vt, VT);
  
  uint A=0, B=0, t, tt, r, i;
  Tt.resize(m.T.d0, 3);     Tt.setZero();
  TT.resize(m.T.d0, 3, 100); TT=-1;
  for(t=0; t<m.T.d0; t++) {
    for(r=0; r<3; r++) {
      if(r==0) { A=m.T(t, 0);  B=m.T(t, 1);  }
      if(r==1) { A=m.T(t, 1);  B=m.T(t, 2);  }
      if(r==2) { A=m.T(t, 2);  B=m.T(t, 0);  }
      
      for(i=0; i<(uint)Vt(A); i++) {
        tt=VT(A, i);
        if(tt!=t && (m.T(tt, 0)==B || m.T(tt, 1)==B || m.T(tt, 2)==B)) {
          TT(t, r, Tt(t, r))=tt;
          Tt(t, r)++;
        }
      }
    }
  }
  
  //cout <<Tt <<TT <<endl;
}
コード例 #3
0
ファイル: TMV_SymBandSVD.cpp プロジェクト: rmjarvis/tmv
    HermBandSVDiv<T>::HermBandSVDiv(const GenSymBandMatrix<T>& A) :
        pimpl(new HermBandSVDiv_Impl(A))
    {
        TMVAssert(A.isherm());

        MatrixView<T> Vt(0,0,0,1,1,NonConj);
        SV_Decompose<T>(A, pimpl->U.view(), pimpl->S.view(), Vt,
                       pimpl->logdet, pimpl->signdet);
        thresh(TMV_Epsilon<T>());
    }
コード例 #4
0
/*
--------------------------------------------------------------------------------------------------
- check collision with stairs
--------------------------------------------------------------------------------------------------
*/
bool PlanesPhysicHandler::ColisionWithStair(const AABB & actorBB, const VECTOR &Speed, VECTOR &ModifiedSpeed)
{
    float moveX = Speed.x;
    float moveZ = Speed.z;

    // calculate norm of speed
    VECTOR speedNorm = Speed.unit();

    float startX = (actorBB.P.x+actorBB.E.x)/2.0f;
    float startZ = (actorBB.P.z+actorBB.E.z)/2.0f;

    std::vector<StairPlane>::const_iterator it = _stairs.begin();
    std::vector<StairPlane>::const_iterator end = _stairs.end();

    // for each stairs
    for(int i=0; it != end; ++it, ++i)
    {
        // project point to plane and check if we cross it
        float DotProduct=speedNorm.dot(it->Normal);

        // Determine If Ray Parallel To Plane
        if (abs(DotProduct) > 0.000001f)
        {
            // Find Distance To Collision Point
            float l2=(it->Normal.dot(it->C1-VECTOR(startX, actorBB.P.y, startZ)))/DotProduct;

            // Test If Collision Behind Start or after end
            if (l2 > 0 && l2 < Speed.length())
            {
                float collionsX = startX + (speedNorm.x * l2);
                float collionsZ = startZ + (speedNorm.z * l2);

                if((collionsX >= it->minX) && (collionsX <= it->maxX))
                {
                    if((collionsZ >= it->minZ) && (collionsZ <= it->maxZ))
                    {
                        VECTOR spmY(Speed.x, 0, Speed.z);
                        VECTOR Vt(it->Normal.dot(spmY)*it->Normal);
                        VECTOR Vn(spmY - Vt);
                        ModifiedSpeed = Vn;
                        return true;
                    }
                }
            }
        }
    }

    return false;
}
コード例 #5
0
ファイル: factor.cpp プロジェクト: caomw/r4r
size_t CMatrixFactorization<double>::Rank(const CDenseArray<double>& A, double tol) {

	CDenseArray<double> U(A.NRows(),A.NRows());
	CDenseArray<double> S(min(A.NRows(),A.NCols()),1);
	CDenseArray<double> Vt(A.NCols(),A.NCols());

	SVD(A,U,S,Vt);

	size_t rank = 0;

	for(size_t i=0; i<S.NRows(); i++) {

		if(S(i,0)>tol)
			rank++;

	}

	return rank;

}
コード例 #6
0
Stokhos::ProductLanczosPCEBasis<ordinal_type, value_type>::
ProductLanczosPCEBasis(
  ordinal_type p,
  const Teuchos::Array< Stokhos::OrthogPolyApprox<ordinal_type, value_type> >& pce,
  const Teuchos::RCP<const Stokhos::Quadrature<ordinal_type, value_type> >& quad,
  const Teuchos::RCP< const Stokhos::Sparse3Tensor<ordinal_type, value_type> >& Cijk,
  const Teuchos::ParameterList& params_) :
  name("Product Lanczos PCE Basis"),
  params(params_)
{
  Teuchos::RCP<const Stokhos::OrthogPolyBasis<ordinal_type,value_type> > pce_basis = pce[0].basis();
  ordinal_type pce_sz = pce_basis->size();

  // Check if basis is a product basis
  Teuchos::RCP<const Stokhos::ProductBasis<ordinal_type,value_type> > prod_basis = Teuchos::rcp_dynamic_cast<const Stokhos::ProductBasis<ordinal_type,value_type> >(pce_basis);
  Teuchos::Array< Teuchos::RCP<const OneDOrthogPolyBasis<ordinal_type,value_type> > > coord_bases;
  if (prod_basis != Teuchos::null)
    coord_bases = prod_basis->getCoordinateBases();

  // Build Lanczos basis for each pce
  bool project = params.get("Project", true);
  bool normalize = params.get("Normalize", true);
  bool limit_integration_order = params.get("Limit Integration Order", false);
  bool use_stieltjes = params.get("Use Old Stieltjes Method", false);
  Teuchos::Array< Teuchos::RCP<const Stokhos::OneDOrthogPolyBasis<int,double > > > coordinate_bases;
  Teuchos::Array<int> is_invariant(pce.size(),-2);
  for (ordinal_type i=0; i<pce.size(); i++) {

    // Check for pce's lying in invariant subspaces, which are pce's that
    // depend on only a single dimension.  In this case use the corresponding
    // original coordinate basis.  Convention is:  -2 -- not invariant, -1 --
    // constant, i >= 0 pce depends only on dimension i
    if (prod_basis != Teuchos::null)
      is_invariant[i] = isInvariant(pce[i]);
    if (is_invariant[i] >= 0) {
      coordinate_bases.push_back(coord_bases[is_invariant[i]]);
    }

    // Exclude constant pce's from the basis since they don't represent
    // stochastic dimensions
    else if (is_invariant[i] != -1) {
      if (use_stieltjes) {
	coordinate_bases.push_back(
	  Teuchos::rcp(
	    new Stokhos::StieltjesPCEBasis<ordinal_type,value_type>(
	      p, Teuchos::rcp(&(pce[i]),false), quad, false,
	      normalize, project, Cijk)));
      }
      else {
	if (project) 
	  coordinate_bases.push_back(
	    Teuchos::rcp(
	      new Stokhos::LanczosProjPCEBasis<ordinal_type,value_type>(
		p, Teuchos::rcp(&(pce[i]),false), Cijk,
		normalize, limit_integration_order)));
	else
	  coordinate_bases.push_back(
	    Teuchos::rcp(
	      new Stokhos::LanczosPCEBasis<ordinal_type,value_type>(
		p, Teuchos::rcp(&(pce[i]),false), quad,
		normalize, limit_integration_order)));
      }
    }
  }
  ordinal_type d = coordinate_bases.size();

  // Build tensor product basis
  tensor_lanczos_basis = 
    Teuchos::rcp(
      new Stokhos::CompletePolynomialBasis<ordinal_type,value_type>(
	coordinate_bases,
	params.get("Cijk Drop Tolerance", 1.0e-15),
	params.get("Use Old Cijk Algorithm", false)));

  // Build reduced quadrature
  Teuchos::ParameterList sg_params;
  sg_params.sublist("Basis").set< Teuchos::RCP< const Stokhos::OrthogPolyBasis<ordinal_type,value_type> > >("Stochastic Galerkin Basis", tensor_lanczos_basis);
  sg_params.sublist("Quadrature") = params.sublist("Reduced Quadrature");
  reduced_quad = 
    Stokhos::QuadratureFactory<ordinal_type,value_type>::create(sg_params);

  // Build Psi matrix -- Psi_ij = Psi_i(x^j)*w_j/<Psi_i^2>
  const Teuchos::Array<value_type>& weights = quad->getQuadWeights();
  const Teuchos::Array< Teuchos::Array<value_type> >& points = 
    quad->getQuadPoints(); 
  const Teuchos::Array< Teuchos::Array<value_type> >& basis_vals = 
    quad->getBasisAtQuadPoints();
  ordinal_type nqp = weights.size();
  SDM Psi(pce_sz, nqp);
  for (ordinal_type i=0; i<pce_sz; i++)
    for (ordinal_type k=0; k<nqp; k++)
      Psi(i,k) = basis_vals[k][i]*weights[k]/pce_basis->norm_squared(i);

  // Build Phi matrix -- Phi_ij = Phi_i(y(x^j))
  ordinal_type sz = tensor_lanczos_basis->size();
  Teuchos::Array<value_type> red_basis_vals(sz);
  Teuchos::Array<value_type> pce_vals(d);
  Phi.shape(sz, nqp);
  for (int k=0; k<nqp; k++) {
    ordinal_type jdx = 0;
    for (int j=0; j<pce.size(); j++) {

      // Exclude constant pce's
      if (is_invariant[j] != -1) {

	// Use the identity mapping for invariant subspaces
	if (is_invariant[j] >= 0)
	  pce_vals[jdx] = points[k][is_invariant[j]];
	else
	  pce_vals[jdx] = pce[j].evaluate(points[k], basis_vals[k]);
	jdx++;

      }

    }
    tensor_lanczos_basis->evaluateBases(pce_vals, red_basis_vals);
    for (int i=0; i<sz; i++)
      Phi(i,k) = red_basis_vals[i];
  }

  bool verbose = params.get("Verbose", false);
 
  // Compute matrix A mapping reduced space to original
  A.shape(pce_sz, sz);
  ordinal_type ret = 
    A.multiply(Teuchos::NO_TRANS, Teuchos::TRANS, 1.0, Psi, Phi, 0.0);
  TEUCHOS_ASSERT(ret == 0);
  //print_matlab(std::cout << "A = " << std::endl, A);

  // Compute pseudo-inverse of A mapping original space to reduced
  // A = U*S*V^T -> A^+ = V*S^+*U^T = (S^+*V^T)^T*U^T where 
  // S^+ is a diagonal matrix comprised of the inverse of the diagonal of S
  // for each nonzero, and zero otherwise
  Teuchos::Array<value_type> sigma;
  SDM U, Vt;
  value_type rank_threshold = params.get("Rank Threshold", 1.0e-12);
  ordinal_type rank = svd_threshold(rank_threshold, A, sigma, U, Vt);
  Ainv.shape(sz, pce_sz);
  TEUCHOS_ASSERT(rank == Vt.numRows());
  for (ordinal_type i=0; i<Vt.numRows(); i++)
    for (ordinal_type j=0; j<Vt.numCols(); j++)
      Vt(i,j) = Vt(i,j) / sigma[i];
  ret = Ainv.multiply(Teuchos::TRANS, Teuchos::TRANS, 1.0, Vt, U, 0.0);
  TEUCHOS_ASSERT(ret == 0);
  //print_matlab(std::cout << "Ainv = " << std::endl, Ainv);

  if (verbose) {
    std::cout << "rank = " << rank << std::endl;
    
    std::cout << "diag(S) = [";
    for (ordinal_type i=0; i<rank; i++)
      std::cout << sigma[i] << " ";
    std::cout << "]" << std::endl;

    // Check A = U*S*V^T
    SDM SVt(rank, Vt.numCols());
    for (ordinal_type i=0; i<Vt.numRows(); i++)
      for (ordinal_type j=0; j<Vt.numCols(); j++)
	SVt(i,j) = Vt(i,j) * sigma[i] * sigma[i];  // since we divide by sigma 
                                                   // above
    SDM err_A(pce_sz,sz);
    err_A.assign(A);
    ret = err_A.multiply(Teuchos::NO_TRANS, Teuchos::NO_TRANS, -1.0, U, SVt, 
			 1.0);
    TEUCHOS_ASSERT(ret == 0);
    std::cout << "||A - U*S*V^T||_infty = " << err_A.normInf() << std::endl;
    //print_matlab(std::cout << "A - U*S*V^T = " << std::endl, err_A);
 
    // Check Ainv*A == I
    SDM err(sz,sz);
    err.putScalar(0.0);
    for (ordinal_type i=0; i<sz; i++)
      err(i,i) = 1.0;
    ret = err.multiply(Teuchos::NO_TRANS, Teuchos::NO_TRANS, 1.0, Ainv, A, 
		       -1.0);
    TEUCHOS_ASSERT(ret == 0);
    std::cout << "||Ainv*A - I||_infty = " << err.normInf() << std::endl;
    //print_matlab(std::cout << "Ainv*A-I = " << std::endl, err);

    // Check A*Ainv == I
    SDM err2(pce_sz,pce_sz);
    err2.putScalar(0.0);
    for (ordinal_type i=0; i<pce_sz; i++)
      err2(i,i) = 1.0;
    ret = err2.multiply(Teuchos::NO_TRANS, Teuchos::NO_TRANS, 1.0, A, Ainv, -1.0);
    TEUCHOS_ASSERT(ret == 0);
    std::cout << "||A*Ainv - I||_infty = " << err2.normInf() << std::endl;
    //print_matlab(std::cout << "A*Ainv-I = " << std::endl, err2);
  }
}
コード例 #7
0
EkleMakale::EkleMakale(const wxString& title,const wxString& doi)
	: wxDialog(NULL,wxID_ANY,title,wxDefaultPosition,wxSize(500,550))
{
	
	wxImage::AddHandler(new wxPNGHandler);
	wxBitmap dialogLogo(srcLocation+wxT("resource/toolbar/contract2.png"),wxBITMAP_TYPE_PNG);
	wxBitmap searchButton(srcLocation+wxT("resource/toolbar/zoom.png"),wxBITMAP_TYPE_PNG);
	wxBitmap okButton(srcLocation+wxT("resource/toolbar/checkmark.png"),wxBITMAP_TYPE_PNG);
	wxBitmap cancelButton(srcLocation+wxT("resource/toolbar/cross.png"),wxBITMAP_TYPE_PNG);
	
	wxPanel *panel = new wxPanel(this,-1);
	wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
	
	wxStaticText *mainleft = new wxStaticText(panel,-1,wxT(" "));
	hbox->Add(mainleft,0,wxEXPAND);
	
	wxPanel *subpanel = new wxPanel(panel,-1);
	wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
	
	vbox->Add(-1,10);
	
	wxPanel *toppanel = new wxPanel(subpanel,-1);
	wxBoxSizer *tophbox = new wxBoxSizer(wxHORIZONTAL);
	wxStaticText *dialogtitle = new wxStaticText(toppanel, -1, wxT("Makale Ekle / Düzenle"));
	wxFont font = dialogtitle->GetFont();
	font.SetPointSize(18);
	font.SetWeight(wxFONTWEIGHT_BOLD);
	dialogtitle->SetFont(font);
	tophbox->Add(dialogtitle,1,wxALIGN_BOTTOM|wxEXPAND);
	wxStaticBitmap *dialoglogo = new wxStaticBitmap(toppanel,-1,dialogLogo);
	tophbox->Add(dialoglogo,0,wxALIGN_RIGHT);
	toppanel->SetSizer(tophbox);
	vbox->Add(toppanel,0,wxEXPAND);

	vbox->Add(new wxStaticLine(subpanel,-1,wxPoint(-1,-1),wxSize(-1,-1),wxLI_HORIZONTAL),0,wxEXPAND);
	vbox->Add(-1,10);
	
	wxPanel *midhpanel = new wxPanel(subpanel,-1);
	wxBoxSizer *midhbox = new wxBoxSizer(wxHORIZONTAL);
	
	wxPanel *midvpanel = new wxPanel(midhpanel,-1);
	wxBoxSizer *midvbox = new wxBoxSizer(wxVERTICAL);
	
	midvbox->Add(-1,10);
	wxPanel *mid1panel = new wxPanel(midvpanel,-1);
	wxBoxSizer *mid1hbox = new wxBoxSizer(wxHORIZONTAL);
	mid1hbox->Add(new wxStaticText(mid1panel,-1,wxT("DOI Numarası ")),1,wxEXPAND);
	paperdoi = new wxTextCtrl(mid1panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	paperdoi->SetValue(doi);
	mid1hbox->Add(paperdoi,0,wxALIGN_RIGHT);
	mid1panel->SetSizer(mid1hbox);
	midvbox->Add(mid1panel,0,wxEXPAND);
	midvbox->Add(-1,10);
	midvpanel->SetSizer(midvbox);
	
	midhbox->Add(midvpanel,0,wxALIGN_CENTER_VERTICAL|wxEXPAND);
	midhbox->Add(new wxStaticText(midhpanel,-1,wxT("")),1,wxEXPAND);
	midhbox->Add(new wxBitmapButton(midhpanel,ADDPAPER_DIALOG_RETRIEVE,searchButton),0,wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT);
	
	midhpanel->SetSizer(midhbox);
	
	vbox->Add(midhpanel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	vbox->Add(new wxStaticLine(subpanel,-1,wxPoint(-1,-1),wxSize(-1,-1),wxLI_HORIZONTAL),0,wxEXPAND);
	
	vbox->Add(-1,10);
	wxPanel *mid2panel = new wxPanel(subpanel,-1);
	wxBoxSizer *mid2hbox = new wxBoxSizer(wxHORIZONTAL);
	mid2hbox->Add(new wxStaticText(mid2panel,-1,wxT("Makale Başlığı")),1,wxEXPAND);
	papertitle = new wxTextCtrl(mid2panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	mid2hbox->Add(papertitle,0,wxALIGN_RIGHT);
	mid2panel->SetSizer(mid2hbox);
	vbox->Add(mid2panel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	wxPanel *mid3panel = new wxPanel(subpanel,-1);
	wxBoxSizer *mid3hbox = new wxBoxSizer(wxHORIZONTAL);
	mid3hbox->Add(new wxStaticText(mid3panel,-1,wxT("Yazarlar")),1,wxEXPAND);
	paperauthors = new wxTextCtrl(mid3panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	mid3hbox->Add(paperauthors,0,wxALIGN_RIGHT);
	mid3panel->SetSizer(mid3hbox);
	vbox->Add(mid3panel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	wxPanel *mid4panel = new wxPanel(subpanel,-1);
	wxBoxSizer *mid4hbox = new wxBoxSizer(wxHORIZONTAL);
	mid4hbox->Add(new wxStaticText(mid4panel,-1,wxT("Dergi")),1,wxEXPAND);
	paperjournal = new wxTextCtrl(mid4panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	mid4hbox->Add(paperjournal,0,wxALIGN_RIGHT);
	mid4panel->SetSizer(mid4hbox);
	vbox->Add(mid4panel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	wxPanel *mid5panel = new wxPanel(subpanel,-1);
	wxBoxSizer *mid5hbox = new wxBoxSizer(wxHORIZONTAL);
	mid5hbox->Add(new wxStaticText(mid5panel,-1,wxT("Cilt")),1,wxEXPAND);
	papervolume = new wxTextCtrl(mid5panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	mid5hbox->Add(papervolume,0,wxALIGN_RIGHT);
	mid5panel->SetSizer(mid5hbox);
	vbox->Add(mid5panel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	wxPanel *mid6panel = new wxPanel(subpanel,-1);
	wxBoxSizer *mid6hbox = new wxBoxSizer(wxHORIZONTAL);
	mid6hbox->Add(new wxStaticText(mid6panel,-1,wxT("Sayı")),1,wxEXPAND);
	paperissue = new wxTextCtrl(mid6panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	mid6hbox->Add(paperissue,0,wxALIGN_RIGHT);
	mid6panel->SetSizer(mid6hbox);
	vbox->Add(mid6panel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	wxPanel *mid7panel = new wxPanel(subpanel,-1);
	wxBoxSizer *mid7hbox = new wxBoxSizer(wxHORIZONTAL);
	mid7hbox->Add(new wxStaticText(mid7panel,-1,wxT("İlk Sayfa / Numara")),1,wxEXPAND);
	paperfirstpage = new wxTextCtrl(mid7panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	mid7hbox->Add(paperfirstpage,0,wxALIGN_RIGHT);
	mid7panel->SetSizer(mid7hbox);
	vbox->Add(mid7panel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	wxPanel *mid8panel = new wxPanel(subpanel,-1);
	wxBoxSizer *mid8hbox = new wxBoxSizer(wxHORIZONTAL);
	mid8hbox->Add(new wxStaticText(mid8panel,-1,wxT("Son Sayfa")),1,wxEXPAND);
	paperlastpage = new wxTextCtrl(mid8panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	mid8hbox->Add(paperlastpage,0,wxALIGN_RIGHT);
	mid8panel->SetSizer(mid8hbox);
	vbox->Add(mid8panel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	wxPanel *mid9panel = new wxPanel(subpanel,-1);
	wxBoxSizer *mid9hbox = new wxBoxSizer(wxHORIZONTAL);
	mid9hbox->Add(new wxStaticText(mid9panel,-1,wxT("Yayın Tarihi")),1,wxEXPAND);
	paperpublished = new wxTextCtrl(mid9panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	mid9hbox->Add(paperpublished,0,wxALIGN_RIGHT);
	mid9panel->SetSizer(mid9hbox);
	vbox->Add(mid9panel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	wxPanel *mid10panel = new wxPanel(subpanel,-1);
	wxBoxSizer *mid10hbox = new wxBoxSizer(wxHORIZONTAL);
	mid10hbox->Add(new wxStaticText(mid10panel,-1,wxT("Yayıncı Linki")),1,wxEXPAND);
	paperlink = new wxTextCtrl(mid10panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	mid10hbox->Add(paperlink,0,wxALIGN_RIGHT);
	mid10panel->SetSizer(mid10hbox);
	vbox->Add(mid10panel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	wxPanel *mid11panel = new wxPanel(subpanel,-1);
	wxBoxSizer *mid11hbox = new wxBoxSizer(wxHORIZONTAL);
	mid11hbox->Add(new wxStaticText(mid11panel,-1,wxT("Konu / Anahtar Kelimeler")),1,wxEXPAND);
	papersubject = new wxTextCtrl(mid11panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	mid11hbox->Add(papersubject,0,wxALIGN_RIGHT);
	mid11panel->SetSizer(mid11hbox);
	vbox->Add(mid11panel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	wxPanel *mid12panel = new wxPanel(subpanel,-1);
	wxBoxSizer *mid12hbox = new wxBoxSizer(wxHORIZONTAL);
	mid12hbox->Add(new wxStaticText(mid12panel,-1,wxT("Referans Kimliği")),1,wxEXPAND);
	paperrefid = new wxTextCtrl(mid12panel,-1,wxT(""),wxPoint(-1,-1),wxSize(300,-1));
	mid12hbox->Add(paperrefid,0,wxALIGN_RIGHT);
	mid12panel->SetSizer(mid12hbox);
	vbox->Add(mid12panel,0,wxEXPAND);
	
	vbox->Add(-1,10);
	
	vbox->Add(new wxStaticText(subpanel,-1,wxT("")),1,wxEXPAND);
	vbox->Add(new wxStaticLine(subpanel,-1,wxPoint(-1,-1),wxSize(-1,-1),wxLI_HORIZONTAL),0,wxEXPAND);
	vbox->Add(-1,10);

	wxPanel *bottompanel = new wxPanel(subpanel,-1);
	wxBoxSizer *bottomhbox = new wxBoxSizer(wxHORIZONTAL);
	bottomhbox->Add(new wxStaticText(bottompanel,-1,wxT(" ")),0,wxEXPAND);
	wxArrayString paperstars;
	paperstars.Add(wxT("Beğeni"));
	paperstars.Add(wxT("0"));
	paperstars.Add(wxT("1"));
	paperstars.Add(wxT("2"));
	paperstars.Add(wxT("3"));
	paperstars.Add(wxT("4"));
	paperstars.Add(wxT("5"));
	paperstar = new wxChoice(bottompanel,-1,wxPoint(-1,-1),wxSize(150,-1),paperstars);
	bottomhbox->Add(paperstar,0,wxEXPAND);
	wxArrayString papercolors;
	papercolors.Add(wxT("İşaretleme Yok"));
	papercolors.Add(wxT("Sarı"));
	papercolors.Add(wxT("Kırmızı"));
	papercolors.Add(wxT("Yeşil"));
	papercolors.Add(wxT("Mavi"));
	papercolor = new wxChoice(bottompanel,-1,wxPoint(-1,-1),wxSize(150,-1),papercolors);
	bottomhbox->Add(papercolor,0,wxEXPAND);
	bottomhbox->Add(new wxStaticText(bottompanel,-1,wxT("")),1,wxEXPAND);
	bottomhbox->Add(new wxBitmapButton(bottompanel,wxID_CANCEL,cancelButton),0,wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT);
	bottomhbox->Add(new wxBitmapButton(bottompanel,wxID_OK,okButton),0,wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT);
	bottompanel->SetSizer(bottomhbox);
	vbox->Add(bottompanel,0,wxEXPAND);
	
	subpanel->SetSizer(vbox);
	hbox->Add(subpanel,1,wxEXPAND);
	hbox->Add(new wxStaticText(panel,-1,wxT(" ")),0,wxEXPAND);
	panel->SetSizer(hbox);
	
	Connect(ADDPAPER_DIALOG_RETRIEVE,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(EkleMakale::DOIRetrieveTrigger));

	if(doi != wxT(""))
	{
		wxString doichecksql;
		doichecksql << wxT("SELECT * FROM papers WHERE doi=='") << doi << wxT("'");
		vtcevap doicheck;
		doicheck = Vt(doichecksql);
		if(doicheck.satir>0)
		{
			papertitle->SetValue(doicheck.sonuc.Item(1));
			paperauthors->SetValue(doicheck.sonuc.Item(2));
			paperjournal->SetValue(doicheck.sonuc.Item(3));
			papervolume->SetValue(doicheck.sonuc.Item(4));
			paperissue->SetValue(doicheck.sonuc.Item(5));
			paperfirstpage->SetValue(doicheck.sonuc.Item(6));
			paperlastpage->SetValue(doicheck.sonuc.Item(7));
			paperpublished->SetValue(doicheck.sonuc.Item(8));
			paperlink->SetValue(doicheck.sonuc.Item(9));
			papersubject->SetValue(doicheck.sonuc.Item(10));
			paperrefid->SetValue(doicheck.sonuc.Item(11));
			paperstar->SetStringSelection(doicheck.sonuc.Item(12));
			papercolor->SetStringSelection(doicheck.sonuc.Item(13));
		}
		else
		{
			EkleMakale::DOIRetrieve();
		}
	}
}
コード例 #8
0
ファイル: mesh.cpp プロジェクト: ipa-nhg/kukadu
void Mesh::clean() {
  uint i, j, idist=0;
  Vector a, b, c, m;
  double mdist=0.;
  arr Tc(T.d0, 3); //tri centers
  arr Tn(T.d0, 3); //tri normals
  uintA Vt(V.d0);
  intA VT(V.d0, 100); //tri-neighbors to a vertex
  Vt.setZero(); VT=-1;
  
  for(i=0; i<T.d0; i++) {
    a.set(&V(T(i, 0), 0)); b.set(&V(T(i, 1), 0)); c.set(&V(T(i, 2), 0));
    
    //tri center
    m=(a+b+c)/3.;
    Tc(i, 0)=m.x;  Tc(i, 1)=m.y;  Tc(i, 2)=m.z;
    
    //farthest tri
    if(m.length()>mdist) { mdist=m.length(); idist=i; }
    
    //tri normal
    b-=a; c-=a; a=b^c; a.normalize();
    Tn(i, 0)=a.x;  Tn(i, 1)=a.y;  Tn(i, 2)=a.z;
    
    //vertex neighbor count
    j=T(i, 0);  VT(j, Vt(j))=i;  Vt(j)++;
    j=T(i, 1);  VT(j, Vt(j))=i;  Vt(j)++;
    j=T(i, 2);  VT(j, Vt(j))=i;  Vt(j)++;
  }
  
  //step through tri list and flip them if necessary
  boolA Tisok(T.d0); Tisok=false;
  uintA Tok; //contains the list of all tris that are ok oriented
  uintA Tnew(T.d0, T.d1);
  Tok.append(idist);
  Tisok(idist)=true;
  int A=0, B=0, D;
  uint r, k, l;
  intA neighbors;
  for(k=0; k<Tok.N; k++) {
    i=Tok(k);
    Tnew(k, 0)=T(i, 0); Tnew(k, 1)=T(i, 1); Tnew(k, 2)=T(i, 2);
    
    for(r=0; r<3; r++) {
      if(r==0) { A=T(i, 0);  B=T(i, 1);  /*C=T(i, 2);*/ }
      if(r==1) { A=T(i, 1);  B=T(i, 2);  /*C=T(i, 0);*/ }
      if(r==2) { A=T(i, 2);  B=T(i, 0);  /*C=T(i, 1);*/ }
      
      //check all triangles that share A & B
      setSection(neighbors, VT[A], VT[B]);
      neighbors.removeAllValues(-1);
      if(neighbors.N>2) MT_MSG("edge shared by more than 2 triangles " <<neighbors);
      neighbors.removeValue(i);
      //if(!neighbors.N) cout <<"mesh.clean warning: edge has only one triangle that shares it" <<endl;
      
      //orient them correctly
      for(l=0; l<neighbors.N; l++) {
        j=neighbors(l); //j is a neighboring triangle sharing A & B
        D=-1;
        //align the neighboring triangle and let D be its 3rd vertex
        if((int)T(j, 0)==A && (int)T(j, 1)==B) D=T(j, 2);
        if((int)T(j, 0)==A && (int)T(j, 2)==B) D=T(j, 1);
        if((int)T(j, 1)==A && (int)T(j, 2)==B) D=T(j, 0);
        if((int)T(j, 1)==A && (int)T(j, 0)==B) D=T(j, 2);
        if((int)T(j, 2)==A && (int)T(j, 0)==B) D=T(j, 1);
        if((int)T(j, 2)==A && (int)T(j, 1)==B) D=T(j, 0);
        if(D==-1) HALT("dammit");
        //determine orientation
        if(!Tisok(j)) {
          T(j, 0)=B;  T(j, 1)=A;  T(j, 2)=D;
          Tok.append(j);
          Tisok(j)=true;
        } else {
          //check if consistent!
        }
      }
      
#if 0
      //compute their rotation
      if(neighbors.N>1) {
        double phi, phimax;
        int jmax=-1;
        Vector ni, nj;
        for(l=0; l<neighbors.N; l++) {
          j=neighbors(l); //j is a neighboring triangle sharing A & B
          
          a.set(&V(T(i, 0), 0)); b.set(&V(T(i, 1), 0)); c.set(&V(T(i, 2), 0));
          b-=a; c-=a; a=b^c; a.normalize();
          ni = a;
          
          a.set(&V(T(j, 0), 0)); b.set(&V(T(j, 1), 0)); c.set(&V(T(j, 2), 0));
          b-=a; c-=a; a=b^c; a.normalize();
          nj = a;
          
          Quaternion q;
          q.setDiff(ni, -nj);
          q.getDeg(phi, c);
          a.set(&V(A, 0)); b.set(&V(B, 0));
          if(c*(a-b) < 0.) phi+=180.;
          
          if(jmax==-1 || phi>phimax) { jmax=j; phimax=phi; }
        }
        if(!Tisok(jmax)) {
          Tok.append(jmax);
          Tisok(jmax)=true;
        }
      } else {
        j = neighbors(0);
        if(!Tisok(j)) {
          Tok.append(j);
          Tisok(j)=true;
        }
      }
#endif
    }
  }
  if(k<T.d0) {
    cout <<"mesh.clean warning: not all triangles connected: " <<k <<"<" <<T.d0 <<endl;
    cout <<"WARNING: cutting of all non-connected triangles!!" <<endl;
    Tnew.resizeCopy(k, 3);
    T=Tnew;
    deleteUnusedVertices();
  }
  computeNormals();
}
コード例 #9
0
ファイル: AutomaticCalibrator.cpp プロジェクト: 8ware/KP-GDV
	/**
	 * Implements "Least-Squares Rigid Motion Using SVD"
	 * See: http://igl.ethz.ch/projects/ARAP/svd_rot.pdf
	 * NOTE: We do not directly follow the paper because we allow mirroring!
	 **/
	cv::Matx44f AutomaticCalibrator::estimateRigidBodyTransformation(
		std::vector<std::pair<cv::Vec3f, cv::Vec3f>> const & vv2v3fCorrespondences)
	{
		std::size_t const uiCorrespondenceCount(vv2v3fCorrespondences.size());
		if(uiCorrespondenceCount < 3)
		{
			throw std::runtime_error("The number of correspondences given to estimateRigidBodyTransformation is required to be >= 3!");
		}

		// Compute centers.
		cv::Vec3f v3CenterLeft;
		cv::Vec3f v3CenterRight;
		for(auto && corr : vv2v3fCorrespondences)
		{
			v3CenterLeft += corr.first;
			v3CenterRight += corr.second;
		}
		v3CenterLeft *= (1.0f / static_cast<float>(uiCorrespondenceCount));
		v3CenterRight *= (1.0f / static_cast<float>(uiCorrespondenceCount));

		// Create a vector with the centered correspondences.
		std::vector<std::pair<cv::Vec3f, cv::Vec3f>> vv2v3fCenteredCorrespondences;
		for(auto && corr : vv2v3fCorrespondences)
		{
			vv2v3fCenteredCorrespondences.push_back(std::make_pair(
				corr.first-v3CenterLeft,
				corr.second-v3CenterRight));
		}

		// Fill the covariance matrix.
		cv::Matx33f H(cv::Matx33f::zeros());
		for(std::size_t i(0); i<3; ++i)
		{
			for(std::size_t j(0); j<3; ++j)
			{
				for(auto && corr : vv2v3fCenteredCorrespondences)
				{
					H(i, j) += corr.second(i) * corr.first(j);
				}
			}
		}

		// Compute the SVD.
		cv::SVD svd(H, cv::SVD::MODIFY_A | cv::SVD::FULL_UV);
		cv::Matx33f U(reinterpret_cast<float*>(svd.u.data));
		cv::Matx33f S(reinterpret_cast<float*>(svd.w.data));
		cv::Matx33f Vt(reinterpret_cast<float*>(svd.vt.data));
			
		// Transpose Vt.
		cv::Matx33f V(Vt.t());
		// Transpose U.
		cv::Matx33f const Ut(U.t());

		// Correct it so that it is a rotation.
		cv::Matx33f DCorrect(cv::Matx33f::eye());

		// The original paper only allows rotations and no reflections.
		// We explicitly want to allow this because the arm coordinate system is not necessarily the same as the vision coordinate system.
		//DCorrect(2, 2) = static_cast<float>(cv::determinant(V*Ut));

		// Compute the roation matrix.
		cv::Matx33f const R(V * DCorrect * Ut);
		// Compute the translation vector.
		cv::Vec3f const t(v3CenterLeft - R * v3CenterRight);

		return cv::Matx44f{
			R(0, 0), R(0, 1), R(0, 2), t(0),
			R(1, 0), R(1, 1), R(1, 2), t(1),
			R(2, 0), R(2, 1), R(2, 2), t(2),
			0.0f, 0.0f, 0.0f, 1.0f};
	}
コード例 #10
0
ファイル: ung_ssm.cpp プロジェクト: helske/bssm
double ung_ssm::psi_filter(const ugg_ssm& approx_model,
  const double approx_loglik, const arma::vec& scales,
  const unsigned int nsim, arma::cube& alpha, arma::mat& weights,
  arma::umat& indices) {
  
  arma::mat alphahat(m, n + 1);
  arma::cube Vt(m, m, n + 1);
  arma::cube Ct(m, m, n + 1);
  approx_model.smoother_ccov(alphahat, Vt, Ct);
  conditional_cov(Vt, Ct);
  
  std::normal_distribution<> normal(0.0, 1.0);
  
  
  for (unsigned int i = 0; i < nsim; i++) {
    arma::vec um(m);
    for(unsigned int j = 0; j < m; j++) {
      um(j) = normal(engine);
    }
    alpha.slice(i).col(0) = alphahat.col(0) + Vt.slice(0) * um;
  }
  
  std::uniform_real_distribution<> unif(0.0, 1.0);
  arma::vec normalized_weights(nsim);
  double loglik = 0.0;
  if(arma::is_finite(y(0))) {
    weights.col(0) = arma::exp(log_weights(approx_model, 0, alpha) - scales(0));
    double sum_weights = arma::accu(weights.col(0));
    if(sum_weights > 0.0){
      normalized_weights = weights.col(0) / sum_weights;
    } else {
      return -std::numeric_limits<double>::infinity();
    }
    loglik = approx_loglik + std::log(sum_weights / nsim);
  } else {
    weights.col(0).ones();
    normalized_weights.fill(1.0 / nsim);
    loglik = approx_loglik;
  }
  
  for (unsigned int t = 0; t < n; t++) {
    arma::vec r(nsim);
    for (unsigned int i = 0; i < nsim; i++) {
      r(i) = unif(engine);
    }
    indices.col(t) = stratified_sample(normalized_weights, r, nsim);
    
    arma::mat alphatmp(m, nsim);
    
    // for (unsigned int i = 0; i < nsim; i++) {
    //   alphatmp.col(i) = alpha.slice(i).col(t);
    // }
    for (unsigned int i = 0; i < nsim; i++) {
      alphatmp.col(i) = alpha.slice(indices(i, t)).col(t);
      //alpha.slice(i).col(t) = alphatmp.col(indices(i, t));
    }
    for (unsigned int i = 0; i < nsim; i++) {
      arma::vec um(m);
      for(unsigned int j = 0; j < m; j++) {
        um(j) = normal(engine);
      }
      alpha.slice(i).col(t + 1) = alphahat.col(t + 1) +
        Ct.slice(t + 1) * (alphatmp.col(i) - alphahat.col(t)) + Vt.slice(t + 1) * um;
    }
    
    if ((t < (n - 1)) && arma::is_finite(y(t + 1))) {
      weights.col(t + 1) =
        arma::exp(log_weights(approx_model, t + 1, alpha) - scales(t + 1));
      double sum_weights = arma::accu(weights.col(t + 1));
      if(sum_weights > 0.0){
        normalized_weights = weights.col(t + 1) / sum_weights;
      } else {
        return -std::numeric_limits<double>::infinity();
      }
      loglik += std::log(sum_weights / nsim);
    } else {
      weights.col(t + 1).ones();
      normalized_weights.fill(1.0 / nsim);
    }
  }
  return loglik;
}