当前位置: 首页>>代码示例>>C++>>正文


C++ ARR_DATA_PTR函数代码示例

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


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

示例1: nb_classify_combine

Datum 
nb_classify_combine(PG_FUNCTION_ARGS)
{
	HeapTupleHeader    tup;
	TupleDesc          resultDesc;
	HeapTuple          result;
	Datum              resultDatum[3];
	bool               resultNull[3];
	nb_classify_state  state[2];
	float8            *prior_data1;
	float8            *prior_data2;
	int                nclasses;
	int                i;

	/* Need to be called with two arguments */
	if (PG_NARGS() != 2)
	{
		ereport(ERROR,
				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
				 errmsg("nb_classify_final called with %d arguments", 
						PG_NARGS())));
	}
	if (PG_ARGISNULL(0) && PG_ARGISNULL(1))
		PG_RETURN_NULL();
	if (PG_ARGISNULL(1))
		PG_RETURN_DATUM(PG_GETARG_DATUM(0));
	if (PG_ARGISNULL(0))
		PG_RETURN_DATUM(PG_GETARG_DATUM(1));


	tup = (fcinfo->context && IsA(fcinfo->context, AggState))
		? PG_GETARG_HEAPTUPLEHEADER(0)
		: PG_GETARG_HEAPTUPLEHEADER_COPY(0);
	get_nb_state(tup, &state[0], 0);
	nclasses = ARR_DIMS(state[0].classes)[0];

	get_nb_state(PG_GETARG_HEAPTUPLEHEADER(1), &state[1], nclasses);

	/* The the prior with maximum likelyhood */
	prior_data1 = (float8*) ARR_DATA_PTR(state[0].accum);
	prior_data2 = (float8*) ARR_DATA_PTR(state[1].accum);
	nclasses = ARR_DIMS(state[0].classes)[0];
	for (i = 0; i < nclasses; i++)
		prior_data1[i] += prior_data2[i];

	/* Construct the return tuple */
	if (get_call_result_type(fcinfo, NULL, &resultDesc) != TYPEFUNC_COMPOSITE)
		elog(ERROR, "return type must be a row type");
	BlessTupleDesc(resultDesc);
	
	resultDatum[0] = PointerGetDatum(state[0].classes);
	resultDatum[1] = PointerGetDatum(state[0].accum);
	resultDatum[2] = PointerGetDatum(state[0].total);
	resultNull[0]  = false;
	resultNull[1]  = false;
	resultNull[2]  = false;

	result = heap_form_tuple(resultDesc, resultDatum, resultNull);
	PG_RETURN_DATUM(HeapTupleGetDatum(result));
}
开发者ID:BenjaminYu,项目名称:gpdb,代码行数:60,代码来源:bayes.c

示例2: _doubleArray_coerceDatum

static jvalue _doubleArray_coerceDatum(Type self, Datum arg)
{
	jvalue     result;
	ArrayType* v      = DatumGetArrayTypeP(arg);
	jsize      nElems = (jsize)ArrayGetNItems(ARR_NDIM(v), ARR_DIMS(v));
	jdoubleArray doubleArray = JNI_newDoubleArray(nElems);

#if (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER < 2)
	JNI_setDoubleArrayRegion(doubleArray, 0, nElems, (jdouble*)ARR_DATA_PTR(v));
#else
	if(ARR_HASNULL(v))
	{
		jsize idx;
		jboolean isCopy = JNI_FALSE;
		bits8* nullBitMap = ARR_NULLBITMAP(v);
		jdouble* values = (jdouble*)ARR_DATA_PTR(v);
		jdouble* elems  = JNI_getDoubleArrayElements(doubleArray, &isCopy);
		for(idx = 0; idx < nElems; ++idx)
		{
			if(arrayIsNull(nullBitMap, idx))
				elems[idx] = 0;
			else
				elems[idx] = *values++;
		}
		JNI_releaseDoubleArrayElements(doubleArray, elems, JNI_COMMIT);
	}
	else
		JNI_setDoubleArrayRegion(doubleArray, 0, nElems, (jdouble*)ARR_DATA_PTR(v));
#endif
	result.l = (jobject)doubleArray;
	return result;
}
开发者ID:ChiralBehaviors,项目名称:pljava,代码行数:32,代码来源:Double.c

