Example #1
0
size_t PawleyFunction::calculateFunctionValues(
    const API::IPeakFunction_sptr &peak, const API::FunctionDomain1D &domain,
    API::FunctionValues &localValues) const {
  size_t domainSize = domain.size();
  const double *domainBegin = domain.getPointerAt(0);
  const double *domainEnd = domain.getPointerAt(domainSize);

  double centre = peak->centre();
  double dx = m_peakRadius * peak->fwhm();

  auto lb = std::lower_bound(domainBegin, domainEnd, centre - dx);
  auto ub = std::upper_bound(lb, domainEnd, centre + dx);

  size_t n = std::distance(lb, ub);

  if (n == 0) {
    throw std::invalid_argument("Null-domain");
  }

  FunctionDomain1DView localDomain(lb, n);
  localValues.reset(localDomain);

  peak->functionLocal(localValues.getPointerToCalculated(0),
                      localDomain.getPointerAt(0), n);

  return std::distance(domainBegin, lb);
}
Example #2
0
bool SearchManager::checkableByDomain(KURL const& url, LinkStatus const& link_parent) const
{
    bool result = false;
    if(localDomain(url))
        result = true;
    else if( (link_parent.externalDomainDepth() + 1) < external_domain_depth_ )
        result = true;
    else
        result = false;
    /*
        if(!result)
            kdDebug(23100) <<  "\n\nURL " << url.url() << " is not checkable by domain\n\n" << endl;
    */
    return result;
}
Example #3
0
vector<LinkStatus*> SearchManager::children(LinkStatus* link)
{
    vector<LinkStatus*> children;

    if(!link || link->absoluteUrl().hasRef())
        return children;

    vector<Node*> const& nodes = link->childrenNodes();

    int count = 0;
    for(uint i = 0; i != nodes.size(); ++i)
    {
        ++count;

        Node* node = nodes[i];
        KURL url;
        if(node->url().isEmpty())
            url = "";
        else
            url = Url::normalizeUrl(node->url(), *link, documentRoot().path());

        if( (node->isLink() &&
                checkable(url, *link) &&
                !Url::existUrl(url, children) &&
                !node->url().isEmpty())
                ||
                node->malformed() )
        {
            LinkStatus* ls = new LinkStatus(node, link);
            ls->setAbsoluteUrl(url);

            if(localDomain(ls->absoluteUrl()))
                ls->setExternalDomainDepth(-1);
            else
                ls->setExternalDomainDepth(link->externalDomainDepth() + 1);

            //ls->setIsLocalRestrict(localDomain(url));
            ls->setIsLocalRestrict(ls->local()); // @todo clean this nonsense

            if(!validUrl(url)) {
                ls->setMalformed(true);
                ls->setErrorOccurred(true); 
            }

            ls->setOnlyCheckHeader(onlyCheckHeader(ls));

            if(link->externalDomainDepth() > external_domain_depth_)
            {
                kdDebug(23100) <<  "link->externalDomainDepth() > external_domain_depth_: "
                << link->externalDomainDepth() << endl;
                kdDebug(23100) <<  "link: " << endl << link->toString() << endl;
                kdDebug(23100) <<  "child: " << endl << ls->toString() << endl;
            }
            Q_ASSERT(link->externalDomainDepth() <= external_domain_depth_);

            children.push_back(ls);
        }
        if(count == 50)
        {
            kapp->processEvents();
            count = 0;
        }
    }

    return children;
}
Example #4
0
void Host::updateHardwareInfo()
{
	SystemMemInfo mi = systemMemoryInfo();
	if( mi.caps & SystemMemInfo::TotalMemory )
		setMemory( mi.totalMemory / 1024 );
#ifdef Q_OS_LINUX
	QString cpu = backtick("cat /proc/cpuinfo");
	QRegExp cpuRx("physical id\\s+: (\\d+)");
	QRegExp bogoRx("bogomips\\s+: (\\d+)");
	QRegExp cpuCoresRx("cpu cores\\s+: (\\d+)");

	LOG_3( "trying to get CPU info\n"+cpu );
	if( bogoRx.indexIn(cpu) != -1 )
		setMhz( bogoRx.cap(1).toInt() );
	int cores = 1;
	if( cpuCoresRx.indexIn(cpu) != -1 )
		cores = cpuCoresRx.cap(1).toInt();

	int cpuId = 0;
	int pos = 0;
	while ((pos = cpuRx.indexIn(cpu, pos)) != -1) {
		int foundCpuId = cpuRx.cap(1).toInt();
		LOG_3("found cpu with physical id: " + QString::number(foundCpuId));
		if( foundCpuId > cpuId )
			cpuId = foundCpuId;
		pos += cpuRx.matchedLength();
		setCpus( (cpuId+1)*cores );
	}
	setCpuName(backtick("uname -p").replace("\n",""));
	setOs(backtick("uname").replace("\n",""));
	setOsVersion(backtick("uname -r").replace("\n",""));
	setArchitecture(backtick("uname -m").replace("\n",""));
	commit();
#endif
#ifdef Q_OS_MAC
	QString sys_profile = backtick("system_profiler -detailLevel -2");
	QRegExp mhzRx("(CPU|Processor) Speed: ([\\d.]+) GHz");
	if( mhzRx.indexIn(sys_profile) != -1 )
		setMhz( (mhzRx.cap(2).toFloat() * 1000) );

	QRegExp cpuNameRx("(CPU|Processor) Name: (.*)\n");
	if( cpuNameRx.indexIn(sys_profile) != -1 )
		setCpuName( cpuNameRx.cap(2).replace("\n","") );

	QRegExp memRx("Memory: (\\d+) GB");
	if( memRx.indexIn(sys_profile) != -1 )
		setMemory( (memRx.cap(1).toInt() * 1024) );

	QRegExp cpuRx("Number Of (CPUs|Cores): (\\d+)");
	if( cpuRx.indexIn(sys_profile) != -1 )
		setCpus( cpuRx.cap(2).toInt() );

	QRegExp osRx("System Version: (Mac OS X) ([\\d.]+)");
	if( osRx.indexIn(sys_profile) != -1 ) {
		setOs( osRx.cap(1) );
		setOsVersion( osRx.cap(2) );
	}

	setArchitecture(backtick("uname -m").replace("\n",""));
#endif
#ifdef Q_OS_WIN
	bool sysInfoSuccess;
	SYSTEM_INFO sysInfo = w32_getSystemInfo( &sysInfoSuccess );
	if( sysInfoSuccess ) {
		QString arch;
		switch( sysInfo.wProcessorArchitecture ) {
			case PROCESSOR_ARCHITECTURE_AMD64:
				arch = "x86_64";
				break;
			case PROCESSOR_ARCHITECTURE_IA64:
				arch = "Itanium";
				break;
			case PROCESSOR_ARCHITECTURE_INTEL:
				arch = "x86";
				break;
		}
#ifndef _WIN64
		if( !isWow64() ) setOs( "win32" );
		else
#endif
		setOs( "win64" );
		setArchitecture( arch );
		QString servicePackVersion;
		int buildNumber;
		setOsVersion( w32_getOsVersion(&servicePackVersion,&buildNumber) );
		setServicePackVersion(servicePackVersion);
		setBuildNumber(buildNumber);
		setCpus( sysInfo.dwNumberOfProcessors );
		QSettings mhzReg( "HKEY_LOCAL_MACHINE\\Hardware\\Description\\System\\CentralProcessor\\0", QSettings::NativeFormat );
		setMhz( mhzReg.value( "~MHz" ).toInt() );
		setWindowsDomain( localDomain() );
	}
#endif
	commit();
	
	
	/*
	 * Anything that will change every time this function is run should probably be in HostStatus, not in Host.
	 * All the above will be recalculated but rarely ever change and cause an actual update.
	 */
	
	HostStatus hs = hostStatus();
	Interval uptime = systemUpTime();
	hs.setSystemStartupTimestamp( uptime == Interval() ? QDateTime() : (uptime * -1.0).adjust(QDateTime::currentDateTime()) );
	hs.commit();
}