/[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

trunk/esys2/paso/src/SystemMatrixPattern.c revision 150 by jgs, Thu Sep 15 03:44:45 2005 UTC trunk/paso/src/SystemMatrixPattern.c revision 631 by dhawcroft, Thu Mar 23 04:27:32 2006 UTC
# Line 1  Line 1 
1  /* $Id$ */  /* $Id$ */
2    
3    /*
4    ********************************************************************************
5    *               Copyright 2006 by ACcESS MNRF                                *
6    *                                                                              *
7    *                 http://www.access.edu.au                                     *
8    *           Primary Business: Queensland, Australia                            *
9    *     Licensed under the Open Software License version 3.0             *
10    *        http://www.opensource.org/licenses/osl-3.0.php                        *
11    ********************************************************************************
12    */
13    
14  /**************************************************************/  /**************************************************************/
15    
16  /* Paso: SystemMatrixPatternPattern */  /* Paso: SystemMatrixPatternPattern */
# Line 18  Line 29 
29    
30  /* allocates a SystemMatrixPattern  */  /* allocates a SystemMatrixPattern  */
31    
32  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) {
33    Paso_SystemMatrixPattern*out;    Paso_SystemMatrixPattern*out;
34    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);
35      index_t loc_min_index,loc_max_index,min_index=index_offset,max_index=index_offset-1;
36    dim_t i;    dim_t i;
37    Paso_resetError();    Paso_resetError();
38    
39      if (type & PATTERN_FORMAT_SYM) {
40        Paso_setError(TYPE_ERROR,"symmetric matrix pattern is not supported yet");
41        return NULL;
42      }
43    #pragma omp parallel private(loc_min_index,loc_max_index,i)    #pragma omp parallel private(loc_min_index,loc_max_index,i)
44    {     {
45       loc_min_index=INDEX_OFFSET;        loc_min_index=index_offset;
46       loc_max_index=INDEX_OFFSET-1;        loc_max_index=index_offset-1;
47       #if PTR_OFFSET>0        if (type & PATTERN_FORMAT_OFFSET1) {
48          #pragma omp for schedule(static)           #pragma omp for schedule(static)
49          for (i=0;i<n_ptr+1;++i) ptr[i]+=PTR_OFFSET;           for (i=0;i<n_ptr;++i) {
50       #endif               if (ptr[i]<ptr[i+1]) {
51       #if INDEX_OFFSET>0                 qsort(&(index[ptr[i]-1]),(size_t)(ptr[i+1]-ptr[i]),sizeof(index_t),Paso_comparIndex);
52          #pragma omp for schedule(static)                 loc_min_index=MIN(loc_min_index,index[ptr[i]-1]);
53          for (i=0;i<n_ptr;++i)                 loc_max_index=MAX(loc_max_index,index[ptr[i+1]-2]);
54               for (k=ptr[i];k<ptr[i+1];++k) index[k]+=INDEX_OFFSET;               }
55       #endif           }
56                  } else {
57       #pragma omp for schedule(static)           #pragma omp for schedule(static)
58       for (i=0;i<n_ptr;++i) {           for (i=0;i<n_ptr;++i) {
59           if (ptr[i]<ptr[i+1]) {               if (ptr[i]<ptr[i+1]) {
60             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);
61             loc_min_index=MIN(loc_min_index,index[ptr[i]]);                 loc_min_index=MIN(loc_min_index,index[ptr[i]]);
62             loc_max_index=MAX(loc_max_index,index[ptr[i+1]-1]);                 loc_max_index=MAX(loc_max_index,index[ptr[i+1]-1]);
63                 }
64           }           }
65       }        }
66       #pragma omp critical        #pragma omp critical
67       {        {
68          min_index=MIN(loc_min_index,min_index);           min_index=MIN(loc_min_index,min_index);
69          max_index=MAX(loc_max_index,max_index);           max_index=MAX(loc_max_index,max_index);
70       }        }
71    }    }
72    if (min_index<INDEX_OFFSET) {    if (min_index<index_offset) {
73      Paso_setError(TYPE_ERROR,"Matrix pattern index out of range.");      Paso_setError(TYPE_ERROR,"Matrix pattern index out of range.");
74      return NULL;      return NULL;
75    }    }
# Line 61  Paso_SystemMatrixPattern* Paso_SystemMat Line 77  Paso_SystemMatrixPattern* Paso_SystemMat
77    out=MEMALLOC(1,Paso_SystemMatrixPattern);    out=MEMALLOC(1,Paso_SystemMatrixPattern);
78    if (Paso_checkPtr(out)) return NULL;    if (Paso_checkPtr(out)) return NULL;
79    out->n_ptr=n_ptr;    out->n_ptr=n_ptr;
80    out->n_index=max_index+1-INDEX_OFFSET;    out->n_index=max_index-index_offset+1;
81    out->ptr=ptr;    out->ptr=ptr;
82    out->index=index;    out->index=index;
83    out->len=out->ptr[out->n_ptr];    out->len=out->ptr[out->n_ptr]-index_offset;
84    out->reference_counter=1;    out->reference_counter=1;
85      out->type=type;
86    #ifdef Paso_TRACE    #ifdef Paso_TRACE
87    printf("Paso_SystemMatrixPattern_dealloc: system matrix pattern as been allocated.\n");    printf("Paso_SystemMatrixPattern_dealloc: system matrix pattern as been allocated.\n");
88    #endif    #endif

Legend:
Removed from v.150  
changed lines
  Added in v.631

  ViewVC Help
Powered by ViewVC 1.1.26