示例3: _doubleArray_coerceObject

static Datum _doubleArray_coerceObject(Type self, jobject doubleArray)
{
	ArrayType* v;
	jsize nElems;

	if(doubleArray == 0)
		return 0;

	nElems = JNI_getArrayLength((jarray)doubleArray);
#if (PGSQL_MAJOR_VER == 8 && PGSQL_MINOR_VER < 2)
	v = createArrayType(nElems, sizeof(jdouble), FLOAT8OID);
#else
	v = createArrayType(nElems, sizeof(jdouble), FLOAT8OID, false);
#endif
	if(!JNI_isInstanceOf( doubleArray, s_DoubleArray_class))
		JNI_getDoubleArrayRegion((jdoubleArray)doubleArray, 0,
					 nElems, (jdouble*)ARR_DATA_PTR(v));
	else
	{
		int idx = 0;
		jdouble *array = (jdouble*)ARR_DATA_PTR(v);

		for(idx = 0; idx < nElems; ++idx)
		{
			array[idx] = JNI_callDoubleMethod(JNI_getObjectArrayElement(doubleArray, idx),
						       s_Double_doubleValue);
		}

	}

	PG_RETURN_ARRAYTYPE_P(v);
}
开发者ID:ChiralBehaviors,项目名称:pljava,代码行数:32,代码来源:Double.c

示例4: _booleanArray_coerceDatum

static jvalue _booleanArray_coerceDatum(Type self, Datum arg)
{
	jvalue     result;
	ArrayType* v      = DatumGetArrayTypeP(arg);
	jsize      nElems = (jsize)ArrayGetNItems(ARR_NDIM(v), ARR_DIMS(v));
	jbooleanArray booleanArray = JNI_newBooleanArray(nElems);

	if(ARR_HASNULL(v))
	{
		jsize idx;
		jboolean isCopy = JNI_FALSE;
		bits8* nullBitMap = ARR_NULLBITMAP(v);
		jboolean* values = (jboolean*)ARR_DATA_PTR(v);
		jboolean* elems  = JNI_getBooleanArrayElements(booleanArray, &isCopy);
		for(idx = 0; idx < nElems; ++idx)
		{
			if(arrayIsNull(nullBitMap, idx))
				elems[idx] = 0;
			else
				elems[idx] = *values++;
		}
		JNI_releaseBooleanArrayElements(booleanArray, elems, JNI_COMMIT);
	}
	else
		JNI_setBooleanArrayRegion(booleanArray, 0, nElems, (jboolean*)ARR_DATA_PTR(v));
	result.l = (jobject)booleanArray;
	return result;
}
开发者ID:AnLingm,项目名称:gpdb,代码行数:28,代码来源:Boolean.c

示例5: alpine_miner_lr_ca_pi

Datum
alpine_miner_lr_ca_pi(PG_FUNCTION_ARGS)
{

        ArrayType  *beta_arg, *columns_arg;
        float8     *beta_data, *columns_data;
        int     beta_count, columns_count;

	bool add_intercept_arg;

	double gx = 0.0;
	double pi = 0.0;

	if (PG_ARGISNULL(0) || PG_ARGISNULL(1) || PG_ARGISNULL(2))
	{
		PG_RETURN_NULL();
	}
        beta_arg = PG_GETARG_ARRAYTYPE_P(0);
        columns_arg = PG_GETARG_ARRAYTYPE_P(1);
	add_intercept_arg = PG_GETARG_BOOL(2);

	beta_data = (float8*) ARR_DATA_PTR(beta_arg);
	columns_data = (float8*) ARR_DATA_PTR(columns_arg);
	
	beta_count = ARR_DIMS(beta_arg)[0];
	columns_count = ARR_DIMS(columns_arg)[0];

	pi = alpine_miner_compute_pi(beta_data, beta_count, columns_data, columns_count, add_intercept_arg);

	PG_RETURN_FLOAT8(pi);
}
开发者ID:thyferny,项目名称:indwa-work,代码行数:31,代码来源:alpine_miner_lr_ca.c

