示例#1
0
int		read_file(const t_hs filename, t_glist_hs *lines)
{
  char		*data;
  int		fd;
  ssize_t	file_length;
  t_hs		ths;
  t_glist_hs	new_lines;

  if ((file_length = get_file_length(filename)) == -1)
    return (-1);
  if ((fd = open_file(filename, O_RDONLY)) == -1)
    return (-1);
  data = egc_malloc_atomic(file_length + 1);
  if (read(fd, data, file_length) == -1)
    {
      close(fd);
      return (-1);
    }
  close(fd);
  ths = hs(data);
  if ((int)hs_length(ths) != file_length)
    return (-1);
  new_lines = hs_split(ths, hs("\n"));
  glist_hs_append_all(lines, &new_lines);
  return (0);
}
示例#2
0
void hanoi_2(int n)
{
    std::stack<hs> stk;
    stk.push(hs(n,'x','y','z'));

    while (!stk.empty()) {
        hs & top = stk.top();
        switch (top.state) {
            case 0:
                if (top.n > 0) {
                    top.state = 1;
                    stk.push(hs(top.n-1, top.a, top.c, top.b));
                } else {
                    stk.pop();
                }
                break;
            case 1:
                std::cout << top.a << " --> " << top.c << std::endl;
                top.state = 2;
                stk.push(hs(top.n-1, top.b, top.a, top.c));
                break;
            case 2:
                stk.pop();
                break;
        }
    }
}
bool hs(int x,int p,int q)
{
	printf("µ÷ÓÃhs(%d,%d,%d):\n",x,p,q);
	int j;
	for(j=1;j<=n;j++)
	{
		printf("\tj=%d,a[j]=%d,oa[j]=%d,b[j]=%d,ob[j]=%d\n",j,a[j],oa[j],b[j],ob[j]);
		} printf("\n");
	if(p==q)
	{
		if(oa[p])return true;
		oa[p]=1;
		if(!ob[p]&&x==b[p]){ob[p]=1;return true;}
		return false;
		}
	else if(p+1==q)
	{
		return hs(x,p,p)||hs(x,q,q);
		}
	else 
	{
		int t=(p+q)/2;
		if(b[t]>x)return hs(x,p,t);
		else return hs(x,t,q);
		}
	return false;
	}
