Changeset 6027


Ignore:
Timestamp:
09/24/10 11:56:20 (15 years ago)
Author:
Mathieu Morlighem
Message:

Added Transpose method

Location:
issm/trunk/src/c/objects/Numerics
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Numerics/ElementMatrix.cpp

    r6021 r6027  
    250250
    251251/*ElementMatrix specific routines: */
    252 /*FUNCTION ElementMatrix::AddValues{{{1*/
    253 void ElementMatrix::AddValues(double* Ke_gg){
    254 
    255         if(Ke_gg){
    256                 for (int i=0;i<this->nrows;i++){
    257                         for(int j=0;j<this->ncols;j++){
    258                                 *(this->values+this->ncols*i+j)+=*(Ke_gg+this->ncols*i+j);
    259                         }
    260                 }
    261         }
    262 }
    263 /*}}}*/
    264252/*FUNCTION ElementMatrix::AddToGlobal{{{1*/
    265253void ElementMatrix::AddToGlobal(Mat Kgg, Mat Kff, Mat Kfs){
     
    327315}
    328316/*}}}*/
     317/*FUNCTION ElementMatrix::Transpose{{{1*/
     318void ElementMatrix::Transpose(void){
     319
     320        /*Intermediaries*/
     321        double *values_copy=NULL;
     322        int     temp;
     323
     324        /*Transpose indices*/
     325        if(!dofsymmetrical){
     326                ISSMERROR("not supported yet");
     327        }
     328
     329        /*Transpose values*/
     330        values_copy=(double*)xmalloc(this->nrows*this->ncols*sizeof(double));
     331        memcpy(values_copy,this->values,this->nrows*this->ncols*sizeof(double));
     332        for (int i=0;i<this->nrows;i++) for(int j=0;j<this->ncols;j++) this->values[j*this->nrows+i]=values_copy[i*this->ncols+j];
     333
     334        /*Update sizes*/
     335        temp=this->nrows;
     336        this->nrows=this->ncols;
     337        this->ncols=temp;
     338
     339        /*Clean up and return*/
     340        xfree((void**)&values_copy);
     341}
     342/*}}}*/
    329343/*FUNCTION ElementMatrix::Echo{{{1*/
    330344void ElementMatrix::Echo(void){
  • issm/trunk/src/c/objects/Numerics/ElementMatrix.h

    r6021 r6027  
    5858                /*}}}*/
    5959                /*ElementMatrix specific routines {{{1*/
    60                 void AddValues(double* Ke_gg);
    6160                void AddToGlobal(Mat Kgg, Mat Kff, Mat Kfs);
    6261                void Echo(void);
    6362                void CheckConsistency(void);
     63                void Transpose(void);
    6464                void Init(ElementMatrix* Ke);
    6565                /*}}}*/
  • issm/trunk/src/c/objects/Numerics/ElementVector.cpp

    r5989 r6027  
    170170
    171171/*ElementVector specific routines: */
    172 /*FUNCTION ElementVector::AddValues(double* Ke_gg){{{1*/
    173 void ElementVector::AddValues(double* pe_gg){
    174 
    175         int i,j;
    176 
    177         if(pe_gg){
    178                 for (i=0;i<this->nrows;i++){
    179                         this->values[i]+=pe_gg[i];
    180                 }
    181         }
    182 }
    183 /*}}}*/
    184172/*FUNCTION ElementVector::AddToGlobal(Vec pg, Vec pf){{{1*/
    185173void ElementVector::AddToGlobal(Vec pg, Vec pf){
  • issm/trunk/src/c/objects/Numerics/ElementVector.h

    r5986 r6027  
    4141                /*}}}*/
    4242                /*ElementVector specific routines {{{1*/
    43                 void AddValues(double* pe_gg);
    4443                void AddToGlobal(Vec pg, Vec pf);
    4544                void Echo(void);
Note: See TracChangeset for help on using the changeset viewer.