int main(int argc, char *argv[]) { printf("No main program.\n"); ML_avoid_unused_param(&argc); ML_avoid_unused_param(argv); return 0; }
// ================================================ ====== ==== ==== == = static int CSR_getrow_ones(ML_Operator *data, int N_requested_rows, int requested_rows[], int allocated_space, int columns[], double values[], int row_lengths[]) { register int *bindx, j; int *rowptr, row, itemp; struct ML_CSR_MSRdata *input_matrix; ML_Operator *mat_in; row = *requested_rows; mat_in = (ML_Operator *) data; input_matrix = (struct ML_CSR_MSRdata *) ML_Get_MyGetrowData(mat_in); rowptr = input_matrix->rowptr; itemp = rowptr[row]; *row_lengths = rowptr[row+1] - itemp; if (*row_lengths > allocated_space) { ML_avoid_unused_param( (void *) &N_requested_rows); return(0); } bindx = &(input_matrix->columns[itemp]); for (j = 0 ; j < *row_lengths; j++) { *columns++ = *bindx++; } for (j = 0 ; j < *row_lengths; j++) { *values++ = 1; } return(1); }
// ====================================================================== static int Ptent1D_getrows(ML_Operator *data, int N_requested_rows, int requested_rows[], int allocated_space, int columns[], double values[], int row_lengths[]) { double* D = (double*)data->data; if (allocated_space < N_requested_rows) { ML_avoid_unused_param(data); return(0); } for (int i = 0; i < N_requested_rows; i++) { row_lengths[i] = 1; columns[i] = requested_rows[i] / 3; values[i] = D[i]; } return(1); }
void ML_get_row_CSR_norow_map(ML_Operator *input_matrix, int N_requested_rows, int requested_rows[], int *allocated_space, int **columns, double **values, int row_lengths[], int index) { int i, *mapper, *t1, row; ML_Operator *next; double *t2; struct ML_CSR_MSRdata *matrix; int *rowptr, *bindx, *col_ptr, itemp, j; double *val, *val_ptr; #ifdef DEBUG2 if (N_requested_rows != 1) { printf("ML_get_matrix_row is currently implemented for only 1 row"); printf(" at a time.\n"); exit(1); } #endif row = requested_rows[0]; #ifdef DEBUG2 if ( (row >= input_matrix->getrow->Nrows) || (row < 0) ) { row_lengths[0] = 0; return; } #endif next = input_matrix->sub_matrix; while ( (next != NULL) && (row < next->getrow->Nrows) ) { input_matrix = next; next = next->sub_matrix; } if (next != NULL) row -= next->getrow->Nrows; matrix = (struct ML_CSR_MSRdata *) input_matrix->data; rowptr = matrix->rowptr; itemp = rowptr[row]; bindx = &(matrix->columns[itemp]); val = &(matrix->values[itemp]); *row_lengths = rowptr[row+1] - itemp; if (*row_lengths+index > *allocated_space) { *allocated_space = 2*(*allocated_space) + 1; if (*row_lengths+index > *allocated_space) *allocated_space = *row_lengths + 5 + index; t1 = (int *) ML_allocate(*allocated_space*sizeof(int )); t2 = (double *) ML_allocate(*allocated_space*sizeof(double)); if (t2 == NULL) { printf("Not enough space to get a matrix row. A row length of \n"); printf("%d was not sufficient\n",(*allocated_space-1)/2); fflush(stdout); ML_avoid_unused_param( (void *) &N_requested_rows); exit(1); } for (i = 0; i < index; i++) t1[i] = (*columns)[i]; for (i = 0; i < index; i++) t2[i] = (*values)[i]; ML_free(*columns); ML_free(*values); *columns = t1; *values = t2; } col_ptr = &((*columns)[index]); val_ptr = &((*values)[index]); for (j = 0 ; j < *row_lengths; j++) { *col_ptr++ = *bindx++; } for (j = 0 ; j < *row_lengths; j++) { *val_ptr++ = *val++; } if ( (input_matrix->getrow->use_loc_glob_map == ML_YES)) { mapper = input_matrix->getrow->loc_glob_map; for (i = 0; i < row_lengths[0]; i++) (*columns)[i+index] = mapper[(*columns)[index+i]]; } }
void ML_get_matrix_row(ML_Operator *input_matrix, int N_requested_rows, int requested_rows[], int *allocated_space, int **columns, double **values, int row_lengths[], int index) { int i, *mapper, *t1, row; ML_Operator *next; double *t2; void *data; int (*getfunction)(void *,int,int*,int,int*,double*,int*); #ifdef DEBUG2 if (N_requested_rows != 1) { printf("ML_get_matrix_row is currently implemented for only 1 row"); printf(" at a time.\n"); exit(1); } #endif row = requested_rows[0]; #ifdef DEBUG2 if ( (row >= input_matrix->getrow->Nrows) || (row < 0) ) { row_lengths[0] = 0; return; } #endif if (input_matrix->getrow->row_map != NULL) { if (input_matrix->getrow->row_map[row] != -1) row = input_matrix->getrow->row_map[row]; else { row_lengths[0] = 0; ML_avoid_unused_param( (void *) &N_requested_rows); return;} } next = input_matrix->sub_matrix; while ( (next != NULL) && (row < next->getrow->Nrows) ) { input_matrix = next; next = next->sub_matrix; } if (next != NULL) row -= next->getrow->Nrows; data = (void *) input_matrix; getfunction = (int (*)(void *,int,int*,int,int*,double*,int*)) input_matrix->getrow->func_ptr; while(getfunction(data,1,&row,*allocated_space-index, &((*columns)[index]), &((*values)[index]), row_lengths) == 0) { *allocated_space = 2*(*allocated_space) + 1; t1 = (int *) ML_allocate(*allocated_space*sizeof(int )); if (t1 == NULL) { printf("Not enough space to get a matrix row. A row length of \n"); printf("%d Was not sufficient\n",(*allocated_space-1)/2); fflush(stdout); exit(1); } else { for (i = 0; i < index; i++) t1[i] = (*columns)[i]; if (*columns != NULL) ML_free(*columns); *columns = t1; } t2 = (double *) ML_allocate(*allocated_space*sizeof(double)); if (t2 == NULL) { printf("Not enough space to get a matrix row. A row length of \n"); printf("%d Was not sufficient\n",(*allocated_space-1)/2); fflush(stdout); exit(1); } for (i = 0; i < index; i++) t2[i] = (*values)[i]; if (*values != NULL) ML_free(*values); *values = t2; } if ( (input_matrix->getrow->use_loc_glob_map == ML_YES)) { mapper = input_matrix->getrow->loc_glob_map; for (i = 0; i < row_lengths[0]; i++) (*columns)[i+index] = mapper[(*columns)[index+i]]; } }