示例#4
0
std::string RepairCRC(const std::string& arData)
{
	HexSequence hs(arData);

	//validate the size of the data
	BOOST_REQUIRE(hs.Size() >= 10);
	BOOST_REQUIRE(hs.Size() <= 292);

	//first determine how much user data is present
	size_t full_blocks = (hs.Size() - 10) / 18;
	size_t partial_size = (hs.Size() - 10) % 18;

	//can't have a partial size < 3 since even 1 byte requires 2 CRC bytes
	if(partial_size > 0) {
		BOOST_REQUIRE(partial_size >= 3);
	}

	//repair the header crc
	DNPCrc::AddCrc(hs, 8);

	boost::uint8_t* ptr = hs + 10;

	// repair the full blocks
	for(size_t i = 0; i < full_blocks; i++) {
		DNPCrc::AddCrc(ptr, 16);
		ptr += 18;
	}

	//repair the partial block
	if(partial_size > 0) DNPCrc::AddCrc(ptr, partial_size - 2);

	return apl::toHex(hs, hs.Size(), true);
}
示例#5
0
int _tmain(int argc, _TCHAR* argv[])
{
	char st[100];
	printf("Input: ");
    gets_s(st);
	int *a = new int[strlen(st)];
	for (int i = 0; i < strlen(st); i++)
	{
		a[i] = st[i] - '0';
	}
	hs(a, strlen(st));
	if (a[0] == 0) 
	{
	for (int i = 1; i<strlen(st);i++)
	{
		if (a[i] != 0)
		{
			a[0] = a[i];
			a[i] = 0;
			break;
		}
	}
	}
	for (int i = 0; i<strlen(st);i++)
	{
		printf("%d", a[i]);
	}
	return 0;
}
示例#6
0
void TGroup::handleEvent(TEvent &event) {
   TView::handleEvent(event);

   handleStruct hs(event, *this);

   if ((event.what & focusedEvents) != 0) {
      phase = phPreProcess;
      forEach(doHandleEvent, &hs);

      phase = phFocused;
      doHandleEvent(current, &hs);

      phase = phPostProcess;
      forEach(doHandleEvent, &hs);
   } else {
      phase = phFocused;
      if ((event.what & positionalEvents) != 0) {
         // get pointer to topmost view holding mouse
         TView *p = firstThat(hasMouse, &event);
         if (p)
            // we have a view; send event to it
            doHandleEvent(p, &hs);
      } else
         forEach(doHandleEvent, &hs);
   }
}
示例#7
0
void TGroup::handleEvent( TEvent& event )
{
    TView::handleEvent( event );

    handleStruct hs( event, *this );

    if( (event.what & focusedEvents) != 0 )
        {
        phase = phPreProcess;
        forEach( doHandleEvent, &hs );

        phase = phFocused;
        doHandleEvent( current, &hs );

        phase = phPostProcess;
        forEach( doHandleEvent, &hs );
        }
    else
        {
        phase = phFocused;
        if( (event.what & positionalEvents) != 0 )
            {
            doHandleEvent( firstThat( hasMouse, &event ), &hs );
            }
        else
            forEach( doHandleEvent, &hs );
        }
}
示例#8
0
HTTPServerRequestImpl::HTTPServerRequestImpl(HTTPServerResponse& response, HTTPServerSession& session, HTTPServerParams* pParams):
	_response(response),
	_pStream(0),
	_pParams(pParams)
{
	poco_check_ptr (_pParams);
	
	_pParams->duplicate();

	HTTPHeaderInputStream hs(session);
	read(hs);
	
	// Now that we know socket is still connected, obtain addresses
	_clientAddress = session.clientAddress();
	_serverAddress = session.serverAddress();
	
	if (getChunkedTransferEncoding())
		_pStream = new HTTPChunkedInputStream(session);
	else if (getContentLength() != HTTPMessage::UNKNOWN_CONTENT_LENGTH)
		_pStream = new HTTPFixedLengthInputStream(session, getContentLength());
	else if (getMethod() == HTTPRequest::HTTP_GET || getMethod() == HTTPRequest::HTTP_HEAD)
		_pStream = new HTTPFixedLengthInputStream(session, 0);
	else
		_pStream = new HTTPInputStream(session);
}
示例#9
0
Example::Example(bool scrbars, MySpriteField& sfield, QWidget* parent,
	const char* name, WFlags f) :
    QWidget(parent,name?name:"example",f),
    field(sfield),
    view(scrbars ? (QWidget*)new QwScrollingSpriteFieldView(&field,this)
	: (QWidget*)new QwSpriteFieldView(&field,this)
	),
    sprite(0),
    textsprite("QwTextSprite",QFont("Helvetica",18)),
    scrollbars(scrbars),
    count(0)
{
    setMouseTracking(TRUE);

    view->move(0,0);
    textsprite.setColor(red);
    if (!btext) textsprite.hide();
    QPixmap pm(63,63);
    pm.fill(black);

    QPainter p;
    p.begin(&pm);
    for (int i=0; i<50; i++) {
	p.setPen(QColor(rand()%255,rand()%255,rand()%255));
	p.drawLine(rand()%62,rand()%62,rand()%62,rand()%62);
    }
    p.setPen(white);
    p.drawText(0,0,63,63,AlignCenter,"DRAWN\nSPRITE");
    pm.setMask(pm.createHeuristicMask());
    p.end();

    QPoint hs(31,31);
    QList<QPixmap> lpm; lpm.append(&pm);
    QList<QPoint> lhs; lhs.append(&hs);
    drawnsprite = new QwSprite( new QwSpritePixmapSequence(lpm,lhs) );

    // Diamond
    QPointArray pa(4);
    pa[0] = QPoint(0,-150);
    pa[1] = QPoint(+150,0);
    pa[2] = QPoint(0,+150);
    pa[3] = QPoint(-150,0);
    polygon = new QwPolygon();
    polygon->setBrush(DiagCrossPattern);
    polygon->setBrush(QBrush(red,DiagCrossPattern));
    polygon->setPoints(pa);

    images=new QwSpritePixmapSequence(
	IMG_SPRITE_DATA, IMG_SPRITE_MASK, NR_ROTS);

    setCount(bouncers);

    resize(WIDTH,HEIGHT);

    // Since it is virtual, ours won't be called in the constructor
    refresh();
    resizeEvent(0);
    startTimer(refresh_delay);
    timer.start();
}
示例#10
0
bool DBManager::existsRequest(std::string card) {
    bool res = false;
    std::string selectQuery = std::string("SELECT COUNT(*) FROM ACCOUNT "
                                                 "WHERE card = \"") + card + std::string("\";");
    sqlite3_stmt * getStmt;
    int ret = 0;
    if (SQLITE_OK != (ret = sqlite3_prepare(database,
                    selectQuery.c_str(),
                    selectQuery.size(),
                    &getStmt,
                    NULL))) {
        std::cout << "Failed to prepare select statement" << std::endl;
    }
    if (SQLITE_ROW != (ret = sqlite3_step(getStmt)))
    {
        std::cout << "Failed to step select" << std::endl;
    }
    std::istringstream hs(reinterpret_cast<const char*>(sqlite3_column_text(getStmt, 0)));
    int count;
    hs >> count;

    if (count != 0) {
        res = true;
    }
    return res;
}
int main(){
    int n;
    char c;
    char cs[1002];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
            scanf("%s",cs);
        for(int j=0;j<n;j++){
            if(cs[j]=='.'){
                inp[i][j]=0;
            } else {
                inp[i][j]=1;
            }
        }
    }
    hs(n);
    d1s1(n); 
    for(int l=0;l<n;l++){
        for(int m=0;m<n;m++){
            printf("%d",inp[l][m]);
            if(m<n-1){
                printf("%c",' ');
            }
        }
        printf("%c",'\n');
    }

}
示例#12
0
int main(int argc, char *argv[])
{
	char *cmd;
    int res;

	set_dlog_level (L_DBG);

    if ((cmd = strrchr(argv[0], '/')) == NULL)
        cmd = argv[0];
    else
        cmd++;

	if (strcmp(cmd, "hmsg_monitor") == 0) {
		str_hash_init(HASH_FILE);
		str_hash_dump();
		dlog(L_INFO, "start hmsg_monitor\n");
		hmsg_monitor();
		return 0;
	} else if (strcmp(cmd, "hs") == 0) {
		res = hs(argc, argv);
	} else {
		dlog(L_ERR, "Invalid command\n");
		usage();
		res = -1;
	}

	return res;
}
示例#13
0
 Region*  buildRegion2( vector< vector<Point> >& cycles){


   //cout << "buildRegion2  called wth " << cycles.size() << " cycles " << endl;

   Line* hss = new Line(80);

   hss->StartBulkLoad();
   int edgeno = 0;
   for(size_t c = 0; c<cycles.size(); c++){
       for(size_t i=0;i<cycles[c].size()-1; i++){
          HalfSegment hs(true, cycles[c][i],cycles[c][i+1]);
          hs.attr.edgeno = edgeno;
          (*hss) += hs;
          hs.SetLeftDomPoint(!hs.IsLeftDomPoint());
          (*hss) += hs; 
          edgeno++;
       }
    }


    hss->EndBulkLoad();

    

    Region* res= new Region(hss->Size());

    hss->Transform(*res);


    hss->DeleteIfAllowed();
    return res;
}
示例#14
0
 void addRegion(vector<pair<Region*, bool> > & regs, vector<Point>& cycle){
   bool isFace = getDir(cycle);
   if(cycle.size()<2){
     return;
   }

   if(!AlmostEqual(cycle[0],cycle[cycle.size()-1])){ // cycle not closed

   }

    if(cycle.size() < 4){
       return;
    }

    Line* hss = new Line(cycle.size()*2);

    hss->StartBulkLoad();
    for(size_t i = 0; i<cycle.size()-1; i++){
       HalfSegment hs(true, cycle[i],cycle[i+1]);
       hs.attr.edgeno = i;
       (*hss) += hs;
       hs.SetLeftDomPoint(!hs.IsLeftDomPoint());
       (*hss) += hs; 
    }
    hss->EndBulkLoad();
    Region* res= new Region(cycle.size()*2);

    hss->Transform(*res);
    hss->DeleteIfAllowed();
    regs.push_back(pair<Region*,bool>(res, isFace));
}
示例#15
0
void MasterTestObject::SendUnsolToMaster(const std::string& arData)
{
	HexSequence hs(arData);
	mAPDU.Reset();
	mAPDU.Write(hs, hs.Size());
	mAPDU.Interpret();
	master.OnUnsolResponse(mAPDU);
}
示例#16
0
 REP( i, N ) {
     x = X[i] + dx;
     y = Y[i] + dy;
     if ( x < 0 || x >= MAXC ||
          y < 0 || y >= MAXC )
          continue;
     hs( dx, dy ) += haystack[x][y];
 }
