示例#1
0
method(MC3DScene, void, updateScene, voida)
{
    MC3DScene_moveCameraOneStep(0, obj, (MCDouble)1.0, (MCDouble)0.0);
    MCCamera_update(0, obj->mainCamera, obj->renderer->context);
    MCLight_update(0, obj->light, obj->renderer->context);
    
    ff(var(skyboxrenderer), updateNodes, var(skybox));

    MCGLRenderer_updateNodes(0, var(renderer), var(rootnode));
}
示例#2
0
static void
aes_decrypt_key256(const unsigned char *key, uint32_t rk[])
{
	uint32_t	ss[9];
#if defined(d_vars)
	d_vars;
#endif
	rk[v(56, (0))] = ss[0] = word_in(key, 0);
	rk[v(56, (1))] = ss[1] = word_in(key, 1);
	rk[v(56, (2))] = ss[2] = word_in(key, 2);
	rk[v(56, (3))] = ss[3] = word_in(key, 3);

#ifdef DEC_KS_UNROLL
	ss[4] = word_in(key, 4);
	rk[v(56, (4))] = ff(ss[4]);
	ss[5] = word_in(key, 5);
	rk[v(56, (5))] = ff(ss[5]);
	ss[6] = word_in(key, 6);
	rk[v(56, (6))] = ff(ss[6]);
	ss[7] = word_in(key, 7);
	rk[v(56, (7))] = ff(ss[7]);
	kdf8(rk, 0); kd8(rk, 1);
	kd8(rk, 2);  kd8(rk, 3);
	kd8(rk, 4);  kd8(rk, 5);
	kdl8(rk, 6);
#else
	rk[v(56, (4))] = ss[4] = word_in(key, 4);
	rk[v(56, (5))] = ss[5] = word_in(key, 5);
	rk[v(56, (6))] = ss[6] = word_in(key, 6);
	rk[v(56, (7))] = ss[7] = word_in(key, 7);
	{
		uint32_t	i;

		for (i = 0; i < 6; ++i)
			k8e(rk,  i);
		k8ef(rk,  6);
#if !(DEC_ROUND == NO_TABLES)
		for (i = MAX_AES_NB; i < 14 * MAX_AES_NB; ++i)
			rk[i] = inv_mcol(rk[i]);
#endif
	}
#endif	/* DEC_KS_UNROLL */
}
示例#3
0
AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1])
{   uint_32t    ss[7];
#if defined( d_vars )
        d_vars;
#endif
    cx->ks[v(48,(0))] = ss[0] = word_in(key, 0);
    cx->ks[v(48,(1))] = ss[1] = word_in(key, 1);
    cx->ks[v(48,(2))] = ss[2] = word_in(key, 2);
    cx->ks[v(48,(3))] = ss[3] = word_in(key, 3);

#if DEC_UNROLL == NONE
    cx->ks[v(48,(4))] = ss[4] = word_in(key, 4);
    cx->ks[v(48,(5))] = ss[5] = word_in(key, 5);
    {   uint_32t i;

        for(i = 0; i < 7; ++i)
            k6e(cx->ks, i);
        k6ef(cx->ks, 7);
#if !(DEC_ROUND == NO_TABLES)
        for(i = N_COLS; i < 12 * N_COLS; ++i)
            cx->ks[i] = inv_mcol(cx->ks[i]);
#endif
    }
#else
    cx->ks[v(48,(4))] = ff(ss[4] = word_in(key, 4));
    cx->ks[v(48,(5))] = ff(ss[5] = word_in(key, 5));
    kdf6(cx->ks, 0); kd6(cx->ks, 1);
    kd6(cx->ks, 2);  kd6(cx->ks, 3);
    kd6(cx->ks, 4);  kd6(cx->ks, 5);
    kd6(cx->ks, 6); kdl6(cx->ks, 7);
#endif
    cx->inf.l = 0;
    cx->inf.b[0] = 12 * 16;

#ifdef USE_VIA_ACE_IF_PRESENT
    if(VIA_ACE_AVAILABLE)
        cx->inf.b[1] = 0xff;
#endif

#if defined( AES_ERR_CHK )
    return EXIT_SUCCESS;
#endif
}
示例#4
0
void Themed::LoadTheme(const char *dir)
{
	theme.Clear();
	FindFile ff(AppendFileName(dir, "*.class"));
	while(ff) {
		String cls = ToLower(GetFileTitle(ff.GetName()));
		theme.GetAdd(cls).Load(dir, cls);
		ff.Next();
	}
}
示例#5
0
文件: rho_etc.cpp 项目: cran/lm.br
double Clmbr::drho( double th,  int k )  const
{
	if(th>=xs[ns-1])  return NaN;  else
		if(Model==M1  &&  th<=xs[0])  return NaN;  else  
			if( !R_FINITE(th) && !ISNAN(th) )  return 0.;  else  {
				const double fsq= ff(th,k);
				double dro = (a0[k] - b0[k]*th)/sqrt(fsq)/fsq; 
				if (th < th0)  dro = -dro;
				return dro;
			}
}
void U2Panel::initClipBoard(){
cout<<"initClipBoard"<<endl;

	QFile ff(cache_file);
	
	QCString cs;
	if(ff.open(IO_ReadOnly)){
		QTextStream smm(&ff);
		smm>>cs;
		clipBd=QString::fromUtf8(cs);
	}
示例#7
0
文件: Ans.cpp 项目: niyuzheno1/CODES
int main(int argc, char *argv[])
{
    setIO("sample");
    for(int i = 1;i<=10000;++i)
     insert(&u,i);
    //u.dpr(u.root,1);
    u.getd(u.root,1);
    ff(debug,"%d\n",u.h);
    closeIO();
    return EXIT_SUCCESS;
}
void
WorkoutWindow::configChanged(qint32)
{
    setProperty("color", GColor(CTRAINPLOTBACKGROUND));
    QFontMetrics fm(workout->bigFont);
    xlabel->setFont(workout->bigFont);
    ylabel->setFont(workout->bigFont);
    IFlabel->setFont(workout->bigFont);
    TSSlabel->setFont(workout->bigFont);
    IFlabel->setFixedWidth(fm.boundingRect(" 0.85 Intensity ").width());
    TSSlabel->setFixedWidth(fm.boundingRect(" 100 Stress ").width());
    xlabel->setFixedWidth(fm.boundingRect(" 00:00:00 ").width());
    ylabel->setFixedWidth(fm.boundingRect(" 1000w ").width());

    scroll->setStyleSheet(TabView::ourStyleSheet());
    toolbar->setStyleSheet(QString("::enabled { background: %1; color: %2; border: 0px; } ")
                           .arg(GColor(CTRAINPLOTBACKGROUND).name())
                           .arg(GCColor::invertColor(GColor(CTRAINPLOTBACKGROUND)).name()));

    xlabel->setStyleSheet("color: darkGray;");
    ylabel->setStyleSheet("color: darkGray;");
    TSSlabel->setStyleSheet("color: darkGray;");
    IFlabel->setStyleSheet("color: darkGray;");

    // maximum of 20 characters per line ?
    QFont f;
    QFontMetrics ff(f);
    code->setFixedWidth(ff.boundingRect("99x999s@999-999r999s@999-999").width()+(20* dpiXFactor));

    // text edit colors
    QPalette palette;
    palette.setColor(QPalette::Window, GColor(CTRAINPLOTBACKGROUND));
    palette.setColor(QPalette::Background, GColor(CTRAINPLOTBACKGROUND));

    // only change base if moved away from white plots
    // which is a Mac thing
#ifndef Q_OS_MAC
    if (GColor(CTRAINPLOTBACKGROUND) != Qt::white)
#endif
    {
        //palette.setColor(QPalette::Base, GCColor::alternateColor(GColor(CTRAINPLOTBACKGROUND)));
        palette.setColor(QPalette::Base, GColor(CTRAINPLOTBACKGROUND));
        palette.setColor(QPalette::Window, GColor(CTRAINPLOTBACKGROUND));
    }

#ifndef Q_OS_MAC // the scrollers appear when needed on Mac, we'll keep that
    code->setStyleSheet(TabView::ourStyleSheet());
#endif

    palette.setColor(QPalette::WindowText, GCColor::invertColor(GColor(CTRAINPLOTBACKGROUND)));
    palette.setColor(QPalette::Text, GCColor::invertColor(GColor(CTRAINPLOTBACKGROUND)));
    code->setPalette(palette);
    repaint();
}
示例#9
0
文件: sip.cpp 项目: jonnenauha/code
//=============================================================================
static string get_line_ (istream& in)
{
    string line;
    
    ios_base::fmtflags ff (in.flags());
    in.setf (ios_base::skipws);
    getline (in, line); 
    in.flags (ff);
    
    return line;
}
示例#10
0
Vector<String> AndroidSDK::FindBuildToolsReleases() const
{
	Vector<String> buildTools;
	
	for(FindFile ff(AppendFileName(BuildToolsDir(), "*")); ff; ff.Next()) {
		if(!ff.IsHidden() && ff.IsFolder())
			buildTools.Add(ff.GetName());
	}
	
	return buildTools;
}
示例#11
0
Vector<String> AndroidSDK::FindPlatforms() const
{
	Vector<String> platforms;
	
	for(FindFile ff(AppendFileName(PlatformsDir(), "*")); ff; ff.Next()) {
		if(!ff.IsHidden() && ff.IsFolder())
			platforms.Add(ff.GetName());
	}
	
	return platforms;
}
示例#12
0
文件: aeskey.c 项目: ParoXoN/YIFCodec
aes_rval aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1])
{   aes_32t    ss[8];
#if defined( d_vars )
        d_vars;
#endif
    cx->ks[0] = ss[0] = word_in(key, 0);
    cx->ks[1] = ss[1] = word_in(key, 1);
    cx->ks[2] = ss[2] = word_in(key, 2);
    cx->ks[3] = ss[3] = word_in(key, 3);

#if DEC_UNROLL == NONE
    cx->ks[4] = ss[4] = word_in(key, 4);
    cx->ks[5] = ss[5] = word_in(key, 5);
    cx->ks[6] = ss[6] = word_in(key, 6);
    cx->ks[7] = ss[7] = word_in(key, 7);
    {   aes_32t i;

        for(i = 0; i < (15 * N_COLS - 9) / 8; ++i)
            ke8(cx->ks,  i);
        kel8(cx->ks,  i);
#if !(DEC_ROUND == NO_TABLES)
        for(i = N_COLS; i < 14 * N_COLS; ++i)
            cx->ks[i] = inv_mcol(cx->ks[i]);

#endif
    }
#else
    cx->ks[4] = ff(ss[4] = word_in(key, 4));
    cx->ks[5] = ff(ss[5] = word_in(key, 5));
    cx->ks[6] = ff(ss[6] = word_in(key, 6));
    cx->ks[7] = ff(ss[7] = word_in(key, 7));
    kdf8(cx->ks, 0); kd8(cx->ks, 1);
    kd8(cx->ks, 2);  kd8(cx->ks, 3);
    kd8(cx->ks, 4);  kd8(cx->ks, 5);
    kdl8(cx->ks, 6);
#endif
    cx->rn = 14;
#if defined( AES_ERR_CHK )
    return aes_good;
#endif
}
示例#13
0
    vector<vector<int>> combinationSum(vector<int>& candidates, int target) {


        vector<vector<int>> res;
        function<bool(int, int, const vector<vector<int>>&)> ff =[&res, &candidates, &ff](int t, int start, const vector<vector<int>>& vec){
            if(t <0)
                return false;
            else if(t == 0){
                copy(vec.begin(), vec.end(), back_inserter(res));
                return true;
            }
            else if (start >= candidates.size())
                return false;
            else if (candidates[start] > t)
                return false;

            bool bret = false;
            for(int i = start; i < candidates.size() && candidates[i] <= t; ++i){
                if(candidates[i] <= t){
                    vector<vector<int>> mvec(vec.begin(), vec.end());
                    for_each(mvec.begin(), mvec.end(), [i, &candidates](vector<int>& item){item.push_back(candidates[i]);});

                    if(ff(t-candidates[i], i, mvec)) {
                        bret = true;
                    }

                }
            }
            return bret;

        };
        vector<vector<int>> vv{vector<int>{}};
        sort(candidates.begin(), candidates.end());
        if(ff(target, 0, vv)){
            return res;
        }
        else{
            return vector<vector<int>>{};
        }

    }
