/[escript]/trunk/paso/src/SystemMatrixPattern.c
ViewVC logotype

Diff of /trunk/paso/src/SystemMatrixPattern.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 414 by jgs, Wed Nov 9 02:02:19 2005 UTC revision 415 by gross, Wed Jan 4 05:37:33 2006 UTC
# Line 18  Line 18 
18    
19  /* allocates a SystemMatrixPattern  */  /* allocates a SystemMatrixPattern  */
20    
21  Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_alloc(int n_ptr, index_t* ptr,index_t* index) {  Paso_SystemMatrixPattern* Paso_SystemMatrixPattern_alloc(int type, int n_ptr, index_t* ptr,index_t* index) {
22    Paso_SystemMatrixPattern*out;    Paso_SystemMatrixPattern*out;
23    index_t loc_min_index,loc_max_index,min_index=INDEX_OFFSET,max_index=INDEX_OFFSET-1;    index_t index_offset=(type & PATTERN_FORMAT_OFFSET1 ? 1:0);
24      index_t loc_min_index,loc_max_index,min_index=index_offset,max_index=index_offset-1;
25    dim_t i;    dim_t i;
26    Paso_resetError();    Paso_resetError();
27    
28      if (type & PATTERN_FORMAT_SYM) {
29        Paso_setError(TYPE_ERROR,"symmetric matrix pattern is not supported yet");
30        return NULL;
31      }
32    #pragma omp parallel private(loc_min_index,loc_max_index,i)    #pragma omp parallel private(loc_min_index,loc_max_index,i)
33    {     {
34       loc_min_index=INDEX_OFFSET;        loc_min_index=index_offset;
35       loc_max_index=INDEX_OFFSET-1;        loc_max_index=index_offset-1;
36       #if PTR_OFFSET>0        if (type & PATTERN_FORMAT_OFFSET1) {
37          #pragma omp for schedule(static)           #pragma omp for schedule(static)
38          for (i=0;i<n_ptr+1;++i) ptr[i]+=PTR_OFFSET;           for (i=0;i<n_ptr;++i) {
39       #endif               if (ptr[i]<ptr[i+1]) {
40       #if INDEX_OFFSET>0                 qsort(&(index[ptr[i]-1]),(size_t)(ptr[i+1]-ptr[i]),sizeof(index_t),Paso_comparIndex);
41          #pragma omp for schedule(static)                 loc_min_index=MIN(loc_min_index,index[ptr[i]-1]);
42          for (i=0;i<n_ptr;++i)                 loc_max_index=MAX(loc_max_index,index[ptr[i+1]]);
43               for (k=ptr[i];k<ptr[i+1];++k) index[k]+=INDEX_OFFSET;               }
44       #endif           }
45                  } else {
46       #pragma omp for schedule(static)           #pragma omp for schedule(static)
47       for (i=0;i<n_ptr;++i) {           for (i=0;i<n_ptr;++i) {
48           if (ptr[i]<ptr[i+1]) {               if (ptr[i]<ptr[i+1]) {
49             qsort(&(index[ptr[i]-PTR_OFFSET]),(size_t)(ptr[i+1]-ptr[i]),sizeof(index_t),Paso_comparIndex);                 qsort(&(index[ptr[i]]),(size_t)(ptr[i+1]-ptr[i]),sizeof(index_t),Paso_comparIndex);
50             loc_min_index=MIN(loc_min_index,index[ptr[i]]);                 loc_min_index=MIN(loc_min_index,index[ptr[i]]);
51             loc_max_index=MAX(loc_max_index,index[ptr[i+1]-1]);                 loc_max_index=MAX(loc_max_index,index[ptr[i+1]-1]);
52                 }
53           }           }
54       }        }
55       #pragma omp critical        #pragma omp critical
56       {        {
57          min_index=MIN(loc_min_index,min_index);           min_index=MIN(loc_min_index,min_index);
58          max_index=MAX(loc_max_index,max_index);           max_index=MAX(loc_max_index,max_index);
59       }        }
60    }    }
61    if (min_index<INDEX_OFFSET) {    if (min_index<index_offset) {
62      Paso_setError(TYPE_ERROR,"Matrix pattern index out of range.");      Paso_setError(TYPE_ERROR,"Matrix pattern index out of range.");
63      return NULL;      return NULL;
64    }    }
# Line 61  Paso_SystemMatrixPattern* Paso_SystemMat Line 66  Paso_SystemMatrixPattern* Paso_SystemMat
66    out=MEMALLOC(1,Paso_SystemMatrixPattern);    out=MEMALLOC(1,Paso_SystemMatrixPattern);
67    if (Paso_checkPtr(out)) return NULL;    if (Paso_checkPtr(out)) return NULL;
68    out->n_ptr=n_ptr;    out->n_ptr=n_ptr;
69    out->n_index=max_index+1-INDEX_OFFSET;    out->n_index=max_index+1-index_offset;
70    out->ptr=ptr;    out->ptr=ptr;
71    out->index=index;    out->index=index;
72    out->len=out->ptr[out->n_ptr];    out->len=out->ptr[out->n_ptr];
73    out->reference_counter=1;    out->reference_counter=1;
74      out->type=type;
75    #ifdef Paso_TRACE    #ifdef Paso_TRACE
76    printf("Paso_SystemMatrixPattern_dealloc: system matrix pattern as been allocated.\n");    printf("Paso_SystemMatrixPattern_dealloc: system matrix pattern as been allocated.\n");
77    #endif    #endif

Legend:
Removed from v.414  
changed lines
  Added in v.415

  ViewVC Help
Powered by ViewVC 1.1.26