• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PG_GETARG_FLOAT8函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PG_GETARG_FLOAT8函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_FLOAT8函数的具体用法?C++ PG_GETARG_FLOAT8怎么用?C++ PG_GETARG_FLOAT8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PG_GETARG_FLOAT8函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: internal_get_array_of_close_canopies

Datum
internal_get_array_of_close_canopies(PG_FUNCTION_ARGS)
{
    SvecType       *svec;
    Datum          *all_canopies;
    int             num_all_canopies;
    float8          threshold;
    PGFunction      metric_fn;
    
    ArrayType      *close_canopies_arr;
    int32          *close_canopies;
    int             num_close_canopies;
    size_t          bytes;
    MemoryContext   mem_context_for_function_calls;
    
    svec = PG_GETARG_SVECTYPE_P(verify_arg_nonnull(fcinfo, 0));
    get_svec_array_elms(PG_GETARG_ARRAYTYPE_P(verify_arg_nonnull(fcinfo, 1)),
        &all_canopies, &num_all_canopies);
    threshold = PG_GETARG_FLOAT8(verify_arg_nonnull(fcinfo, 2));
    metric_fn = get_metric_fn(PG_GETARG_INT32(verify_arg_nonnull(fcinfo, 3)));
    
    mem_context_for_function_calls = setup_mem_context_for_functional_calls();
    close_canopies = (int32 *) palloc(sizeof(int32) * num_all_canopies);
    num_close_canopies = 0;
    for (int i = 0; i < num_all_canopies; i++) {
        if (compute_metric(metric_fn, mem_context_for_function_calls,
                PointerGetDatum(svec), all_canopies[i]) < threshold)
            close_canopies[num_close_canopies++] = i + 1 /* lower bound */;
    }
    MemoryContextDelete(mem_context_for_function_calls);

    /* If we cannot find any close canopy, return NULL. Note that the result
     * we return will be passed to internal_kmeans_closest_centroid() and if the
     * array of close canopies is NULL, then internal_kmeans_closest_centroid()
     * will consider and compute the distance to all centroids. */
    if (num_close_canopies == 0)
        PG_RETURN_NULL();

    bytes = ARR_OVERHEAD_NONULLS(1) + sizeof(int32) * num_close_canopies;
    close_canopies_arr = (ArrayType *) palloc0(bytes);
    SET_VARSIZE(close_canopies_arr, bytes);
    ARR_ELEMTYPE(close_canopies_arr) = INT4OID;
    ARR_NDIM(close_canopies_arr) = 1;
    ARR_DIMS(close_canopies_arr)[0] = num_close_canopies;
    ARR_LBOUND(close_canopies_arr)[0] = 1;
    memcpy(ARR_DATA_PTR(close_canopies_arr), close_canopies,
        sizeof(int32) * num_close_canopies);

    PG_RETURN_ARRAYTYPE_P(close_canopies_arr);
}
开发者ID:CheJharia,项目名称:madlib,代码行数:50,代码来源:kmeans.c


示例2: dsign

/*
 *		dsign			- returns -1 if the argument is less than 0, 0
 *						  if the argument is equal to 0, and 1 if the
 *						  argument is greater than zero.
 */
