예제 #1
0
파일: plan.hpp 프로젝트: ddemidov/vexcl
    void transform(const Expr &in) {
        if(profile) {
            std::ostringstream prof_name;
            prof_name << "fft(n={";
            for(size_t i = 0 ; i < sizes.size() ; i++) {
                if(i != 0) prof_name << ", ";
                prof_name << sizes[i];
            }
            prof_name << "}, scale=" << scale << ")";
            profile->tic_cl(prof_name.str());
            profile->tic_cl("in");
        }
        vector<T2> &in_c = bufs[input];
        if(cl_vector_length<Tv>::value == 1) in_c = r2c(in);
        else in_c = in;
        if(profile) profile->toc("in");
        for(auto run = kernels.begin(); run != kernels.end(); ++run) {
            if(!run->once || run->count == 0) {
#ifdef FFT_DUMP_ARRAYS
                for(auto b = bufs.begin(); b != bufs.end(); ++b)
                    std::cerr << "   " << std::setprecision(2) << (*b)()() << " = " << (*b) << std::endl;
                std::cerr << "run " << run->desc << std::endl;
#endif
                if(profile) {
                    std::ostringstream s;
                    s << "(k" << (run - kernels.begin()) << ")";
                    if(run->once) s << " ONCE";
                    s << " " << run->desc;
                    profile->tic_cl(s.str());
                }
                run->kernel(queues[0]);
                run->count++;
                if(profile) profile->toc("");
            }
        }
#ifdef FFT_DUMP_ARRAYS
        for(auto b = bufs.begin(); b != bufs.end(); ++b)
            std::cerr << "   " << (*b)()() << " = " << (*b) << std::endl;
#endif
        if (profile) profile->toc("");
    }
예제 #2
0
long esweep_toComplex(esweep_data *a) {
	Complex *complex;
	Wave *wave;
	Polar *polar;
	long size;
	
	if ((a==NULL) || ((*a).data==NULL) || ((*a).size<=0)) return ERR_EMPTY_CONTAINER;
	
	switch ((*a).type) {
		case WAVE:
			size=(long) (pow(2, ceil(log((*a).size)/log(2)))+0.5);
			wave=(Wave*) (*a).data;
			complex=(Complex*) calloc(size, sizeof(Complex)); /* zero padding */
			r2c(complex, wave, (*a).size);
			free(wave);
			(*a).data=complex;
			break;
		case POLAR:
			size=(*a).size;
			polar=(Polar*) (*a).data;
			complex=(Complex*) (*a).data; 
			p2c(complex, polar, (*a).size);
			free(polar);
			(*a).data=complex;
			break;
		case COMPLEX:
		case SURFACE:
		case AUDIO:
		default:
			return ERR_NOT_ON_THIS_TYPE;
	}
	
	(*a).size=size;
	(*a).type=COMPLEX;
	
	return ERR_OK;
}
예제 #3
0
파일: r2c.c 프로젝트: ISLEcode/kornshell
main(int argc, char** argv)
{
	char*		file;
	Sfio_t*		ip;

	error_info.id = "r2c";
	state.delimiter = ':';
	state.terminator = '\n';
	state.window = 4 * 1024 * 1024;
	state.level = 9;
	for (;;)
	{
		switch (optget(argv, "d:[delimiter]l#[compression-level]q:[quote]t:[terminator]vw#[window-size]T#[test-mask]"))
		{
		case 'd':
			state.delimiter = *opt_info.arg;
			continue;
		case 'l':
			state.level = opt_info.num;
			continue;
		case 'q':
			state.quote = *opt_info.arg;
			continue;
		case 't':
			state.delimiter = *opt_info.arg;
			continue;
		case 'v':
			state.verbose = 1;
			continue;
		case 'w':
			state.window = opt_info.num;
			continue;
		case 'T':
			state.test |= opt_info.num;
			continue;
		case '?':
			error(ERROR_USAGE|4, opt_info.arg);
			continue;
		case ':':
			error(2, opt_info.arg);
			continue;
		}
		break;
	}
	argv += opt_info.index;
	if (error_info.errors)
		error(ERROR_USAGE|4, "%s", optusage(NiL));
	state.cache = state.window;
	if (state.level > 0 && sfdcgzip(sfstdout, state.level) < 0)
		error(3, "output compress discipline error");
	if (!*argv)
		r2c("/dev/stdin", sfstdin, sfstdout);
	else
		while (file = *argv++)
		{
			if (streq(file, "-"))
			{
				file = "/dev/stdin";
				ip = sfstdin;
			}
			else if (!(ip = sfopen(NiL, file, "r")))
			{
				error(ERROR_SYSTEM|2, "%s: cannot read", file);
				continue;
			}
			r2c(file, ip, sfstdout);
			if (ip != sfstdin)
				sfclose(ip);
		}
	flush(sfstdout);
	return error_info.errors != 0;
}