Actual source code: strgen.c
1: /*$Id: strgen.c,v 1.21 2001/03/23 23:21:08 balay Exp $*/
3: #include src/vec/is/impls/general/general.h
5: EXTERN int ISDuplicate_General(IS,IS *);
6: EXTERN int ISDestroy_General(IS);
7: EXTERN int ISGetIndices_General(IS,int **);
8: EXTERN int ISRestoreIndices_General(IS,int **);
9: EXTERN int ISGetSize_General(IS,int *);
10: EXTERN int ISGetLocalSize_General(IS,int *);
11: EXTERN int ISInvertPermutation_General(IS,int,IS *);
12: EXTERN int ISView_General(IS,PetscViewer);
13: EXTERN int ISSort_General(IS);
14: EXTERN int ISSorted_General(IS,PetscTruth*);
16: static struct _ISOps myops = { ISGetSize_General,
17: ISGetLocalSize_General,
18: ISGetIndices_General,
19: ISRestoreIndices_General,
20: ISInvertPermutation_General,
21: ISSort_General,
22: ISSorted_General,
23: ISDuplicate_General,
24: ISDestroy_General,
25: ISView_General};
27: /*@C
28: ISStrideToGeneral - Converts a stride index set to a general index set.
30: Collective on IS
32: Input Parameters:
33: . is - the index set
35: Level: advanced
37: Concepts: index sets^converting
38: Concepts: stride^converting index sets
40: .seealso: ISCreateStride(), ISCreateBlock(), ISCreateGeneral()
41: @*/
42: int ISStrideToGeneral(IS inis)
43: {
44: int ierr,step;
45: IS_General *sub;
46: PetscTruth stride,flg;
49: ISStride(inis,&stride);
50: if (!stride) SETERRQ(1,"Can only convert stride index sets");
52: PetscNew(IS_General,&sub);
53: PetscLogObjectMemory(inis,sizeof(IS_General));
54:
55: ierr = ISGetIndices(inis,&sub->idx);
56: /* Note: we never restore the indices, since we need to keep the copy generated */
57: ierr = ISGetLocalSize(inis,&sub->n);
59: ISStrideGetInfo(inis,PETSC_NULL,&step);
60: if (step > 0) sub->sorted = PETSC_TRUE; else sub->sorted = PETSC_FALSE;
62: /* Remove the old stride data set */
63: PetscFree(inis->data);
65: inis->type = IS_GENERAL;
66: inis->data = (void*)sub;
67: inis->isperm = PETSC_FALSE;
68: PetscMemcpy(inis->ops,&myops,sizeof(myops));
69: PetscOptionsHasName(PETSC_NULL,"-is_view",&flg);
70: if (flg) {
71: ISView(inis,PETSC_VIEWER_STDOUT_(inis->comm));
72: }
73: return(0);
74: }