Changeset 24682


Ignore:
Timestamp:
04/01/20 10:14:06 (5 years ago)
Author:
Mathieu Morlighem
Message:

NEW: implemented SetZeroEntry to all matrices types

Location:
issm/trunk-jpl/src/c/toolkits/issm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/toolkits/issm/IssmAbsMat.h

    r24679 r24682  
    4343                virtual void SetValues(int m,int* idxm,int n,int* idxn,doubletype* values,InsMode mode)=0;
    4444                virtual void Convert(MatrixType type)=0;
    45                 virtual void SetZero(void){};
     45                virtual void SetZero(void)=0;
    4646                #ifndef _HAVE_WRAPPERS_
    4747                virtual IssmAbsVec<IssmDouble>* Solve(IssmAbsVec<IssmDouble>* pf, Parameters* parameters)=0;
  • issm/trunk-jpl/src/c/toolkits/issm/IssmDenseMat.h

    r23049 r24682  
    112112
    113113                /*IssmAbsMat virtual functions*/
    114                 /*Echo{{{*/
    115                 void Echo(void){
    116 
    117                         int i,j;
     114                void Echo(void){/*{{{*/
     115
    118116                        _printf_("IssmDenseMat size " << this->M << "-" << this->N << "\n");
    119                         for(i=0;i<M;i++){
    120                                 for(j=0;j<N;j++){
     117                        for(int i=0;i<M;i++){
     118                                for(int j=0;j<N;j++){
    121119                                        _printf_(this->matrix[N*i+j] << " ");
    122120                                }
     
    125123                }
    126124                /*}}}*/
    127                 /*Assemble{{{*/
    128                 void Assemble(void){
     125                void Assemble(void){/*{{{*/
    129126
    130127                        /*do nothing*/
     
    132129                }
    133130                /*}}}*/
    134                 /*Norm{{{*/
    135                 doubletype Norm(NormMode mode){
     131                doubletype Norm(NormMode mode){/*{{{*/
    136132
    137133                        doubletype norm;
     
    167163                }
    168164                /*}}}*/
    169                 /*GetSize{{{*/
    170                 void GetSize(int* pM,int* pN){
    171 
     165                void GetSize(int* pM,int* pN){/*{{{*/
    172166                        *pM=this->M;
    173167                        *pN=this->N;
    174 
    175                 }
    176                 /*}}}*/
    177                 /*GetLocalSize{{{*/
    178                 void GetLocalSize(int* pM,int* pN){
     168                }
     169                /*}}}*/
     170                void GetLocalSize(int* pM,int* pN){/*{{{*/
    179171
    180172                        *pM=this->M;
     
    183175                }
    184176                /*}}}*/
    185                 /*MatMult{{{*/
    186                 void MatMult(IssmAbsVec<doubletype>* Xin,IssmAbsVec<doubletype>* AXin){
     177                void MatMult(IssmAbsVec<doubletype>* Xin,IssmAbsVec<doubletype>* AXin){/*{{{*/
    187178
    188179                        /*We assume that the vectors coming in are of compatible type: */
     
    214205                }
    215206                /*}}}*/
    216                 /*Duplicate{{{*/
    217                 IssmDenseMat<doubletype>* Duplicate(void){
     207                IssmDenseMat<doubletype>* Duplicate(void){/*{{{*/
    218208
    219209                        doubletype dummy=0;
     
    223213                }
    224214                /*}}}*/
    225                 /*ToSerial{{{*/
    226                 doubletype* ToSerial(void){
     215                doubletype* ToSerial(void){/*{{{*/
    227216
    228217                        doubletype* buffer=NULL;
     
    236225                }
    237226                /*}}}*/
    238                 /*SetValues{{{*/
    239                 void SetValues(int m,int* idxm,int n,int* idxn,doubletype* values,InsMode mode){
     227                void SetValues(int m,int* idxm,int n,int* idxn,doubletype* values,InsMode mode){/*{{{*/
    240228
    241229                        int i,j;
     
    254242                }
    255243                /*}}}*/
    256                 /*Convert{{{*/
    257                 void Convert(MatrixType type){
     244                void Convert(MatrixType type){/*{{{*/
    258245
    259246                        /*do nothing*/
     
    261248                }
    262249                /*}}}*/         
     250                void SetZero(void){/*{{{*/
     251                        for(int i=0;i<M;i++){
     252                                for(int j=0;j<N;j++){
     253                                        this->matrix[N*i+j] = 0.;
     254                                }
     255                        }
     256                }/*}}}*/
    263257                #ifndef _HAVE_WRAPPERS_
    264                 /*Solve{{{*/
    265                 IssmAbsVec<IssmDouble>* Solve(IssmAbsVec<IssmDouble>* pfin, Parameters* parameters){
     258                IssmAbsVec<IssmDouble>* Solve(IssmAbsVec<IssmDouble>* pfin, Parameters* parameters){/*{{{*/
    266259
    267260                        /*First off, we assume that the type of IssmAbsVec is IssmSeqVec. So downcast: */
  • issm/trunk-jpl/src/c/toolkits/issm/IssmMpiDenseMat.h

    r22737 r24682  
    400400                }
    401401                /*}}}*/
     402                void SetZero(void){/*{{{*/
     403                        for(int i=0;i<this->m*this->N;i++) this->matrix[i] = 0.;
     404                }/*}}}*/
    402405                void Convert(MatrixType type){/*{{{*/
    403406                        _error_("not supported yet!");
  • issm/trunk-jpl/src/c/toolkits/issm/IssmMpiSparseMat.h

    r23532 r24682  
    9191                void Init(int Min,int Nin){/*{{{*/
    9292                       
    93                         int i;
    94 
    9593                        this->buckets=new DataSet();
    9694
     
    107105                        if (m*N){
    108106                                this->matrix=xNew<SparseRow<doubletype>*>(m);
    109                                 for(i=0;i<m;i++){
     107                                for(int i=0;i<m;i++){
    110108                                        this->matrix[i]=new SparseRow<doubletype>(N);
    111109                                }
     
    114112                /*}}}*/
    115113                ~IssmMpiSparseMat(){/*{{{*/
    116                         int i;
    117 
    118114                        if(m*N){
    119                                 for(i=0;i<m;i++){
     115                                for(int i=0;i<m;i++){
    120116                                        delete this->matrix[i];
    121117                                }
    122118                                xDelete<SparseRow<doubletype>*>(this->matrix);
    123119                        }
    124                         M=0;
    125                         N=0;
    126                         m=0;
     120                        this->M=0;
     121                        this->N=0;
     122                        this->m=0;
    127123                        delete this->buckets;
    128124                }
     
    421417                }
    422418                /*}}}*/
     419                void SetZero(void){/*{{{*/
     420
     421                        /*Reset buckets*/
     422                        delete this->buckets;
     423                        this->buckets=new DataSet();
     424
     425                        /*reset matrix*/
     426                        if(m*N){
     427                                for(int i=0;i<m;i++) delete this->matrix[i];
     428                                xDelete<SparseRow<doubletype>*>(this->matrix);
     429
     430                                this->matrix=xNew<SparseRow<doubletype>*>(m);
     431                                for(int i=0;i<m;i++) this->matrix[i]=new SparseRow<doubletype>(N);
     432                        }
     433
     434                        /*Reallocate matrix*/
     435                }/*}}}*/
    423436                void Convert(MatrixType type){/*{{{*/
    424437                        _error_("not supported yet!");
  • issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h

    r23643 r24682  
    380380                void Set(doubletype value){/*{{{*/
    381381
    382                         int i;
    383                         for(i=0;i<this->m;i++)this->vector[i]=value;
     382                        for(int i=0;i<this->m;i++)this->vector[i]=value;
    384383
    385384                }
  • issm/trunk-jpl/src/c/toolkits/issm/IssmSeqVec.h

    r23643 r24682  
    173173                void Set(doubletype value){/*{{{*/
    174174
    175                         int i;
    176                         for(i=0;i<this->M;i++)this->vector[i]=value;
     175                        for(int i=0;i<this->M;i++)this->vector[i]=value;
    177176
    178177                }
Note: See TracChangeset for help on using the changeset viewer.