Changeset 11670


Ignore:
Timestamp:
03/07/12 19:00:56 (13 years ago)
Author:
Eric.Larour
Message:

Starting abstraction of Matrix and Vector objects, to step away from Petsc libraries.

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

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Makefile.am

    r11665 r11670  
    1 INCLUDES = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@  @METISINCL@  @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@  @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@  @TRIANGLEINCL@ @HYPREINCL@ @MLINCL@ @TAOINCL@
     1INCLUDES = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@  @METISINCL@  @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@  @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@  @TRIANGLEINCL@ @HYPREINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@
    22EXEEXT=$(ISSMEXT)
    33
     
    120120                                        ./objects/Numerics/ElementVector.h\
    121121                                        ./objects/Numerics/ElementVector.cpp\
     122                                        ./objects/Numerics/Matrix.h\
     123                                        ./objects/Numerics/Matrix.cpp\
     124                                        ./objects/Numerics/Vector.h\
     125                                        ./objects/Numerics/Vector.cpp\
    122126                                        ./objects/Params/Param.h\
    123127                                        ./objects/Params/BoolParam.cpp\
     
    724728                                    ./toolkits/matlab/matlabincludes.h\
    725729                                    ./toolkits/matlab/MatlabNArrayToNArray.cpp\
     730                                    ./toolkits/matlab/MatlabMatrixToMatrix.cpp\
     731                                    ./toolkits/matlab/MatlabVectorToVector.cpp\
    726732                                    ./io/Matlab/matlabio.h\
    727733                                    ./io/Matlab/WriteMatlabData.cpp\
  • issm/trunk-jpl/src/c/io/Matlab/FetchMatlabData.cpp

    r9320 r11670  
    305305}
    306306/*}}}*/
     307/*FUNCTION FetchMatlabData(Matrix** pmatrix,const mxArray* dataref){{{1*/
     308void FetchMatlabData(Matrix** pmatrix,const mxArray* dataref){
     309       
     310        Matrix* outmatrix=NULL;
     311        int dummy=0;
     312
     313        if (mxIsClass(dataref,"double") ){
     314
     315                /*Check dataref is not pointing to NaN: */
     316                if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
     317                        outmatrix=NULL;
     318                }
     319                else{
     320
     321                        /*Convert matlab matrix to petsc matrix: */
     322                        outmatrix=MatlabMatrixToMatrix(dataref);
     323                }
     324        }
     325        else{
     326                /*This is an error: we don't have the correct input!: */
     327                _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     328        }
     329
     330        /*Assign output pointers:*/
     331        *pmatrix=outmatrix;
     332}
     333/*}}}*/
    307334/*FUNCTION FetchMatlabData(double** pvector,int* pM,const mxArray* dataref){{{1*/
    308335void FetchMatlabData(double** pvector,int* pM,const mxArray* dataref){
     
    442469                /*Convert matlab vector to petsc vector: */
    443470                MatlabVectorToPetscVector(&vector,&dummy,dataref);
     471        }
     472        else{
     473                /*This is an error: we don't have the correct input!: */
     474                _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
     475        }
     476
     477        /*Assign output pointers:*/
     478        *pvector=vector;
     479}
     480/*}}}*/
     481/*FUNCTION FetchMatlabData(Vector** pvector,const mxArray* dataref){{{1*/
     482void FetchMatlabData(Vector** pvector,const mxArray* dataref){
     483
     484        Vector* vector=NULL;
     485        int dummy;
     486
     487        if(mxIsEmpty(dataref)){
     488                /*Nothing to pick up. Just initialize matrix pointer to NULL: */
     489                vector=NULL;
     490        }
     491        else if (mxIsClass(dataref,"double") ){
     492
     493                /*Convert matlab vector to petsc vector: */
     494                vector=MatlabVectorToVector(dataref);
    444495        }
    445496        else{
  • issm/trunk-jpl/src/c/io/Matlab/WriteMatlabData.cpp

    r11202 r11670  
    5858}
    5959/*}}}*/
     60/*FUNCTION WriteMatlabData(mxArray** pdataref,Matrix* matrix){{{1*/
     61void WriteMatlabData(mxArray** pdataref,Matrix* matrix){
     62               
     63        mxArray* dataref=NULL;
     64       
     65        if(matrix){
     66               
     67                /*call toolkit routine: */
     68                dataref=matrix->ToMatlabMatrix();
     69        }
     70        else{
     71                dataref = mxCreateDoubleMatrix(0,0,mxREAL);
     72        }
     73
     74        *pdataref=dataref;
     75}
     76/*}}}*/
    6077/*FUNCTION WriteMatlabData(mxArray** pdataref,double* matrix, int M,int N){{{1*/
    6178void WriteMatlabData(mxArray** pdataref,double* matrix, int M,int N){
     
    117134                /*call toolkit routine: */
    118135                PetscVectorToMatlabVector(&dataref,vector);
     136        }
     137        else{
     138                dataref = mxCreateDoubleMatrix(0,0,mxREAL);
     139        }
     140        *pdataref=dataref;
     141
     142}
     143/*}}}*/
     144/*FUNCTION WriteMatlabData(mxArray** pdataref,Vector* vector){{{1*/
     145void WriteMatlabData(mxArray** pdataref,Vector* vector){
     146       
     147        mxArray* dataref=NULL;
     148       
     149        if(vector){
     150               
     151                /*call toolkit routine: */
     152                dataref=vector->ToMatlabVector();
    119153        }
    120154        else{
  • issm/trunk-jpl/src/c/io/Matlab/matlabio.h

    r10205 r11670  
    1717void WriteMatlabData(mxArray** pdataref,DataSet* dataset);
    1818void WriteMatlabData(mxArray** pdataref,Mat matrix);
     19void WriteMatlabData(mxArray** pdataref,Matrix* matrix);
    1920void WriteMatlabData(mxArray** pdataref,double* matrix, int M,int N);
    2021void WriteMatlabData(mxArray** pdataref,int*    matrix, int M,int N);
    2122void WriteMatlabData(mxArray** pdataref,Vec vector);
     23void WriteMatlabData(mxArray** pdataref,Vector* vector);
    2224void WriteMatlabData(mxArray** pdataref,double* vector, int M);
    2325void WriteMatlabData(mxArray** pdataref,int integer);
     
    3436void FetchMatlabData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
    3537void FetchMatlabData(Mat* pmatrix,const mxArray* dataref);
     38void FetchMatlabData(Matrix** pmatrix,const mxArray* dataref);
    3639void FetchMatlabData(int** pvector,int* pM,const mxArray* dataref);
    3740void FetchMatlabData(float** pvector,int* pM,const mxArray* dataref);
     
    3942void FetchMatlabData(bool** pvector,int* pM,const mxArray* dataref);
    4043void FetchMatlabData(Vec* pvector,const mxArray* dataref);
     44void FetchMatlabData(Vector** pvector,const mxArray* dataref);
    4145void FetchMatlabData(char** pstring,const mxArray* dataref);
    4246void FetchMatlabData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
  • issm/trunk-jpl/src/c/objects/objects.h

    r11295 r11670  
    120120#include "./Numerics/ElementMatrix.h"
    121121#include "./Numerics/ElementVector.h"
     122#include "./Numerics/Vector.h"
     123#include "./Numerics/Matrix.h"
    122124
    123125/*Params: */
  • issm/trunk-jpl/src/c/toolkits/matlab/matlabincludes.h

    r8901 r11670  
    88#ifdef _SERIAL_
    99#include <mex.h>
     10class Matrix;
     11class Vector;
     12
    1013int MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
    1114int MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
    1215int MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
     16Matrix* MatlabMatrixToMatrix(const mxArray* mxmatrix);
     17Vector* MatlabVectorToVector(const mxArray* mxvector);
    1318#endif
    1419
Note: See TracChangeset for help on using the changeset viewer.