本文整理匯總了C++中GET_INDEX函數的典型用法代碼示例。如果您正苦於以下問題:C++ GET_INDEX函數的具體用法?C++ GET_INDEX怎麽用?C++ GET_INDEX使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GET_INDEX函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: matrix_set_many_on_column
void matrix_set_many_on_column(matrix_type * matrix , int row_offset , int elements , const double * data , int column) {
if ((row_offset + elements) <= matrix->rows) {
if (matrix->row_stride == 1) /* Memory is continous ... */
memcpy( &matrix->data[ GET_INDEX( matrix , row_offset , column) ] , data , elements * sizeof * data);
else {
int i;
for (i = 0; i < elements; i++)
matrix->data[ row_offset + GET_INDEX( matrix , i , column) ] = data[i];
}
} else
util_abort("%s: range violation \n" , __func__);
}
示例2: matrix_det2
double matrix_det2( const matrix_type * A) {
if ((A->rows == 2) && (A->columns == 2)) {
double a00 = A->data[GET_INDEX(A,0,0)];
double a01 = A->data[GET_INDEX(A,0,1)];
double a10 = A->data[GET_INDEX(A,1,0)];
double a11 = A->data[GET_INDEX(A,1,1)];
return a00 * a11 - a10 * a01;
} else {
util_abort("%s: hardcoded for 2x2 matrices A is: %d x %d \n",__func__, A->rows , A->columns);
return 0;
}
}
示例3: matrix_row_column_dot_product
double matrix_row_column_dot_product(const matrix_type * m1 , int row1 , const matrix_type * m2 , int col2) {
if (m1->columns != m2->rows)
util_abort("%s: size mismatch: m1:[%d,%d] m2:[%d,%d] \n",__func__ , matrix_get_rows( m1 ) , matrix_get_columns( m1 ) , matrix_get_rows( m2 ) , matrix_get_columns( m2 ));
{
int k;
double sum = 0;
for( k = 0; k < m1->columns; k++)
sum += m1->data[ GET_INDEX(m1 , row1 , k) ] * m2->data[ GET_INDEX(m2, k , col2) ];
return sum;
}
}
示例4: matrix_columns_equal
bool matrix_columns_equal( const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2) {
if (m1->rows != m2->rows)
return false;
{
int row;
for (row=0; row < m1->rows; row++) {
if (memcmp( &m1->data[ GET_INDEX(m1 , row , col1)] , &m2->data[ GET_INDEX(m2 , row , col2)] , sizeof * m1->data) != 0)
return false;
}
}
return true;
}
示例5: matrix_transpose
void matrix_transpose(const matrix_type * A , matrix_type * T) {
if ((A->columns == T->rows) && (A->rows == T->columns)) {
int i,j;
for (i=0; i < A->rows; i++) {
for (j=0; j < A->columns; j++) {
size_t src_index = GET_INDEX(A , i , j );
size_t target_index = GET_INDEX(T , j , i );
T->data[ target_index ] = A->data[ src_index ];
}
}
} else
util_abort("%s: size mismatch\n",__func__);
}
示例6: reset_pnodes
int reset_pnodes(int curr, int pnode)
{
struct msm_bus_inode_info *info;
struct msm_bus_fabric_device *fabdev;
int index, next_pnode;
fabdev = msm_bus_get_fabric_device(GET_FABID(curr));
index = GET_INDEX(pnode);
info = fabdev->algo->find_node(fabdev, curr);
if (!info) {
MSM_BUS_ERR("Cannot find node info!\n");
return -ENXIO;
}
MSM_BUS_DBG("Starting the loop--remove\n");
do {
struct msm_bus_inode_info *hop;
fabdev = msm_bus_get_fabric_device(GET_FABID(curr));
if (!fabdev) {
MSM_BUS_ERR("Fabric not found\n");
return -ENXIO;
}
next_pnode = info->pnode[index].next;
info->pnode[index].next = -2;
curr = GET_NODE(next_pnode);
index = GET_INDEX(next_pnode);
if (IS_NODE(curr))
hop = fabdev->algo->find_node(fabdev, curr);
else
hop = fabdev->algo->find_gw_node(fabdev, curr);
if (!hop) {
MSM_BUS_ERR("Null Info found for hop\n");
return -ENXIO;
}
MSM_BUS_DBG("%d[%d] = %d\n", info->node_info->priv_id, index,
info->pnode[index].next);
MSM_BUS_DBG("num_pnodes: %d: %d\n", info->node_info->priv_id,
info->num_pnodes);
info = hop;
} while (GET_NODE(info->pnode[index].next) != info->node_info->priv_id);
info->pnode[index].next = -2;
MSM_BUS_DBG("%d[%d] = %d\n", info->node_info->priv_id, index,
info->pnode[index].next);
MSM_BUS_DBG("num_pnodes: %d: %d\n", info->node_info->priv_id,
info->num_pnodes);
return 0;
}
示例7: matrix_inplace_diag_sqrt
// Comment
void matrix_inplace_diag_sqrt(matrix_type *Cd)
{
int nrows = Cd->rows;
if (Cd->rows != Cd->columns) {
util_abort("%s: size mismatch \n",__func__);
}
else{
int i;
for ( i=0; i<nrows; i++)
{
Cd->data[GET_INDEX(Cd , i , i)] = sqrt(Cd->data[GET_INDEX(Cd , i , i)]);
}
}
}
示例8: matrix_column_column_dot_product
double matrix_column_column_dot_product(const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2) {
if (m1->rows != m2->rows)
util_abort("%s: size mismatch \n",__func__);
if (col1 >= m1->columns || col2 >= m2->columns)
util_abort("%s: size mismatch \n",__func__);
{
int row;
double sum = 0;
for( row = 0; row < m1->rows; row++)
sum += m1->data[ GET_INDEX(m1 , row , col1) ] * m2->data[ GET_INDEX(m2, row , col2) ];
return sum;
}
}
示例9: matrix_inplace_sub
/* Updates matrix A by subtracting matrix B - elementwise. */
void matrix_inplace_sub(matrix_type * A , const matrix_type * B) {
if ((A->rows == B->rows) && (A->columns == B->columns)) {
int i,j;
for (j = 0; j < A->columns; j++)
for (i=0; i < A->rows; i++)
A->data[ GET_INDEX(A,i,j) ] -= B->data[ GET_INDEX(B,i,j) ];
} else
util_abort("%s: size mismatch A:[%d,%d] B:[%d,%d]\n",__func__ ,
matrix_get_rows(A),
matrix_get_columns(A),
matrix_get_rows(B),
matrix_get_columns(B));
}
示例10: file_geo_nappe
/*****************************************
* Read nappe characterization in a file *
*****************************************/
GEO *
file_geo_nappe (BYTE Type, FILE *File)
{
GEO_NAPPE *Geo;
PNT *Pnt, *PntA, *PntB, *PntC, *PntD;
FCT *Fct;
VECTOR U, V;
REAL Real;
INDEX Index;
INIT_MEM (Geo, 1, GEO_NAPPE);
Geo->Type = Type;
GET_INDEX (Geo->NbrPnt);
INIT_MEM (Geo->TabPnt, Geo->NbrPnt, PNT);
GET_INDEX (Geo->NbrFct);
INIT_MEM (Geo->TabFct, Geo->NbrFct, FCT);
Geo->Min.x = Geo->Min.y = Geo->Min.z = INFINITY;
Geo->Max.x = Geo->Max.y = Geo->Max.z = -INFINITY;
for (Index = 0, Pnt = Geo->TabPnt; Index < Geo->NbrPnt; Index++, Pnt++) {
GET_VECTOR (Pnt->Point);
VEC_MIN (Geo->Min, Pnt->Point);
VEC_MAX (Geo->Max, Pnt->Point);
}
for (Index = 0, Fct = Geo->TabFct; Index < Geo->NbrFct; Index++, Fct++) {
if (fscanf (File, " ( %d %d %d %d )", &Fct->i, &Fct->j, &Fct->k, &Fct->l) < 4)
return (FALSE);
Fct->NumFct = Index;
PntA = Geo->TabPnt + Fct->i;
PntB = Geo->TabPnt + Fct->j;
PntC = Geo->TabPnt + Fct->k;
PntD = Geo->TabPnt + Fct->l;
VEC_SUB (U, PntC->Point, PntA->Point);
VEC_SUB (V, PntD->Point, PntB->Point);
VEC_CROSS (Fct->Normal, U, V);
VEC_UNIT (Fct->Normal, Real);
VEC_INC (PntA->Normal, Fct->Normal);
VEC_INC (PntB->Normal, Fct->Normal);
VEC_INC (PntC->Normal, Fct->Normal);
VEC_INC (PntD->Normal, Fct->Normal);
}
for (Index = 0, Pnt = Geo->TabPnt; Index < Geo->NbrPnt; Index++, Pnt++)
VEC_UNIT (Pnt->Normal, Real);
return ((GEO *) Geo);
}
示例11: ubidi_getVisualRun
U_CAPI UBiDiDirection U_EXPORT2
ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
int32_t *pLogicalStart, int32_t *pLength)
{
int32_t start;
UErrorCode errorCode = U_ZERO_ERROR;
RETURN_IF_NOT_VALID_PARA_OR_LINE(pBiDi, errorCode, UBIDI_LTR);
ubidi_getRuns(pBiDi, &errorCode);
if(U_FAILURE(errorCode)) {
return UBIDI_LTR;
}
RETURN_IF_BAD_RANGE(runIndex, 0, pBiDi->runCount, errorCode, UBIDI_LTR);
start=pBiDi->runs[runIndex].logicalStart;
if(pLogicalStart!=NULL) {
*pLogicalStart=GET_INDEX(start);
}
if(pLength!=NULL) {
if(runIndex>0) {
*pLength=pBiDi->runs[runIndex].visualLimit-
pBiDi->runs[runIndex-1].visualLimit;
} else {
*pLength=pBiDi->runs[0].visualLimit;
}
}
return (UBiDiDirection)GET_ODD_BIT(start);
}
示例12: output_line
static void output_line(FILE *out_file, DATA *data, DPOINT *where,
double *est, int n_outfl) {
int i;
assert(out_file != NULL);
assert(out_file != stdout);
if (data->mode & X_BIT_SET) {
fprintf(out_file, " ");
fprintf(out_file, gl_format, where->x);
}
if (data->mode & Y_BIT_SET) {
fprintf(out_file, " ");
fprintf(out_file, gl_format, where->y);
}
if (data->mode & Z_BIT_SET) {
fprintf(out_file, " ");
fprintf(out_file, gl_format, where->z);
}
if (data->mode & S_BIT_SET)
fprintf(out_file, " %d", where->u.stratum + strata_min);
if (data->colnvalue > 0) {
fprintf(out_file, " ");
fprintf(out_file, gl_format, where->attr);
}
for (i = 0; i < n_outfl; i++)
fprintf(out_file, " %s", my_dtoa(gl_format, &(est[i])));
if (data->point_ids)
fprintf(out_file, " %s",data->point_ids[GET_INDEX(where)]);
fprintf(out_file, "\n");
return;
}
示例13: matrix_get_column_abssum
double matrix_get_column_abssum(const matrix_type * matrix , int column) {
double sum = 0;
int i;
for (i=0; i < matrix->rows; i++)
sum += fabs( matrix->data[ GET_INDEX( matrix , i , column ) ] );
return sum;
}
示例14: matrix_get_row_sum
double matrix_get_row_sum(const matrix_type * matrix , int row) {
double sum = 0;
int j;
for (j=0; j < matrix->columns; j++)
sum += matrix->data[ GET_INDEX( matrix , row , j ) ];
return sum;
}
示例15: run_experiment_ji
double run_experiment_ji ( mtype_t * matrix , mtype_t scalar , int buffer_size ) {
int i, j, iter;
hptimer_t start , end;
double final_time ;
start = get_time ();
for ( iter = 0; iter < MAX_ITERS ; ++ iter ) {
for (j = 0; j < buffer_size ; ++j ) {
for (i = 0; i < buffer_size ; ++i ) {
matrix [ GET_INDEX (i, j, buffer_size ) ] = scalar * matrix [ GET_INDEX (i, j, buffer_size ) ];
}
}
}
end = get_time ();
return final_time = diff_timers (start , end) / MAX_ITERS ;
}