示例6: alpine_miner_dot_product

Datum
alpine_miner_dot_product( PG_FUNCTION_ARGS)
{
	ArrayType  *ax = PG_GETARG_ARRAYTYPE_P(0);
	ArrayType  *ay = PG_GETARG_ARRAYTYPE_P(1);
	
	float8		*x, *y, z = 0.0;
	int			i, *dimx, *dimy;
	
	/* Sanity check: does it look like an array at all? */
	if (ARR_NDIM(ax) <= 0 || ARR_NDIM(ax) > MAXDIM)
		PG_RETURN_NULL();
	if (ARR_NDIM(ay) <= 0 || ARR_NDIM(ay) > MAXDIM)
		PG_RETURN_NULL();

	// Assign variables for the input arrays 
	x = (float8 *) ARR_DATA_PTR( ax);
	y = (float8 *) ARR_DATA_PTR( ay);	

	// Read arrays dimensions 
	dimx = ARR_DIMS( ax);
	dimy = ARR_DIMS( ay);

	// Run the calculation
	for (i=0; i < dimx[0] && i < dimy[0]; i++) {
		z = z + (x[i] * y[i]);
	}
	
	PG_RETURN_FLOAT8( z);
}
开发者ID:thyferny,项目名称:indwa-work,代码行数:30,代码来源:alpine_miner_pr_ca.c

示例7: alpine_miner_has_novel_product

Datum
alpine_miner_has_novel_product( PG_FUNCTION_ARGS)
{
	ArrayType  *ax = PG_GETARG_ARRAYTYPE_P(0);
	ArrayType  *ay = PG_GETARG_ARRAYTYPE_P(1);
	
	float8		*x, *y;
	int			i, *dimx, *dimy;
	
	/* Sanity check: does it look like an array at all? */
	if (ARR_NDIM(ax) <= 0 || ARR_NDIM(ax) > MAXDIM)
		PG_RETURN_NULL();
	if (ARR_NDIM(ay) <= 0 || ARR_NDIM(ay) > MAXDIM)
		PG_RETURN_NULL();
	
	// Assign variables for the input arrays 
	x = (float8 *) ARR_DATA_PTR( ax);
	y = (float8 *) ARR_DATA_PTR( ay);	
	
	// Read arrays dimensions 
	dimx = ARR_DIMS( ax);
	dimy = ARR_DIMS( ay);
	
	// Check one by one
	for (i=0; i < dimx[0] && i < dimy[0]; i++) {
		if (x[i]==0.0 && y[i]!=0.0) {
			PG_RETURN_INT32( 1);
		}
	}
	
	PG_RETURN_INT32( 0);
}
开发者ID:thyferny,项目名称:indwa-work,代码行数:32,代码来源:alpine_miner_pr_ca.c

示例8: NativeArrayToMappedVector