示例#14
0
void IOWorker::start(Spikework::Stack &s) {
	if(!input_filename.empty()) {
		ifstream ff(input_filename);
	    Stream str(ff, Stream::Binary);
        Ptr<SerializableBase> o = str.readBase();
        if(Ptr<SpikesList> sp = o.as<SpikesList>()) {
            s.push(sp->convertToBinaryTimeSeries(dt));
        } else {
            s.push(o);
        }
	}
}
示例#15
0
文件: pomp_fun.c 项目: cran/pomp
SEXP load_stack_decr (SEXP pack) {
  SEXP s;
  const char *pkg;
  void (*ff)(int *);
  PROTECT(s = NEW_INTEGER(1));
  pkg = (const char *) CHAR(STRING_ELT(pack,0));
  ff = (void (*)(int *)) R_GetCCallable(pkg,"__pomp_load_stack_decr");
  ff(INTEGER(s));
  if (*(INTEGER(s)) < 0) errorcall(R_NilValue,"impossible!");
  UNPROTECT(1);
  return s;
}
示例#16
0
//__attribute__((noinline))
void f(short delta)
{
    short p0 = 2, s;
    for (s = 0; s < 2; s++)
    {
        p0 += delta;
        ff(s);
        if (nunmap[p0] == 17) {
            //asm volatile("");
        }
    }
}
示例#17
0
void WorkspaceWork::LoadActualPackage()
{
	Time utime = FileGetTime(ConfigFile("version"));
	filelist.Clear();
	fileindex.Clear();
	bool open = true;
	Time tm = GetSysTime();
	for(int i = 0; i < actual.file.GetCount(); i++) {
		Package::File& f = actual.file[i];
		if(f.separator) {
			open = closed.Find(Sepfo(actualpackage, f)) < 0;
			filelist.Add(f, open ? IdeImg::SeparatorClose() : IdeImg::SeparatorOpen(),
			             ListFont().Bold(), open ? SColorMark : SColorText, true, 0, Null);
			fileindex.Add(i);
		}
		else
		if(open) {
			Color uln = Null;
			String p = SourcePath(GetActivePackage(), f);
			if(showtime) {
				FindFile ff(p);
				if(ff) {
					Time ftm = Time(ff.GetLastWriteTime());
					if(ftm > utime) {
						int64 t = tm - ftm;
						if(t < 24 * 3600)
							uln = SColorMark;
						else
						if(t < 32 * 24 * 3600)
							uln = SColorDisabled;
					}
				}
			}
			Image m = IdeFileImage(f, f.optimize_speed, false, f.pch);
			if(GetFileExt(p) == ".tpp" && IsFolder(p)) {
				if(FileExists(AppendFileName(p, "all.i")))
					m = TopicImg::IGroup();
				else
					m = TopicImg::Group();
			}
		#ifdef PLATFORM_WIN32
			p = ToLower(p);
		#endif
			if(errorfiles.Find(p) >= 0) {
				m = ImageOverRed(m);
				uln = LtRed;
			}
			filelist.Add(f, m, ListFont(), SColorText, false, 0,
			             Null, SColorMark, Null, Null, Null, uln);
			fileindex.Add(i);
		}
	}
}
示例#18
0
VectorXd feedForwardNetwork::rpropTrain(MatrixXd x, MatrixXd y, int numepochs, int batchsize, double incScale, double decScale, double incScaleMax, double decScaleMin, bool verbose) {
	// initialize training parameters
	std::vector<MatrixXd> dW(layer_size.size()-1);
	std::vector<VectorXd> dB(layer_size.size()-1);
	std::vector<ArrayXXi> signDeltaW(layer_size.size()-1);
	std::vector<ArrayXi> signDeltaB(layer_size.size()-1);

	for(int i = 0; i < layer_size.size()-1; i++) {
		dW[i].setConstant(layer_size[i+1], layer_size[i], 0.1);
		dB[i].setConstant(layer_size[i+1], 0.1);
		signDeltaW[i].setZero(layer_size[i+1], layer_size[i]);
		signDeltaB[i].setZero(layer_size[i+1]);
		}

	long n_sample = x.cols();
	if (batchsize > n_sample) batchsize = n_sample;
	int n_batch = n_sample / batchsize; // truncated if not divided
	int remainder = n_sample - n_batch*batchsize;

	int n_batch2 = n_batch; // n_batch2 is the actual batch number
	if (remainder > 0) n_batch2++;

	int s = 0;  // update iteration, total iteration = numepoch x numbatch
	VectorXd loss(numepochs*n_batch2);  // mean sum of square error/loss
	MatrixXd error;  //raw error: per sample per output dimension
	error.setConstant(numepochs, n_batch2, -1);
	PermutationMatrix<Dynamic, Dynamic> perm(n_sample);

	MatrixXd x_perm(x);
	MatrixXd y_perm(y);

	for (int i = 0; i < numepochs; i++) {
		if (verbose) cout <<  "Epoch " << i + 1 << endl;
		perm.setIdentity();
		random_shuffle(perm.indices().data(), perm.indices().data() + perm.indices().size());
		x_perm = x_perm * perm;  // col = sample, shuffle samples
		y_perm = y_perm * perm;
		int this_batchsize = batchsize;

		for(int j = 0; j < n_sample; j +=batchsize) {
			if (j >= n_sample - remainder) this_batchsize = remainder;
			error = ff(x_perm.middleCols(j, this_batchsize), y_perm.middleCols(j,  this_batchsize));
			rprop(error, dW, dB, signDeltaW, signDeltaB, incScale, decScale, incScaleMax, decScaleMin);
			if (output == "softmax") {
				loss[s] = -(y_perm.middleCols(j, this_batchsize).array() * post[layer_size.size()-1].array().log()).colwise().sum().mean();
			} else {
				loss[s] = error.array().square().mean();
				}
			s++;
			}
		}
	return loss;
	}