void SurfaceHeight<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  if (memoizer_.haveStoredData(workset)) return;

#ifndef ALBANY_KOKKOS_UNDER_DEVELOPMENT
  switch (hs_type) {
    case NONE: //no surface height: hs = 0
      for (int cell=0; cell < workset.numCells; ++cell) {
        for (int qp=0; qp < numQPs; ++qp) 
          hs(cell,qp) = 0.0; 
      }
      break; 
    case MOUNTAIN:  //surface height for test case 5
      const double R = pi/9.0; 
      const double lambdac = 1.5*pi;
      const double thetac = pi/6.0;  
      for (int cell=0; cell < workset.numCells; ++cell) {
        for (int qp = 0; qp < numQPs; ++qp) {
          MeshScalarT lambda = sphere_coord(cell,qp,0);
          MeshScalarT theta = sphere_coord(cell,qp,1);
          MeshScalarT radius2 = (lambda-lambdac)*(lambda-lambdac) + (theta-thetac)*(theta-thetac);
          //r^2 = min(R^2, (lambda-lambdac)^2 + (theta-thetac)^2); 
          MeshScalarT r;  
          if (radius2 > R*R) r = R; 
          else r = sqrt(radius2); 
          //hs = hs0*(1-r/R) for test case 5 
          hs(cell,qp) = hs0*(1.0-r/R); 
        }
      }
      break; 
  }