VectorType
NativeArrayToMappedVector(Datum inDatum, bool inNeedMutableClone) {
    typedef typename VectorType::Scalar Scalar;

    ArrayType* array = reinterpret_cast<ArrayType*>(
        madlib_DatumGetArrayTypeP(inDatum));
    size_t arraySize = ARR_NDIM(array) == 1
        ? ARR_DIMS(array)[0]
        : ARR_DIMS(array)[0] * ARR_DIMS(array)[1];

    if (!(ARR_NDIM(array) == 1
        || (ARR_NDIM(array) == 2
            && (ARR_DIMS(array)[0] == 1 || ARR_DIMS(array)[1] == 1)))) {

        std::stringstream errorMsg;
        errorMsg << "Invalid type conversion to matrix. Expected one-"
            "dimensional array but got " << ARR_NDIM(array)
            << " dimensions.";
        throw std::invalid_argument(errorMsg.str());
    }
    
    Scalar* origData = reinterpret_cast<Scalar*>(ARR_DATA_PTR(array));
    Scalar* data;

    if (inNeedMutableClone) {
        data = reinterpret_cast<Scalar*>(
            defaultAllocator().allocate<dbal::FunctionContext, dbal::DoNotZero,
                dbal::ThrowBadAlloc>(sizeof(Scalar) * arraySize));
        std::copy(origData, origData + arraySize, data);
    } else {
        data = reinterpret_cast<Scalar*>(ARR_DATA_PTR(array));
    }
    
    return VectorType(data, arraySize);
}
开发者ID:0x0all,项目名称:madlib,代码行数:35,代码来源:EigenIntegration_impl.hpp

示例9: findentropy

Datum findentropy(PG_FUNCTION_ARGS) {
	ArrayType *values  = PG_GETARG_ARRAYTYPE_P(0);
	ArrayType *classes = PG_GETARG_ARRAYTYPE_P(1);
	int posvalues = PG_GETARG_INT32(2);
	int posclasses = PG_GETARG_INT32(3);

	int dimvalues = ARR_NDIM(values);
    int *dimsvalues = ARR_DIMS(values);
	int numvalues = ArrayGetNItems(dimvalues,dimsvalues);
	
    int32 *vals_values=(int32 *)ARR_DATA_PTR(values);
    int32 *vals_classes=(int32 *)ARR_DATA_PTR(classes);
  
  	int *pre_entropy = (int*)palloc(sizeof(int)*posclasses);
  	int i;
  	int j;
  	int sum = 0;
  	float8 result = 0;
  	
	for (i=0; i<posvalues; ++i){
       memset(pre_entropy, 0, sizeof(int)*posclasses);
       for(j=0, sum=0; j<numvalues; ++j){
       		if(vals_values[j] == (i+1)){
       			pre_entropy[vals_classes[j]-1]++;
       			sum++;
       		}
       }
       result += entropyWeighted(pre_entropy, posclasses, (float)sum, (float)numvalues);
	}
	free(pre_entropy);
    PG_RETURN_FLOAT8((float8)result);
}
开发者ID:abhigp,项目名称:madlib,代码行数:32,代码来源:decision_tree.c

示例10: alpine_plda_first

Datum
alpine_plda_first(PG_FUNCTION_ARGS)
{
	ArrayType *assign;
	ArrayType *topiccount;
	int32 * assign_array_data;
	int32 * topiccount_array_data;
	Datum values[2];
	int32 column_size,topicnumber;
	int32 temptopic;
	int32 k;
	bool * isnulls ;
	TupleDesc tuple;
	HeapTuple ret;
	Datum * arr1;
	Datum * arr2;
	if (PG_ARGISNULL(0)){
		 PG_RETURN_NULL();
	}
 
	column_size=PG_GETARG_INT32(0);
	topicnumber=PG_GETARG_INT32(1);
	 
	arr1 = palloc0(column_size * sizeof(Datum));//Datum * 
 
 	assign = construct_array(arr1,column_size,INT4OID,4,true,'i');
 
	assign_array_data = (int32 *)ARR_DATA_PTR(assign);
 
	arr2 = palloc0(topicnumber * sizeof(Datum));//Datum * 
	topiccount = construct_array(arr2,topicnumber,INT4OID,4,true,'i');
	topiccount_array_data = (int32 *)ARR_DATA_PTR(topiccount);
 
	for ( k = 0; k < column_size; k++){
		temptopic = random() % topicnumber + 1;
		assign_array_data[k] = temptopic;
		topiccount_array_data[temptopic-1]++;		 	
	}
 
	values[0] = PointerGetDatum(assign);
	values[1] = PointerGetDatum(topiccount);
 
	if (get_call_result_type(fcinfo, NULL, &tuple) != TYPEFUNC_COMPOSITE)
		ereport(ERROR,
			(errcode( ERRCODE_FEATURE_NOT_SUPPORTED ),
			 errmsg( "function returning record called in context "
				 "that cannot accept type record" )));
	tuple = BlessTupleDesc(tuple);
	isnulls = palloc0(2 * sizeof(bool));
	ret = heap_form_tuple(tuple, values, isnulls);
 
	if (isnulls[0] || isnulls[1])
		ereport(ERROR,
			(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
			 errmsg("function \"%s\" produced null results",
				format_procedure(fcinfo->flinfo->fn_oid))));
 PG_RETURN_DATUM(HeapTupleGetDatum(ret));
      
}	
开发者ID:thyferny,项目名称:indwa-work,代码行数:59,代码来源:alpine_miner_plda.c