示例#19
0
static int	check_a(int *pile1, int *pile2, char **buf, int r[3][5])
{
	if (r[0][1] > 1 && r[1][0] && !(r[1][1] || r[1][2]))
	{
		if (r[0][2] > 1 && r[2][0])
			return ((my_ss(pile1, pile2, r[0][1], r[0][2])
					&& !ff("SWAP C", "ss ", buf, r[0])) ? 0 : 1);
			return ((my_sx(pile1, r[0][1])
					&& !ff("SWAP A", "sa ", buf, r[0])) ? 0 : 1);
	}
	else if (r[0][1] > 1 && r[1][1])
	{
		if (r[0][2] > 1 && !r[2][0] && r[2][1])
			return ((my_rr(pile1, pile2, r[0][1], r[0][2])
					&& !ff("ROTATE C", "rr ", buf, r[0])) ? 0 : 1);
			return ((my_rx(pile1, r[0][1])
					&& !ff("ROTATE A", "ra ", buf, r[0])) ? 0 : 1);
	}
	else if (r[0][1] > 1 && r[1][2])
	{
		if (r[0][2] > 1 && !r[2][0] && r[2][2])
			return ((my_rrr(pile1, pile2, r[0][1], r[0][2])
					&& !ff("REVERSE C", "rrr ", buf, r[0])) ? 0 : 1);
			return ((my_rrx(pile1, r[0][1])
					&& !ff("REVERSE A", "rra ", buf, r[0])) ? 0 : 1);
	}
	return (-1);
}
示例#20
0
aes_rval aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1])
{   aes_32t    ss[7];
#if defined( d_vars )
        d_vars;
#endif
    cx->ks[0] = ss[0] = word_in(key, 0);
    cx->ks[1] = ss[1] = word_in(key, 1);
    cx->ks[2] = ss[2] = word_in(key, 2);
    cx->ks[3] = ss[3] = word_in(key, 3);

#if DEC_UNROLL == NONE
    cx->ks[4] = ss[4] = word_in(key, 4);
    cx->ks[5] = ss[5] = word_in(key, 5);
    {   aes_32t i;

        for(i = 0; i < (13 * N_COLS - 7) / 6; ++i)
            ke6(cx->ks, i);
        kel6(cx->ks, 7);
#if !(DEC_ROUND == NO_TABLES)
        for(i = N_COLS; i < 12 * N_COLS; ++i)
            cx->ks[i] = inv_mcol(cx->ks[i]);
#endif
    }
#else
    cx->ks[4] = ff(ss[4] = word_in(key, 4));
    cx->ks[5] = ff(ss[5] = word_in(key, 5));
    kdf6(cx->ks, 0); kd6(cx->ks, 1);
    kd6(cx->ks, 2);  kd6(cx->ks, 3);
    kd6(cx->ks, 4);  kd6(cx->ks, 5);
    kd6(cx->ks, 6); kdl6(cx->ks, 7);
#endif
    cx->rn = 12;
	#if CC_AES_USE_HARDWARE
	bcopy(key, cx->keyBytes, 24);
	cx->keyLength = 24;
	#endif
#if defined( AES_ERR_CHK )
    return aes_good;
#endif
}
示例#21
0
int main()
{
	long long int sum = 1;
	for (long int num = 2; num < 100000000 ;num++){
		if (ff(num) == 0){
			std::cout << num << std::endl;
			sum += num;
		}
	}
	std::cout << sum << std::endl;
	//1739023853137
	return 0;
}
示例#22
0
	void operator() (struct HashFile &file)
	{
		QFile ff(file.file.filePath());
		if (!ff.open(QIODevice::ReadOnly))
			return;

		QByteArray data = ff.readAll();

		file.hash = QCryptographicHash::hash(data, QCryptographicHash::Md5).toHex();

		qDebug() << file.file.filePath() << value << file.hash;
		value++;
	}
