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

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

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

revision 3004 by jfenwick, Thu Jan 28 02:03:15 2010 UTC revision 3005 by gross, Thu Apr 22 05:59:31 2010 UTC
# Line 33  void Paso_SparseMatrix_addRow_CSR_OFFSET Line 33  void Paso_SparseMatrix_addRow_CSR_OFFSET
33     for (ir=0;ir< A->pattern->numOutput;ir++) {     for (ir=0;ir< A->pattern->numOutput;ir++) {
34         for (irb=0;irb< A->row_block_size;irb++) {         for (irb=0;irb< A->row_block_size;irb++) {
35        irow=irb+A->row_block_size*ir;        irow=irb+A->row_block_size*ir;
36            fac=0.;        fac=0.;
37        for (iptr=A->pattern->ptr[ir];iptr<A->pattern->ptr[ir+1]; iptr++) {        for (iptr=A->pattern->ptr[ir];iptr<A->pattern->ptr[ir+1]; iptr++) {
38            for (icb=0;icb< A->col_block_size;icb++)            for (icb=0;icb< A->col_block_size;icb++)
39                   fac+=A->val[iptr*A->block_size+irb+A->row_block_size*icb];                   fac+=A->val[iptr*A->block_size+irb+A->row_block_size*icb];
40    
41            }            }
42            array[irow]+=fac;            array[irow]+=fac;
43          }         }
44     }     }
45  }  }
46    void Paso_SparseMatrix_copyBlockToMainDiagonal(Paso_SparseMatrix * A_p, const double* in)
47    {
48       index_t ir;
49       const dim_t n = A_p->pattern->numOutput;
50       const dim_t nblk = A_p->block_size;
51       const size_t nblk_size=sizeof(double)*nblk  ;
52       const index_t* main_ptr=Paso_SparseMatrix_borrowMainDiagonalPointer(A_p);
53       #pragma omp parallel for private(ir) schedule(static)
54       for (ir=0;ir< n;ir++) {
55           memcpy((void *)(&(A_p->val[main_ptr[ir]*nblk])), (void *)( &in[nblk*ir] ),  nblk_size);
56       }
57    
58    }
59    void Paso_SparseMatrix_copyBlockFromMainDiagonal(Paso_SparseMatrix * A_p, double* out)
60    {
61       index_t ir;
62       const dim_t n = A_p->pattern->numOutput;
63       const dim_t nblk =A_p->block_size;
64       const size_t nblk_size=sizeof(double)*nblk  ;
65       const index_t* main_ptr=Paso_SparseMatrix_borrowMainDiagonalPointer(A_p);
66       #pragma omp parallel for private(ir) schedule(static)
67       for (ir=0;ir< n;ir++) {
68           memcpy((void *)( &out[nblk*ir] ), (void *)(&(A_p->val[main_ptr[ir]*nblk])), nblk_size);
69       }
70    }
71    
72    void Paso_SparseMatrix_copyFromMainDiagonal(Paso_SparseMatrix * A_p, double* out)
73    {
74       index_t ir, ib;
75       const dim_t n = A_p->pattern->numOutput;
76       const dim_t nblk = A_p->block_size;
77       const dim_t blk = MIN(A_p->row_block_size, A_p->col_block_size);
78       const index_t* main_ptr=Paso_SparseMatrix_borrowMainDiagonalPointer(A_p);
79       #pragma omp parallel for private(ir,ib) schedule(static)
80       for (ir=0;ir< n;ir++) {
81           for (ib=0;ib<blk; ib++) {
82            out[ir*blk+ib] = A_p->val[main_ptr[ir]*nblk+ib+A_p->row_block_size*ib];
83           }
84       }
85    
86    }
87    
88    void Paso_SparseMatrix_copyToMainDiagonal(Paso_SparseMatrix * A_p, const double* in)
89    {
90       index_t ir, ib;
91       const dim_t n = A_p->pattern->numOutput;
92       const dim_t nblk = A_p->block_size;
93       const dim_t blk = MIN(A_p->row_block_size, A_p->col_block_size);
94       const index_t* main_ptr=Paso_SparseMatrix_borrowMainDiagonalPointer(A_p);
95       #pragma omp parallel for private(ir,ib) schedule(static)
96       for (ir=0;ir< n;ir++) {
97           for (ib=0;ib<blk; ib++) {
98             A_p->val[main_ptr[ir]*nblk+ib+A_p->row_block_size*ib] = in[ir*blk+ib];
99           }
100       }
101    
102    }

Legend:
Removed from v.3004  
changed lines
  Added in v.3005

  ViewVC Help
Powered by ViewVC 1.1.26