示例11: cword_count

Datum cword_count(PG_FUNCTION_ARGS)
{
	ArrayType * count_arr, * doc_arr, * topics_arr;
	int32 * count, * doc, * topics;
	int32 doclen, num_topics, dsize, i;
	Datum * array;
	int32 idx;

	if (!(fcinfo->context && IsA(fcinfo->context, AggState)))
		elog(ERROR, "cword_count not used as part of an aggregate");

	doclen = PG_GETARG_INT32(3);
	num_topics = PG_GETARG_INT32(4);
	dsize = PG_GETARG_INT32(5);

	/* Construct a zero'd array at the first call of this function */
	if (PG_ARGISNULL(0)) {
		array = palloc0(dsize*num_topics*sizeof(Datum));
		count_arr =
		    construct_array(array,dsize*num_topics,INT4OID,4,true,'i');
	} else {
		count_arr = PG_GETARG_ARRAYTYPE_P(0);
	}
	doc_arr = PG_GETARG_ARRAYTYPE_P(1);
	topics_arr = PG_GETARG_ARRAYTYPE_P(2);

	/* Check that the input arrays are of the right dimension and type */
	if (ARR_NDIM(count_arr) != 1 || ARR_ELEMTYPE(count_arr) != INT4OID ||
	    ARR_NDIM(doc_arr) != 1 || ARR_ELEMTYPE(doc_arr) != INT4OID ||
	    ARR_NDIM(topics_arr) != 1 || ARR_ELEMTYPE(topics_arr) != INT4OID)
		ereport
		 (ERROR,
		  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
		   errmsg("transition function \"%s\" called with invalid parameters",
			  format_procedure(fcinfo->flinfo->fn_oid))));

	count = (int32 *)ARR_DATA_PTR(count_arr);
	doc = (int32 *)ARR_DATA_PTR(doc_arr);
	topics = (int32 *)ARR_DATA_PTR(topics_arr);

	/* Update the word-topic count */
	for (i=0; i!=doclen; i++) {
		idx = (doc[i]-1) * num_topics + (topics[i]-1);

		if (idx < 0 || idx >= dsize*num_topics)
			ereport
			 (ERROR,
			  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
		           errmsg("function \"%s\" called with invalid parameters",
				  format_procedure(fcinfo->flinfo->fn_oid))));
		
		count[idx]++;
	}
	PG_RETURN_BYTEA_P(count_arr);
}
开发者ID:dcking,项目名称:madlib,代码行数:55,代码来源:plda.c

示例12: alpine_miner_lr_ca_derivative

