Exemplo n.º 1
0
int getG(long long x, int low = 2)
{
	if (x <= maxn && g[x] != -1)
	{
		return g[x];
	}
	printf("%lld\n", x);
	long long ans = -1;
	int sqr = sqrt(x + 0.5);
	for (int i = low; i <= sqr; ++i)
	{
		if (x % i == 0)
		{
			if (x / i % i == 0)
			{
				ans = getMu(x / i, i) * powmod(i, K);
			}
			else
			{
				ans = getMu(x / i, i) * powmod(i, K) - getG(x / i, i);
			}
			break;
		}
	}
	if (ans == -1)
	{
		ans = powmod(x, K) - 1;
	}
	if (x <= maxn)
	{
		g[x] = ans;
	}
	return ans;
}
void StationaryCholesky::computeGammak( const gsl_matrix *Rt, double reg ) {
  gsl_matrix_view submat;
  
  for (size_t k = 0; k < getMu(); k++) { 
    submat = gsl_matrix_submatrix(myGammaK, 0, k * getD(), getD(), getD());
    myStStruct->AtVkB(&submat.matrix, k, Rt, Rt, myTempVijtRt);
 
    if (reg > 0) {
      gsl_vector diag = gsl_matrix_diagonal(&submat.matrix).vector;
      gsl_vector_add_constant(&diag, reg);
    }    
  }
  submat = gsl_matrix_submatrix(myGammaK, 0, getMu() * getD(), getD(), getD());
  gsl_matrix_set_zero(&submat.matrix);
}
Exemplo n.º 3
0
int main(){
    getMu();
    int t1,t2,k,kase=1,temp,_;
    long long  ans1,ans2;
    scanf("%d",&_);
    while(_--){
        scanf("%*d%d%*d%d%d",&t1,&t2,&k);
        if(k==0){
            printf("Case %d: 0\n",kase++);
            continue;
        }
        t1=t1/k;
        t2=t2/k;
        if(t1>t2){
            temp=t1;
            t1=t2;
            t2=temp;
        }
        ans1=ans2=0;
        for(int i=1;i<=t1;i++)
            ans1+=(long long)mu[i]*(t1/i)*(t2/i);
        for(int i=1;i<=t1;i++)
            ans2+=(long long)mu[i]*(t1/i)*(t1/i);
        printf("Case %d: %I64d\n",kase++,ans1-ans2/2);
    }
    return 0;
}
Exemplo n.º 4
0
QString LevelOneDec::getAlphaString(int i)
{
    double vecMultiplic = 0;
    double muMultiplic = 0;
    if (!i)
    {
        return QString::number(0);
    }
    else
    {
        for (size_t j = 0; j < col; ++j)
        {
            vecMultiplic += vectorSensorReadings2DToLevelOne[0][j] * vectorSensorReadings2DToLevelOne[i][j];
            muMultiplic = getMu(0) * getMu(i);
        }
    }
    return QString::number(ArcCos(vecMultiplic/muMultiplic), 'f', 6);
}
Exemplo n.º 5
0
/*!
    \fn CvGaborFeature::writeTXT(const char *filename) const
 */
void CvGaborFeature::writeTXT(const char *filename) const
{
  FILE * file;
  file = fopen (filename,"a");
  
  int x = getx();
  int y = gety();
  int Mu = getMu();
  int Nu = getNu();
  double merror = geterror();
  
  fprintf (file, "%d %d %d %d %f\n",x, y, Nu, Mu, merror);

  fclose(file);
}
Exemplo n.º 6
0
/*!
    \fn CvGaborFeature::writeXML(const char* filename) const
 */