aes_rval aes_decrypt_key192(const void *in_key, aes_decrypt_ctx cx[1])
{   aes_32t    ss[7];
#ifdef  d_vars
        d_vars;
#endif
    cx->ks[0] = ss[0] = word_in(in_key, 0);
    cx->ks[1] = ss[1] = word_in(in_key, 1);
    cx->ks[2] = ss[2] = word_in(in_key, 2);
    cx->ks[3] = ss[3] = word_in(in_key, 3);

#if DEC_UNROLL == NONE
    cx->ks[4] = ss[4] = word_in(in_key, 4);
    cx->ks[5] = ss[5] = word_in(in_key, 5);
    {   aes_32t i;

        for(i = 0; i < (13 * N_COLS - 1) / 6; ++i)
            ke6(cx->ks, i);
#if !(DEC_ROUND == NO_TABLES)
        for(i = N_COLS; i < 12 * N_COLS; ++i)
            cx->ks[i] = inv_mcol(cx->ks[i]);
#endif
    }
#else
    cx->ks[4] = ff(ss[4] = word_in(in_key, 4));
    cx->ks[5] = ff(ss[5] = word_in(in_key, 5));
    kdf6(cx->ks, 0); kd6(cx->ks, 1);
    kd6(cx->ks, 2);  kd6(cx->ks, 3);
    kd6(cx->ks, 4);  kd6(cx->ks, 5);
    kd6(cx->ks, 6); kdl6(cx->ks, 7);
#endif

    /* cx->ks[45] ^ cx->ks[52] ^ cx->ks[53] is zero for a 256 bit       */
    /* key and must be non-zero for 128 and 192 bits keys   */
    cx->ks[53] = cx->ks[45];
    cx->ks[52] = 12;
#ifdef AES_ERR_CHK
    return aes_good;
#endif
}
示例#24
0
int main() {
  int x,y,z, v;
    x=y=z=0;
    int b=0;

    if (x*y==3) {
        while (b) {
            y=y+2;
            z=z+x;
	    v = foo(z) * bar(z,y);
	    y = 3 * foo(2*x);
        }
    } else {
        x=x+3;
        x=x+1;
    }
    int param = 60;
    int i = ff(param);
    i = pro(i);
    ff(i);

}
示例#25
0
文件: maps.cpp 项目: cgiocoli/libCG
// try to read also the field of view
void readFits (std::string fn, std:: valarray<float> &map, int &nx, int &ny, double &fov) {
    std::auto_ptr<FITS> ff(new FITS (fn, Read));
    PHDU *h0=&ff->pHDU();
    nx=h0->axis(0);
    ny=h0->axis(1);
    h0->read(map);
    try {
        h0->readKey ("SIDEL",fov);
    }
    catch(CCfits::HDU::NoSuchKeyword) {
        fov=-1;
    }
}
示例#26
0
int main(void)
{
  int (*f)(void);
  int (*ff)(void);
  int (*ffff[4])(int, int) = { plus, minus, times, divide };

  f = test;
  printf("%d\n", f());
  ff = test2();
  printf("%d\n", ff());
  printf("%d\n", ffff[1](10, 5));
  return (0);
}
示例#27
0
void
call_func(struct tab_t * F, char *argv[]){
  const int MAXARG=8; /* max number of arguments */
  int N=1;            /* table length */
  int i,j;
  /* arguments: first and last value, step, current value */
  double A1[MAXARG], A2[MAXARG], dA[MAXARG], A[MAXARG];
  double (*ff)() = F->func;

  /* parse arguments */
  for (j=0; j<F->narg; j++){
    int n1 = parse_range(argv[j], &A1[j], &A2[j], &dA[j]);
    if (N!=1 && n1!=1 && n1!=N) error("wrong table size");
    if (n1!=1) N=n1;
    A[j] = atof(argv[j]);
  }

  /* print table header */
  if (N>1){
    printf("# %s\n", F->comm);
    printf("# %s %s\n", F->args, F->name);
  }

  /* call the function */
  for (i=0;i<N;i++){
    for (j=0; j<F->narg; j++){
      A[j] = A1[j] + i*dA[j];
      if (N>1) printf("%e ", A[j]);
    }
    switch(F->narg){
      case 0: printf("%e\n", ff()); break;
      case 1: printf("%e\n", ff(&A[0])); break;
      case 2: printf("%e\n", ff(&A[0],&A[1])); break;
      case 3: printf("%e\n", ff(&A[0],&A[1],&A[2])); break;
      case 4: printf("%e\n", ff(&A[0],&A[1],&A[2],&A[3])); break;
      case 5: printf("%e\n", ff(&A[0],&A[1],&A[2],&A[3],&A[4])); break;
      case 6: printf("%e\n", ff(&A[0],&A[1],&A[2],&A[3],&A[4],&A[5])); break;
      case 7: printf("%e\n", ff(&A[0],&A[1],&A[2],&A[3],&A[4],&A[5],&A[6])); break;
      case 8: printf("%e\n", ff(&A[0],&A[1],&A[2],&A[3],&A[4],&A[5],&A[6],&A[7])); break;
      default:
        error("Error: unsupported function prototype\n");
    }
  }
}
示例#28
0
文件: rho_etc.cpp 项目: cran/lm.br
double Clmbr::rho( double th,  int k )  const
// compute the rho function,  accurately 
{
	if( th>=xs[ns-1] || (Model==M1  &&  th<=xs[0])  )  return NaN;  else  {	//1

// check if th0 or th is on an end-interval
		bool  th1= false, th2= false, th01= false, th02= false;
		if( xs[ns-2] <= th && th < xs[ns-1] ) th2= true;  else  {
			if( (Model==M1 && xs[0]<th && th<=xs[1]) || (Model==M2 && th<=xs[0]) || (Model==M3 && (!R_FINITE(th) && !ISNAN(th))) ) th1= true;
		}
		if( xs[ns-2] <= th0 && th0 < xs[ns-1] ) th02= true;  else  {
			if(  ( Model==M1 && xs[0]<th0 && th0<=xs[1] )  ||  ( Model==M2 && th0<=xs[0] ) || (Model==M3 && (!R_FINITE(th0) && !ISNAN(th0)))  ) th01 = true;
		}

		if( th==th0 || (th1 && th01) || (th2 && th02) )  return 1.;  else  {	//2

			if( (th01 || th02)  &&  !(th1 || th2) )  {	//3

				const double fsq= ff(th,k);
				const double num= qx0[k] - q10[k]*th;
				return  num/sqrt(fsq);

			}  else  {	//3 

				if( th1 || th2 )  {	//4

					if(th1)  return  g0u1;  else  return  g0u2;

				}  else  { 
										
					const double num= f0x[k] - f01[k]*th;
					return  num/sqrt(ff(th0,k0)*ff(th,k));

				}	//4
			} //3
		} //2
	} //1

}
示例#29
0
void Settings::SetFont(const char *name, const BFont *font, fontspec family)
{
	BString pname(name);
	FFont ff(font);
	FFont dummy;
	if (family == M_PLAIN_FONT) pname.Append(FONT);
	else if (family == M_BOLD_FONT) pname.Append(BFONT);
	else pname.Append(FFONT);
	if (FindMessageFont(&pref, pname.String(), 0, &dummy) != B_OK)
		AddMessageFont(&pref, pname.String(), &ff);
	else
		pref.ReplaceFlat(pname.String(), &ff);
}
示例#30
0
void InitWwwTpp()
{
	String wwwtpp = AppendFileName(uppbox, "uppweb/www.tpp");
	FindFile ff(AppendFileName(wwwtpp, "*"));
	static Vector<String> data;
	while(ff) {
		RLOG(ff.GetName());
		Topic p = ReadTopic0(LoadFile(AppendFileName(wwwtpp, ff.GetName())));
		data.Add(p.text);
		RegisterTopic__("<uppweb/www.tpp/all.i>", GetFileTitle(ff.GetName()), p.title, data.Top(), data.Top().GetCount());
		ff.Next();
	}
};