Datum
alpine_miner_lr_ca_derivative(PG_FUNCTION_ARGS)
{

        ArrayType  *beta_arg, *columns_arg, *result;
        float8     *beta_data, *columns_data, *result_data;
	int         beta_count, columns_count, result_count;

	bool add_intercept_arg;
	double weight_arg;
	int y_arg;
        int         size;

	double gx = 0.0;
	double pi = 0.0;
	if (PG_ARGISNULL(0) || PG_ARGISNULL(1) || PG_ARGISNULL(2) || PG_ARGISNULL(3) || PG_ARGISNULL(4) || PG_ARGISNULL(5)){
		PG_RETURN_NULL();
	}
	result = PG_GETARG_ARRAYTYPE_P(0);
        beta_arg = PG_GETARG_ARRAYTYPE_P(1);

        columns_arg = PG_GETARG_ARRAYTYPE_P(2);
	add_intercept_arg = PG_GETARG_BOOL(3);
	weight_arg = PG_GETARG_FLOAT8(4);
	y_arg = PG_GETARG_INT32(5);

	result_data = (float8*) ARR_DATA_PTR(result);
	beta_data = (float8*) ARR_DATA_PTR(beta_arg);
	columns_data = (float8*) ARR_DATA_PTR(columns_arg);
	
	result_count = ARR_DIMS(result)[0];
	beta_count = ARR_DIMS(beta_arg)[0];
	columns_count = ARR_DIMS(columns_arg)[0];
//	float8 * column_array_data = (float8*) ARR_DATA_PTR(column_array);
	if (result_count == 1){
		result_count = beta_count;
       	 	size =  result_count * sizeof(float8) + ARR_OVERHEAD_NONULLS(1);
        	result = (ArrayType *) palloc(size);
	        SET_VARSIZE(result, size);
       	 	result->ndim = 1;
        	result->dataoffset = 0;
        	result->elemtype = FLOAT8OID;
        	ARR_DIMS(result)[0] = result_count;
        	ARR_LBOUND(result)[0] = 1;
		result_data = (float8*) ARR_DATA_PTR(result);
        	memset(result_data, 0,  result_count * sizeof(float8));
	}

	pi = alpine_miner_compute_pi(beta_data,  beta_count, columns_data,  columns_count, add_intercept_arg);

	alpine_miner_compute_derivative(columns_count,columns_data, result_data
		,weight_arg, y_arg, add_intercept_arg,  pi);
        PG_RETURN_ARRAYTYPE_P(result);
}
开发者ID:thyferny,项目名称:indwa-work,代码行数:54,代码来源:alpine_miner_lr_ca.c

示例13: float8arr_equals_internal

/*
 * Equality
 */
static bool
float8arr_equals_internal(ArrayType *left, ArrayType *right)
{
        int dimleft = ARR_NDIM(left), dimright = ARR_NDIM(right);
        int *dimsleft = ARR_DIMS(left), *dimsright = ARR_DIMS(right);
	int numleft = ArrayGetNItems(dimleft,dimsleft);
	int numright = ArrayGetNItems(dimright,dimsright);
        double *vals_left=(double *)ARR_DATA_PTR(left), *vals_right=(double *)ARR_DATA_PTR(right);
        bits8 *bitmap_left=ARR_NULLBITMAP(left), *bitmap_right=ARR_NULLBITMAP(right);
        int   bitmask=1;

        if ((dimsleft!=dimsright) || (numleft!=numright))
	{
		return(false);
	}

	/*
	 * Note that we are only defined for FLOAT8OID
	 */
        //get_typlenbyvalalign(ARR_ELEMTYPE(array),
        //                                         &typlen, &typbyval, &typalign);

	/*
	 * First we'll check to see if the null bitmaps are equivalent
	 */
	if (bitmap_left)
		if (! bitmap_right) return(false);
	if (bitmap_right)
		if (! bitmap_left) return(false);

	if (bitmap_left)
	{
        	for (int i=0; i<numleft; i++)
		{
                	if ((*bitmap_left & bitmask) == 0)
                		if ((*bitmap_left & bitmask) != 0)
			  		return(false);
                        bitmask <<= 1;
                        if (bitmask == 0x100)
                        {
                                bitmap_left++;
                                bitmask = 1;
                        }
		}
	}

	/*
	 * Now we check for equality of all array values
	 */
       	for (int i=0; i<numleft; i++)
		if (vals_left[i] != vals_right[i]) return(false);

        return(true);
}
开发者ID:50wu,项目名称:gpdb,代码行数:57,代码来源:operators.c

