int main (void) { A2 = fA(); B2 = fB(); C2 = fC(); D2 = fD(); return all (0); }
void QA::closeEntry(void) { if( isCheckData ) { // data: structure defined in hdhC.h for( size_t i=0 ; i < qaExp.varMeDa.size() ; ++i ) { if( qaExp.varMeDa[i].var->isNoData() ) continue; // skip time test for proceeding time steps when var is fixed if( isNotFirstRecord && qaExp.varMeDa[i].var->isFixed ) continue; hdhC::FieldData fA( qaExp.varMeDa[i].var->pDS->get() ) ; // test overflow of ranges specified in a table, or // plausibility of the extrema. qaExp.varMeDa[i].qaData.test(i, fA); storeData(qaExp.varMeDa[i], fA); } } // This here is only for the regular QA time series file if( qaTime.isTime && isCheckTimeValues ) storeTime(); ++currQARec; return; }
void symbolicSample() { std::string ans; char rowChar[5]; int rowTmp = ROW; sprintf(rowChar, "%d", rowTmp); std::string row = rowChar; /** Create a variable X and an identity function */ symbolic_matrix_type X("X", ROW, COL); SymbolicMMFunc fX(X, false); /** Create constants A,B and C and identity functions */ symbolic_matrix_type A("A", ROW, COL); SymbolicMMFunc fA(A, true); /** Scalar-matrix function placeholder */ SymbolicSMFunc func; /** Create the scalar-matrix function. */ func = trace (fA * inv(fX)); /** Output the function value and derivative value. */ std::cout << "Function Value: "<<func.functionVal.getString()<<std::endl; std::cout << "Derivative Value: "<<func.derivativeVal.getString()<<std::endl; AMD::SymbolicScalarMatlab num("10"); SymbolicSMFunc constant1(num, ROW, COL); SymbolicSMFunc constant2(num, ROW, COL); SymbolicSMFunc constant3(num, ROW, COL); func = trace(constant3*fA*inv(fX)) + constant1 + constant2; std::cout << "Function Value: " << func.functionVal.getString() << std::endl; std::cout << "Derivative Vale: " << func.derivativeVal.getString() << std::endl; }
void BulletGeneric6dofConstraint::updateConstructionInfo() { if (mGeneric6DofConstraint != 0) { delete (mGeneric6DofConstraint); } btRigidBody *rbA = ((BulletRigidBody*)owner_object()-> getComponent(COMPONENT_TYPE_PHYSICS_RIGID_BODY))->getRigidBody(); btVector3 p(mPosition.x, mPosition.y, mPosition.z); btMatrix3x3 m(mRotationA.vec[0], mRotationA.vec[1], mRotationA.vec[2], mRotationA.vec[3], mRotationA.vec[4], mRotationA.vec[5], mRotationA.vec[6], mRotationA.vec[7], mRotationA.vec[8]); btTransform fA(m, p); p = rbA->getWorldTransform().getOrigin() + p; p -= mRigidBodyB->getRigidBody()->getWorldTransform().getOrigin(); m.setValue(mRotationB.vec[0], mRotationB.vec[1], mRotationB.vec[2], mRotationB.vec[3], mRotationB.vec[4], mRotationB.vec[5], mRotationB.vec[6], mRotationB.vec[7], mRotationB.vec[8]); btTransform fB(m, p); mGeneric6DofConstraint = new btGeneric6DofConstraint(*rbA, *mRigidBodyB->getRigidBody(), fA, fB, false); mGeneric6DofConstraint->setLinearLowerLimit(Common2Bullet(mLinearLowerLimits)); mGeneric6DofConstraint->setLinearUpperLimit(Common2Bullet(mLinearUpperLimits)); mGeneric6DofConstraint->setAngularLowerLimit(Common2Bullet(mAngularLowerLimits)); mGeneric6DofConstraint->setAngularUpperLimit(Common2Bullet(mAngularUpperLimits)); mGeneric6DofConstraint->setBreakingImpulseThreshold(mBreakingImpulse); }
void g() { mixed_up<A, B, C> m; fA(m); fB(m); fC(m); }
int main (int argc, char *argv[]) { Extrae_user_function(1); fA(); fB(); Extrae_user_function(0); return 0; }
void initFullAlphabet (void) { _String fA ((unsigned long)256); for (long i=0; i<256; i++) { fA[i]=i; } FullAlphabet = fA; }
int mainasdfaf234(int argc,const char** argv){ std::vector<column_type> column_list,column_list_; column_list.push_back(column_type(t_int)); Schema* input=new SchemaFix(column_list); BlockStreamSingleColumnScan::State bsscs_state("/home/claims/temp/Uniform_0_99.column",input); PhysicalOperatorBase* bsscs1=new BlockStreamSingleColumnScan(bsscs_state); PhysicalOperatorBase* bsscs2=new BlockStreamSingleColumnScan(bsscs_state); int f=atoi(argv[2]); AttributeComparator fA(column_type(t_int),Comparator::L,0,&f); std::vector<AttributeComparator> ComparatorList; ComparatorList.push_back(fA); BlockStreamFilter::State bsf_state(input,bsscs1,ComparatorList,4096); PhysicalOperatorBase* bsf=new BlockStreamFilter(bsf_state); // BlockStreamBase *block=new BlockStreamFix(4096,4); int choice=0; while(choice==0){ // bsf->open(); bsf->Open(); unsigned long long int start=curtick(); while(bsf->Next(block)){ block->setEmpty(); } printf("Time=%f Throughput=%f.\n",getSecond(start),1024/getSecond(start)); bsf->Close(); printf("Continue(0) or Not(1) ?\n"); scanf("%d",&choice); } }
float forceThin(float** arr, const int N, const int M, const int x, const int y, const std::vector<ivec2> borders) { vec2 a(x-0.5,y+0.5); vec2 b(x+0.5,y+0.5); vec2 c(x+0.5,y-0.5); vec2 d(x-0.5,y-0.5); vec2 fA(0.0,0.0); vec2 fB(0.0,0.0); vec2 fC(0.0,0.0); vec2 fD(0.0,0.0); for (unsigned int i=0; i < borders.size(); ++i) { if (distance(ivec2(x,y), borders[i]) <= 16) { std::vector<ivec2> line; line = draw_line(ivec2(x,y), borders[i]); bool outofsight = false; //printf("(%d,%d)\n(%d,%d) %zd\n", x, y, borders[i].x, borders[i].y, line.size()); for (unsigned int j=0; j < line.size(); ++j) { //printf("\t%d\n", j); outofsight |= arr[line[j].x][line[j].y] == 0.5; } if (!outofsight) { float dist = distance(a, borders[i]); float dx = a.x - borders[i].x; float dy = a.y - borders[i].y; fA = fA + vec2(dx/(abs(dx)+abs(dy)) / dist, dy/(abs(dx)+abs(dy)) / dist); dist = distance(b, borders[i]); dx = b.x - borders[i].x; dy = b.y - borders[i].y; fB = fB + vec2(dx/(abs(dx)+abs(dy)) / dist, dy/(abs(dx)+abs(dy)) / dist); dist = distance(c, borders[i]); dx = c.x - borders[i].x; dy = c.y - borders[i].y; fC = fC + vec2(dx/(abs(dx)+abs(dy)) / dist, dy/(abs(dx)+abs(dy)) / dist); dist = distance(d, borders[i]); dx = d.x - borders[i].x; dy = d.y - borders[i].y; fD = fD + vec2(dx/(abs(dx)+abs(dy)) / dist, dy/(abs(dx)+abs(dy)) / dist); } } } //S |= fA.x*fB.x <= 0.0 && abs(fA.y)+abs(fB.y) > abs(fA.x)+abs(fB.x); //S |= fC.x*fD.x <= 0.0 && abs(fC.y)+abs(fD.y) > abs(fC.x)+abs(fD.x); //S |= fA.y*fD.y <= 0.0 && abs(fA.y)+abs(fD.y) > abs(fA.x)+abs(fD.x); //S |= fB.y*fC.y <= 0.0 && abs(fB.y)+abs(fC.y) > abs(fB.x)+abs(fC.x); //S |= fA.x*fC.x <= 0.0 && fA.y * fC.y <= 0.0; //S |= fB.x*fD.x <= 0.0 && fB.y * fD.y <= 0.0; //S |= fA.x*fB.x <= 0.0 && fC.x*fD.x <= 0.0 && (abs(fA.x)+abs(fB.x) > abs(fA.y)+abs(fB.y) || abs(fC.x)+abs(fD.x) > abs(fC.y)+abs(fD.y)); //S |= fA.y*fD.y <= 0.0 && fB.y*fC.y <= 0.0 && (abs(fA.y)+abs(fD.y) > abs(fA.x)+abs(fD.x) || abs(fB.y)+abs(fC.y) > abs(fB.x)+abs(fC.x)); //S |= fA.x*fC.x <= 0.0 && fA.y*fC.y <= 0.0; //S |= fB.x*fD.x <= 0.0 && fB.y*fD.y <= 0.0; //dot products to find change in direction float dot; float min_dot = INFINITY; dot = fA.x*fB.x + fA.y*fB.y; if (dot < min_dot) min_dot = dot; dot = fB.x*fC.x + fB.y*fC.y; if (dot < min_dot) min_dot = dot; dot = fA.x*fD.x + fA.y*fD.y; if (dot < min_dot) min_dot = dot; dot = fC.x*fD.x + fC.y*fD.y; if (dot < min_dot) min_dot = dot; dot = fA.x*fC.x + fA.y*fC.y; if (dot < min_dot) min_dot = dot; dot = fB.x*fD.x + fB.y*fD.y; if (dot < min_dot) min_dot = dot; return min_dot; }
Vector4 Rgba::ToVector4() const { return Vector4(fR(), fG(), fB(), fA()); }
BasicMesh MeshTransferer::transfer(const vector<PhGUtils::Matrix3x3d> &S1grad) { if( !(S0set && T0set) ) { throw "S0 or T0 not set."; } auto &S = S1grad; auto &T = T0grad; int nfaces = S0.faces.nrow; int nverts = S0.verts.nrow; // assemble sparse matrix A int nrowsA = nfaces * 3; int nsv = stationary_vertices.size(); int nrowsC = nsv; int nrows = nrowsA + nrowsC; int ncols = nverts; int ntermsA = nfaces*9; int ntermsC = stationary_vertices.size(); int nterms = ntermsA + ntermsC; SparseMatrix A(nrows, ncols, nterms); // fill in the deformation gradient part for(int i=0, ioffset=0;i<nfaces;++i) { /* * Ai: * 1 2 3 4 5 ... nfaces*3 * 1 2 3 4 5 ... nfaces*3 * 1 2 3 4 5 ... nfaces*3 * Ai = reshape(Ai, 1, nfaces*9) * * Aj = reshape(repmat(S0.faces', 3, 1), 1, nfaces*9) * Av = reshape(cell2mat(T)', 1, nfaces*9) */ int *f = S0.faces.rowptr(i); auto Ti = T[i]; A.append(ioffset, f[0], Ti(0)); A.append(ioffset, f[1], Ti(1)); A.append(ioffset, f[2], Ti(2)); ++ioffset; A.append(ioffset, f[0], Ti(3)); A.append(ioffset, f[1], Ti(4)); A.append(ioffset, f[2], Ti(5)); ++ioffset; A.append(ioffset, f[0], Ti(6)); A.append(ioffset, f[1], Ti(7)); A.append(ioffset, f[2], Ti(8)); ++ioffset; } // fill in the lower part of A, stationary vertices part for(int i=0;i<nsv;++i) { A.append(nrowsA+i, stationary_vertices[i], 1); } ofstream fA("A.txt"); fA<<A; fA.close(); // fill in c matrix DenseMatrix c(nrows, 3); for(int i=0;i<3;++i) { for(int j=0, joffset=0;j<nfaces;++j) { auto &Sj = S[j]; c(joffset, i) = Sj(0, i); ++joffset; c(joffset, i) = Sj(1, i); ++joffset; c(joffset, i) = Sj(2, i); ++joffset; } } for(int i=0;i<3;++i) { for(int j=0, joffset=nrowsA;j<nsv;++j,++joffset) { auto vj = T0.verts.rowptr(stationary_vertices[j]); c(joffset, i) = vj[i]; } } cholmod_sparse *G = A.to_sparse(); cholmod_sparse *Gt = cholmod_transpose(G, 2, global::cm); // compute GtD // just multiply Dsi to corresponding elemenets double *Gtx = (double*)Gt->x; const int* Gtp = (const int*)(Gt->p); for(int i=0;i<nrowsA;++i) { int fidx = i/3; for(int j=Gtp[i];j<Gtp[i+1];++j) { Gtx[j] *= Ds(fidx); } } // compute GtDG cholmod_sparse *GtDG = cholmod_ssmult(Gt, G, 0, 1, 1, global::cm); GtDG->stype = 1; // compute GtD * c cholmod_dense *GtDc = cholmod_allocate_dense(ncols, 3, ncols, CHOLMOD_REAL, global::cm); double alpha[2] = {1, 0}; double beta[2] = {0, 0}; cholmod_sdmult(Gt, 0, alpha, beta, c.to_dense(), GtDc, global::cm); // solve for GtDG \ GtDc cholmod_factor *L = cholmod_analyze(GtDG, global::cm); cholmod_factorize(GtDG, L, global::cm); cholmod_dense *x = cholmod_solve(CHOLMOD_A, L, GtDc, global::cm); // make a copy of T0 BasicMesh Td = T0; // change the vertices with x double *Vx = (double*)x->x; for(int i=0;i<nverts;++i) { Td.verts(i, 0) = Vx[i]; Td.verts(i, 1) = Vx[i+nverts]; Td.verts(i, 2) = Vx[i+nverts*2]; } // release memory cholmod_free_sparse(&G, global::cm); cholmod_free_sparse(&Gt, global::cm); cholmod_free_sparse(&GtDG, global::cm); cholmod_free_dense(&GtDc, global::cm); cholmod_free_factor(&L, global::cm); cholmod_free_dense(&x, global::cm); return Td; }
void fi::VPDetectionCloud::ClusterKDirectionPatches(const pcl::PointCloud<pcl::PointXYZ>::Ptr &_InCloud, Eigen::VectorXf &fRobustEstimatedVP) { unsigned int fNumOfNormals = _InCloud->points.size() * m_ModelParams->fPercentageOfNormals / 100; unsigned int fNumOfCrossProducts = m_ModelParams->fNumOfCrossProducts; unsigned int fNumberOfRansacIterations = m_ModelParams->fNumOfIterations; unsigned int m_k = m_ModelParams->m_k; if ( m_k == 0) { m_k = 5; } double fEPS = m_ModelParams->fEPSInDegrees; Eigen::Vector4f fEstimatedVP1; //// Create the normal estimation class, and pass the input dataset to it //pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normal_estimation; //normal_estimation.setInputCloud (cloud); //// Create an empty kdtree representation, and pass it to the normal estimation object. //// Its content will be filled inside the object, based on the given input dataset (as no other search surface is given). //pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>); //normal_estimation.setSearchMethod (tree); //// Output datasets //pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>); //PtCloudDataPtr InPclDataPtr1(new PtCloudData()); ///*pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(pclData);*/ //boost::shared_ptr<PtCloudData> InPclDataPtr(new PtCloudData(pclData)); int nPointCandidates = _InCloud->points.size(); // Consider using more precise timers such as gettimeofday on *nix or // GetTickCount/timeGetTime/QueryPerformanceCounter on Windows. boost::mt19937 randGen(std::time(0)); // Now we set up a distribution. Boost provides a bunch of these as well. // This is the preferred way to generate numbers in a certain range. // initialize a uniform distribution between 0 and the max=nPointCandidates boost::uniform_int<> uInt8Dist(0, nPointCandidates); // Finally, declare a variate_generator which maps the random number // generator and the distribution together. This variate_generator // is usable like a function call. boost::variate_generator< boost::mt19937&, boost::uniform_int<> > GetRand(randGen, uInt8Dist); //sample random points and compute their normals pcl::IndicesPtr indices(new std::vector<int>()); for (unsigned int i = 0; i < fNumOfNormals; i++) { indices->push_back(GetRand() % nPointCandidates); } /*pcl::NormalEstimationOMP fd;*/ // 6-8 times faster ? pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne; ne.setInputCloud (_InCloud); ne.setSearchMethod (pcl::search::KdTree<pcl::PointXYZ>::Ptr (new pcl::search::KdTree<pcl::PointXYZ>)); ne.setKSearch (m_k); //ne.setRadiusSearch (fRadius); //////toDo Set Cloud and radius hier correctly! //ne.setSearchSurface(source.surface); ne.setIndices(indices); pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>()); ne.compute (*normals); //typedef boost::scoped_ptr<Eigen::Vector4f> fXProds; std::vector<boost::shared_ptr<Eigen::Vector4f> > fVPHypothesis; std::vector<boost::shared_ptr<Eigen::Vector4f> > fVPHypothesisInliers; //sample random points and compute their normals for (unsigned int i = 0; i < fNumOfCrossProducts; i++) { unsigned int fIndexA = GetRand() % fNumOfNormals; unsigned int fIndexB = GetRand() % fNumOfNormals; pcl::Normal &fnormalA = normals->points.at(fIndexA); pcl::Normal &fnormalB = normals->points.at(fIndexB); Eigen::Vector4f fA(fnormalA.normal_x, fnormalA.normal_y, fnormalA.normal_z, 0); Eigen::Vector4f fB(fnormalB.normal_x, fnormalB.normal_y, fnormalB.normal_z, 0); Eigen::Vector4f fC = fA.cross3(fB); boost::shared_ptr<Eigen::Vector4f> ftmpRes(new Eigen::Vector4f(fC)); /*fXProds faVPHypothesis(new Eigen::Vector4f(fC));*/ fVPHypothesis.push_back(ftmpRes); //tmpdistances = sqrt ((line_pt - fPlaneB->points[j].getVector4fMap ()).cross3 (line_dir).squaredNorm ()); } //The Cross products are then the direction we are looking. Find the majority w.r.t a ref Direction! Eigen::Vector4f fRefDir (1.0, 0.0, 0.0, 0); //Validate the best using RANSAC w.r.t refDir unsigned int counterMax = 0; unsigned int iBest; for (unsigned int g = 0; g < fNumberOfRansacIterations; g++) { unsigned int gIndex = GetRand() % fNumOfCrossProducts; Eigen::Vector4f &fu1 = *fVPHypothesis.at(gIndex); double fAnglesInRadians = pcl::getAngle3D(fu1, fRefDir); double fAngleInDegrees = pcl::rad2deg(fAnglesInRadians); //score the selected hypothesis unsigned int sCounter = 0 ; for (unsigned int l = 0; l < fNumOfCrossProducts; l++) { //const float sAnglesInRadianstmp = Math3d::Angle(*((*crosProds)[l]), sRefDir); //const float sAnglesInDegreestmp = sAnglesInRadianstmp * 180.0f / CV_PI; Eigen::Vector4f &fu1tmp = *fVPHypothesis.at(l); double fAnglesInRadianstmp = pcl::getAngle3D(fu1tmp, fRefDir); double fAngleInDegreestmp = pcl::rad2deg(fAnglesInRadianstmp); if (fabsf(fAngleInDegreestmp - fAngleInDegrees) <= fEPS) //Tolerance of 2 Degress!!! { sCounter++; } } if (sCounter > counterMax) { counterMax = sCounter; iBest = gIndex; } } //Insert the Estimated VP! //fEstimatedVP1 = *fVPHypothesis.at(l); /*delete m_pclDataPtr;*/ //collect all the inliers and do WLeastSquaresFit Eigen::Vector4f &fBestModel = *fVPHypothesis.at(iBest); double fAnglesInRadiansBest = pcl::getAngle3D(fBestModel, fRefDir); double fAngleInDegreesBest = pcl::rad2deg(fAnglesInRadiansBest); pcl::PointCloud<pcl::PointXYZ>::Ptr fVPCandidates(new pcl::PointCloud<pcl::PointXYZ>); fVPCandidates->width = counterMax; fVPCandidates->height = 1; fVPCandidates->resize(fVPCandidates->width * fVPCandidates->height); unsigned int ii = 0; for (unsigned int l = 0; l < fNumOfCrossProducts; l++) { Eigen::Vector4f &fu1tmp = *fVPHypothesis.at(l); double fAnglesInRadianstmp = pcl::getAngle3D(fu1tmp, fRefDir); double fAngleInDegreestmp = pcl::rad2deg(fAnglesInRadianstmp); if (fabsf(fAngleInDegreestmp - fAngleInDegreesBest) <= fEPS) //Tolerance of 2 Degrees!!! { fVPCandidates->points[ii].x = fu1tmp(0); fVPCandidates->points[ii].y = fu1tmp(1); fVPCandidates->points[ii].z = fu1tmp(2); /*boost::scoped_ptr<Eigen::Vector4f> ftmpInliers(new Eigen::Vector4f(fu1tmp)); fVPHypothesisInliers.push_back(ftmpInliers);*/ if (ii > counterMax) { std::cout<<" Something went really wrong!..."<<std::endl; return; } ii++; } } //Robust fitting the inliers using WleastSquears fit //Eigen::VectorXf optimized_vp_coefficients; LSLineFitting(fVPCandidates, fRobustEstimatedVP); //collect data for }
static int in_iterator_test () { cout << "test in\n"; std::vector<column_type> column_list; column_list.push_back(column_type(t_u_long)); column_list.push_back(column_type(t_int)); column_list.push_back(column_type(t_u_long)); column_list.push_back(column_type(t_int)); column_list.push_back(column_type(t_int)); column_list.push_back(column_type(t_int)); Schema* input=new SchemaFix(column_list); Schema* output=new SchemaFix(column_list); unsigned block_size = 64*1024-sizeof(unsigned); ExpandableBlockStreamSingleColumnScan::State ebsscs1_state("/home/claims/data/wangli/T0G0P0",input, block_size); BlockStreamIteratorBase* ebssc1=new ExpandableBlockStreamSingleColumnScan(ebsscs1_state); unsigned long f = 20000; AttributeComparator fA(column_type(t_u_long),Comparator::L,0,&f); std::vector<AttributeComparator> ComparatorList; ComparatorList.push_back(fA); ExpandableBlockStreamFilter::State ebsf_state(input, ebssc1, ComparatorList, block_size); BlockStreamIteratorBase* ebfs = new ExpandableBlockStreamFilter(ebsf_state); ExpandableBlockStreamSingleColumnScan::State ebsscs2_state("/home/claims/data/wangli/T0G0P0",input, block_size); BlockStreamIteratorBase* ebssc2=new ExpandableBlockStreamSingleColumnScan(ebsscs1_state); BlockStreamInIterator::State bsii_state(ebfs, ebssc2, input, input, 0, 0, block_size); BlockStreamIteratorBase* bsii = new BlockStreamInIterator(bsii_state); std::vector<string> attr_name; attr_name.push_back("rowid"); attr_name.push_back("Trade_Date"); attr_name.push_back("Order_No"); attr_name.push_back("Sec_Code"); attr_name.push_back("Trade_Dir"); attr_name.push_back("Order_Type"); BlockStreamPrint::State bsp1_state(input, ebfs, block_size, attr_name, "\t"); BlockStreamIteratorBase* bsp1 = new BlockStreamPrint(bsp1_state); bsp1->print(); bsp1->open(0); BlockStreamBase* block = BlockStreamBase::createBlock(input, block_size); while(bsp1->next(block)); { } bsp1->close(); BlockStreamPrint::State bsp_state(input, bsii, block_size, attr_name, "\t"); BlockStreamIteratorBase* bsp = new BlockStreamPrint(bsp_state); bsp->open(0); // BlockStreamBase* block = BlockStreamBase::createBlock(input, block_size); while(bsp->next(block)); { } bsp->close(); PhysicalQueryPlan IM(bsp); Message4K M4K = PhysicalQueryPlan::serialize4K(IM); PhysicalQueryPlan tmp = PhysicalQueryPlan::deserialize4K(M4K); tmp.run(); return 0; }