#else

   switch (hs_type) {
    case NONE:
      Kokkos::parallel_for(SurfaceHeight_Policy(0,workset.numCells),*this);
    break;
    case  MOUNTAIN:
      Kokkos::parallel_for(SurfaceHeight_MOUNTAIN_Policy(0,workset.numCells),*this);
    break;
   }

#endif
}
示例#18
0
void AsyncSlaveTestObject::SendToSlave(const std::string& arData, SequenceInfo aSeq)
{
	HexSequence hs(arData);
	mAPDU.Reset();
	mAPDU.Write(hs, hs.Size());
	mAPDU.Interpret();
	LOG_BLOCK(LEV_INTERPRET, "<= " << mAPDU.ToString());
	slave.OnRequest(mAPDU, aSeq);
}
示例#19
0
void MasterTestObject::RespondToMaster(const std::string& arData, bool aFinal)
{
	HexSequence hs(arData);
	mAPDU.Reset();
	mAPDU.Write(hs, hs.Size());
	mAPDU.Interpret();
	if(aFinal) master.OnFinalResponse(mAPDU);
	else master.OnPartialResponse(mAPDU);
}
void MockPhysicalLayerAsync::TriggerRead(const std::string& arData)
{
	HexSequence hs(arData);
	assert(hs.Size() <= this->mNumToRead);
	memcpy(mpWriteBuff, hs.Buffer(), hs.Size());
	mNumToRead = 0;
	error_code ec(errc::success, get_generic_category());
	this->OnReadCallback(ec, mpWriteBuff, hs.Size());
}
示例#21
0
am_status_t BaseService::sendRequest(Connection& conn,
        const BodyChunk& headerPrefix,
        const std::string& uri,
        const std::string& uriParameters,
        const Http::HeaderList& headerList,
        const Http::CookieList& cookieList,
        const BodyChunk& contentLine,
        const BodyChunk& headerSuffix,
        const BodyChunkList& bodyChunkList) const {

    Connection::ConnHeaderMap hdrs;
    size_t hListSize = headerList.size();
    Http::Cookie theCookie;
    for (size_t idx = 0; idx < hListSize; idx++) {
        std::string headerLine;
        theCookie = headerList[idx];
        headerLine.append(theCookie.name);
        headerLine.append(": ");
        headerLine.append(theCookie.value);
        hdrs.insert(Connection::ConnHeaderMapValue(headerLine, ""));
    }

    size_t listSize = cookieList.size();
    if (listSize > 0) {
        std::string cookieLine("Cookie: ");
        for (size_t iii = 0; iii < listSize; iii++) {
            theCookie = cookieList[iii];
            cookieLine.append(theCookie.name);
            cookieLine.append("=");
            cookieLine.append(theCookie.value);
            if (iii != listSize - 1) {
                cookieLine.append(";");
            }
        }
        hdrs.insert(Connection::ConnHeaderMapValue(cookieLine, ""));
    }

    std::string hsorig(headerSuffix.data);
    hsorig.erase(hsorig.size() - 2);
    std::stringstream hs(hsorig);
    std::string line;
    while (std::getline(hs, line)) {
        if (line != "")
            hdrs.insert(Connection::ConnHeaderMapValue(line, ""));
    }

    std::string body;
    for (std::size_t i = 0; i < bodyChunkList.size(); ++i) {
        body.append(bodyChunkList[i].data);
    }

    std::string u(uri + uriParameters);
    return conn.sendRequest(headerPrefix.data.c_str(),
            u, hdrs, body);
}
示例#22
0
static t_result         lex_token(const char **string_p)
{
  t_result              result;

  result = lex_token_impl(string_p);
  if (result.token || result.error)
    return (result);
  result = lex_word(string_p);
  if (result.token || result.error)
    return (result);
  return (RESULT_ERROR(hs("Unexpected character"), *string_p));
}
示例#23
0
bool IsFrameEqual(LinkFrame& frame, const std::string& arData)
{

	HexSequence hs(arData);
	if(frame.GetSize() != hs.Size()) return false;
	boost::uint8_t* buff = frame.GetBuffer();

	for(size_t i = 0; i < hs.Size(); i++) {
		if(buff[i] != hs[i]) return false;
	}

	return true;
}
示例#24
0
static t_hs     parser_setup_pipeline(t_node *node)
{
  int           i;
  t_node        *child;
  int           pipefd[2];

  i = 0;
  while (i < glist_voidp_length(&node->children))
    {
      child = glist_voidp_get(&node->children, i);
      if (i)
        child->redir.input = pipefd[0];
      if ((i + 1) < glist_voidp_length(&node->children))
        {
          if (pipe(pipefd))
            return (hs("pipe() error"));
          child->redir.output = pipefd[1];
        }
      i++;
    }
  return (hs(""));
}
示例#25
0
Num solve_Sss(Num X, Num T, Num r, Num b, Num v)
{
  Num N = 2 * b / (v * v);
  Num M = 2 * r / (v * v);
  Num Sj = seed_Sss(N, M, X, T, b, v);

  Num K = 1 - exp(-r * T);
  Num d1 = bsm_general::d1(Sj, X, T, b, v);
  Num q1_ = q1(N, M, K);
  Num VS = X - Sj;
  Num HS = hs(d1, Sj, X, T, r, b, v, q1_);
  Num bj_ = bj(d1, T, r, b, v, q1_);
  Num eps = 1e-6;
  while (std::abs(VS - HS) / X > eps) {
    Sj = (X - HS + bj_ * Sj) / (1 + bj_);
    d1 = bsm_general::d1(Sj, X, T, b, v);
    VS = X - Sj;
    HS = hs(d1, Sj, X, T, r, b, v, q1_);
    bj_ = bj(d1, T, r, b, v, q1_);
  }
  return Sj;
}
示例#26
0
文件: main.cpp 项目: CCJY/coliru
    	bool Parse( Furrovine::String filename ) {
    		class ASTDeclConsumer : public clang::ASTConsumer {
    	public:
			ASTDeclConsumer( std::vector<clang::Decl*>& arg )
				: vec( arg ) {}
			std::vector<clang::Decl*>& vec;
			bool HandleTopLevelDecl( clang::DeclGroupRef arg ) {
				for ( auto && x : arg ) {
					vec.push_back( x );
				}
				return true;
			}
		};

		ASTDeclConsumer astconsumer( declarations );

		llvm::StringRef llvmfilename( reinterpret_cast<char*>( filename.data( ) ) );
		
		clang::CompilerInstance ci;
		clang::DiagnosticsEngine diagnosticsengine( diagnosticids, llvmdiagnosticsoptions.getPtr(), new clang::TextDiagnosticPrinter( errorstream, llvmdiagnosticsoptions.getPtr(), false ), true );
		clang::FileManager filemanager( filesystemoptions );
		clang::SourceManager sourcemanager( diagnosticsengine, filemanager );
		std::unique_ptr<clang::TargetInfo> targetinfo( clang::TargetInfo::CreateTargetInfo( diagnosticsengine, &targetoptions ) );
		targetinfo->setCXXABI( clang::TargetCXXABI::Microsoft );
		clang::HeaderSearchOptions& headersearchoptions = *llvmheadersearchoptions;
		clang::HeaderSearch hs( llvmheadersearchoptions, filemanager, diagnosticsengine, languageoptions, targetinfo.get( ) );
		clang::PreprocessorOptions& preprocessoroptions = *llvmpreprocessoroptions;
		clang::Preprocessor preprocessor( llvmpreprocessoroptions, diagnosticsengine, languageoptions, targetinfo.get( ), sourcemanager, hs, ci );
		clang::InitializePreprocessor( preprocessor, preprocessoroptions, headersearchoptions, frontendoptions );
		preprocessor.getBuiltinInfo( ).InitializeBuiltins( preprocessor.getIdentifierTable( ), languageoptions );
		clang::ASTContext astcontext( languageoptions, sourcemanager, targetinfo.get( ), preprocessor.getIdentifierTable( ), preprocessor.getSelectorTable( ), preprocessor.getBuiltinInfo( ), 1024 );
		clang::Sema sema( preprocessor, astcontext, astconsumer, clang::TU_Complete, null );

		const clang::DirectoryLookup* directlookup = nullptr;
		auto entry = hs.LookupFile( llvmfilename, true, nullptr, directlookup, nullptr, nullptr, nullptr, nullptr );
		if ( !entry )
			entry = filemanager.getFile( llvmfilename );
		if ( !entry )
			throw Furrovine::TException<std::exception>( "Could not find file " + filename );

		auto fileid = sourcemanager.createFileID( entry, clang::SourceLocation( ), clang::SrcMgr::CharacteristicKind::C_User );
		if ( fileid.isInvalid( ) )
			throw Furrovine::TException<std::exception>( "Error translating file " + filename );
		
		sourcemanager.setMainFileID( fileid );
		diagnosticsengine.getClient( )->BeginSourceFile( languageoptions, &preprocessor );
		clang::ParseAST( sema );
		diagnosticsengine.getClient( )->EndSourceFile( );

		return diagnosticsengine.getClient( )->getNumErrors() == 0;
    	}