示例14: alpine_miner_covar_sam_accum

Datum
alpine_miner_covar_sam_accum(PG_FUNCTION_ARGS)
{
	ArrayType *state;
	float8 * state_array_data;
	ArrayType * column_array;
	int column_size;
	float8 * column_array_data;
	int i;
	int k ;
	int j;

	if (PG_ARGISNULL(0)){
		 PG_RETURN_NULL();
	}
	state = PG_GETARG_ARRAYTYPE_P(0);
	
	state_array_data = (float8*) ARR_DATA_PTR(state);
	
	column_array = PG_GETARG_ARRAYTYPE_P(1);
	column_size = ARR_DIMS(column_array)[0];
	column_array_data = (float8*) ARR_DATA_PTR(column_array);
	if (ARR_DIMS(state)[0] == 1){
			
			int result_size = column_size * ( column_size + 1)/2 + column_size+2;
       	 	int size =  result_size * sizeof(float8) + ARR_OVERHEAD_NONULLS(1);
        	state = (ArrayType *) palloc(size);
	        SET_VARSIZE(state, size);
       	 	state->ndim = 1;
        	state->dataoffset = 0;
        	state->elemtype = FLOAT8OID;
        	ARR_DIMS(state)[0] = result_size;
        	ARR_LBOUND(state)[0] = 1;
			state_array_data = (float8*) ARR_DATA_PTR(state);
	     	memset(state_array_data, 0,  result_size * sizeof(float8));
	}
	
		k	= 0;
        for ( i = 0; i < column_size; i++){
			for(j = i; j < column_size; j++){
                	state_array_data[k] += column_array_data[i] * column_array_data[j];
			k++;
		}
	}
	for( i = 0; i < column_size; i++){
		state_array_data[k + i] += column_array_data[i];
	}
	state_array_data[k+i]++;
	state_array_data[k+i+1]=column_size;
        PG_RETURN_ARRAYTYPE_P(state);
}	
开发者ID:thyferny,项目名称:indwa-work,代码行数:51,代码来源:alpine_miner_covar_sam.c

示例15: alpine_miner_covar_sam_final

Datum
alpine_miner_covar_sam_final(PG_FUNCTION_ARGS){
		ArrayType *state ;
		ArrayType *result;
		float8 * resultData;
		float8 * state_array_data;
		int total_length;
		int column_size;
		float8 row_size;
		int result_size;
		int size;
		int k=0;
		int i,j;
		int sam_row_size;

		if (PG_ARGISNULL(0))
			PG_RETURN_NULL();
		state = PG_GETARG_ARRAYTYPE_P(0);

		state_array_data = (float8*) ARR_DATA_PTR(state);
		total_length=ARR_DIMS(state)[0];


		column_size=state_array_data[total_length-1];
		row_size=state_array_data[total_length-2];
		result_size=column_size*(column_size+1)/2;
		size = result_size * sizeof(float8) + ARR_OVERHEAD_NONULLS(1);
		result = (ArrayType *) palloc(size);
		SET_VARSIZE(result, size);
		result->ndim = 1;
		result->dataoffset = 0;
		result->elemtype = FLOAT8OID;
		ARR_DIMS(result)[0] = result_size;
		ARR_LBOUND(result)[0] = 1;
		resultData = (float8*) ARR_DATA_PTR(result);
		memset(resultData, 0, result_size * sizeof(float8));

		 sam_row_size=row_size-1;
		 if(sam_row_size<=0)
		sam_row_size=1;
		  k=0;
		for (  i = 0; i < column_size; i++){
				for(  j = i; j < column_size; j++){
		         	resultData[k] =state_array_data[k]/sam_row_size- state_array_data[result_size+i] * state_array_data[result_size+j]/row_size/sam_row_size;
				k++;
			}
		}
		PG_RETURN_ARRAYTYPE_P(result);

}
开发者ID:thyferny,项目名称:indwa-work,代码行数:50,代码来源:alpine_miner_covar_sam.c


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