Datum
dsign(PG_FUNCTION_ARGS)
{
	float8		arg1 = PG_GETARG_FLOAT8(0);
	float8		result;

	if (arg1 > 0)
		result = 1.0;
	else if (arg1 < 0)
		result = -1.0;
	else
		result = 0.0;

	PG_RETURN_FLOAT8(result);
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:20,代码来源:float.c


示例3: hashfloat8

Datum
hashfloat8(PG_FUNCTION_ARGS)
{
	float8		key = PG_GETARG_FLOAT8(0);

	/*
	 * On IEEE-float machines, minus zero and zero have different bit
	 * patterns but should compare as equal.  We must ensure that they
	 * have the same hash value, which is most easily done this way:
	 */
	if (key == (float8) 0)
		PG_RETURN_UINT32(0);

	return hash_any((unsigned char *) &key, sizeof(key));
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:15,代码来源:hashfunc.c


示例4: earth_get_square

Datum earth_get_square(PG_FUNCTION_ARGS)
{
	Point	   *pt = PG_GETARG_POINT_P(0);
	double	   dist = PG_GETARG_FLOAT8(1);
	BOX	   *box;

    if(!( (earth_check_point(pt) == 0) && (earth_check_dist(dist) == 0))) 
    		ereport(ERROR,
			(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
			errmsg("attempt to get a box form a dist:%.10f rad for a point:(lat=%.10f, lon=%.10f) out of range",dist,pt->x,pt->y)));
	
	box = earth_get_box_internal(pt, dist);

	PG_RETURN_BOX_P(box);
}
开发者ID:olivierch,项目名称:openBarter,代码行数:15,代码来源:earthrad.c


示例5: cash_div_flt8

/* cash_div_flt8()
 * Divide cash by float8.
 *
 * XXX Don't know if rounding or truncating is correct behavior.
 * Round for now. - tgl 97/04/15
 */
Datum
cash_div_flt8(PG_FUNCTION_ARGS)
{
    Cash		c = PG_GETARG_CASH(0);
    float8		f = PG_GETARG_FLOAT8(1);
    Cash		result;

    if (f == 0.0)
        ereport(ERROR,
                (errcode(ERRCODE_DIVISION_BY_ZERO),
                 errmsg("division by zero")));

    result = rint(c / f);
    PG_RETURN_CASH(result);
}
开发者ID:yangineer,项目名称:cscd43-1,代码行数:21,代码来源:cash.c


示例6: aggr_InfoGain

Datum aggr_InfoGain(PG_FUNCTION_ARGS) {
	ArrayType *state  = PG_GETARG_ARRAYTYPE_P(0);
	int dimstate = ARR_NDIM(state);
    int *dimsstate = ARR_DIMS(state);
	int numstate = ArrayGetNItems(dimstate,dimsstate);
    float8 *vals_state=(float8 *)ARR_DATA_PTR(state);
    
	float8 truevalue = PG_GETARG_FLOAT8(1);
	float8 trueweight = PG_GETARG_FLOAT8(2);
	int32 posclasses = PG_GETARG_INT32(3);
	int32 trueclass = PG_GETARG_INT32(5);
   	ArrayType *pgarray;

	vals_state[0] += trueweight;
	vals_state[trueclass] += trueweight;
	
	vals_state[(int)(truevalue*(posclasses+1))] += trueweight;
	vals_state[(int)(truevalue*(posclasses+1) + trueclass)] += trueweight;
  
    pgarray = construct_array((Datum *)vals_state,
		numstate,FLOAT8OID,
		sizeof(float8),true,'d');
    PG_RETURN_ARRAYTYPE_P(pgarray);
}
开发者ID:abhigp,项目名称:madlib,代码行数:24,代码来源:decision_tree.c


示例7: cube_f8

/* Create a one dimensional box with identical upper and lower coordinates */
Datum
cube_f8(PG_FUNCTION_ARGS)
{
	double		x = PG_GETARG_FLOAT8(0);
	NDBOX	   *result;
	int			size;

	size = offsetof(NDBOX, x[0]) +sizeof(double) * 2;
	result = (NDBOX *) palloc0(size);
	SET_VARSIZE(result, size);
	result->dim = 1;
	result->x[0] = result->x[1] = x;

	PG_RETURN_NDBOX(result);
}
开发者ID:DBInsight,项目名称:postgres-x2,代码行数:16,代码来源:cube.c


示例8: cube_f8

/* Create a one dimensional box with identical upper and lower coordinates */
Datum
cube_f8(PG_FUNCTION_ARGS)
{
	NDBOX	   *result;
	int			size;

	size = offsetof(NDBOX, x[0]) + sizeof(double) * 2;
	result = (NDBOX *) palloc(size);
	memset(result, 0, size);
	result->size = size;
	result->dim = 1;
	result->x[0] = PG_GETARG_FLOAT8(0);
	result->x[1] = result->x[0];

	PG_RETURN_NDBOX(result);
}
开发者ID:asurinsaka,项目名称:postgresql-8.2.19-lru,代码行数:17,代码来源:cube.c


示例9: dsqrt

/*
 *		dsqrt			- returns square root of arg1
 */
Datum
dsqrt(PG_FUNCTION_ARGS)
{
	float8		arg1 = PG_GETARG_FLOAT8(0);
	float8		result;

	if (arg1 < 0)
		ereport(ERROR,
				(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
				 errmsg("cannot take square root of a negative number")));

	result = sqrt(arg1);

	CheckFloat8Val(result);
	PG_RETURN_FLOAT8(result);
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:19,代码来源:float.c


示例10: orafce_to_char_float8

Datum
orafce_to_char_float8(PG_FUNCTION_ARGS)
{
	float8		arg0 = PG_GETARG_FLOAT8(0);
	StringInfo	buf = makeStringInfo();
	struct lconv *lconv = PGLC_localeconv();
	char	   *p;

	appendStringInfo(buf, "%f", arg0);

	for (p = buf->data; *p; p++)
		if (*p == '.')
			*p = lconv->decimal_point[0];

	PG_RETURN_TEXT_P(cstring_to_text(buf->data));
}
开发者ID:50wu,项目名称:gpdb,代码行数:16,代码来源:convert.c


示例11: float48div

Datum
float48div(PG_FUNCTION_ARGS)
{
	float4		arg1 = PG_GETARG_FLOAT4(0);
	float8		arg2 = PG_GETARG_FLOAT8(1);
	float8		result;

	if (arg2 == 0.0)
		ereport(ERROR,
				(errcode(ERRCODE_DIVISION_BY_ZERO),
				 errmsg("division by zero")));

	result = arg1 / arg2;
	CheckFloat8Val(result);
	PG_RETURN_FLOAT8(result);
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:16,代码来源:float.c


示例12: cube_f8

/* Create a one dimensional box with identical upper and lower coordinates */
Datum
cube_f8(PG_FUNCTION_ARGS)
{
	double		x = PG_GETARG_FLOAT8(0);
	NDBOX	   *result;
	int			size;

	size = POINT_SIZE(1);
	result = (NDBOX *) palloc0(size);
	SET_VARSIZE(result, size);
	SET_DIM(result, 1);
	SET_POINT_BIT(result);
	result->x[0] = x;

	PG_RETURN_NDBOX(result);
}
开发者ID:adam8157,项目名称:gpdb,代码行数:17,代码来源:cube.c


示例13: delta_e_cmc_full

Datum
delta_e_cmc_full(PG_FUNCTION_ARGS)
{
    float8  result;
    float8 l1 = PG_GETARG_FLOAT8(0);
    float8 a1 = PG_GETARG_FLOAT8(1);
    float8 b1 = PG_GETARG_FLOAT8(2);
    float8 l2 = PG_GETARG_FLOAT8(3);
    float8 a2 = PG_GETARG_FLOAT8(4);
    float8 b2 = PG_GETARG_FLOAT8(5);
    float8 pl = PG_GETARG_FLOAT8(6);
    float8 pc = PG_GETARG_FLOAT8(7);

    result = colors_delta_e_cmc(l1, a1, b1, l2, a2, b2, pl, pc);

    PG_RETURN_FLOAT8(result);

}
开发者ID:zejn,项目名称:pg-colors,代码行数:18,代码来源:colors.c


示例14: dbms_alert_waitany

Datum
dbms_alert_waitany(PG_FUNCTION_ARGS)
{
	float8 timeout;
	TupleDesc   tupdesc;
	AttInMetadata       *attinmeta;
	HeapTuple   tuple;
	Datum       result;
	char *str[3] = {NULL, NULL, "1"};
	int cycle = 0;
	float8 endtime;
	TupleDesc	btupdesc;

	if (PG_ARGISNULL(0))
		timeout = TDAYS;
	else
		timeout = PG_GETARG_FLOAT8(0);

	WATCH_PRE(timeout, endtime, cycle);
	if (ora_lock_shmem(SHMEMMSGSZ, MAX_PIPES, MAX_EVENTS, MAX_LOCKS, false))
	{
		str[1]  = find_and_remove_message_item(-1, sid,
							   true, false, false, NULL, &str[0]);
		if (str[0])
		{
			str[2] = "0";
			LWLockRelease(shmem_lock);
			break;
		}
		LWLockRelease(shmem_lock);
	}
	WATCH_POST(timeout, endtime, cycle);

	get_call_result_type(fcinfo, NULL, &tupdesc);
	btupdesc = BlessTupleDesc(tupdesc);
	attinmeta = TupleDescGetAttInMetadata(btupdesc);
	tuple = BuildTupleFromCStrings(attinmeta, str);
	result = HeapTupleGetDatum(tuple);

	if (str[0])
		pfree(str[0]);

	if (str[1])
		pfree(str[1]);

	return result;
}
开发者ID:WhiteCatmi,项目名称:orafce,代码行数:47,代码来源:alert.c


示例15: gbt_float8_distance

Datum
gbt_float8_distance(PG_FUNCTION_ARGS)
{
	GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
	float8		query = PG_GETARG_FLOAT8(1);

	/* Oid		subtype = PG_GETARG_OID(3); */
	float8KEY  *kkk = (float8KEY *) DatumGetPointer(entry->key);
	GBT_NUMKEY_R key;

	key.lower = (GBT_NUMKEY *) &kkk->lower;
	key.upper = (GBT_NUMKEY *) &kkk->upper;

	PG_RETURN_FLOAT8(
			gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
		);
}
开发者ID:BioBD,项目名称:Hypothetical_Indexes,代码行数:17,代码来源:btree_float8.c


示例16: internal_remove_close_canopies

Datum
internal_remove_close_canopies(PG_FUNCTION_ARGS) {
    ArrayType      *all_canopies_arr;
    Datum          *all_canopies;
    int             num_all_canopies;
    PGFunction      metric_fn;
    float8          threshold;
    
    Datum          *close_canopies;
    int             num_close_canopies;
    bool            addIndexI;
    MemoryContext   mem_context_for_function_calls;

    all_canopies_arr = PG_GETARG_ARRAYTYPE_P(verify_arg_nonnull(fcinfo, 0));
    get_svec_array_elms(all_canopies_arr, &all_canopies, &num_all_canopies);
    metric_fn = get_metric_fn(PG_GETARG_INT32(verify_arg_nonnull(fcinfo, 1)));
    threshold = PG_GETARG_FLOAT8(verify_arg_nonnull(fcinfo, 2));
    
    mem_context_for_function_calls = setup_mem_context_for_functional_calls();
    close_canopies = (Datum *) palloc(sizeof(Datum) * num_all_canopies);
    num_close_canopies = 0;
    for (int i = 0; i < num_all_canopies; i++) {
        addIndexI = true;
        for (int j = 0; j < num_close_canopies; j++) {
            if (compute_metric(metric_fn, mem_context_for_function_calls,
                all_canopies[i], close_canopies[j]) < threshold) {
                
                addIndexI = false;
                break;
            }
        }
        if (addIndexI)
            close_canopies[num_close_canopies++] = all_canopies[i];
    }
    MemoryContextDelete(mem_context_for_function_calls);
    
    PG_RETURN_ARRAYTYPE_P(
        construct_array(
            close_canopies, /* elems */
            num_close_canopies, /* nelems */
            ARR_ELEMTYPE(all_canopies_arr), /* elmtype */
            -1, /* elmlen */
            false, /* elmbyval */
            'd') /* elmalign */
        );
}
开发者ID:0x0all,项目名称:madlib,代码行数:46,代码来源:kmeans.c


示例17: gbt_float8_consistent

Datum
gbt_float8_consistent(PG_FUNCTION_ARGS)
{

	GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
	float8		query = PG_GETARG_FLOAT8(1);
	float8KEY  *kkk = (float8KEY *) DatumGetPointer(entry->key);
	GBT_NUMKEY_R key;
	StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);

	key.lower = (GBT_NUMKEY *) & kkk->lower;
	key.upper = (GBT_NUMKEY *) & kkk->upper;

	PG_RETURN_BOOL(
				   gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo)
		);
}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:17,代码来源:btree_float8.c


示例18: pg_sleep

/*
 * pg_sleep - delay for N seconds
 */
Datum
pg_sleep(PG_FUNCTION_ARGS)
{
	float8		secs = PG_GETARG_FLOAT8(0);
	float8		endtime;

	/*
	 * We sleep using WaitLatch, to ensure that we'll wake up promptly if an
	 * important signal (such as SIGALRM or SIGINT) arrives.  Because
	 * WaitLatch's upper limit of delay is INT_MAX milliseconds, and the user
	 * might ask for more than that, we sleep for at most 10 minutes and then
	 * loop.
	 *
	 * By computing the intended stop time initially, we avoid accumulation of
	 * extra delay across multiple sleeps.  This also ensures we won't delay
	 * less than the specified time when WaitLatch is terminated early by a
	 * non-query-canceling signal such as SIGHUP.
	 */
#define GetNowFloat()	((float8) GetCurrentTimestamp() / 1000000.0)

	endtime = GetNowFloat() + secs;

	for (;;)
	{
		float8		delay;
		long		delay_ms;

		CHECK_FOR_INTERRUPTS();

		delay = endtime - GetNowFloat();
		if (delay >= 600.0)
			delay_ms = 600000;
		else if (delay > 0.0)
			delay_ms = (long) ceil(delay * 1000.0);
		else
			break;

		(void) WaitLatch(MyLatch,
						 WL_LATCH_SET | WL_TIMEOUT,
						 delay_ms,
						 WAIT_EVENT_PG_SLEEP);
		ResetLatch(MyLatch);
	}

	PG_RETURN_VOID();
}
开发者ID:dreamsxin,项目名称:postgresql-1,代码行数:49,代码来源:misc.c


示例19: pgm_svm_train

Datum pgm_svm_train(PG_FUNCTION_ARGS){

    PGM_Matriz_Double *matrix = (PGM_Matriz_Double*)PG_GETARG_POINTER(0);
    PGM_Vetor_Double *vector = (PGM_Vetor_Double*)PG_GETARG_POINTER(1);

    struct svm_parameter *param = (struct svm_parameter*) pgm_malloc (sizeof(struct svm_parameter));
    struct svm_problem* prob;
    //Cross Validation
    int cross_validation = 0,
        n_fold = PG_GETARG_INT32(14);

    if (n_fold < 2 && n_fold != 0) exit_with_help();
    else if( n_fold >= 2){
        cross_validation = 1;
        elog(ERROR,"CROSS VALIDATION NÃO IMPLEMENTADO");
    }

    //Mount Parameter Struct
    param->svm_type = PG_GETARG_INT32(2);
	param->kernel_type= PG_GETARG_INT32(3);
	param->degree= PG_GETARG_INT32(4);
	param->gamma= PG_GETARG_FLOAT8(5);
	param->coef0= PG_GETARG_FLOAT8(6);
	param->cache_size= PG_GETARG_FLOAT8(7);
	param->eps= PG_GETARG_FLOAT8(8);
	param->C= PG_GETARG_FLOAT8(9);
	param->nr_weight = 0;
	param->weight_label = NULL;
	param->weight = NULL;
	param->nu= PG_GETARG_FLOAT8(10);
	param->p= PG_GETARG_FLOAT8(11);
	param->shrinking= PG_GETARG_INT32(12);
	param->probability= PG_GETARG_INT32(13);

	prob = PGM_Matriz_Double2svm_problem(matrix,vector,param);

	if (cross_validation){
        do_cross_validation(prob,param,n_fold);
        elog(ERROR,"CROSS VALIDATION NÃO IMPLEMENTADO"); // Pergunta ao Filipe sobre isso!
        PG_RETURN_VOID();
	}else{

        MemoryContext contextoAnterior = MemoryContextSwitchTo( CurTransactionContext );
        struct svm_model *model = svm_train(prob,param);
        MemoryContextSwitchTo( contextoAnterior );
        PG_RETURN_POINTER(model);
	}
}
开发者ID:faustofjunqueira,项目名称:pgminer,代码行数:48,代码来源:pgm_svm.c


示例20: quantile_append_numeric

Datum
quantile_append_numeric(PG_FUNCTION_ARGS)
{
    
    struct_numeric * data;
    
    MemoryContext oldcontext;
    MemoryContext aggcontext;

    GET_AGG_CONTEXT("quantile_append_numeric", fcinfo, aggcontext);
    
    oldcontext = MemoryContextSwitchTo(aggcontext);
        
    if (PG_ARGISNULL(0)) {
        data = (struct_numeric*)palloc(sizeof(struct_numeric));
        data->elements  = (Numeric*)palloc(SLICE_SIZE*sizeof(Numeric));
        data->nelements = SLICE_SIZE;
        data->next = 0;
        
        data->quantiles = (double*)palloc(sizeof(double));
        data->quantiles[0] = PG_GETARG_FLOAT8(2);
        data->nquantiles = 1;
    } else {
        data = (struct_numeric*)PG_GETARG_POINTER(0);
    }
    
    /* ignore NULL values */
    if (! PG_ARGISNULL(1)) {
    
        Numeric element = PG_GETARG_NUMERIC(1);
        
        if (data->next > data->nelements-1) {
            data->elements = (Numeric*)repalloc(data->elements, sizeof(Numeric)*(data->nelements + SLICE_SIZE));
            data->nelements = data->nelements + SLICE_SIZE;
        }
        
        data->elements[data->next++] = element;
        
    }
    
    MemoryContextSwitchTo(oldcontext);
    
    PG_RETURN_POINTER(data);

}
开发者ID:kimhanse,项目名称:quantile,代码行数:45,代码来源:quantile.c



注:本文中的PG_GETARG_FLOAT8函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PG_GETARG_HS函数代码示例发布时间:2022-05-30
下一篇:
C++ PG_GETARG_DATUM函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap