Exemple #1
0
void
ffi_pl_perl_to_complex_float(SV *sv, float *ptr)
{
  if(sv_isobject(sv) && sv_derived_from(sv, "Math::Complex"))
  {
    ptr[0] = decompose(sv, 0);
    ptr[1] = decompose(sv, 1);
  }
  else if(SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVAV)
  {
    AV *av = (AV*) SvRV(sv);
    SV **real_sv, **imag_sv;
    real_sv = av_fetch(av, 0, 0);
    imag_sv = av_fetch(av, 1, 0);
    ptr[0] = real_sv != NULL ? SvNV(*real_sv) : 0.0;
    ptr[1]= imag_sv != NULL ? SvNV(*imag_sv) : 0.0;
  }
  else if(SvOK(sv))
  {
    ptr[0] = SvNV(sv);
    ptr[1] = 0.0;
  }
  else
  {
    ptr[0] = 0.0;
    ptr[1] = 0.0;
  }
}
void AnimatedTransform::setTransforms(const Transform& t1, const Transform& t2) {
    _actuallyAnimated = true;
    _transforms[0] = t1;
    _transforms[1] = t2;
    // Decompose matrices
    decompose(t1.getMatrix(), &_translations[0], &_rotations[0], &_scales[0]);
    decompose(t2.getMatrix(), &_translations[1], &_rotations[1], &_scales[1]);
    if (dot(_rotations[0], _rotations[1]) < 0.f) {
        _rotations[1] = -_rotations[1];
    }
}
Exemple #3
0
/*
 * n:剩余数值
 * visited:设置访问标志
 * sum:当前元素的总和
 * 当前记录数组可用的位置
 */
