示例#1
0
文件: cs_supp.c 项目: nasa/QuIP
static void init_cstepit_params(SINGLE_QSP_ARG_DECL)
{
	double xmin[MAX_OPT_PARAMS];
	double xmax[MAX_OPT_PARAMS];
	double deltx[MAX_OPT_PARAMS];
	double delmn[MAX_OPT_PARAMS];
	double ans[MAX_OPT_PARAMS];
	List *lp;
	Node *np;
	Opt_Param *opp;
	int i,n;
	int nfmax;		/* max. # function calls */

#ifdef THREAD_SAFE_QUERY
	cs_qsp = THIS_QSP;
#endif // THREAD_SAFE_QUERY

	lp = opt_param_list();
	if( lp == NULL ) return;

	n_prms=eltcount(lp);
	n=reset_n_params(n_prms);
	if( n != n_prms ) n_prms = n;

	np=QLIST_HEAD(lp);
	i=0;
	while( np!= NULL && i < n_prms ){
		opp = (Opt_Param *)(np->n_data);

		xmin[i]=opp->minv;
		xmax[i]=opp->maxv;
		deltx[i]=opp->delta;
		delmn[i]=opp->mindel;
		ans[i]=opp->ans;

		i++;
		np=np->n_next;
	}
	nfmax=100000;

	/* copy to fortran */

	setvals(QSP_ARG  ans,n_prms);
	setminmax(QSP_ARG  xmin,xmax,n_prms);
	setdelta(QSP_ARG  deltx,delmn,n_prms);
//advise("SETTING ntrace to 1 FOR MAX DEBUG!");
//	settrace(1);
	setmaxcalls(nfmax);
}
示例#2
0
void _disown_child( QSP_ARG_DECL  Data_Obj *dp )
{
	Node *np;

	if( OBJ_PARENT(dp) == NULL ) return;
	
	np=remData(OBJ_CHILDREN( OBJ_PARENT(dp) ),dp);
	assert( np != NULL );

	rls_node(np);

	if( eltcount(OBJ_CHILDREN( OBJ_PARENT(dp) )) == 0 ){
		rls_list(OBJ_CHILDREN( OBJ_PARENT(dp) ));	/* free list */
		OBJ_CHILDREN( OBJ_PARENT(dp) ) = NULL;
	}
}
示例#3
0
文件: pgr.c 项目: jbmulligan/quip
int get_camera_names( QSP_ARG_DECL  Data_Obj *str_dp )
{
	// Could check format of object here...
	// Should be string table with enough entries to hold the modes
	// Should the strings be rows or multidim pixels?
	List *lp;
	Node *np;
	PGR_Cam *pgcp;
	int i, n;

	lp = pgc_list();
	if( lp == NULL ){
		WARN("No cameras!?");
		return 0;
	}

	n=eltcount(lp);
	if( OBJ_COLS(str_dp) < n ){
		sprintf(ERROR_STRING,"String object %s has too few columns (%ld) to hold %d camera names",
			OBJ_NAME(str_dp),(long)OBJ_COLS(str_dp),n);
		WARN(ERROR_STRING);
		n = OBJ_COLS(str_dp);
	}
		
	np=QLIST_HEAD(lp);
	i=0;
	while(np!=NULL){
		char *dst;
		pgcp = (PGR_Cam *) NODE_DATA(np);
		dst = OBJ_DATA_PTR(str_dp);
		dst += i * OBJ_PXL_INC(str_dp);
		if( strlen(pgcp->pc_name)+1 > OBJ_COMPS(str_dp) ){
			sprintf(ERROR_STRING,"String object %s has too few components (%ld) to hold camera name \"%s\"",
				OBJ_NAME(str_dp),(long)OBJ_COMPS(str_dp),pgcp->pc_name);
			WARN(ERROR_STRING);
		} else {
			strcpy(dst,pgcp->pc_name);
		}
		i++;
		if( i>=n )
			np=NULL;
		else
			np = NODE_NEXT(np);
	}

	return i;
}
示例#4
0
文件: lookmenu.c 项目: nasa/QuIP
static COMMAND_FUNC( do_read_data )	/** read a data file */
{
	FILE *fp;
	const char *filename;
	char num_str[16];

	filename=nameof("data file");
	fp=try_open( filename, "r" );
	if( !fp ) return;

	/* We used to clear the data tables here,
	 * but now they are dynamically allocated
	 * and cleared at that time...
	 */

	/* clear old classes */
	do_delete_all_classes(SINGLE_QSP_ARG);
	//curr_tcp=NULL;
	n_have_classes=0;
	if( read_exp_data(QSP_ARG  fp) != 0 ){
		fclose(fp);
		sprintf(ERROR_STRING,"do_read_data:  error return from read_exp_data, file %s",filename);
		WARN(ERROR_STRING);
		return;
	}
	fclose(fp);
	n_have_classes = eltcount(class_list());

	sprintf(num_str,"%d",n_have_classes);	// BUG?  buffer overflow
						// if n_have_classes too big???
	assign_reserved_var( "n_classes" , num_str );
	
	if( verbose ){
		sprintf(ERROR_STRING,"File %s read, %d classes, %d x-values",
			filename,n_have_classes,_nvals);
		advise(ERROR_STRING);
	}
}
示例#5
0
文件: pgr.c 项目: jbmulligan/quip
int get_feature_choices( PGR_Cam *pgcp, const char ***chp )
{
	int n;
	const char * /* const */ * sptr;
	Node *np;

	n=eltcount(pgcp->pc_feat_lp);
	if( n <= 0 ) return(0);

	sptr = (const char **) getbuf( n * sizeof(char *) );
	*chp = sptr;

	np=QLIST_HEAD(pgcp->pc_feat_lp);
	while(np!=NULL){
		dc1394feature_info_t *f;
		f= (dc1394feature_info_t *) np->n_data;
		*sptr = /*(char *)dc1394_feature_desc[f->id - DC1394_FEATURE_MIN]*/
			dc1394_feature_get_string(f->id) ;
		sptr++;
		np=np->n_next;
	}
	return n;
}
示例#6
0
static void _list_dump_info(QSP_ARG_DECL Container *cnt_p)
{
	print_container_info_header(cnt_p);
	sprintf(MSG_STR,"\tlist with %d elements\n",eltcount(cnt_p->cnt_lp));
	prt_msg(MSG_STR);
}
示例#7
0
inline static long _list_eltcount(Container *cnt_p)
{
	return eltcount(cnt_p->cnt_lp);
}