示例#27
0
static t_hs	get_hostname(void)
{
  int		fd;
  char		c;
  t_hs		host;

  host = hs("");
  if ((fd = open_file(hs("/etc/hostname"), O_RDONLY)) == -1)
    return (hs("42sh"));
  while (42)
    {
      if (read(fd, &c, 1) == -1)
	{
	  close(fd);
	  return (hs("42sh"));
	}
      if (c == '\n' || c == '\0')
	break ;
      host = hs_concat_hs_char(host, c);
    }
  close(fd);
  return (host);
}
示例#28
0
void ResponseLoaderTestObject::Load(const std::string& arAPDU)
{
	fdo.Clear();
	HexSequence hs(arAPDU);
	APDU f;
	f.Write(hs, hs.Size());
	f.Interpret();

	ResponseLoader rl(mpLogger, &fdo);
	for(HeaderReadIterator hdr = f.BeginRead(); !hdr.IsEnd(); ++hdr)
	{
		rl.Process(hdr);
	}
}
KOKKOS_INLINE_FUNCTION
void SurfaceHeight<EvalT, Traits>::
operator() (const SurfaceHeight_MOUNTAIN_Tag& tag, const int& cell) const{
   const double R = pi/9.0;
      const double lambdac = 1.5*pi;
      const double thetac = pi/6.0;
        for (int qp = 0; qp < numQPs; ++qp) {
          MeshScalarT lambda = sphere_coord(cell,qp,0);
          MeshScalarT theta = sphere_coord(cell,qp,1);
          MeshScalarT radius2 = (lambda-lambdac)*(lambda-lambdac) + (theta-thetac)*(theta-thetac);
          //r^2 = min(R^2, (lambda-lambdac)^2 + (theta-thetac)^2); 
          MeshScalarT r;
          if (radius2 > R*R) r = R;
          else r = sqrt(radius2);
          hs(cell,qp) = hs0*(1.0-r/R);
        }
}
示例#30
0
typename heat::HeatKernelSignature<PointT>::HeatSignature 
heat::HeatKernelSignature<PointT>::compute(const int x, const double t, const int n_functions) {

    HeatSignature hs(new std::vector<double>(_cloud->size()));

    for (int y = 0; y < _cloud->size(); y++) {

        double sum = 0.0;
        for (int j = 0; j < n_functions; j++) {
            double lambda = _eigenvalue(j);
            Eigen::VectorXd psi = _eigenfunctions.col(j);
            sum += exp(-lambda * t) * psi(x) * psi(y); 
        }

        hs->at(y) = sum;
    }

    return hs;
}