void CvGaborFeature::writeXML(const char* filename) const
{
  CvMemStorage* storage = cvCreateMemStorage( 0 );
  CvFileStorage* fs = cvOpenFileStorage( filename, storage, CV_STORAGE_WRITE);
 
  cvStartWriteStruct( fs, "CvGaborFeature",
                      CV_NODE_MAP, NULL,
                      cvAttrList(0,0));
  cvWriteInt(fs, "x", getx());
  cvWriteInt(fs, "y", gety());
  cvWriteInt(fs, "Mu",getMu());
  cvWriteInt(fs, "Nu",getNu());
  cvEndWriteStruct(fs); 
  cvEndWriteStruct( fs );
  
  cvReleaseFileStorage(&fs);
  cvReleaseMemStorage(&storage);
}
void StationaryCholesky::computeGammaUpperTrg( const gsl_matrix *R, double reg ) {
  computeGammak(R, reg);
  
  size_t row_gam, col_gam, icor;
  double *gp = myPackedCholesky;
    
  for (size_t i = 0; i < myDMu; i++) {
    for (size_t j = 0; j < getD(); j++) {
      icor = i + j + 1;
      gp[i + j * myDMu] = gsl_matrix_get(myGammaK, 
          icor % getD(), j + (getMu() - (icor / getD())) * getD());
    }
  }
  for (size_t r = 1; r < getN(); r++) {
    gp +=  myDMu * getD();
    memcpy(gp, myPackedCholesky, myDMu * getD() * sizeof(double));
  }
}
Exemplo n.º 8
0
void LevelOneDec::setVectorsToTables()
{
    for (size_t i = 0; i < row; ++i)
    {
        muVector.push_back(getMu(i));
        alphaVector.push_back(getAlphaString(i));
    }

    createVector2DSensReadingsLow(0.003);
    createVector2DSensReadingsHigh(0.003);

    for (size_t i = 0; i < row; ++i)
    {
        muLowerLimitVector.push_back(getMuLowerLimit(i));
        muUpperLimitVector.push_back(getMuHighLimit(i));
    }

#ifdef _DEBUG
    qDebug() << "Size of mu Low:" << muLowerLimitVector.size();
    qDebug() << "Size of mu High:" << muUpperLimitVector.size();
#endif

    avrg_mu = getAvrgMu();
    avrg_alpha = getAvrgAlpha();

    for (size_t i = 0; i <= row; ++i)
    {
        getMuForecast(i, 0.1);
        getAlphaForecast(i, 0.1);
    }

    tableLevelOneModel->setCurrencyVectors(vectorDateToLevelOne,
                                           muVector,
                                           muVectorForecast,
                                           alphaVector,
                                           alphaVectorForecast);

    tableStabilityLevelOneModel->setCurrencyVectors(vectorDateToLevelOne,
                                                    muLowerLimitVector,
                                                    muVector,
                                                    muUpperLimitVector);

    viewTableLevelOneModel->selectRow(row);
}
void AdaptiveSO2CPGSynPlas::updateWeights() {
    const double& phi     = getPhi();
    const double& beta    = getBeta();
    const double& gamma   = getGamma();
    const double& epsilon = getEpsilon();
    const double& mu      = getMu();
    const double& F       = getOutput(2);
    const double& w01     = getWeight(0,1);
    const double& x       = getOutput(0);
    const double& y       = getOutput(1);
    const double& P       = getPerturbation();

    // general approach
    setPhi    ( phi     + mu * gamma * F * w01 * y );
    setBeta   ( beta    + betaHebbRate    * x * F - betaDecayRate    * (beta    - betaZero) );
    setGamma  ( gamma   + gammaHebbRate   * x * F - gammaDecayRate   * (gamma   - gammaZero) );
    setEpsilon( epsilon + epsilonHebbRate * F * P - epsilonDecayRate * (epsilon - epsilonZero) );

}
Exemplo n.º 10
0
int main()
{
	getMu();
	memset(num, 0, sizeof(num));
	for (int i = 0; i < cnt; i++)
		for (LL j = prime[i]; j < N; j = j * prime[i])
		for (int k = j; k < N; k+=j)
			num[k]++;
	memset(f, 0, sizeof(f));
	for (int i = 1; i < N; i++)
		for (int j = i; j < N; j+=i)
		f[j][num[i]] += mu[j/i];
	for (int i = 1; i < N; i++)
		for (int j = 1; j < 25; j++)
			f[i][j] += f[i][j-1];
	for (int i = 1; i < N; i++)
		for (int j = 0; j < 25; j++)
			f[i][j] += f[i-1][j];

	int T;
	scanf("%d", &T);
	while (T--)
	{
		LL n, m, p;
		scanf("%lld%lld%lld", &n, &m, &p);
		LL ans = 0;
		if (n > m)
		{
			n = n ^ m;
			m = n ^ m;
			n = n ^ m;
		}
		for (int i = 1; i <= n; i++)
		{
			int k = MIN(n/(n/i), m/(m/i));
			ans += (f[k][p] - f[i-1][p])*(n/i)*(m/i);
			i = k;
		}
		printf("%lld\n", ans);
	}
	return 0;
}
Exemplo n.º 11
0
int getMu(long long x, int low = 2)
{
	if (x <= maxn)
	{
		return mu[x];
	}
	int sqr = sqrt(x + 0.5);
	for (int i = low; i <= sqr; ++i)
	{
		if (x % i == 0)
		{
			if (x / i % i == 0)
			{
				return 0;
			}
			return getMu(x / i, i + 1) * -1;
		}
	}
	return -1;
}
StationaryCholesky::StationaryCholesky( const StationaryStructure *s,  size_t d ) : 
                                      MuDependentCholesky(s, d), myStStruct(s)  {
  myGammaK = gsl_matrix_alloc(d, d * (getMu() + 1));
}