int decompose(int n,int a[],int visited[],int size,int sum,int idx,int current)
{
	int i;

	if(n == 0) {
		puts("decompose:");
		for(i = 0;i < idx;++i)
			printf("%d ",a[i]);
		printf("\n");
		count++;
		//printf("sum:%d,n:%d,idx:%d\n",sum,n,idx);
		//printf("idx:%d,%d\n",idx,a[idx]);
		//getchar();
		return 0;
	}
	
	//printf("begin loop:%d,idx:%d,sum:%d,n:%d,a[0]:%d\n",current,idx,sum,n,a[0]);
	//print(a,idx);
	for(i = current;i <= size;i++) {
		if(!visited[i] && n >= i && sum >= 0 && idx < size) {
			//printf("a[0]:%d,idx:%d,i:%d\n",a[0],idx,i);
			a[idx] = i;
			visited[i] = 1;
			sum += i;
			n -= i;
			//print(a,idx);
			//printf("idx:%d,i:%d,n:%d,sum:%d\n",idx,i,n,sum);
			break;
		}
	}
	//puts("--------end loop -----------");
	//not found i,clear idx
	if(i == size+1) {
		idx--;
		visited[a[idx]] = 0;
		n += a[idx];
		sum -= a[idx];
		//printf("not found,clear idx:%d,a[idx]:%d,sum:%d,n:%d\n",idx,a[idx],sum,n);
		return 0;
	}
	
	//choose i
	//printf("next recursion idx:%d,sum:%d,n:%d\n",idx+1,sum,n);
	decompose(n,a,visited,size,sum,idx+1,a[idx]+1);
	//dont' choose i
	visited[a[idx]] = 0;
	n += a[idx];
	sum -= a[idx];
	//clear i
	decompose(n,a,visited,size,sum,idx,a[idx]+1);
	
	return 0;
}
Exemple #4
0
static int
decompose(VMPM *vmpm, int offset, int level, int blocksize)
{
  int token_length = 0;
  int ntokens = 0;
  int i, result;
  Token *t;
  Token **tmp;

  for (; level >= 0; level--) {
    token_length = ipow(vmpm->r, level);
    ntokens = blocksize / token_length;
    if (ntokens > 0)
      break;
  }
  if (level == -1)
    return -1;

  if ((tmp = realloc(vmpm->token[level],
		     (vmpm->token_index[level] + ntokens) * sizeof(Token *))) == NULL)
    memory_error(NULL, MEMORY_ERROR);
  vmpm->token[level] = tmp;

  if (level >= 1) {
    for (i = 0; i < ntokens; i++) {
      if (register_to_token_hash(vmpm, offset + i * token_length, token_length, USED_FLAG, vmpm->newtoken[level], &t)) {
	/* already registered token */
	vmpm->token[level][vmpm->token_index[level]] = t;
      } else {
	/* newly registered token */
	vmpm->token[level][vmpm->token_index[level]] = t;
	vmpm->newtoken[level]++;
	result = decompose(vmpm, offset + i * token_length, level - 1, token_length);
      }
      vmpm->token_index[level]++;
    }
  } else {
    for (i = 0; i < ntokens; i++) {
      vmpm->token[level][vmpm->token_index[level]] = (Token *)((int)vmpm->buffer[offset + i]);
      vmpm->token_index[level]++;
    }
  }

  if (blocksize - ntokens * token_length > 0)
    decompose(vmpm, offset + ntokens * token_length, level - 1, blocksize - ntokens * token_length);

  return ntokens * token_length;
}
Foam::labelList Foam::metisDecomp::decompose
(
    const labelListList& globalCellCells,
    const pointField& cellCentres,
    const scalarField& cellWeights
)
{
    if (cellCentres.size() != globalCellCells.size())
    {
        FatalErrorIn
        (
            "metisDecomp::decompose"
            "(const pointField&, const labelListList&, const scalarField&)"
        )   << "Inconsistent number of cells (" << globalCellCells.size()
            << ") and number of cell centres (" << cellCentres.size()
            << ")." << exit(FatalError);
    }


    // Make Metis CSR (Compressed Storage Format) storage
    //   adjncy      : contains neighbours (= edges in graph)
    //   xadj(celli) : start of information in adjncy for celli

    CompactListList<label> cellCells(globalCellCells);

    // Decompose using default weights
    labelList decomp;
    decompose(cellCells.m(), cellCells.offsets(), cellWeights, decomp);

    return decomp;
}
Foam::labelList Foam::metisDecomp::decompose
(
    const polyMesh& mesh,
    const pointField& points,
    const scalarField& pointWeights
)
{
    if (points.size() != mesh.nCells())
    {
        FatalErrorIn
        (
            "metisDecomp::decompose(const pointField&,const scalarField&)"
        )   << "Can use this decomposition method only for the whole mesh"
            << endl
            << "and supply one coordinate (cellCentre) for every cell." << endl
            << "The number of coordinates " << points.size() << endl
            << "The number of cells in the mesh " << mesh.nCells()
            << exit(FatalError);
    }

    CompactListList<label> cellCells;
    calcCellCells(mesh, identity(mesh.nCells()), mesh.nCells(), cellCells);

    // Decompose using default weights
    labelList decomp;
    decompose(cellCells.m(), cellCells.offsets(), pointWeights, decomp);

    return decomp;
}
void
test_1_2_ja_flat(void)
{
    cut_assert_equal_string("Sample of OpenDocument Text 1.2 (flat)\n"
                            "OpenDocument Text 1.2 (flat) の日本語サンプル\n",
                            decompose("1.2_ja.fodt"));
}
void
test_1_2_ja(void)
{
    cut_assert_equal_string("Sample of OpenDocument Text 1.2\n"
                            "OpenDocument Text 1.2 の日本語サンプル\n",
                            decompose("1.2_ja.odt"));
}
static le_int32 getCharClass(LEUnicode ch, LEUnicode &lead, LEUnicode &vowel, LEUnicode &trail)
{
    lead  = LJMO_FILL;
    vowel = VJMO_FILL;
    trail = TJMO_FIRST;

    if (ch >= LJMO_FIRST && ch <= LJMO_LAST) {
        lead  = ch;
        return CC_L;
    }

    if (ch >= VJMO_FIRST && ch <= VJMO_LAST) {
        vowel = ch;
        return CC_V;
    }

    if (ch > TJMO_FIRST && ch <= TJMO_LAST) {
        trail = ch;
        return CC_T;
    }

    le_int32 c = decompose(ch, lead, vowel, trail);

    if (c == 2) {
        return CC_LV;
    }

    if (c == 3) {
        return CC_LVT;
    }

    trail = ch;
    return CC_X;
}
Exemple #10
0
void Bigint::internalDivide(const Bigint& number, const bool& isDecimal, const int& precision)
{
	std::string mstring;
	std::vector<int> mparts;
	std::string fnvalue = toString();
	std::string snvalue = number.toString();
	if(fnvalue.length()>snvalue.length())
	{
		if(!number.isPositive)
			mstring = snvalue.substr(1);
		else
			mstring = snvalue;
		mparts = parts;
	}
	else
	{
		if(!number.isPositive)
			mstring = fnvalue.substr(1);
		else
			mstring = fnvalue;
		mparts = number.parts;
	}
	if(mstring!="" && mparts.size()>0)
	{
		int recurse = 0;
		std::string build;
		decompose(fnvalue, snvalue, number, recurse, build, isDecimal, precision);
		try {
			create(build);
		} catch (...) {
		}
	}
}
void decompose(char* in,char* wr,Decomposed_word **morph_list, Dictionary    dict){

	char *o;
	char tempstr[MDWL];
	int i;
	Decomposed_word  *morph_node;
 	o=(char *) xalloc(MAX_WORD*sizeof(char));
	strcpy(o,"");
 	for (i=0;wr[i]!='\0';i++){
		o=strncat(o,wr+i,1);
		if (dictionary_lookup(dict, o))
		{
          strcpy(tempstr,in);
		  strcat(in," ");
          strcat(in,o);
		  decompose(in, wr+i+1,morph_list, dict);
          strcpy(in,tempstr);
		}
	}
	if ((wr[0]=='\0')&&(in[0]))	{

		morph_node=(Decomposed_word *) xalloc(sizeof(Decomposed_word));
		strcpy(morph_node->word,in);
		morph_node->next = (*morph_list);
		if(*morph_list!=NULL){
			(*morph_list)->prev=morph_node;
		}
		(*morph_list)=morph_node;

	}
	xfree(o,MAX_WORD*sizeof(char));
}
void Physics3DComponent::syncPhysicsToNode()
{
    if (_physics3DObj->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY
     || _physics3DObj->getObjType() == Physics3DObject::PhysicsObjType::COLLIDER)
    {
        Mat4 parentMat;
        if (_owner->getParent())
            parentMat = _owner->getParent()->getNodeToWorldTransform();
        
        auto mat = parentMat.getInversed() * _physics3DObj->getWorldTransform();
        //remove scale, no scale support for physics
        float oneOverLen = 1.f / sqrtf(mat.m[0] * mat.m[0] + mat.m[1] * mat.m[1] + mat.m[2] * mat.m[2]);
        mat.m[0] *= oneOverLen;
        mat.m[1] *= oneOverLen;
        mat.m[2] *= oneOverLen;
        oneOverLen = 1.f / sqrtf(mat.m[4] * mat.m[4] + mat.m[5] * mat.m[5] + mat.m[6] * mat.m[6]);
        mat.m[4] *= oneOverLen;
        mat.m[5] *= oneOverLen;
        mat.m[6] *= oneOverLen;
        oneOverLen = 1.f / sqrtf(mat.m[8] * mat.m[8] + mat.m[9] * mat.m[9] + mat.m[10] * mat.m[10]);
        mat.m[8] *= oneOverLen;
        mat.m[9] *= oneOverLen;
        mat.m[10] *= oneOverLen;
        
        mat *= _transformInPhysics;
        static Vec3 scale, translation;
        static Quaternion quat;
        mat.decompose(&scale, &quat, &translation);
        _owner->setPosition3D(translation);
        quat.normalize();
        _owner->setRotationQuat(quat);
    }
}
Exemple #13
0
// Get decomposed filename .......................................
FileName FileName::getDecomposedFileName() const
{
    String str;
    size_t no;
    decompose(no, str);
    return str;
}
int main(void)
{
	double pi = 3.1415;
	int int_part;
	double frac_part;
	int num;
	int *p = 0x8048000;

	printf("*p = %d\n", *p);
	printf("input a number:\n");
	scanf("%d", 0x8048000);
	printf("*p = %d\n", *p);
	return 0;

	printf("&int_part = %p\n", &int_part);

	decompose(pi, &int_part, &frac_part);

	printf("int_part = %d\n", int_part);
	printf("frac_part = %f\n", frac_part);

	printf("&int_part = %p\n", &int_part);

	return 0;
}
Exemple #15
0
int main() {
    int n;
    int i;
    bool first_print = true;
    init_number();
    scanf("%d", &n);
    for(i = 1; i <= n; i++) {
        decompose(i);
    }
    for(i = 2; i <= n; i++) {
        if(composit_number[i] && record[i] >= 1) {
            if(record[i] == 1) {
                if(first_print) {
                    printf("%d", i);
                    first_print = false;
                }
                else
                    printf("*%d", i);
            }
            else {
                if(first_print) {
                    printf("%d^%d", i, record[i]);
                    first_print = false;
                }
                else
                    printf("*%d^%d", i, record[i]);
            }
        }
    }
    return 0;
}
void TransformationMatrix::blend(const TransformationMatrix& from, double progress)
{
    if (from.isIdentity() && isIdentity())
        return;
        
    // decompose
    DecomposedType fromDecomp;
    DecomposedType toDecomp;
    from.decompose(fromDecomp);
    decompose(toDecomp);

    // interpolate
    blendFloat(fromDecomp.scaleX, toDecomp.scaleX, progress);
    blendFloat(fromDecomp.scaleY, toDecomp.scaleY, progress);
    blendFloat(fromDecomp.scaleZ, toDecomp.scaleZ, progress);
    blendFloat(fromDecomp.skewXY, toDecomp.skewXY, progress);
    blendFloat(fromDecomp.skewXZ, toDecomp.skewXZ, progress);
    blendFloat(fromDecomp.skewYZ, toDecomp.skewYZ, progress);
    blendFloat(fromDecomp.translateX, toDecomp.translateX, progress);
    blendFloat(fromDecomp.translateY, toDecomp.translateY, progress);
    blendFloat(fromDecomp.translateZ, toDecomp.translateZ, progress);
    blendFloat(fromDecomp.perspectiveX, toDecomp.perspectiveX, progress);
    blendFloat(fromDecomp.perspectiveY, toDecomp.perspectiveY, progress);
    blendFloat(fromDecomp.perspectiveZ, toDecomp.perspectiveZ, progress);
    blendFloat(fromDecomp.perspectiveW, toDecomp.perspectiveW, progress);
    
    slerp(&fromDecomp.quaternionX, &toDecomp.quaternionX, progress);
        
    // recompose
    recompose(fromDecomp);
}
Exemple #17
0
static vumatptr load(const char* n){
  typedef std::vector<VUMATPtrHandler> VUMATPtrContainer;
  static LibrariesHandler libraries;
  static VUMATPtrContainer fcts;
#ifdef HAVE_STD_MUTEX
   static std::mutex m;
   std::lock_guard<std::mutex> lock(m);
#else /* HAVE_STD_MUTEX */
   lock l;
#endif  /* HAVE_STD_MUTEX */
  try{
    VUMATPtrContainer::const_iterator p;
    p = std::find_if(fcts.begin(),fcts.end(),VUMATNameCompare(n));
    if(p==fcts.end()){
      const std::pair<std::string,std::string> lf = decompose(n);
      const std::string& lib = lf.first;
      const std::string& fct = lf.second;
      if(lib.empty()){
	report("","","",n);
	return NULLPTR(vumatptr);
      }
#if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
      libptr l = ::LoadLibrary(TEXT (lib.c_str()));
#else
      libptr l = ::dlopen(lib.c_str(),RTLD_NOW);
#endif
      if(l==NULLPTR(libptr)){
#if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
	report(lib,"",getLastWin32Error(),n);
#else
	report(lib,"",::dlerror(),n);
#endif	
	return NULLPTR(vumatptr);
      }
      libraries.insert(std::make_pair(lib,l));
      union {
	void *ptr;
	vumatptr f;
      } r;
#if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
      r.f = reinterpret_cast<vumatptr>(::GetProcAddress(l,fct.c_str()));
#else
      r.ptr = ::dlsym(l,fct.c_str());
#endif
      if(r.ptr==NULLPTR(void *)){
#if (defined _WIN32 || defined _WIN64) && (!defined __CYGWIN__)
	report(lib,fct,getLastWin32Error(),n);
#else
	report(lib,fct,::dlerror(),n);
#endif	
	return NULLPTR(vumatptr);
      }
      VUMATPtrHandler h;
      h.name = std::string(n,n+80);
      h.ptr  = r.f;
      fcts.push_back(h);
      return r.f;
    }
    return p->ptr;
  }
Exemple #18
0
void
Subdivider::drawSurfaces( long nuid )
{
    renderhints.init( );

    if (qlist == NULL) return;
    for( Quilt *q = qlist; q; q = q->next ) {
	if( q->isCulled( ) == CULL_TRIVIAL_REJECT ) {
	    freejarcs( initialbin );
	    return;
	}
    }

    REAL from[2], to[2];
    qlist->getRange( from, to, spbrkpts, tpbrkpts );

    if( ! initialbin.isnonempty() ) {
	makeBorderTrim( from, to );
    } else {
	REAL rate[2];
	qlist->findRates( spbrkpts, tpbrkpts, rate );

    	if( decompose( initialbin, min(rate[0], rate[1]) ) ) 
	    mylongjmp( jumpbuffer, 31 );
    }

    backend.bgnsurf( renderhints.wiretris, renderhints.wirequads, nuid );
    subdivideInS( initialbin );
    backend.endsurf();
}
Matrix inverse( Matrix const & matrix )
{
    assert( matrix.rows() == matrix.cols() );

    auto [ p, lu ] = decompose( matrix, Strategy::LUP );

    std::vector< Matrix > xSolutions;
    xSolutions.reserve( lu.rows() );

    for ( std::size_t i{ 0 }; i < lu.rows(); ++i )
    {
        Matrix m{ lu.rows(), 1 };
        m( i, 0 ) = 1;
        m = p * m;
        supstitution::forward( lu, m );
        supstitution::backward( lu, m );
        xSolutions.emplace_back( m );
    }

    for ( std::size_t i{ 0 }; i < lu.rows(); ++i )
    {
        for ( std::size_t j{ 0 }; j < lu.cols(); ++j )
        {
            lu( i, j ) = xSolutions[ j ]( i, 0 );
        }
    }

    Matrix identity{ Matrix::Identity( lu.rows() ) };
    if ( lu.hasNan() || lu.hasInf() )
    {
        LOG_ERROR( "Matirx does not have inverse." );
    }

    return lu;
}
double CameraAnimator::determineDurationFactor()
{
    // first try: if the start and end orientation differ by more than 90 degree, make the full animation
    dp::math::Quatf diffQuat = m_cameraMoveStart->getOrientation() / m_cameraMoveTarget->getOrientation();
    dp::math::Vec3f axis;
    float angle;
    decompose( diffQuat, axis, angle );
    double durationFactor = dp::math::clamp( (double)(angle / dp::math::PI_HALF), 0.0, 1.0 );

    // second try: if position moves about the focus distance (in fact the medium between start and end), make the full
    // animation.
    float mediumFocus = 0.5f * ( m_cameraMoveStart->getFocusDistance() + m_cameraMoveTarget->getFocusDistance() );
    float posDistance = dp::math::distance( m_cameraMoveStart->getPosition(), m_cameraMoveTarget->getPosition() );
    durationFactor = dp::math::clamp( (double)(posDistance / mediumFocus), durationFactor, 1.0 );

    // third try: if near distance changes by more than 25%, make the full animation
    durationFactor = clampDeviation( m_cameraMoveStart->getNearDistance(), m_cameraMoveTarget->getNearDistance(), 0.25f, durationFactor );

    // fourth try: if focus distance changes by more than 25%, make the full animation
    durationFactor = clampDeviation( m_cameraMoveStart->getFocusDistance(), m_cameraMoveTarget->getFocusDistance(), 0.25f, durationFactor );

    // fifth try: if far distance changes by more than 25%, make the full animation
    durationFactor = clampDeviation( m_cameraMoveStart->getFarDistance(), m_cameraMoveTarget->getFarDistance(), 0.25f, durationFactor );

    // sixth try: if window size changes by more than 25%, make the full animation
    durationFactor = clampDeviation( m_cameraMoveStart->getWindowSize()[0], m_cameraMoveTarget->getWindowSize()[0], 0.25f, durationFactor );
    durationFactor = clampDeviation( m_cameraMoveStart->getWindowSize()[1], m_cameraMoveTarget->getWindowSize()[1], 0.25f, durationFactor );

    // ignore windowOffset, lowerLeft, upperRight for now! I don't expect them to change much.
    return( durationFactor );
}
Exemple #21
0
/* Wait until file has a stable size --------------------------------------- */
void FileName::waitUntilStableSize(size_t time_step)
{
    size_t idx;
    FileName basicName;
    decompose(idx, basicName);

    if (!exists())
        return;
    Stat info1, info2;
    if (stat(basicName.c_str(), &info1))
        REPORT_ERROR(ERR_UNCLASSIFIED,
                     (String)"FileName::waitUntilStableSize: Cannot get size of file " + *this);
    off_t size1 = info1.st_size;
    do
    {
        usleep(time_step);
        if (stat(basicName.c_str(), &info2))
            REPORT_ERROR(ERR_UNCLASSIFIED,
                         (String)"FileName::waitUntilStableSize: Cannot get size of file " + *this);
        off_t size2 = info2.st_size;
        if (size1 == size2)
            break;
        size1 = size2;
    }
    while (true);
    return;
}
set<MinimalSeparator> IndSetExtBySeparators::extendToMaxIndependentSet(
		const set<MinimalSeparator>& minSeps) {

	queue<SubGraph> Q;

	// create a copy of minSeps
	set<MinimalSeparator> maximalSet = minSeps;

	SubGraph sg = SubGraph(graph);
	if (maximalSet.empty()) {
		Q.push(sg);
	} else {
		Q = decompose(sg, minSeps);
	}

	vector<NodeSet> cComponents;

	while (!Q.empty()) {
		SubGraph& c = Q.front();

		vector<Node> unconnectedNodes = getUnconnectedNodes(c);

		if (unconnectedNodes[0] >= 0) { // <=> not clique

			NodeSet minSepInC = findMinSep(unconnectedNodes, c);

			c.addClique(minSepInC); // saturate

			// c components when removing minSepInC group
			cComponents = c.getComponents(minSepInC);

			for (NodeSet& cComponent : cComponents) {
				NodeSet cComponentNeighbors = c.getNeighbors(cComponent);

				// mapping of the node indices in the component c to the node
				// indices in the main graph
				vector<int>& cNodeMapInMainGraph = c.getNodeMapToMainGraph();

				includeNodesToMaximalSet(cNodeMapInMainGraph, maximalSet,
						cComponentNeighbors, minSepInC);

				// subComp nodes merged with its neighbors
				NodeSet cComponentNeighborsMerged = mergeComponentAndNeighbors(
						cComponent, cComponentNeighbors);

				// create a sub graph out of c component and subCompMerged nodes
				SubGraph cComponentSubGraph = SubGraph(c,
						cComponentNeighborsMerged);
				Q.push(cComponentSubGraph);

			}

		}

		Q.pop();
	}

	return maximalSet;
}
Exemple #23
0
int main(int argc,char *argv[])
{
	int n=0;
	int *parray=readfile(FILENAM,&n);
	int *darray=decompose(atoi(argv[1]),parray,n);
	printdarr(darray,parray);
	return 0;	
}
Exemple #24
0
void quaterN::decomposeStitch(int discontinuity)
{
	quaterN rotY, offset;
	decompose(rotY, offset);
	rotY.c1stitch(discontinuity);
	offset.c1stitch(discontinuity);
	combine(rotY, offset);
}
Exemple #25
0
	std::vector<CodePoint> Normalizer::decompose (const CodePoint * begin, const CodePoint * end) const {
	
		std::vector<CodePoint> retr;
		for (;begin!=end;++begin) decompose(retr,*begin);
		
		return retr;
	
	}
 FOR(lint m, primes()){
     lint p = powl(2, m) - 1;
     printf("2**%lld-1 = %lld, with factors:",m,p);
     FOR(lint factor, decompose(p)){
         printf(" %lld",factor);
         fflush(stdout);
         CONTINUE;
     }
Exemple #27
0
	std::vector<CodePoint> Normalizer::ToNFD (const CodePoint * begin, const CodePoint * end) const {
	
		auto retr=decompose(begin,end);
		
		sort(retr.begin(),retr.end());
		
		return retr;
	
	}
//fill(d, d + n, -1)
//decompose(0, -1, 0)
void decompose(int root, int parent, int level) {  
	find(root, -1, find(root, -1, INF));
	int c = centroid;
	par[c] = parent;
	d[c] = level;
	calc_in_component(centroid, -1, level);
	for(int to : g[c])
		if(d[to] == -1)
			decompose(to, c, level + 1);
}
Exemple #29
0
Foam::labelList Foam::decompositionMethod::decompose
(
    const polyMesh& mesh,
    const pointField& points
)
{
    scalarField weights(points.size(), 1.0);

    return decompose(mesh, points, weights);
}
Exemple #30
0
Foam::labelList Foam::decompositionMethod::decompose
(
    const labelListList& globalCellCells,
    const pointField& cc
)
{
    scalarField cWeights(cc.size(), 1.0);

    return decompose(globalCellCells, cc, cWeights);
}