[13980] | 1 | Index: ../trunk-jpl/src/c/python/python-binding.h
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/c/python/python-binding.h (revision 13748)
|
---|
| 4 | +++ ../trunk-jpl/src/c/python/python-binding.h (revision 13749)
|
---|
| 5 | @@ -1,7 +0,0 @@
|
---|
| 6 | -#ifndef _PYTHON_BINDING_H_
|
---|
| 7 | -#define _PYTHON_BINDING_H_
|
---|
| 8 | -
|
---|
| 9 | -#include "./io/pythonio.h"
|
---|
| 10 | -#include "./include/python_macros.h"
|
---|
| 11 | -
|
---|
| 12 | -#endif
|
---|
| 13 | Index: ../trunk-jpl/src/c/python/include/python_macros.h
|
---|
| 14 | ===================================================================
|
---|
| 15 | --- ../trunk-jpl/src/c/python/include/python_macros.h (revision 13748)
|
---|
| 16 | +++ ../trunk-jpl/src/c/python/include/python_macros.h (revision 13749)
|
---|
| 17 | @@ -1,96 +0,0 @@
|
---|
| 18 | -/* \file python_macros.h
|
---|
| 19 | - * \brief: macros used for the python bindings
|
---|
| 20 | - */
|
---|
| 21 | -
|
---|
| 22 | -#ifndef _PYTHON_MACROS_H_
|
---|
| 23 | -#define _PYTHON_MACROS_H_
|
---|
| 24 | -
|
---|
| 25 | -/*Header {{{*/
|
---|
| 26 | -
|
---|
| 27 | -#ifdef HAVE_CONFIG_H
|
---|
| 28 | - #include <config.h>
|
---|
| 29 | -#else
|
---|
| 30 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 31 | -#endif
|
---|
| 32 | -/*}}}*/
|
---|
| 33 | -
|
---|
| 34 | -#ifdef _HAVE_PYTHON_
|
---|
| 35 | -/* MODULEBOOT/MODULEEND {{{*/
|
---|
| 36 | -
|
---|
| 37 | -/*The following macros hide the error exception handling in a matlab module. Just put
|
---|
| 38 | - * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions
|
---|
| 39 | - * will be trapped*/
|
---|
| 40 | -#define MODULEBOOT(); \
|
---|
| 41 | - PyObject *output = PyTuple_New(NLHS); \
|
---|
| 42 | - int nrhs = (int)PyTuple_Size(args); \
|
---|
| 43 | - if(!output) return NULL;\
|
---|
| 44 | - try{ \
|
---|
| 45 | - IssmComm::SetComm(-1);
|
---|
| 46 | -
|
---|
| 47 | -#define MODULEEND(); }\
|
---|
| 48 | - catch(ErrorException &exception){\
|
---|
| 49 | - PyErr_SetString(PyExc_TypeError,exception.PythonReport()); \
|
---|
| 50 | - return NULL;\
|
---|
| 51 | - } \
|
---|
| 52 | - catch (exception &e){\
|
---|
| 53 | - PyErr_SetString(PyExc_TypeError,exprintf("Standard exception: %s\n",e.what()));\
|
---|
| 54 | - return NULL;\
|
---|
| 55 | - }\
|
---|
| 56 | - catch(...){\
|
---|
| 57 | - PyErr_SetString(PyExc_TypeError,"An unexpected error occurred");\
|
---|
| 58 | - return NULL;\
|
---|
| 59 | - }\
|
---|
| 60 | - return output;
|
---|
| 61 | -//}}}
|
---|
| 62 | -#if _PYTHON_MAJOR_ >=3
|
---|
| 63 | -/* WRAPPER 3.2 {{{*/
|
---|
| 64 | -#define WRAPPER(modulename,...) \
|
---|
| 65 | -\
|
---|
| 66 | -static PyObject* modulename(PyObject* self,PyObject* args);\
|
---|
| 67 | -static PyMethodDef modulename##_funcs[] = {\
|
---|
| 68 | - {#modulename, (PyCFunction)modulename, METH_VARARGS, ""},\
|
---|
| 69 | - {NULL,NULL,0,NULL}\
|
---|
| 70 | -};\
|
---|
| 71 | -\
|
---|
| 72 | -static struct PyModuleDef modulename##module= {\
|
---|
| 73 | - PyModuleDef_HEAD_INIT,\
|
---|
| 74 | - #modulename, /* name of module */\
|
---|
| 75 | - NULL, /* module documentation, may be NULL */\
|
---|
| 76 | - -1, /* size of per-interpreter state of the module,\
|
---|
| 77 | - or -1 if the module keeps state in global variables. */\
|
---|
| 78 | - modulename##_funcs\
|
---|
| 79 | -};\
|
---|
| 80 | -\
|
---|
| 81 | -PyMODINIT_FUNC PyInit_##modulename(void){\
|
---|
| 82 | -\
|
---|
| 83 | - import_array();\
|
---|
| 84 | - return PyModule_Create(&modulename##module);\
|
---|
| 85 | -}\
|
---|
| 86 | -\
|
---|
| 87 | -static PyObject* modulename(PyObject* self,PyObject* args)
|
---|
| 88 | -/*}}}*/
|
---|
| 89 | -#else
|
---|
| 90 | -/* WRAPPER 2.7 {{{*/
|
---|
| 91 | -#define WRAPPER(modulename,...) \
|
---|
| 92 | -\
|
---|
| 93 | -static PyObject* modulename(PyObject* self,PyObject* args);\
|
---|
| 94 | -static PyMethodDef modulename##_funcs[] = {\
|
---|
| 95 | - {#modulename, (PyCFunction)modulename, METH_VARARGS, ""},\
|
---|
| 96 | - {NULL,NULL,0,NULL}\
|
---|
| 97 | -};\
|
---|
| 98 | -\
|
---|
| 99 | -PyMODINIT_FUNC init##modulename(void){\
|
---|
| 100 | -\
|
---|
| 101 | - import_array();\
|
---|
| 102 | - (void) Py_InitModule(#modulename, modulename##_funcs);\
|
---|
| 103 | -}\
|
---|
| 104 | -\
|
---|
| 105 | -static PyObject* modulename(PyObject* self,PyObject* args)
|
---|
| 106 | -/*}}}*/
|
---|
| 107 | -#endif
|
---|
| 108 | -/* CHECKARGUMENTS {{{*/
|
---|
| 109 | -#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumPythonArguments(args, NRHS,functionpointer)
|
---|
| 110 | -/*}}}*/
|
---|
| 111 | -#endif
|
---|
| 112 | -
|
---|
| 113 | -#endif
|
---|
| 114 | Index: ../trunk-jpl/src/c/python/io/pythonio.h
|
---|
| 115 | ===================================================================
|
---|
| 116 | --- ../trunk-jpl/src/c/python/io/pythonio.h (revision 13748)
|
---|
| 117 | +++ ../trunk-jpl/src/c/python/io/pythonio.h (revision 13749)
|
---|
| 118 | @@ -1,43 +0,0 @@
|
---|
| 119 | -/*\file pythonio.h
|
---|
| 120 | - *\brief: I/O for ISSM in python mode
|
---|
| 121 | - */
|
---|
| 122 | -
|
---|
| 123 | -#ifndef _PYTHON_IO_H_
|
---|
| 124 | -#define _PYTHON_IO_H_
|
---|
| 125 | -
|
---|
| 126 | -#ifdef HAVE_CONFIG_H
|
---|
| 127 | -#include <config.h>
|
---|
| 128 | -#else
|
---|
| 129 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 130 | -#endif
|
---|
| 131 | -
|
---|
| 132 | -#include "../../classes/classes.h"
|
---|
| 133 | -#include "../../Container/Container.h"
|
---|
| 134 | -#include "../../include/include.h"
|
---|
| 135 | -
|
---|
| 136 | -void WriteData(PyObject* py_tuple,int index, double* matrix, int M,int N);
|
---|
| 137 | -void WriteData(PyObject* py_tuple,int index, int integer);
|
---|
| 138 | -void WriteData(PyObject* py_tuple,int index, char* string);
|
---|
| 139 | -void WriteData(PyObject* py_tuple,int index);
|
---|
| 140 | -void WriteData(PyObject* py_tuple,int index, SeqMat<double>* matrix);
|
---|
| 141 | -void WriteData(PyObject* py_tuple,int index, SeqVec<double>* vector);
|
---|
| 142 | -void WriteData(PyObject* py_tuple,int index, BamgGeom* bamggeom);
|
---|
| 143 | -void WriteData(PyObject* py_tuple,int index, BamgMesh* bamgmesh);
|
---|
| 144 | -void WriteData(PyObject* py_tuple,int index, RiftStruct* riftstruct);
|
---|
| 145 | -
|
---|
| 146 | -void FetchData(double** pvector,int* pM,PyObject* py_ref);
|
---|
| 147 | -void FetchData(double** pmatrix,int* pM,int *pN,PyObject* py_array);
|
---|
| 148 | -void FetchData(int** pmatrix,int* pM,int *pN,PyObject* py_matrix);
|
---|
| 149 | -void FetchData(char** pstring,PyObject* py_unicode);
|
---|
| 150 | -void FetchData(double* pscalar,PyObject* py_float);
|
---|
| 151 | -void FetchData(int* pinteger,PyObject* py_long);
|
---|
| 152 | -void FetchData(bool* pbool,PyObject* py_boolean);
|
---|
| 153 | -void FetchData(BamgGeom** bamggeom,PyObject* py_dict);
|
---|
| 154 | -void FetchData(BamgMesh** bamgmesh,PyObject* py_dict);
|
---|
| 155 | -void FetchData(BamgOpts** bamgopts,PyObject* py_dict);
|
---|
| 156 | -void FetchData(Options** poptions,int istart, int nrhs,PyObject* py_tuple);
|
---|
| 157 | -void FetchData(DataSet** pcontours,PyObject* py_list);
|
---|
| 158 | -
|
---|
| 159 | -int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void ));
|
---|
| 160 | -
|
---|
| 161 | -#endif /* _IO_H_ */
|
---|
| 162 | Index: ../trunk-jpl/src/c/python/io/CheckNumPythonArguments.cpp
|
---|
| 163 | ===================================================================
|
---|
| 164 | --- ../trunk-jpl/src/c/python/io/CheckNumPythonArguments.cpp (revision 13748)
|
---|
| 165 | +++ ../trunk-jpl/src/c/python/io/CheckNumPythonArguments.cpp (revision 13749)
|
---|
| 166 | @@ -1,35 +0,0 @@
|
---|
| 167 | -/*!\file CheckNumPythonArguments.cpp:
|
---|
| 168 | - * \brief: check number of arguments and report an usage error message.
|
---|
| 169 | - */
|
---|
| 170 | -
|
---|
| 171 | -#ifdef HAVE_CONFIG_H
|
---|
| 172 | - #include <config.h>
|
---|
| 173 | -#else
|
---|
| 174 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 175 | -#endif
|
---|
| 176 | -
|
---|
| 177 | -#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
|
---|
| 178 | -#define NO_IMPORT
|
---|
| 179 | -
|
---|
| 180 | -#include "../../toolkits/toolkits.h"
|
---|
| 181 | -#include "../../shared/Exceptions/exceptions.h"
|
---|
| 182 | -#include "../../include/include.h"
|
---|
| 183 | -
|
---|
| 184 | -int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void )){
|
---|
| 185 | -
|
---|
| 186 | - Py_ssize_t size=0;
|
---|
| 187 | -
|
---|
| 188 | - /*figure out size of tuple in input: */
|
---|
| 189 | - size=PyTuple_Size(inputs);
|
---|
| 190 | -
|
---|
| 191 | - /*check on requested size: */
|
---|
| 192 | - if (size==0){
|
---|
| 193 | - function();
|
---|
| 194 | - _error_("usage: see above");
|
---|
| 195 | - }
|
---|
| 196 | - else if (size!=NRHS ) {
|
---|
| 197 | - function();
|
---|
| 198 | - _error_("usage error.");
|
---|
| 199 | - }
|
---|
| 200 | - return 1;
|
---|
| 201 | -}
|
---|
| 202 | Index: ../trunk-jpl/src/c/python/io/FetchPythonData.cpp
|
---|
| 203 | ===================================================================
|
---|
| 204 | --- ../trunk-jpl/src/c/python/io/FetchPythonData.cpp (revision 13748)
|
---|
| 205 | +++ ../trunk-jpl/src/c/python/io/FetchPythonData.cpp (revision 13749)
|
---|
| 206 | @@ -1,356 +0,0 @@
|
---|
| 207 | -/*\file FetchData.cpp:
|
---|
| 208 | - * \brief: general I/O interface to fetch data in python
|
---|
| 209 | - */
|
---|
| 210 | -
|
---|
| 211 | -#ifdef HAVE_CONFIG_H
|
---|
| 212 | - #include <config.h>
|
---|
| 213 | -#else
|
---|
| 214 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 215 | -#endif
|
---|
| 216 | -
|
---|
| 217 | -#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
|
---|
| 218 | -#define NO_IMPORT
|
---|
| 219 | -
|
---|
| 220 | -#include "../../toolkits/toolkits.h"
|
---|
| 221 | -#include "../../include/include.h"
|
---|
| 222 | -#include "../../shared/shared.h"
|
---|
| 223 | -#include "../../io/io.h"
|
---|
| 224 | -void FetchData(char** pstring,PyObject* py_string);
|
---|
| 225 | -
|
---|
| 226 | -/*Primitive data types*/
|
---|
| 227 | -/*FUNCTION FetchData(double* pscalar,PyObject* py_float){{{*/
|
---|
| 228 | -void FetchData(double* pscalar,PyObject* py_float){
|
---|
| 229 | -
|
---|
| 230 | - double scalar;
|
---|
| 231 | -
|
---|
| 232 | - /*return internal value: */
|
---|
| 233 | - scalar=PyFloat_AsDouble(py_float);
|
---|
| 234 | -
|
---|
| 235 | - /*output: */
|
---|
| 236 | - *pscalar=scalar;
|
---|
| 237 | -}
|
---|
| 238 | -/*}}}*/
|
---|
| 239 | -/*FUNCTION FetchData(int* pinteger,PyObject* py_long){{{*/
|
---|
| 240 | -void FetchData(int* pinteger, PyObject* py_long){
|
---|
| 241 | -
|
---|
| 242 | - int integer;
|
---|
| 243 | -
|
---|
| 244 | - /*return internal value: */
|
---|
| 245 | - integer=(int)PyLong_AsLong(py_long);
|
---|
| 246 | -
|
---|
| 247 | - /*output: */
|
---|
| 248 | - *pinteger=integer;
|
---|
| 249 | -}
|
---|
| 250 | -/*}}}*/
|
---|
| 251 | -/*FUNCTION FetchData(bool* pboolean,PyObject* py_boolean){{{*/
|
---|
| 252 | -void FetchData(bool* pboolean,PyObject* py_boolean){
|
---|
| 253 | -
|
---|
| 254 | - bool boolean;
|
---|
| 255 | -
|
---|
| 256 | - /*check this is indeed a subtype of long type: */
|
---|
| 257 | - if(!PyBool_Check(py_boolean))_error_("expecting a boolean in input!");
|
---|
| 258 | -
|
---|
| 259 | - /*extract boolean: */
|
---|
| 260 | - boolean=(bool)PyLong_AsLong(py_boolean);
|
---|
| 261 | -
|
---|
| 262 | - /*simple copy: */
|
---|
| 263 | - *pboolean=boolean;
|
---|
| 264 | -
|
---|
| 265 | -}
|
---|
| 266 | -/*}}}*/
|
---|
| 267 | -/*FUNCTION FetchData(double** pmatrix,int* pM, int* pN, PyObject* py_matrix){{{*/
|
---|
| 268 | -void FetchData(double** pmatrix,int* pM,int *pN,PyObject* py_matrix){
|
---|
| 269 | -
|
---|
| 270 | - /*output: */
|
---|
| 271 | - double* dmatrix=NULL;
|
---|
| 272 | - double* matrix=NULL;
|
---|
| 273 | - int M,N;
|
---|
| 274 | - int ndim;
|
---|
| 275 | - npy_intp* dims=NULL;
|
---|
| 276 | -
|
---|
| 277 | - /*retrive dimensions: */
|
---|
| 278 | - ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
|
---|
| 279 | - if(ndim!=2)_error_("expecting an MxN matrix in input!");
|
---|
| 280 | - dims=PyArray_DIMS((PyArrayObject*)py_matrix);
|
---|
| 281 | - M=dims[0]; N=dims[1];
|
---|
| 282 | -
|
---|
| 283 | - if (M && N) {
|
---|
| 284 | - /*retrieve internal value: */
|
---|
| 285 | - dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
|
---|
| 286 | -
|
---|
| 287 | - /*copy matrix: */
|
---|
| 288 | - matrix=xNew<double>(M*N);
|
---|
| 289 | - memcpy(matrix,dmatrix,(M*N)*sizeof(double));
|
---|
| 290 | - }
|
---|
| 291 | - else
|
---|
| 292 | - matrix=NULL;
|
---|
| 293 | -
|
---|
| 294 | - /*output: */
|
---|
| 295 | - if(pM)*pM=M;
|
---|
| 296 | - if(pN)*pN=N;
|
---|
| 297 | - if(pmatrix)*pmatrix=matrix;
|
---|
| 298 | -}
|
---|
| 299 | -/*}}}*/
|
---|
| 300 | -/*FUNCTION FetchData(int** pmatrix,int* pM, int* pN, PyObject* py_matrix){{{*/
|
---|
| 301 | -void FetchData(int** pmatrix,int* pM,int *pN,PyObject* py_matrix){
|
---|
| 302 | -
|
---|
| 303 | - /*output: */
|
---|
| 304 | - double* dmatrix=NULL;
|
---|
| 305 | - int* matrix=NULL;
|
---|
| 306 | - int M,N;
|
---|
| 307 | -
|
---|
| 308 | - /*intermediary:*/
|
---|
| 309 | - int i;
|
---|
| 310 | - int ndim;
|
---|
| 311 | - npy_intp* dims=NULL;
|
---|
| 312 | -
|
---|
| 313 | - /*retrive dimensions: */
|
---|
| 314 | - ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
|
---|
| 315 | - if(ndim!=2)_error_("expecting an MxN matrix in input!");
|
---|
| 316 | - dims=PyArray_DIMS((PyArrayObject*)py_matrix);
|
---|
| 317 | - M=dims[0]; N=dims[1];
|
---|
| 318 | -
|
---|
| 319 | - if (M && N) {
|
---|
| 320 | - /*retrieve internal value: */
|
---|
| 321 | - dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
|
---|
| 322 | -
|
---|
| 323 | - /*transform into integer matrix: */
|
---|
| 324 | - matrix=xNew<int>(M*N);
|
---|
| 325 | - for(i=0;i<M*N;i++)matrix[i]=(int)dmatrix[i];
|
---|
| 326 | - }
|
---|
| 327 | - else
|
---|
| 328 | - matrix=NULL;
|
---|
| 329 | -
|
---|
| 330 | - /*output: */
|
---|
| 331 | - if(pM)*pM=M;
|
---|
| 332 | - if(pN)*pN=N;
|
---|
| 333 | - if(pmatrix)*pmatrix=matrix;
|
---|
| 334 | -}
|
---|
| 335 | -/*}}}*/
|
---|
| 336 | -/*FUNCTION FetchData(double** pvector,int* pM, PyObject* py_vector){{{*/
|
---|
| 337 | -void FetchData(double** pvector,int* pM,PyObject* py_vector){
|
---|
| 338 | -
|
---|
| 339 | - /*output: */
|
---|
| 340 | - double* dvector=NULL;
|
---|
| 341 | - double* vector=NULL;
|
---|
| 342 | - int M;
|
---|
| 343 | - int ndim;
|
---|
| 344 | - npy_intp* dims=NULL;
|
---|
| 345 | -
|
---|
| 346 | - /*retrive dimensions: */
|
---|
| 347 | - ndim=PyArray_NDIM((const PyArrayObject*)py_vector);
|
---|
| 348 | - if(ndim!=1)_error_("expecting an Mx1 vector in input!");
|
---|
| 349 | - dims=PyArray_DIMS((PyArrayObject*)py_vector);
|
---|
| 350 | - M=dims[0];
|
---|
| 351 | -
|
---|
| 352 | - if (M) {
|
---|
| 353 | - /*retrieve internal value: */
|
---|
| 354 | - dvector=(double*)PyArray_DATA((PyArrayObject*)py_vector);
|
---|
| 355 | -
|
---|
| 356 | - /*copy vector: */
|
---|
| 357 | - vector=xNew<double>(M);
|
---|
| 358 | - memcpy(vector,dvector,(M)*sizeof(double));
|
---|
| 359 | - }
|
---|
| 360 | - else
|
---|
| 361 | - vector=NULL;
|
---|
| 362 | -
|
---|
| 363 | - /*output: */
|
---|
| 364 | - if(pM)*pM=M;
|
---|
| 365 | - if(pvector)*pvector=vector;
|
---|
| 366 | -}
|
---|
| 367 | -/*}}}*/
|
---|
| 368 | -
|
---|
| 369 | -/*ISSM objects*/
|
---|
| 370 | -/*FUNCTION FetchData(BamgGeom** pbamggeom,PyObject* py_dict){{{*/
|
---|
| 371 | -void FetchData(BamgGeom** pbamggeom,PyObject* py_dict){
|
---|
| 372 | -
|
---|
| 373 | - /*Initialize output*/
|
---|
| 374 | - BamgGeom* bamggeom=new BamgGeom();
|
---|
| 375 | -
|
---|
| 376 | - /*Fetch all fields*/
|
---|
| 377 | - FetchData(&bamggeom->Vertices,&bamggeom->VerticesSize[0],&bamggeom->VerticesSize[1],PyDict_GetItemString(py_dict,"Vertices"));
|
---|
| 378 | - FetchData(&bamggeom->Edges, &bamggeom->EdgesSize[0], &bamggeom->EdgesSize[1], PyDict_GetItemString(py_dict,"Edges"));
|
---|
| 379 | - FetchData(&bamggeom->Corners, &bamggeom->CornersSize[0], &bamggeom->CornersSize[1], PyDict_GetItemString(py_dict,"Corners"));
|
---|
| 380 | - FetchData(&bamggeom->RequiredVertices,&bamggeom->RequiredVerticesSize[0],&bamggeom->RequiredVerticesSize[1],PyDict_GetItemString(py_dict,"RequiredVertices"));
|
---|
| 381 | - FetchData(&bamggeom->RequiredEdges, &bamggeom->RequiredEdgesSize[0], &bamggeom->RequiredEdgesSize[1], PyDict_GetItemString(py_dict,"RequiredEdges"));
|
---|
| 382 | - FetchData(&bamggeom->CrackedEdges,&bamggeom->CrackedEdgesSize[0],&bamggeom->CrackedEdgesSize[1],PyDict_GetItemString(py_dict,"CrackedEdges"));
|
---|
| 383 | - FetchData(&bamggeom->SubDomains,&bamggeom->SubDomainsSize[0],&bamggeom->SubDomainsSize[1],PyDict_GetItemString(py_dict,"SubDomains"));
|
---|
| 384 | -
|
---|
| 385 | - /*Assign output pointers:*/
|
---|
| 386 | - *pbamggeom=bamggeom;
|
---|
| 387 | -}
|
---|
| 388 | -/*}}}*/
|
---|
| 389 | -/*FUNCTION FetchData(BamgMesh** pbamgmesh,PyObject* py_dict){{{*/
|
---|
| 390 | -void FetchData(BamgMesh** pbamgmesh,PyObject* py_dict){
|
---|
| 391 | -
|
---|
| 392 | - /*Initialize output*/
|
---|
| 393 | - BamgMesh* bamgmesh=new BamgMesh();
|
---|
| 394 | -
|
---|
| 395 | - /*Fetch all fields*/
|
---|
| 396 | - FetchData(&bamgmesh->Vertices,&bamgmesh->VerticesSize[0],&bamgmesh->VerticesSize[1],PyDict_GetItemString(py_dict,"Vertices"));
|
---|
| 397 | - FetchData(&bamgmesh->Edges, &bamgmesh->EdgesSize[0], &bamgmesh->EdgesSize[1], PyDict_GetItemString(py_dict,"Edges"));
|
---|
| 398 | - FetchData(&bamgmesh->Triangles, &bamgmesh->TrianglesSize[0], &bamgmesh->TrianglesSize[1], PyDict_GetItemString(py_dict,"Triangles"));
|
---|
| 399 | - FetchData(&bamgmesh->CrackedEdges,&bamgmesh->CrackedEdgesSize[0],&bamgmesh->CrackedEdgesSize[1],PyDict_GetItemString(py_dict,"CrackedEdges"));
|
---|
| 400 | - FetchData(&bamgmesh->VerticesOnGeomEdge,&bamgmesh->VerticesOnGeomEdgeSize[0],&bamgmesh->VerticesOnGeomEdgeSize[1],PyDict_GetItemString(py_dict,"VerticesOnGeomEdge"));
|
---|
| 401 | - FetchData(&bamgmesh->VerticesOnGeomVertex,&bamgmesh->VerticesOnGeomVertexSize[0],&bamgmesh->VerticesOnGeomVertexSize[1],PyDict_GetItemString(py_dict,"VerticesOnGeomVertex"));
|
---|
| 402 | - FetchData(&bamgmesh->EdgesOnGeomEdge, &bamgmesh->EdgesOnGeomEdgeSize[0], &bamgmesh->EdgesOnGeomEdgeSize[1], PyDict_GetItemString(py_dict,"EdgesOnGeomEdge"));
|
---|
| 403 | - FetchData(&bamgmesh->IssmSegments,&bamgmesh->IssmSegmentsSize[0],&bamgmesh->IssmSegmentsSize[1],PyDict_GetItemString(py_dict,"IssmSegments"));
|
---|
| 404 | -
|
---|
| 405 | - /*Assign output pointers:*/
|
---|
| 406 | - *pbamgmesh=bamgmesh;
|
---|
| 407 | -}
|
---|
| 408 | -/*}}}*/
|
---|
| 409 | -/*FUNCTION FetchData(BamgOpts** pbamgopts,PyObject* py_dict){{{*/
|
---|
| 410 | -void FetchData(BamgOpts** pbamgopts,PyObject* py_dict){
|
---|
| 411 | -
|
---|
| 412 | - /*Initialize output*/
|
---|
| 413 | - BamgOpts* bamgopts=new BamgOpts();
|
---|
| 414 | -
|
---|
| 415 | - /*Fetch all fields*/
|
---|
| 416 | - FetchData(&bamgopts->anisomax,PyDict_GetItemString(py_dict,"anisomax"));
|
---|
| 417 | - FetchData(&bamgopts->cutoff,PyDict_GetItemString(py_dict,"cutoff"));
|
---|
| 418 | - FetchData(&bamgopts->coeff,PyDict_GetItemString(py_dict,"coeff"));
|
---|
| 419 | - FetchData(&bamgopts->errg,PyDict_GetItemString(py_dict,"errg"));
|
---|
| 420 | - FetchData(&bamgopts->gradation,PyDict_GetItemString(py_dict,"gradation"));
|
---|
| 421 | - FetchData(&bamgopts->Hessiantype,PyDict_GetItemString(py_dict,"Hessiantype"));
|
---|
| 422 | - FetchData(&bamgopts->MaxCornerAngle,PyDict_GetItemString(py_dict,"MaxCornerAngle"));
|
---|
| 423 | - FetchData(&bamgopts->maxnbv,PyDict_GetItemString(py_dict,"maxnbv"));
|
---|
| 424 | - FetchData(&bamgopts->maxsubdiv,PyDict_GetItemString(py_dict,"maxsubdiv"));
|
---|
| 425 | - FetchData(&bamgopts->Metrictype,PyDict_GetItemString(py_dict,"Metrictype"));
|
---|
| 426 | - FetchData(&bamgopts->nbjacobi,PyDict_GetItemString(py_dict,"nbjacobi"));
|
---|
| 427 | - FetchData(&bamgopts->nbsmooth,PyDict_GetItemString(py_dict,"nbsmooth"));
|
---|
| 428 | - FetchData(&bamgopts->omega,PyDict_GetItemString(py_dict,"omega"));
|
---|
| 429 | - FetchData(&bamgopts->power,PyDict_GetItemString(py_dict,"power"));
|
---|
| 430 | - FetchData(&bamgopts->verbose,PyDict_GetItemString(py_dict,"verbose"));
|
---|
| 431 | -
|
---|
| 432 | - FetchData(&bamgopts->Crack,PyDict_GetItemString(py_dict,"Crack"));
|
---|
| 433 | - FetchData(&bamgopts->geometricalmetric,PyDict_GetItemString(py_dict,"geometricalmetric"));
|
---|
| 434 | - FetchData(&bamgopts->KeepVertices,PyDict_GetItemString(py_dict,"KeepVertices"));
|
---|
| 435 | - FetchData(&bamgopts->splitcorners,PyDict_GetItemString(py_dict,"splitcorners"));
|
---|
| 436 | -
|
---|
| 437 | - FetchData(&bamgopts->hmin,PyDict_GetItemString(py_dict,"hmin"));
|
---|
| 438 | - FetchData(&bamgopts->hmax,PyDict_GetItemString(py_dict,"hmax"));
|
---|
| 439 | - FetchData(&bamgopts->hminVertices,&bamgopts->hminVerticesSize[0],&bamgopts->hminVerticesSize[1],PyDict_GetItemString(py_dict,"hminVertices"));
|
---|
| 440 | - FetchData(&bamgopts->hmaxVertices,&bamgopts->hmaxVerticesSize[0],&bamgopts->hmaxVerticesSize[1],PyDict_GetItemString(py_dict,"hmaxVertices"));
|
---|
| 441 | - FetchData(&bamgopts->hVertices,&bamgopts->hVerticesSize[0],&bamgopts->hVerticesSize[1],PyDict_GetItemString(py_dict,"hVertices"));
|
---|
| 442 | - FetchData(&bamgopts->metric,&bamgopts->metricSize[0],&bamgopts->metricSize[1],PyDict_GetItemString(py_dict,"metric"));
|
---|
| 443 | - FetchData(&bamgopts->field,&bamgopts->fieldSize[0],&bamgopts->fieldSize[1],PyDict_GetItemString(py_dict,"field"));
|
---|
| 444 | - FetchData(&bamgopts->err,&bamgopts->errSize[0],&bamgopts->errSize[1],PyDict_GetItemString(py_dict,"err"));
|
---|
| 445 | -
|
---|
| 446 | - /*Additional checks*/
|
---|
| 447 | - bamgopts->Check();
|
---|
| 448 | -
|
---|
| 449 | - /*Assign output pointers:*/
|
---|
| 450 | - *pbamgopts=bamgopts;
|
---|
| 451 | -}
|
---|
| 452 | -/*}}}*/
|
---|
| 453 | -/*FUNCTION FetchData(Options** poptions,int istart, int nrhs,PyObject* py_tuple){{{*/
|
---|
| 454 | -void FetchData(Options** poptions,int istart, int nrhs,PyObject* py_tuple){
|
---|
| 455 | -
|
---|
| 456 | - char *name = NULL;
|
---|
| 457 | - Option *option = NULL;
|
---|
| 458 | -
|
---|
| 459 | - /*Initialize output*/
|
---|
| 460 | - Options* options=new Options();
|
---|
| 461 | -
|
---|
| 462 | - /*Fetch all options*/
|
---|
| 463 | - for (int i=istart; i<nrhs; i=i+2){
|
---|
| 464 | - if (!PyString_Check(PyTuple_GetItem(py_tuple,(Py_ssize_t)i))) _error_("Argument " << i+1 << " must be name of option");
|
---|
| 465 | -
|
---|
| 466 | - FetchData(&name,PyTuple_GetItem(py_tuple,(Py_ssize_t)i));
|
---|
| 467 | - if(i+1 == nrhs) _error_("Argument " << i+2 << " must exist and be value of option \"" << name << "\".");
|
---|
| 468 | -
|
---|
| 469 | - _pprintLine_("FetchData for Options not implemented yet, ignoring option \"" << name << "\"!");
|
---|
| 470 | -
|
---|
| 471 | -// option=(Option*)OptionParse(name,&PyTuple_GetItem(py_tuple,(Py_ssize_t)(i+1)));
|
---|
| 472 | -// options->AddOption(option);
|
---|
| 473 | -// option=NULL;
|
---|
| 474 | - }
|
---|
| 475 | -
|
---|
| 476 | - /*Assign output pointers:*/
|
---|
| 477 | - *poptions=options;
|
---|
| 478 | -}
|
---|
| 479 | -/*}}}*/
|
---|
| 480 | -/*FUNCTION FetchData(DataSet** pcontours,PyObject* py_list){{{*/
|
---|
| 481 | -void FetchData(DataSet** pcontours,PyObject* py_list){
|
---|
| 482 | -
|
---|
| 483 | - int numcontours,test1,test2;
|
---|
| 484 | - char *contourname = NULL;
|
---|
| 485 | - DataSet *contours = NULL;
|
---|
| 486 | - Contour<double> *contouri = NULL;
|
---|
| 487 | - PyObject *py_dicti = NULL;
|
---|
| 488 | - PyObject *py_item = NULL;
|
---|
| 489 | -
|
---|
| 490 | - if (PyString_Check(py_list)){
|
---|
| 491 | - FetchData(&contourname,py_list);
|
---|
| 492 | - contours=DomainOutlineRead<double>(contourname);
|
---|
| 493 | - }
|
---|
| 494 | - else if(PyList_Check(py_list)){
|
---|
| 495 | -
|
---|
| 496 | - contours=new DataSet(0);
|
---|
| 497 | - numcontours=(int)PyList_Size(py_list);
|
---|
| 498 | -
|
---|
| 499 | - for(int i=0;i<numcontours;i++){
|
---|
| 500 | -
|
---|
| 501 | - contouri=xNew<Contour<double> >(1);
|
---|
| 502 | - py_dicti=PyList_GetItem(py_list,(Py_ssize_t)i);
|
---|
| 503 | -
|
---|
| 504 | - py_item = PyDict_GetItemString(py_dicti,"nods");
|
---|
| 505 | - if(!py_item) _error_("input structure does not have a 'nods' field");
|
---|
| 506 | - FetchData(&contouri->nods,py_item);
|
---|
| 507 | -
|
---|
| 508 | - py_item = PyDict_GetItemString(py_dicti,"x");
|
---|
| 509 | - if(!py_item) _error_("input structure does not have a 'x' field");
|
---|
| 510 | - FetchData(&contouri->x,&test1,&test2,py_item);
|
---|
| 511 | - if(test1!=contouri->nods || test2!=1) _error_("field x should be of size ["<<contouri->nods<<" 1]");
|
---|
| 512 | -
|
---|
| 513 | - py_item = PyDict_GetItemString(py_dicti,"y");
|
---|
| 514 | - if(!py_item) _error_("input structure does not have a 'y' field");
|
---|
| 515 | - FetchData(&contouri->y,&test1,&test2,py_item);
|
---|
| 516 | - if(test1!=contouri->nods || test2!=1) _error_("field y should be of size ["<<contouri->nods<<" 1]");
|
---|
| 517 | -
|
---|
| 518 | - contours->AddObject(contouri);
|
---|
| 519 | - }
|
---|
| 520 | - }
|
---|
| 521 | - else{
|
---|
| 522 | - _error_("Contour is neither a string nor a structure and cannot be loaded");
|
---|
| 523 | - }
|
---|
| 524 | -
|
---|
| 525 | - /*clean-up and assign output pointer*/
|
---|
| 526 | - xDelete<char>(contourname);
|
---|
| 527 | - *pcontours=contours;
|
---|
| 528 | -}
|
---|
| 529 | -/*}}}*/
|
---|
| 530 | -
|
---|
| 531 | -/*Python version dependent: */
|
---|
| 532 | -#if _PYTHON_MAJOR_ >= 3
|
---|
| 533 | -/*FUNCTION FetchData(char** pstring,PyObject* py_unicode){{{*/
|
---|
| 534 | -void FetchData(char** pstring,PyObject* py_unicode){
|
---|
| 535 | -
|
---|
| 536 | - PyObject* py_bytes;
|
---|
| 537 | - char* string=NULL;
|
---|
| 538 | -
|
---|
| 539 | - /*convert to bytes format: */
|
---|
| 540 | - PyUnicode_FSConverter(py_unicode,&py_bytes);
|
---|
| 541 | -
|
---|
| 542 | - /*convert from bytes to string: */
|
---|
| 543 | - string=PyBytes_AS_STRING(py_bytes);
|
---|
| 544 | -
|
---|
| 545 | - *pstring=string;
|
---|
| 546 | -}
|
---|
| 547 | -/*}}}*/
|
---|
| 548 | -#else
|
---|
| 549 | -/*FUNCTION FetchData(char** pstring,PyObject* py_string){{{*/
|
---|
| 550 | -void FetchData(char** pstring,PyObject* py_string){
|
---|
| 551 | -
|
---|
| 552 | - char* string=NULL;
|
---|
| 553 | -
|
---|
| 554 | - /*extract internal string: */
|
---|
| 555 | - string=PyString_AsString(py_string);
|
---|
| 556 | -
|
---|
| 557 | - /*copy string (note strlen does not include trailing NULL): */
|
---|
| 558 | - *pstring=xNew<char>(strlen(string)+1);
|
---|
| 559 | - memcpy(*pstring,string,(strlen(string)+1)*sizeof(char));
|
---|
| 560 | -}
|
---|
| 561 | -/*}}}*/
|
---|
| 562 | -#endif
|
---|
| 563 | Index: ../trunk-jpl/src/c/python/io/WritePythonData.cpp
|
---|
| 564 | ===================================================================
|
---|
| 565 | --- ../trunk-jpl/src/c/python/io/WritePythonData.cpp (revision 13748)
|
---|
| 566 | +++ ../trunk-jpl/src/c/python/io/WritePythonData.cpp (revision 13749)
|
---|
| 567 | @@ -1,198 +0,0 @@
|
---|
| 568 | -/* \file WriteData.c:
|
---|
| 569 | - * \brief: general interface for writing data
|
---|
| 570 | - */
|
---|
| 571 | -
|
---|
| 572 | -#ifdef HAVE_CONFIG_H
|
---|
| 573 | - #include <config.h>
|
---|
| 574 | -#else
|
---|
| 575 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 576 | -#endif
|
---|
| 577 | -
|
---|
| 578 | -#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
|
---|
| 579 | -#define NO_IMPORT
|
---|
| 580 | -
|
---|
| 581 | -#include "../../toolkits/toolkits.h"
|
---|
| 582 | -#include "../../include/include.h"
|
---|
| 583 | -#include "../../modules/modules.h"
|
---|
| 584 | -#include "../../Container/Container.h"
|
---|
| 585 | -#include "../../shared/shared.h"
|
---|
| 586 | -#include "../../io/io.h"
|
---|
| 587 | -#include "../../EnumDefinitions/EnumDefinitions.h"
|
---|
| 588 | -PyObject* PyArrayFromCopiedData(int dims[2],double* data);
|
---|
| 589 | -PyObject* PyArrayFromCopiedData(int dimi,int dimj,double* data);
|
---|
| 590 | -
|
---|
| 591 | -/*Primitive data types*/
|
---|
| 592 | -/*FUNCTION WriteData(PyObject* py_tuple,int index,int integer){{{*/
|
---|
| 593 | -void WriteData(PyObject* py_tuple, int index, int integer){
|
---|
| 594 | -
|
---|
| 595 | - PyTuple_SetItem(py_tuple, index, PyInt_FromSsize_t((Py_ssize_t)integer));
|
---|
| 596 | -
|
---|
| 597 | -}/*}}}*/
|
---|
| 598 | -/*FUNCTION WriteData(PyObject* py_tuple,int index,char* string){{{*/
|
---|
| 599 | -void WriteData(PyObject* py_tuple, int index, char* string){
|
---|
| 600 | -
|
---|
| 601 | - PyTuple_SetItem(py_tuple, index, PyUnicode_FromString(string));
|
---|
| 602 | -
|
---|
| 603 | -}/*}}}*/
|
---|
| 604 | -/*FUNCTION WriteData(PyObject* py_tuple,int index, double* matrix, int M, int N){{{*/
|
---|
| 605 | -void WriteData(PyObject* tuple, int index, double* matrix, int M,int N){
|
---|
| 606 | -
|
---|
| 607 | - npy_intp dims[2]={0,0};
|
---|
| 608 | - PyObject* array=NULL;
|
---|
| 609 | -
|
---|
| 610 | - dims[0]=(npy_intp)M;
|
---|
| 611 | - dims[1]=(npy_intp)N;
|
---|
| 612 | - array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,matrix);
|
---|
| 613 | -
|
---|
| 614 | - PyTuple_SetItem(tuple, index, array);
|
---|
| 615 | -}/*}}}*/
|
---|
| 616 | -/*FUNCTION WriteData(PyObject* py_tuple,int index){{{*/
|
---|
| 617 | -void WriteData(PyObject* py_tuple, int index){
|
---|
| 618 | -
|
---|
| 619 | - PyTuple_SetItem(py_tuple, index, Py_None);
|
---|
| 620 | -
|
---|
| 621 | -}/*}}}*/
|
---|
| 622 | -
|
---|
| 623 | -/*ISSM objects*/
|
---|
| 624 | -/*FUNCTION WriteData(PyObject* py_tuple,int index,BamgGeom* bamggeom){{{*/
|
---|
| 625 | -void WriteData(PyObject* py_tuple,int index,BamgGeom* bamggeom){
|
---|
| 626 | -
|
---|
| 627 | - PyObject* dict=NULL;
|
---|
| 628 | -
|
---|
| 629 | - dict=PyDict_New();
|
---|
| 630 | -
|
---|
| 631 | - PyDict_SetItemString(dict,"Vertices",PyArrayFromCopiedData(bamggeom->VerticesSize,bamggeom->Vertices));
|
---|
| 632 | - PyDict_SetItemString(dict,"Edges",PyArrayFromCopiedData(bamggeom->EdgesSize,bamggeom->Edges));
|
---|
| 633 | - PyDict_SetItemString(dict,"TangentAtEdges",PyArrayFromCopiedData(bamggeom->TangentAtEdgesSize,bamggeom->TangentAtEdges));
|
---|
| 634 | - PyDict_SetItemString(dict,"Corners",PyArrayFromCopiedData(bamggeom->CornersSize,bamggeom->Corners));
|
---|
| 635 | - PyDict_SetItemString(dict,"RequiredVertices",PyArrayFromCopiedData(bamggeom->RequiredVerticesSize,bamggeom->RequiredVertices));
|
---|
| 636 | - PyDict_SetItemString(dict,"RequiredEdges",PyArrayFromCopiedData(bamggeom->RequiredEdgesSize,bamggeom->RequiredEdges));
|
---|
| 637 | - PyDict_SetItemString(dict,"CrackedEdges",PyArrayFromCopiedData(bamggeom->CrackedEdgesSize,bamggeom->CrackedEdges));
|
---|
| 638 | - PyDict_SetItemString(dict,"SubDomains",PyArrayFromCopiedData(bamggeom->SubDomainsSize,bamggeom->SubDomains));
|
---|
| 639 | -
|
---|
| 640 | - PyTuple_SetItem(py_tuple, index, dict);
|
---|
| 641 | -}
|
---|
| 642 | -/*}}}*/
|
---|
| 643 | -/*FUNCTION WriteData(PyObject* py_tuple,int index,BamgMesh* bamgmesh){{{*/
|
---|
| 644 | -void WriteData(PyObject* py_tuple,int index,BamgMesh* bamgmesh){
|
---|
| 645 | -
|
---|
| 646 | - PyObject* dict=NULL;
|
---|
| 647 | -
|
---|
| 648 | - dict=PyDict_New();
|
---|
| 649 | -
|
---|
| 650 | - PyDict_SetItemString(dict,"Vertices",PyArrayFromCopiedData(bamgmesh->VerticesSize,bamgmesh->Vertices));
|
---|
| 651 | - PyDict_SetItemString(dict,"Edges",PyArrayFromCopiedData(bamgmesh->EdgesSize,bamgmesh->Edges));
|
---|
| 652 | - PyDict_SetItemString(dict,"Triangles",PyArrayFromCopiedData(bamgmesh->TrianglesSize,bamgmesh->Triangles));
|
---|
| 653 | - PyDict_SetItemString(dict,"Quadrilaterals",PyArrayFromCopiedData(bamgmesh->QuadrilateralsSize,bamgmesh->Quadrilaterals));
|
---|
| 654 | - PyDict_SetItemString(dict,"IssmEdges",PyArrayFromCopiedData(bamgmesh->IssmEdgesSize,bamgmesh->IssmEdges));
|
---|
| 655 | - PyDict_SetItemString(dict,"IssmSegments",PyArrayFromCopiedData(bamgmesh->IssmSegmentsSize,bamgmesh->IssmSegments));
|
---|
| 656 | - PyDict_SetItemString(dict,"VerticesOnGeomVertex",PyArrayFromCopiedData(bamgmesh->VerticesOnGeomVertexSize,bamgmesh->VerticesOnGeomVertex));
|
---|
| 657 | - PyDict_SetItemString(dict,"VerticesOnGeomEdge",PyArrayFromCopiedData(bamgmesh->VerticesOnGeomEdgeSize,bamgmesh->VerticesOnGeomEdge));
|
---|
| 658 | - PyDict_SetItemString(dict,"EdgesOnGeomEdge",PyArrayFromCopiedData(bamgmesh->EdgesOnGeomEdgeSize,bamgmesh->EdgesOnGeomEdge));
|
---|
| 659 | - PyDict_SetItemString(dict,"SubDomains",PyArrayFromCopiedData(bamgmesh->SubDomainsSize,bamgmesh->SubDomains));
|
---|
| 660 | - PyDict_SetItemString(dict,"SubDomainsFromGeom",PyArrayFromCopiedData(bamgmesh->SubDomainsFromGeomSize,bamgmesh->SubDomainsFromGeom));
|
---|
| 661 | - PyDict_SetItemString(dict,"ElementConnectivity",PyArrayFromCopiedData(bamgmesh->ElementConnectivitySize,bamgmesh->ElementConnectivity));
|
---|
| 662 | - PyDict_SetItemString(dict,"NodalConnectivity",PyArrayFromCopiedData(bamgmesh->NodalConnectivitySize,bamgmesh->NodalConnectivity));
|
---|
| 663 | - PyDict_SetItemString(dict,"NodalElementConnectivity",PyArrayFromCopiedData(bamgmesh->NodalElementConnectivitySize,bamgmesh->NodalElementConnectivity));
|
---|
| 664 | - PyDict_SetItemString(dict,"CrackedVertices",PyArrayFromCopiedData(bamgmesh->CrackedVerticesSize,bamgmesh->CrackedVertices));
|
---|
| 665 | - PyDict_SetItemString(dict,"CrackedEdges",PyArrayFromCopiedData(bamgmesh->CrackedEdgesSize,bamgmesh->CrackedEdges));
|
---|
| 666 | -
|
---|
| 667 | - PyTuple_SetItem(py_tuple, index, dict);
|
---|
| 668 | -}
|
---|
| 669 | -/*}}}*/
|
---|
| 670 | -/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqMat<double>* matrix){{{*/
|
---|
| 671 | -void WriteData(PyObject* py_tuple,int index,SeqMat<double>* matrix){
|
---|
| 672 | -
|
---|
| 673 | - int M,N;
|
---|
| 674 | - double* buffer=NULL;
|
---|
| 675 | - npy_intp dims[2]={0,0};
|
---|
| 676 | - PyObject* array=NULL;
|
---|
| 677 | -
|
---|
| 678 | - buffer=matrix->ToSerial();
|
---|
| 679 | - matrix->GetSize(&M,&N);
|
---|
| 680 | - dims[0]=(npy_intp)M;
|
---|
| 681 | - dims[1]=(npy_intp)N;
|
---|
| 682 | - array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,buffer);
|
---|
| 683 | -
|
---|
| 684 | - PyTuple_SetItem(py_tuple, index, array);
|
---|
| 685 | -
|
---|
| 686 | -}/*}}}*/
|
---|
| 687 | -/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqVec<double>* vector){{{*/
|
---|
| 688 | -void WriteData(PyObject* py_tuple,int index,SeqVec<double>* vector){
|
---|
| 689 | -
|
---|
| 690 | - int M;
|
---|
| 691 | - double* buffer=NULL;
|
---|
| 692 | - npy_intp dim=10;
|
---|
| 693 | - PyObject* array=NULL;
|
---|
| 694 | -
|
---|
| 695 | - buffer=vector->ToMPISerial();
|
---|
| 696 | - vector->GetSize(&M);
|
---|
| 697 | - dim=(npy_intp)M;
|
---|
| 698 | - array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE,buffer);
|
---|
| 699 | -
|
---|
| 700 | - PyTuple_SetItem(py_tuple, index, array);
|
---|
| 701 | -}
|
---|
| 702 | -/*}}}*/
|
---|
| 703 | -/*FUNCTION WriteData(PyObject* py_tuple,int index,RiftStruct* riftstruct){{{*/
|
---|
| 704 | -void WriteData(PyObject* py_tuple,int index,RiftStruct* riftstruct){
|
---|
| 705 | -
|
---|
| 706 | - int i;
|
---|
| 707 | - PyObject* list=NULL;
|
---|
| 708 | - PyObject* dict=NULL;
|
---|
| 709 | -
|
---|
| 710 | - list=PyList_New((Py_ssize_t)0);
|
---|
| 711 | -
|
---|
| 712 | - for (i=0; i<riftstruct->numrifts; i++) {
|
---|
| 713 | - dict=PyDict_New();
|
---|
| 714 | -
|
---|
| 715 | - PyDict_SetItemString(dict,"numsegs" ,PyInt_FromSsize_t((Py_ssize_t)riftstruct->riftsnumsegments[i]));
|
---|
| 716 | - PyDict_SetItemString(dict,"segments" ,PyArrayFromCopiedData(riftstruct->riftsnumsegments[i] ,3,riftstruct->riftssegments[i]));
|
---|
| 717 | - PyDict_SetItemString(dict,"pairs" ,PyArrayFromCopiedData(riftstruct->riftsnumpairs[i] ,2,riftstruct->riftspairs[i]));
|
---|
| 718 | - PyDict_SetItemString(dict,"tips" ,PyArrayFromCopiedData(1 ,2,&riftstruct->riftstips[2*i]));
|
---|
| 719 | - PyDict_SetItemString(dict,"penaltypairs" ,PyArrayFromCopiedData(riftstruct->riftsnumpenaltypairs[i],7,riftstruct->riftspenaltypairs[i]));
|
---|
| 720 | - PyDict_SetItemString(dict,"fill" ,PyInt_FromSsize_t((Py_ssize_t)IceEnum));
|
---|
| 721 | - PyDict_SetItemString(dict,"friction" ,PyInt_FromSsize_t((Py_ssize_t)0));
|
---|
| 722 | - PyDict_SetItemString(dict,"fraction" ,PyFloat_FromDouble(0.));
|
---|
| 723 | - PyDict_SetItemString(dict,"fractionincrement",PyFloat_FromDouble(0.1));
|
---|
| 724 | - PyDict_SetItemString(dict,"state" ,PyArrayFromCopiedData(riftstruct->riftsnumpenaltypairs[i],1,riftstruct->state[i]));
|
---|
| 725 | -
|
---|
| 726 | - PyList_Append(list, dict);
|
---|
| 727 | - }
|
---|
| 728 | -
|
---|
| 729 | - PyTuple_SetItem(py_tuple, index, list);
|
---|
| 730 | -}
|
---|
| 731 | -/*}}}*/
|
---|
| 732 | -
|
---|
| 733 | -/*Utils*/
|
---|
| 734 | -/*FUNCTION PyArrayFromCopiedData(int dims[2],double* data){{{*/
|
---|
| 735 | -PyObject* PyArrayFromCopiedData(int dims[2],double* data){
|
---|
| 736 | -
|
---|
| 737 | - double* pydata;
|
---|
| 738 | - npy_intp pydims[2]={0,0};
|
---|
| 739 | -
|
---|
| 740 | - /* note that PyArray_SimpleNewFromData does not copy the data, so that when the original
|
---|
| 741 | - object (e.g. bamggeom,bamgmesh) is deleted, the data is gone. */
|
---|
| 742 | -
|
---|
| 743 | - pydims[0]=(npy_intp)dims[0];
|
---|
| 744 | - pydims[1]=(npy_intp)dims[1];
|
---|
| 745 | - pydata=xNew<IssmDouble>(dims[0]*dims[1]);
|
---|
| 746 | - memcpy(pydata,data,dims[0]*dims[1]*sizeof(double));
|
---|
| 747 | - return PyArray_SimpleNewFromData(2,pydims,NPY_DOUBLE,pydata);
|
---|
| 748 | -}
|
---|
| 749 | -/*}}}*/
|
---|
| 750 | -/*FUNCTION PyArrayFromCopiedData(int dimi,int dimj,double* data){{{*/
|
---|
| 751 | -PyObject* PyArrayFromCopiedData(int dimi,int dimj,double* data){
|
---|
| 752 | -
|
---|
| 753 | - double* pydata;
|
---|
| 754 | - npy_intp pydims[2]={0,0};
|
---|
| 755 | -
|
---|
| 756 | - /* note that PyArray_SimpleNewFromData does not copy the data, so that when the original
|
---|
| 757 | - object (e.g. bamggeom,bamgmesh) is deleted, the data is gone. */
|
---|
| 758 | -
|
---|
| 759 | - pydims[0]=(npy_intp)dimi;
|
---|
| 760 | - pydims[1]=(npy_intp)dimj;
|
---|
| 761 | - pydata=xNew<IssmDouble>(dimi*dimj);
|
---|
| 762 | - memcpy(pydata,data,dimi*dimj*sizeof(double));
|
---|
| 763 | - return PyArray_SimpleNewFromData(2,pydims,NPY_DOUBLE,pydata);
|
---|
| 764 | -}
|
---|
| 765 | -/*}}}*/
|
---|
| 766 | Index: ../trunk-jpl/src/c/issm-binding.h
|
---|
| 767 | ===================================================================
|
---|
| 768 | --- ../trunk-jpl/src/c/issm-binding.h (revision 13748)
|
---|
| 769 | +++ ../trunk-jpl/src/c/issm-binding.h (revision 13749)
|
---|
| 770 | @@ -1,18 +0,0 @@
|
---|
| 771 | -#ifndef _ISSM_BINDING_H_
|
---|
| 772 | -#define _ISSM_BINDING_H_
|
---|
| 773 | -
|
---|
| 774 | -#ifdef HAVE_CONFIG_H
|
---|
| 775 | - #include <config.h>
|
---|
| 776 | -#else
|
---|
| 777 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 778 | -#endif
|
---|
| 779 | -
|
---|
| 780 | -#ifdef _HAVE_MATLAB_MODULES_
|
---|
| 781 | -#include "./matlab/matlab-binding.h"
|
---|
| 782 | -#endif
|
---|
| 783 | -
|
---|
| 784 | -#ifdef _HAVE_PYTHON_MODULES_
|
---|
| 785 | -#include "./python/python-binding.h"
|
---|
| 786 | -#endif
|
---|
| 787 | -
|
---|
| 788 | -#endif
|
---|
| 789 | Index: ../trunk-jpl/src/c/matlab/include/matlab_macros.h
|
---|
| 790 | ===================================================================
|
---|
| 791 | --- ../trunk-jpl/src/c/matlab/include/matlab_macros.h (revision 13748)
|
---|
| 792 | +++ ../trunk-jpl/src/c/matlab/include/matlab_macros.h (revision 13749)
|
---|
| 793 | @@ -1,44 +0,0 @@
|
---|
| 794 | -/* \file matlab macros.h
|
---|
| 795 | - * \brief: macros used for the matlab bindings
|
---|
| 796 | - */
|
---|
| 797 | -
|
---|
| 798 | -/*Header {{{*/
|
---|
| 799 | -#ifndef _MATLAB_MACROS_H_
|
---|
| 800 | -#define _MATLAB_MACROS_H_
|
---|
| 801 | -
|
---|
| 802 | -#ifdef HAVE_CONFIG_H
|
---|
| 803 | - #include <config.h>
|
---|
| 804 | -#else
|
---|
| 805 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 806 | -#endif
|
---|
| 807 | -/*}}}*/
|
---|
| 808 | -
|
---|
| 809 | -#ifdef _HAVE_MATLAB_
|
---|
| 810 | -/* MODULEBOOT/MODULEEND {{{*/
|
---|
| 811 | -
|
---|
| 812 | -/*The following macros hide the error exception handling in a matlab module. Just put
|
---|
| 813 | - * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions
|
---|
| 814 | - * will be trapped*/
|
---|
| 815 | -#define MODULEBOOT(); try{ \
|
---|
| 816 | - IssmComm::SetComm(-1);
|
---|
| 817 | -
|
---|
| 818 | -#define MODULEEND(); }\
|
---|
| 819 | - catch(ErrorException &exception){\
|
---|
| 820 | - mexErrMsgTxt(exception.MatlabReport()); \
|
---|
| 821 | - }\
|
---|
| 822 | - catch (exception &e){\
|
---|
| 823 | - mexErrMsgTxt(exprintf("Standard exception: %s\n",e.what()));\
|
---|
| 824 | - }\
|
---|
| 825 | - catch(...){\
|
---|
| 826 | - mexErrMsgTxt("An unexpected error occurred");\
|
---|
| 827 | - }
|
---|
| 828 | -/*}}}*/
|
---|
| 829 | -/* WRAPPER {{{*/
|
---|
| 830 | -#define WRAPPER(modulename,...) void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
|
---|
| 831 | -/*}}}*/
|
---|
| 832 | -/* CHECKARGUMENTS {{{*/
|
---|
| 833 | -#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,functionpointer)
|
---|
| 834 | -/*}}}*/
|
---|
| 835 | -#endif
|
---|
| 836 | -
|
---|
| 837 | -#endif
|
---|
| 838 | Index: ../trunk-jpl/src/c/matlab/io/OptionParse.cpp
|
---|
| 839 | ===================================================================
|
---|
| 840 | --- ../trunk-jpl/src/c/matlab/io/OptionParse.cpp (revision 13748)
|
---|
| 841 | +++ ../trunk-jpl/src/c/matlab/io/OptionParse.cpp (revision 13749)
|
---|
| 842 | @@ -1,203 +0,0 @@
|
---|
| 843 | -/*\file OptionParse.c
|
---|
| 844 | - *\brief: functions to parse the mex options.
|
---|
| 845 | - */
|
---|
| 846 | -#ifdef HAVE_CONFIG_H
|
---|
| 847 | - #include <config.h>
|
---|
| 848 | -#else
|
---|
| 849 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 850 | -#endif
|
---|
| 851 | -
|
---|
| 852 | -#include <cstring>
|
---|
| 853 | -#include <mex.h>
|
---|
| 854 | -#include "../../shared/shared.h"
|
---|
| 855 | -#include "../../io/io.h"
|
---|
| 856 | -#include "../../include/include.h"
|
---|
| 857 | -#include "./matlabio.h"
|
---|
| 858 | -
|
---|
| 859 | -GenericOption<double>* OptionDoubleParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 860 | -
|
---|
| 861 | - GenericOption<double> *odouble = NULL;
|
---|
| 862 | -
|
---|
| 863 | - /*check and parse the name */
|
---|
| 864 | - odouble=new GenericOption<double>();
|
---|
| 865 | - odouble->name =xNew<char>(strlen(name)+1);
|
---|
| 866 | - memcpy(odouble->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 867 | - FetchData(&odouble->value,prhs[0]);
|
---|
| 868 | - odouble->numel=1;
|
---|
| 869 | - odouble->ndims=1;
|
---|
| 870 | - odouble->size=NULL;
|
---|
| 871 | -
|
---|
| 872 | - return(odouble);
|
---|
| 873 | -}/*}}}*/
|
---|
| 874 | -GenericOption<double*>* OptionDoubleArrayParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 875 | -
|
---|
| 876 | - GenericOption<double*> *odouble = NULL;
|
---|
| 877 | -
|
---|
| 878 | - /*check and parse the name */
|
---|
| 879 | - odouble=new GenericOption<double*>();
|
---|
| 880 | - odouble->name =xNew<char>(strlen(name)+1);
|
---|
| 881 | - memcpy(odouble->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 882 | -
|
---|
| 883 | - /*check and parse the value */
|
---|
| 884 | - if (!mxIsClass(prhs[0],"double")){
|
---|
| 885 | - _error_("Value of option \"" << odouble->name << "\" must be class \"double\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
|
---|
| 886 | - }
|
---|
| 887 | - FetchData(&odouble->value,&odouble->numel,&odouble->ndims,&odouble->size,prhs[0]);
|
---|
| 888 | -
|
---|
| 889 | - return(odouble);
|
---|
| 890 | -}/*}}}*/
|
---|
| 891 | -GenericOption<bool*>* OptionLogicalParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 892 | -
|
---|
| 893 | - GenericOption<bool*> *ological = NULL;
|
---|
| 894 | -
|
---|
| 895 | - /*check and parse the name */
|
---|
| 896 | - ological=new GenericOption<bool*>();
|
---|
| 897 | - ological->name =xNew<char>(strlen(name)+1);
|
---|
| 898 | - memcpy(ological->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 899 | -
|
---|
| 900 | - /*check and parse the value */
|
---|
| 901 | - if (!mxIsClass(prhs[0],"logical")){
|
---|
| 902 | - _error_("Value of option \"" << ological->name << "\" must be class \"logical\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
|
---|
| 903 | - }
|
---|
| 904 | - FetchData(&ological->value,&ological->numel,&ological->ndims,&ological->size,prhs[0]);
|
---|
| 905 | -
|
---|
| 906 | - return(ological);
|
---|
| 907 | -}/*}}}*/
|
---|
| 908 | -GenericOption<char*>* OptionCharParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 909 | -
|
---|
| 910 | - GenericOption<char*> *ochar = NULL;
|
---|
| 911 | -
|
---|
| 912 | - /*check and parse the name */
|
---|
| 913 | - ochar=new GenericOption<char*>();
|
---|
| 914 | - ochar->name =xNew<char>(strlen(name)+1);
|
---|
| 915 | - memcpy(ochar->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 916 | -
|
---|
| 917 | - /*check and parse the value */
|
---|
| 918 | - if (!mxIsClass(prhs[0],"char")){
|
---|
| 919 | - _error_("Value of option \"" << ochar->name << "\" must be class \"char\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
|
---|
| 920 | - }
|
---|
| 921 | - FetchData(&ochar->value,&ochar->numel,&ochar->ndims,&ochar->size,prhs[0]);
|
---|
| 922 | -
|
---|
| 923 | - return(ochar);
|
---|
| 924 | -}/*}}}*/
|
---|
| 925 | -GenericOption<Options**>* OptionStructParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 926 | -
|
---|
| 927 | - int i;
|
---|
| 928 | - char namei[161];
|
---|
| 929 | - Option* option = NULL;
|
---|
| 930 | - GenericOption<Options**> *ostruct = NULL;
|
---|
| 931 | - const mwSize *ipt = NULL;
|
---|
| 932 | - const mxArray *structi;
|
---|
| 933 | - mwIndex sindex;
|
---|
| 934 | -
|
---|
| 935 | - /*check and parse the name */
|
---|
| 936 | - ostruct=new GenericOption<Options**>();
|
---|
| 937 | - ostruct->name =xNew<char>(strlen(name)+1);
|
---|
| 938 | - memcpy(ostruct->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 939 | -
|
---|
| 940 | - /*check and parse the value */
|
---|
| 941 | - if (!mxIsClass(prhs[0],"struct")){
|
---|
| 942 | - _error_("Value of option \"" << ostruct->name << "\" must be class \"struct\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
|
---|
| 943 | - }
|
---|
| 944 | - ostruct->numel=mxGetNumberOfElements(prhs[0]);
|
---|
| 945 | - ostruct->ndims=mxGetNumberOfDimensions(prhs[0]);
|
---|
| 946 | - ipt =mxGetDimensions(prhs[0]);
|
---|
| 947 | - ostruct->size =xNew<int>(ostruct->ndims);
|
---|
| 948 | - for (i=0; i<ostruct->ndims; i++) ostruct->size[i]=(int)ipt[i];
|
---|
| 949 | - if (ostruct->numel) ostruct->value=xNew<Options*>(ostruct->numel);
|
---|
| 950 | -
|
---|
| 951 | - /*loop through and process each element of the struct array */
|
---|
| 952 | - for (sindex=0; sindex<ostruct->numel; sindex++) {
|
---|
| 953 | - ostruct->value[sindex]=new Options;
|
---|
| 954 | -
|
---|
| 955 | - /*loop through and process each field for the element */
|
---|
| 956 | - for (i=0; i<mxGetNumberOfFields(prhs[0]); i++) {
|
---|
| 957 | - sprintf(namei,"%s.%s",name,mxGetFieldNameByNumber(prhs[0],i));
|
---|
| 958 | - structi=mxGetFieldByNumber(prhs[0],sindex,i);
|
---|
| 959 | -
|
---|
| 960 | - option=(Option*)OptionParse(namei,&structi);
|
---|
| 961 | - ostruct->value[sindex]->AddObject((Object*)option);
|
---|
| 962 | - option=NULL;
|
---|
| 963 | - }
|
---|
| 964 | - }
|
---|
| 965 | -
|
---|
| 966 | - return(ostruct);
|
---|
| 967 | -}/*}}}*/
|
---|
| 968 | -GenericOption<Options*>* OptionCellParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 969 | -
|
---|
| 970 | - int i;
|
---|
| 971 | - int *dims;
|
---|
| 972 | - char namei[161];
|
---|
| 973 | - char cstr[81];
|
---|
| 974 | - GenericOption<Options*> *ocell = NULL;
|
---|
| 975 | - Option *option = NULL;
|
---|
| 976 | - const mwSize *ipt = NULL;
|
---|
| 977 | - const mxArray *celli;
|
---|
| 978 | - mwIndex cindex;
|
---|
| 979 | -
|
---|
| 980 | - /*check and parse the name */
|
---|
| 981 | - ocell=new GenericOption<Options*>();
|
---|
| 982 | - ocell->name =xNew<char>(strlen(name)+1);
|
---|
| 983 | - memcpy(ocell->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 984 | -
|
---|
| 985 | - /*check and parse the value */
|
---|
| 986 | - if (!mxIsClass(prhs[0],"cell")){
|
---|
| 987 | - _error_("Value of option \"" << ocell->name << "\" must be class \"cell\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
|
---|
| 988 | - }
|
---|
| 989 | -
|
---|
| 990 | - ocell->numel=mxGetNumberOfElements(prhs[0]);
|
---|
| 991 | - ocell->ndims=mxGetNumberOfDimensions(prhs[0]);
|
---|
| 992 | - ipt =mxGetDimensions(prhs[0]);
|
---|
| 993 | - ocell->size =xNew<int>(ocell->ndims);
|
---|
| 994 | - for (i=0; i<ocell->ndims; i++) ocell->size[i]=(int)ipt[i];
|
---|
| 995 | - ocell->value=new Options;
|
---|
| 996 | -
|
---|
| 997 | - /*loop through and process each element of the cell array */
|
---|
| 998 | - dims=xNew<int>(ocell->ndims);
|
---|
| 999 | - for (cindex=0; cindex<ocell->numel; cindex++) {
|
---|
| 1000 | - ColumnWiseDimsFromIndex(dims,(int)cindex,ocell->size,ocell->ndims);
|
---|
| 1001 | - StringFromDims(cstr,dims,ocell->ndims);
|
---|
| 1002 | - #ifdef _INTEL_WIN_
|
---|
| 1003 | - _snprintf(namei,161,"%s%s",name,cstr);
|
---|
| 1004 | - #else
|
---|
| 1005 | - snprintf(namei,161,"%s%s",name,cstr);
|
---|
| 1006 | - #endif
|
---|
| 1007 | - celli=mxGetCell(prhs[0],cindex);
|
---|
| 1008 | -
|
---|
| 1009 | - option=(Option*)OptionParse(namei,&celli);
|
---|
| 1010 | - ocell->value->AddObject((Object*)option);
|
---|
| 1011 | - option=NULL;
|
---|
| 1012 | - }
|
---|
| 1013 | - xDelete<int>(dims);
|
---|
| 1014 | -
|
---|
| 1015 | - return(ocell);
|
---|
| 1016 | -}/*}}}*/
|
---|
| 1017 | -Option* OptionParse(char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 1018 | -
|
---|
| 1019 | - Option *option = NULL;
|
---|
| 1020 | - mxArray *lhs[1];
|
---|
| 1021 | -
|
---|
| 1022 | - /*parse the value according to the matlab data type */
|
---|
| 1023 | - if (mxIsClass(prhs[0],"double") && (mxGetNumberOfElements(prhs[0])==1))
|
---|
| 1024 | - option=(Option*)OptionDoubleParse(name,prhs);
|
---|
| 1025 | - else if(mxIsClass(prhs[0],"double") && (mxGetNumberOfElements(prhs[0])!=1))
|
---|
| 1026 | - option=(Option*)OptionDoubleArrayParse(name,prhs);
|
---|
| 1027 | - else if(mxIsClass(prhs[0],"logical"))
|
---|
| 1028 | - option=(Option*)OptionLogicalParse(name,prhs);
|
---|
| 1029 | - else if(mxIsClass(prhs[0],"char"))
|
---|
| 1030 | - option=(Option*)OptionCharParse(name,prhs);
|
---|
| 1031 | - else if(mxIsClass(prhs[0],"struct"))
|
---|
| 1032 | - option=(Option*)OptionStructParse(name,prhs);
|
---|
| 1033 | - else if(mxIsClass(prhs[0],"cell"))
|
---|
| 1034 | - option=(Option*)OptionCellParse(name,prhs);
|
---|
| 1035 | - else {
|
---|
| 1036 | - _pprintLine_(" Converting value of option \"" << name << "\" from unrecognized class \"" << mxGetClassName(prhs[0]) << "\" to class \"" << "struct" << "\".");
|
---|
| 1037 | - if (!mexCallMATLAB(1,lhs,1,(mxArray**)prhs,"struct")) {
|
---|
| 1038 | - option=(Option*)OptionStructParse(name,(const mxArray**)lhs);
|
---|
| 1039 | - mxDestroyArray(lhs[0]);
|
---|
| 1040 | - }
|
---|
| 1041 | - else _error_("Second argument value of option \""<< name <<"\" is of unrecognized class \""<< mxGetClassName(prhs[0]) <<"\".");
|
---|
| 1042 | - }
|
---|
| 1043 | -
|
---|
| 1044 | - return(option);
|
---|
| 1045 | -}/*}}}*/
|
---|
| 1046 | Index: ../trunk-jpl/src/c/matlab/io/MatlabMatrixToSeqMat.cpp
|
---|
| 1047 | ===================================================================
|
---|
| 1048 | --- ../trunk-jpl/src/c/matlab/io/MatlabMatrixToSeqMat.cpp (revision 13748)
|
---|
| 1049 | +++ ../trunk-jpl/src/c/matlab/io/MatlabMatrixToSeqMat.cpp (revision 13749)
|
---|
| 1050 | @@ -1,29 +0,0 @@
|
---|
| 1051 | -/*!\file MatlabMatrixToSeqMat.cpp
|
---|
| 1052 | - */
|
---|
| 1053 | -
|
---|
| 1054 | -/*Headers:*/
|
---|
| 1055 | -/*{{{*/
|
---|
| 1056 | -#ifdef HAVE_CONFIG_H
|
---|
| 1057 | - #include <config.h>
|
---|
| 1058 | -#else
|
---|
| 1059 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 1060 | -#endif
|
---|
| 1061 | -
|
---|
| 1062 | -#include <mex.h>
|
---|
| 1063 | -#include <stdio.h>
|
---|
| 1064 | -#include <string.h>
|
---|
| 1065 | -#include "../../toolkits/toolkits.h"
|
---|
| 1066 | -#include "../../shared/shared.h"
|
---|
| 1067 | -#include "./matlabio.h"
|
---|
| 1068 | -
|
---|
| 1069 | -/*}}}*/
|
---|
| 1070 | -
|
---|
| 1071 | -SeqMat<double>* MatlabMatrixToSeqMat(const mxArray* dataref){
|
---|
| 1072 | -
|
---|
| 1073 | - SeqMat<double>* output=NULL;
|
---|
| 1074 | -
|
---|
| 1075 | - output=new SeqMat<double>();
|
---|
| 1076 | - MatlabMatrixToDoubleMatrix(&output->matrix,&output->M,&output->N,dataref);
|
---|
| 1077 | - return output;
|
---|
| 1078 | -
|
---|
| 1079 | -}
|
---|
| 1080 | Index: ../trunk-jpl/src/c/matlab/io/MatlabVectorToPetscVec.cpp
|
---|
| 1081 | ===================================================================
|
---|
| 1082 | --- ../trunk-jpl/src/c/matlab/io/MatlabVectorToPetscVec.cpp (revision 13748)
|
---|
| 1083 | +++ ../trunk-jpl/src/c/matlab/io/MatlabVectorToPetscVec.cpp (revision 13749)
|
---|
| 1084 | @@ -1,108 +0,0 @@
|
---|
| 1085 | -/* \file MatlabVectorToPetscVector.cpp
|
---|
| 1086 | - * \brief: convert a sparse or dense matlab vector to a serial Petsc vector:
|
---|
| 1087 | - */
|
---|
| 1088 | -
|
---|
| 1089 | -#ifdef HAVE_CONFIG_H
|
---|
| 1090 | - #include <config.h>
|
---|
| 1091 | -#else
|
---|
| 1092 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 1093 | -#endif
|
---|
| 1094 | -
|
---|
| 1095 | -/*Petsc includes: */
|
---|
| 1096 | -#include "petscmat.h"
|
---|
| 1097 | -#include "petscvec.h"
|
---|
| 1098 | -#include "petscksp.h"
|
---|
| 1099 | -
|
---|
| 1100 | -/*Matlab includes: */
|
---|
| 1101 | -#include "mex.h"
|
---|
| 1102 | -
|
---|
| 1103 | -#include "../../shared/shared.h"
|
---|
| 1104 | -#include "matlabio.h"
|
---|
| 1105 | -
|
---|
| 1106 | -PetscVec* MatlabVectorToPetscVec(const mxArray* mxvector){
|
---|
| 1107 | -
|
---|
| 1108 | - int dummy;
|
---|
| 1109 | - PetscVec* vector=new PetscVec();
|
---|
| 1110 | -
|
---|
| 1111 | - MatlabVectorToPetscVec(&vector->vector,&dummy, mxvector);
|
---|
| 1112 | -
|
---|
| 1113 | - return vector;
|
---|
| 1114 | -}
|
---|
| 1115 | -
|
---|
| 1116 | -int MatlabVectorToPetscVec(Vec* pvector,int* pvector_rows,const mxArray* mxvector){
|
---|
| 1117 | -
|
---|
| 1118 | - int rows, cols;
|
---|
| 1119 | - double* mxvector_ptr=NULL;
|
---|
| 1120 | - int ierr;
|
---|
| 1121 | - int i,j;
|
---|
| 1122 | -
|
---|
| 1123 | - /*output: */
|
---|
| 1124 | - Vec vector=NULL;
|
---|
| 1125 | -
|
---|
| 1126 | - /*matlab indices: */
|
---|
| 1127 | - mwIndex* ir=NULL;
|
---|
| 1128 | - mwIndex* jc=NULL;
|
---|
| 1129 | - double* pr=NULL;
|
---|
| 1130 | - int count;
|
---|
| 1131 | - int nnz;
|
---|
| 1132 | - int nz;
|
---|
| 1133 | -
|
---|
| 1134 | - /*petsc indices: */
|
---|
| 1135 | - int* idxm=NULL;
|
---|
| 1136 | -
|
---|
| 1137 | - /*Ok, first check if we are dealing with a sparse or full vector: */
|
---|
| 1138 | - if (mxIsSparse(mxvector)){
|
---|
| 1139 | -
|
---|
| 1140 | - /*Dealing with sparse vector: recover size first: */
|
---|
| 1141 | - mxvector_ptr=(double*)mxGetPr(mxvector);
|
---|
| 1142 | - rows=mxGetM(mxvector);
|
---|
| 1143 | - cols=mxGetN(mxvector);
|
---|
| 1144 | - nnz=mxGetNzmax(mxvector);
|
---|
| 1145 | - nz=(int)((double)nnz/(double)rows);
|
---|
| 1146 | -
|
---|
| 1147 | - ierr=VecCreateSeq(PETSC_COMM_SELF,rows,&vector);CHKERRQ(ierr);
|
---|
| 1148 | -
|
---|
| 1149 | - /*Now, get ir,jc and pr: */
|
---|
| 1150 | - pr=mxGetPr(mxvector);
|
---|
| 1151 | - ir=mxGetIr(mxvector);
|
---|
| 1152 | - jc=mxGetJc(mxvector);
|
---|
| 1153 | -
|
---|
| 1154 | - /*Now, start inserting data into sparse vector: */
|
---|
| 1155 | - count=0;
|
---|
| 1156 | - for(i=0;i<cols;i++){
|
---|
| 1157 | - for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 1158 | - VecSetValue(vector,ir[count],pr[count],INSERT_VALUES);
|
---|
| 1159 | - count++;
|
---|
| 1160 | - }
|
---|
| 1161 | - }
|
---|
| 1162 | -
|
---|
| 1163 | - }
|
---|
| 1164 | - else{
|
---|
| 1165 | -
|
---|
| 1166 | - /*Dealing with dense vector: recover pointer and size: */
|
---|
| 1167 | - mxvector_ptr=(double*)mxGetPr(mxvector);
|
---|
| 1168 | - rows=mxGetM(mxvector);
|
---|
| 1169 | - cols=mxGetN(mxvector);
|
---|
| 1170 | -
|
---|
| 1171 | - /*Create serial vector: */
|
---|
| 1172 | - ierr=VecCreateSeq(PETSC_COMM_SELF,rows,&vector);CHKERRQ(ierr);
|
---|
| 1173 | -
|
---|
| 1174 | - /*Insert mxvector_ptr values into petsc vector: */
|
---|
| 1175 | - idxm=xNew<int>(rows);
|
---|
| 1176 | -
|
---|
| 1177 | - for(i=0;i<rows;i++)idxm[i]=i;
|
---|
| 1178 | -
|
---|
| 1179 | - ierr=VecSetValues(vector,rows,idxm,mxvector_ptr,INSERT_VALUES);CHKERRQ(ierr);
|
---|
| 1180 | -
|
---|
| 1181 | - }
|
---|
| 1182 | -
|
---|
| 1183 | - /*Assemble vector: */
|
---|
| 1184 | - VecAssemblyBegin(vector);
|
---|
| 1185 | - VecAssemblyEnd(vector);
|
---|
| 1186 | -
|
---|
| 1187 | - /*Assign output pointer: */
|
---|
| 1188 | - *pvector=vector;
|
---|
| 1189 | - *pvector_rows=rows;
|
---|
| 1190 | -
|
---|
| 1191 | - return 1;
|
---|
| 1192 | -}
|
---|
| 1193 | Index: ../trunk-jpl/src/c/matlab/io/MatlabVectorToDoubleVector.cpp
|
---|
| 1194 | ===================================================================
|
---|
| 1195 | --- ../trunk-jpl/src/c/matlab/io/MatlabVectorToDoubleVector.cpp (revision 13748)
|
---|
| 1196 | +++ ../trunk-jpl/src/c/matlab/io/MatlabVectorToDoubleVector.cpp (revision 13749)
|
---|
| 1197 | @@ -1,94 +0,0 @@
|
---|
| 1198 | -/* \file MatlabVectorToDoubleVector.cpp
|
---|
| 1199 | - * \brief: convert a sparse or dense matlab vector to a serial vector:
|
---|
| 1200 | - */
|
---|
| 1201 | -
|
---|
| 1202 | -#ifdef HAVE_CONFIG_H
|
---|
| 1203 | - #include <config.h>
|
---|
| 1204 | -#else
|
---|
| 1205 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 1206 | -#endif
|
---|
| 1207 | -
|
---|
| 1208 | -#include <string.h>
|
---|
| 1209 | -
|
---|
| 1210 | -/*Matlab includes: */
|
---|
| 1211 | -#include "mex.h"
|
---|
| 1212 | -
|
---|
| 1213 | -#include "../../shared/shared.h"
|
---|
| 1214 | -
|
---|
| 1215 | -int MatlabVectorToDoubleVector(double** pvector,int* pvector_rows,const mxArray* mxvector){
|
---|
| 1216 | -
|
---|
| 1217 | - int rows,cols;
|
---|
| 1218 | - double* mxvector_ptr=NULL;
|
---|
| 1219 | - int ierr;
|
---|
| 1220 | - int i,j;
|
---|
| 1221 | -
|
---|
| 1222 | - /*output: */
|
---|
| 1223 | - double* vector=NULL;
|
---|
| 1224 | -
|
---|
| 1225 | - /*matlab indices: */
|
---|
| 1226 | - mwIndex* ir=NULL;
|
---|
| 1227 | - mwIndex* jc=NULL;
|
---|
| 1228 | - double* pr=NULL;
|
---|
| 1229 | - int count;
|
---|
| 1230 | - int nnz;
|
---|
| 1231 | - int nz;
|
---|
| 1232 | -
|
---|
| 1233 | - /*Ok, first check if we are dealing with a sparse or full vector: */
|
---|
| 1234 | - if (mxIsSparse(mxvector)){
|
---|
| 1235 | -
|
---|
| 1236 | - /*Dealing with sparse vector: recover size first: */
|
---|
| 1237 | - mxvector_ptr=(double*)mxGetPr(mxvector);
|
---|
| 1238 | - rows=mxGetM(mxvector);
|
---|
| 1239 | - cols=mxGetN(mxvector);
|
---|
| 1240 | - nnz=mxGetNzmax(mxvector);
|
---|
| 1241 | -
|
---|
| 1242 | - /*Check that input is actualy a vector*/
|
---|
| 1243 | - if (cols!=1) _error_("input vector of size " << rows << "x" << cols << " should have only one column");
|
---|
| 1244 | -
|
---|
| 1245 | - nz=(int)((double)nnz/(double)rows);
|
---|
| 1246 | -
|
---|
| 1247 | - if(rows){
|
---|
| 1248 | - vector=xNewZeroInit<double>(rows);
|
---|
| 1249 | -
|
---|
| 1250 | - /*Now, get ir,jc and pr: */
|
---|
| 1251 | - pr=mxGetPr(mxvector);
|
---|
| 1252 | - ir=mxGetIr(mxvector);
|
---|
| 1253 | - jc=mxGetJc(mxvector);
|
---|
| 1254 | -
|
---|
| 1255 | - /*Now, start inserting data into sparse vector: */
|
---|
| 1256 | - count=0;
|
---|
| 1257 | - for(i=0;i<cols;i++){
|
---|
| 1258 | - for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 1259 | - vector[ir[count]]=pr[count];
|
---|
| 1260 | - count++;
|
---|
| 1261 | - }
|
---|
| 1262 | - }
|
---|
| 1263 | - }
|
---|
| 1264 | -
|
---|
| 1265 | - }
|
---|
| 1266 | - else{
|
---|
| 1267 | -
|
---|
| 1268 | - /*Dealing with dense vector: recover pointer and size: */
|
---|
| 1269 | - mxvector_ptr=(double*)mxGetPr(mxvector);
|
---|
| 1270 | - rows=mxGetM(mxvector);
|
---|
| 1271 | - cols=mxGetN(mxvector);
|
---|
| 1272 | -
|
---|
| 1273 | - /*Check that input is actualy a vector*/
|
---|
| 1274 | - if (cols!=1) _error_("input vector of size " << rows << "x" << cols << " should have only one column");
|
---|
| 1275 | -
|
---|
| 1276 | - /*allocate and memcpy*/
|
---|
| 1277 | - if(rows){
|
---|
| 1278 | - vector=xNew<double>(rows);
|
---|
| 1279 | - memcpy(vector,mxvector_ptr,rows*sizeof(double));
|
---|
| 1280 | - }
|
---|
| 1281 | - else{
|
---|
| 1282 | - vector=NULL;
|
---|
| 1283 | - }
|
---|
| 1284 | - }
|
---|
| 1285 | -
|
---|
| 1286 | - /*Assign output pointer: */
|
---|
| 1287 | - *pvector=vector;
|
---|
| 1288 | - *pvector_rows=rows;
|
---|
| 1289 | -
|
---|
| 1290 | - return 1;
|
---|
| 1291 | -}
|
---|
| 1292 | Index: ../trunk-jpl/src/c/matlab/io/FetchMatlabData.cpp
|
---|
| 1293 | ===================================================================
|
---|
| 1294 | --- ../trunk-jpl/src/c/matlab/io/FetchMatlabData.cpp (revision 13748)
|
---|
| 1295 | +++ ../trunk-jpl/src/c/matlab/io/FetchMatlabData.cpp (revision 13749)
|
---|
| 1296 | @@ -1,693 +0,0 @@
|
---|
| 1297 | -/*\file FetchData.cpp:
|
---|
| 1298 | - * \brief: general I/O interface to fetch data in matlab
|
---|
| 1299 | - */
|
---|
| 1300 | -
|
---|
| 1301 | -#ifdef HAVE_CONFIG_H
|
---|
| 1302 | - #include <config.h>
|
---|
| 1303 | -#else
|
---|
| 1304 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 1305 | -#endif
|
---|
| 1306 | -
|
---|
| 1307 | -#include <mex.h>
|
---|
| 1308 | -#include "../../shared/shared.h"
|
---|
| 1309 | -#include "../../include/include.h"
|
---|
| 1310 | -#include "./matlabio.h"
|
---|
| 1311 | -
|
---|
| 1312 | -/*Primitive data types*/
|
---|
| 1313 | -/*FUNCTION FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
|
---|
| 1314 | -void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){
|
---|
| 1315 | -
|
---|
| 1316 | - double* outmatrix=NULL;
|
---|
| 1317 | - int outmatrix_rows,outmatrix_cols;
|
---|
| 1318 | -
|
---|
| 1319 | - if(mxIsEmpty(dataref) ){
|
---|
| 1320 | - /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 1321 | - outmatrix_rows=0;
|
---|
| 1322 | - outmatrix_cols=0;
|
---|
| 1323 | - outmatrix=NULL;
|
---|
| 1324 | - }
|
---|
| 1325 | - else if( mxIsClass(dataref,"double") ||
|
---|
| 1326 | - mxIsClass(dataref,"single") ||
|
---|
| 1327 | - mxIsClass(dataref,"int16") ||
|
---|
| 1328 | - mxIsClass(dataref,"int8") ||
|
---|
| 1329 | - mxIsClass(dataref,"uint8")){
|
---|
| 1330 | - /*Check dataref is not pointing to NaN: */
|
---|
| 1331 | - if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
|
---|
| 1332 | - outmatrix_rows=0;
|
---|
| 1333 | - outmatrix_cols=0;
|
---|
| 1334 | - outmatrix=NULL;
|
---|
| 1335 | - }
|
---|
| 1336 | - else{
|
---|
| 1337 | - if(!mxIsClass(dataref,"double") && !mxIsClass(dataref,"single")){
|
---|
| 1338 | - _printLine_("Warning: converting matlab data from '" << mxGetClassName(dataref) << "' to 'double'");
|
---|
| 1339 | - }
|
---|
| 1340 | - /*Convert matlab matrix to double* matrix: */
|
---|
| 1341 | - MatlabMatrixToDoubleMatrix(&outmatrix,&outmatrix_rows,&outmatrix_cols,dataref);
|
---|
| 1342 | - }
|
---|
| 1343 | - }
|
---|
| 1344 | - else{
|
---|
| 1345 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1346 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1347 | - }
|
---|
| 1348 | -
|
---|
| 1349 | - /*Assign output pointers:*/
|
---|
| 1350 | - *pmatrix=outmatrix;
|
---|
| 1351 | - if (pM)*pM=outmatrix_rows;
|
---|
| 1352 | - if (pN)*pN=outmatrix_cols;
|
---|
| 1353 | -
|
---|
| 1354 | -}
|
---|
| 1355 | -/*}}}*/
|
---|
| 1356 | -/*FUNCTION FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
|
---|
| 1357 | -void FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
|
---|
| 1358 | -
|
---|
| 1359 | - int outmatrix_numel,outmatrix_ndims;
|
---|
| 1360 | - double *outmatrix = NULL;
|
---|
| 1361 | - int *outmatrix_size = NULL;
|
---|
| 1362 | -
|
---|
| 1363 | - if(mxIsEmpty(dataref) ){
|
---|
| 1364 | - /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 1365 | - outmatrix_numel = 0;
|
---|
| 1366 | - outmatrix_ndims = 0;
|
---|
| 1367 | - outmatrix_size = NULL;
|
---|
| 1368 | - outmatrix = NULL;
|
---|
| 1369 | - }
|
---|
| 1370 | - else if( mxIsClass(dataref,"double") ||
|
---|
| 1371 | - mxIsClass(dataref,"single") ||
|
---|
| 1372 | - mxIsClass(dataref,"int16") ||
|
---|
| 1373 | - mxIsClass(dataref,"int8") ||
|
---|
| 1374 | - mxIsClass(dataref,"uint8")){
|
---|
| 1375 | -
|
---|
| 1376 | - /*Check dataref is not pointing to NaN: */
|
---|
| 1377 | - if (mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1)){
|
---|
| 1378 | - outmatrix_numel = 0;
|
---|
| 1379 | - outmatrix_ndims = 0;
|
---|
| 1380 | - outmatrix_size = NULL;
|
---|
| 1381 | - outmatrix = NULL;
|
---|
| 1382 | - }
|
---|
| 1383 | - else{
|
---|
| 1384 | - if(!mxIsClass(dataref,"double") && !mxIsClass(dataref,"single")){
|
---|
| 1385 | - _printLine_("Warning: converting matlab data from '" << mxGetClassName(dataref) << "' to 'double'");
|
---|
| 1386 | - }
|
---|
| 1387 | - /*Convert matlab n-dim array to double* matrix: */
|
---|
| 1388 | - MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
|
---|
| 1389 | - }
|
---|
| 1390 | - }
|
---|
| 1391 | - else{
|
---|
| 1392 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1393 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1394 | - }
|
---|
| 1395 | -
|
---|
| 1396 | - /*Assign output pointers:*/
|
---|
| 1397 | - *pmatrix=outmatrix;
|
---|
| 1398 | - if (pnumel)*pnumel=outmatrix_numel;
|
---|
| 1399 | - if (pndims)*pndims=outmatrix_ndims;
|
---|
| 1400 | - if (psize )*psize =outmatrix_size;
|
---|
| 1401 | - else xDelete<int>(outmatrix_size);
|
---|
| 1402 | -
|
---|
| 1403 | -}
|
---|
| 1404 | -/*}}}*/
|
---|
| 1405 | -/*FUNCTION FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
|
---|
| 1406 | -void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){
|
---|
| 1407 | -
|
---|
| 1408 | - int i,outmatrix_rows,outmatrix_cols;
|
---|
| 1409 | - double *doublematrix=NULL;
|
---|
| 1410 | - int *outmatrix=NULL;
|
---|
| 1411 | -
|
---|
| 1412 | - if(mxIsEmpty(dataref) ){
|
---|
| 1413 | - /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 1414 | - outmatrix_rows=0;
|
---|
| 1415 | - outmatrix_cols=0;
|
---|
| 1416 | - outmatrix=NULL;
|
---|
| 1417 | - }
|
---|
| 1418 | - else if( mxIsClass(dataref,"double") ||
|
---|
| 1419 | - mxIsClass(dataref,"single") ||
|
---|
| 1420 | - mxIsClass(dataref,"int16") ||
|
---|
| 1421 | - mxIsClass(dataref,"int8") ||
|
---|
| 1422 | - mxIsClass(dataref,"uint8")){
|
---|
| 1423 | -
|
---|
| 1424 | - /*Check dataref is not pointing to NaN: */
|
---|
| 1425 | - if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
|
---|
| 1426 | - outmatrix_rows=0;
|
---|
| 1427 | - outmatrix_cols=0;
|
---|
| 1428 | - outmatrix=NULL;
|
---|
| 1429 | - }
|
---|
| 1430 | - else{
|
---|
| 1431 | - if(!mxIsClass(dataref,"double") && !mxIsClass(dataref,"single")){
|
---|
| 1432 | - _printLine_("Warning: converting matlab data from '" << mxGetClassName(dataref) << "' to 'double'");
|
---|
| 1433 | - }
|
---|
| 1434 | - /*Convert matlab matrix to double* matrix: */
|
---|
| 1435 | - MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref);
|
---|
| 1436 | -
|
---|
| 1437 | - /*Convert double matrix into integer matrix: */
|
---|
| 1438 | - outmatrix=xNew<int>(outmatrix_rows*outmatrix_cols);
|
---|
| 1439 | - for(i=0;i<outmatrix_rows*outmatrix_cols;i++)outmatrix[i]=(int)doublematrix[i];
|
---|
| 1440 | - }
|
---|
| 1441 | - }
|
---|
| 1442 | - else{
|
---|
| 1443 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1444 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1445 | - }
|
---|
| 1446 | -
|
---|
| 1447 | - /*Assign output pointers:*/
|
---|
| 1448 | - *pmatrix=outmatrix;
|
---|
| 1449 | - if (pM)*pM=outmatrix_rows;
|
---|
| 1450 | - if (pN)*pN=outmatrix_cols;
|
---|
| 1451 | -}
|
---|
| 1452 | -/*}}}*/
|
---|
| 1453 | -/*FUNCTION FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
|
---|
| 1454 | -void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){
|
---|
| 1455 | -
|
---|
| 1456 | - int i,outmatrix_rows,outmatrix_cols;
|
---|
| 1457 | - double *doublematrix=NULL;
|
---|
| 1458 | - bool *outmatrix=NULL;
|
---|
| 1459 | -
|
---|
| 1460 | - if(mxIsEmpty(dataref) ){
|
---|
| 1461 | - /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 1462 | - outmatrix_rows=0;
|
---|
| 1463 | - outmatrix_cols=0;
|
---|
| 1464 | - outmatrix=NULL;
|
---|
| 1465 | - }
|
---|
| 1466 | - else if (mxIsClass(dataref,"double") ){
|
---|
| 1467 | -
|
---|
| 1468 | - /*Check dataref is not pointing to NaN: */
|
---|
| 1469 | - if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
|
---|
| 1470 | - outmatrix_rows=0;
|
---|
| 1471 | - outmatrix_cols=0;
|
---|
| 1472 | - outmatrix=NULL;
|
---|
| 1473 | - }
|
---|
| 1474 | - else{
|
---|
| 1475 | -
|
---|
| 1476 | - /*Convert matlab matrix to double* matrix: */
|
---|
| 1477 | - MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref);
|
---|
| 1478 | -
|
---|
| 1479 | - /*Convert double matrix into integer matrix: */
|
---|
| 1480 | - outmatrix=xNew<bool>(outmatrix_rows*outmatrix_cols);
|
---|
| 1481 | - for(i=0;i<outmatrix_rows;i++)outmatrix[i]=(bool)doublematrix[i];
|
---|
| 1482 | - }
|
---|
| 1483 | - }
|
---|
| 1484 | - else{
|
---|
| 1485 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1486 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1487 | - }
|
---|
| 1488 | -
|
---|
| 1489 | - /*Assign output pointers:*/
|
---|
| 1490 | - *pmatrix=outmatrix;
|
---|
| 1491 | - if (pM)*pM=outmatrix_rows;
|
---|
| 1492 | - if (pN)*pN=outmatrix_cols;
|
---|
| 1493 | -}
|
---|
| 1494 | -/*}}}*/
|
---|
| 1495 | -/*FUNCTION FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
|
---|
| 1496 | -void FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
|
---|
| 1497 | -
|
---|
| 1498 | - int i;
|
---|
| 1499 | - int outmatrix_numel,outmatrix_ndims;
|
---|
| 1500 | - int* outmatrix_size=NULL;
|
---|
| 1501 | - double* doublematrix=NULL;
|
---|
| 1502 | - bool* outmatrix=NULL;
|
---|
| 1503 | -
|
---|
| 1504 | - if(mxIsEmpty(dataref) ){
|
---|
| 1505 | - /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 1506 | - outmatrix_numel=0;
|
---|
| 1507 | - outmatrix_ndims=0;
|
---|
| 1508 | - outmatrix_size =NULL;
|
---|
| 1509 | - outmatrix=NULL;
|
---|
| 1510 | - }
|
---|
| 1511 | - else if (mxIsClass(dataref,"logical") ){
|
---|
| 1512 | -
|
---|
| 1513 | - /*Check dataref is not pointing to NaN: */
|
---|
| 1514 | - if ( mxIsNaN(*((bool*)mxGetData(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
|
---|
| 1515 | - outmatrix_numel=0;
|
---|
| 1516 | - outmatrix_ndims=0;
|
---|
| 1517 | - outmatrix_size =NULL;
|
---|
| 1518 | - outmatrix=NULL;
|
---|
| 1519 | - }
|
---|
| 1520 | - else{
|
---|
| 1521 | -
|
---|
| 1522 | - /*Convert matlab n-dim array to bool* matrix: */
|
---|
| 1523 | - MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
|
---|
| 1524 | - }
|
---|
| 1525 | - }
|
---|
| 1526 | - else if (mxIsClass(dataref,"double") ){
|
---|
| 1527 | -
|
---|
| 1528 | - /*Check dataref is not pointing to NaN: */
|
---|
| 1529 | - if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
|
---|
| 1530 | - outmatrix_numel=0;
|
---|
| 1531 | - outmatrix_ndims=0;
|
---|
| 1532 | - outmatrix_size =NULL;
|
---|
| 1533 | - outmatrix=NULL;
|
---|
| 1534 | - }
|
---|
| 1535 | - else{
|
---|
| 1536 | -
|
---|
| 1537 | - /*Convert matlab n-dim array to double* matrix: */
|
---|
| 1538 | - MatlabNArrayToNArray(&doublematrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
|
---|
| 1539 | -
|
---|
| 1540 | - /*Convert double matrix into bool matrix: */
|
---|
| 1541 | - outmatrix=xNew<bool>(outmatrix_numel);
|
---|
| 1542 | - for(i=0;i<outmatrix_numel;i++)outmatrix[i]=(bool)doublematrix[i];
|
---|
| 1543 | - xDelete<double>(doublematrix);
|
---|
| 1544 | - }
|
---|
| 1545 | - }
|
---|
| 1546 | - else{
|
---|
| 1547 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1548 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1549 | - }
|
---|
| 1550 | -
|
---|
| 1551 | - /*Assign output pointers:*/
|
---|
| 1552 | - *pmatrix=outmatrix;
|
---|
| 1553 | - if (pnumel)*pnumel=outmatrix_numel;
|
---|
| 1554 | - if (pndims)*pndims=outmatrix_ndims;
|
---|
| 1555 | - if (psize )*psize =outmatrix_size;
|
---|
| 1556 | - else xDelete<int>(outmatrix_size);
|
---|
| 1557 | -
|
---|
| 1558 | -}
|
---|
| 1559 | -/*}}}*/
|
---|
| 1560 | -/*FUNCTION FetchData(double** pvector,int* pM,const mxArray* dataref){{{*/
|
---|
| 1561 | -void FetchData(double** pvector,int* pM,const mxArray* dataref){
|
---|
| 1562 | -
|
---|
| 1563 | - double* outvector=NULL;
|
---|
| 1564 | - int outvector_rows;
|
---|
| 1565 | -
|
---|
| 1566 | - if(mxIsEmpty(dataref)){
|
---|
| 1567 | - /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 1568 | - outvector_rows=0;
|
---|
| 1569 | - outvector=NULL;
|
---|
| 1570 | - }
|
---|
| 1571 | - else if (mxIsClass(dataref,"double") ){
|
---|
| 1572 | -
|
---|
| 1573 | - /*Convert matlab vector to double* vector: */
|
---|
| 1574 | - MatlabVectorToDoubleVector(&outvector,&outvector_rows,dataref);
|
---|
| 1575 | -
|
---|
| 1576 | - }
|
---|
| 1577 | - else{
|
---|
| 1578 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1579 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1580 | - }
|
---|
| 1581 | -
|
---|
| 1582 | - /*Assign output pointers:*/
|
---|
| 1583 | - *pvector=outvector;
|
---|
| 1584 | - if (pM)*pM=outvector_rows;
|
---|
| 1585 | -}
|
---|
| 1586 | -/*}}}*/
|
---|
| 1587 | -/*FUNCTION FetchData(int** pvector,int* pM,const mxArray* dataref){{{*/
|
---|
| 1588 | -void FetchData(int** pvector,int* pM,const mxArray* dataref){
|
---|
| 1589 | -
|
---|
| 1590 | - int i;
|
---|
| 1591 | - double *doublevector = NULL;
|
---|
| 1592 | - int *outvector = NULL;
|
---|
| 1593 | - int outvector_rows;
|
---|
| 1594 | -
|
---|
| 1595 | - if(mxIsEmpty(dataref)){
|
---|
| 1596 | - /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 1597 | - outvector_rows=0;
|
---|
| 1598 | - outvector=NULL;
|
---|
| 1599 | - }
|
---|
| 1600 | - else if (mxIsClass(dataref,"double") ){
|
---|
| 1601 | -
|
---|
| 1602 | - /*Convert matlab vector to double* vector: */
|
---|
| 1603 | - MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
|
---|
| 1604 | -
|
---|
| 1605 | - /*Convert double vector into integer vector: */
|
---|
| 1606 | - outvector=xNew<int>(outvector_rows);
|
---|
| 1607 | - for(i=0;i<outvector_rows;i++)outvector[i]=(int)doublevector[i];
|
---|
| 1608 | - }
|
---|
| 1609 | - else{
|
---|
| 1610 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1611 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1612 | - }
|
---|
| 1613 | -
|
---|
| 1614 | - /*Assign output pointers:*/
|
---|
| 1615 | - *pvector=outvector;
|
---|
| 1616 | - if (pM)*pM=outvector_rows;
|
---|
| 1617 | -}
|
---|
| 1618 | -/*}}}*/
|
---|
| 1619 | -/*FUNCTION FetchData(bool** pvector,int* pM,const mxArray* dataref){{{*/
|
---|
| 1620 | -void FetchData(bool** pvector,int* pM,const mxArray* dataref){
|
---|
| 1621 | -
|
---|
| 1622 | - int i;
|
---|
| 1623 | - double *doublevector = NULL;
|
---|
| 1624 | - bool *outvector = NULL;
|
---|
| 1625 | - int outvector_rows;
|
---|
| 1626 | -
|
---|
| 1627 | - if(mxIsEmpty(dataref)){
|
---|
| 1628 | - /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 1629 | - outvector_rows=0;
|
---|
| 1630 | - outvector=NULL;
|
---|
| 1631 | - }
|
---|
| 1632 | - else if (mxIsClass(dataref,"double") ){
|
---|
| 1633 | -
|
---|
| 1634 | - /*Convert matlab vector to double* vector: */
|
---|
| 1635 | - MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
|
---|
| 1636 | -
|
---|
| 1637 | - /*Convert double vector into integer vector: */
|
---|
| 1638 | - outvector=xNew<bool>(outvector_rows);
|
---|
| 1639 | - for(i=0;i<outvector_rows;i++)outvector[i]=(bool)doublevector[i];
|
---|
| 1640 | - }
|
---|
| 1641 | - else{
|
---|
| 1642 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1643 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1644 | - }
|
---|
| 1645 | -
|
---|
| 1646 | - /*Assign output pointers:*/
|
---|
| 1647 | - *pvector=outvector;
|
---|
| 1648 | - if (pM)*pM=outvector_rows;
|
---|
| 1649 | -}
|
---|
| 1650 | -/*}}}*/
|
---|
| 1651 | -/*FUNCTION FetchData(float** pvector,int* pM,const mxArray* dataref){{{*/
|
---|
| 1652 | -void FetchData(float** pvector,int* pM,const mxArray* dataref){
|
---|
| 1653 | -
|
---|
| 1654 | - int i;
|
---|
| 1655 | - double *doublevector = NULL;
|
---|
| 1656 | - float *outvector = NULL;
|
---|
| 1657 | - int outvector_rows;
|
---|
| 1658 | -
|
---|
| 1659 | - if(mxIsEmpty(dataref)){
|
---|
| 1660 | - /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 1661 | - outvector_rows=0;
|
---|
| 1662 | - outvector=NULL;
|
---|
| 1663 | - }
|
---|
| 1664 | - else if (mxIsClass(dataref,"double") ){
|
---|
| 1665 | -
|
---|
| 1666 | - /*Convert matlab vector to double* vector: */
|
---|
| 1667 | - MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
|
---|
| 1668 | -
|
---|
| 1669 | - /*Convert double vector into float vector: */
|
---|
| 1670 | - outvector=xNew<float>(outvector_rows);
|
---|
| 1671 | - for(i=0;i<outvector_rows;i++)outvector[i]=(float)doublevector[i];
|
---|
| 1672 | - }
|
---|
| 1673 | - else{
|
---|
| 1674 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1675 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1676 | - }
|
---|
| 1677 | -
|
---|
| 1678 | - /*Assign output pointers:*/
|
---|
| 1679 | - *pvector=outvector;
|
---|
| 1680 | - if (pM)*pM=outvector_rows;
|
---|
| 1681 | -}
|
---|
| 1682 | -/*}}}*/
|
---|
| 1683 | -/*FUNCTION FetchData(char** pstring,const mxArray* dataref){{{*/
|
---|
| 1684 | -void FetchData(char** pstring,const mxArray* dataref){
|
---|
| 1685 | -
|
---|
| 1686 | - char* outstring=NULL;
|
---|
| 1687 | -
|
---|
| 1688 | - /*Ok, the string should be coming directly from the matlab workspace: */
|
---|
| 1689 | - if (!mxIsClass(dataref,"char")){
|
---|
| 1690 | - _error_("input data_type is not a string!");
|
---|
| 1691 | - }
|
---|
| 1692 | - else{
|
---|
| 1693 | - /*Recover the string:*/
|
---|
| 1694 | - int stringlen;
|
---|
| 1695 | -
|
---|
| 1696 | - stringlen = mxGetM(dataref)*mxGetN(dataref)+1;
|
---|
| 1697 | - outstring =xNew<char>(stringlen);
|
---|
| 1698 | - mxGetString(dataref,outstring,stringlen);
|
---|
| 1699 | - }
|
---|
| 1700 | -
|
---|
| 1701 | - /*Assign output pointers:*/
|
---|
| 1702 | - *pstring=outstring;
|
---|
| 1703 | -}/*}}}*/
|
---|
| 1704 | -/*FUNCTION FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
|
---|
| 1705 | -void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
|
---|
| 1706 | -
|
---|
| 1707 | - int outmatrix_numel,outmatrix_ndims;
|
---|
| 1708 | - int* outmatrix_size=NULL;
|
---|
| 1709 | - char* outmatrix=NULL;
|
---|
| 1710 | -
|
---|
| 1711 | - if(mxIsEmpty(dataref) ){
|
---|
| 1712 | - /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 1713 | - outmatrix_numel=0;
|
---|
| 1714 | - outmatrix_ndims=0;
|
---|
| 1715 | - outmatrix_size =NULL;
|
---|
| 1716 | - outmatrix=NULL;
|
---|
| 1717 | - }
|
---|
| 1718 | - else if (mxIsClass(dataref,"char") ){
|
---|
| 1719 | -
|
---|
| 1720 | - /*Convert matlab n-dim array to char* matrix: */
|
---|
| 1721 | - MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
|
---|
| 1722 | - }
|
---|
| 1723 | - else{
|
---|
| 1724 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1725 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1726 | - }
|
---|
| 1727 | -
|
---|
| 1728 | - /*Assign output pointers:*/
|
---|
| 1729 | - *pmatrix=outmatrix;
|
---|
| 1730 | - if (pnumel)*pnumel=outmatrix_numel;
|
---|
| 1731 | - if (pndims)*pndims=outmatrix_ndims;
|
---|
| 1732 | - if (psize )*psize =outmatrix_size;
|
---|
| 1733 | - else xDelete<int>(outmatrix_size);
|
---|
| 1734 | -
|
---|
| 1735 | -}
|
---|
| 1736 | -/*}}}*/
|
---|
| 1737 | -/*FUNCTION FetchData(double* pscalar,const mxArray* dataref){{{*/
|
---|
| 1738 | -void FetchData(double* pscalar,const mxArray* dataref){
|
---|
| 1739 | -
|
---|
| 1740 | - double scalar;
|
---|
| 1741 | -
|
---|
| 1742 | - if (!mxIsClass(dataref,"double")){
|
---|
| 1743 | - _error_("input data_type is not a double!");
|
---|
| 1744 | - }
|
---|
| 1745 | - else{
|
---|
| 1746 | - /*Recover the double: */
|
---|
| 1747 | - scalar=mxGetScalar(dataref);
|
---|
| 1748 | - }
|
---|
| 1749 | -
|
---|
| 1750 | - /*Assign output pointers:*/
|
---|
| 1751 | - *pscalar=scalar;
|
---|
| 1752 | -}
|
---|
| 1753 | -/*}}}*/
|
---|
| 1754 | -/*FUNCTION FetchData(int* pinteger,const mxArray* dataref){{{*/
|
---|
| 1755 | -void FetchData(int* pinteger,const mxArray* dataref){
|
---|
| 1756 | -
|
---|
| 1757 | - int integer;
|
---|
| 1758 | -
|
---|
| 1759 | - if (!mxIsClass(dataref,"double")){
|
---|
| 1760 | - _error_("input data_type is not a scalar!");
|
---|
| 1761 | - }
|
---|
| 1762 | - else{
|
---|
| 1763 | - /*Recover the double: */
|
---|
| 1764 | - integer=(int)mxGetScalar(dataref);
|
---|
| 1765 | - }
|
---|
| 1766 | -
|
---|
| 1767 | - /*Assign output pointers:*/
|
---|
| 1768 | - *pinteger=integer;
|
---|
| 1769 | -}
|
---|
| 1770 | -/*}}}*/
|
---|
| 1771 | -/*FUNCTION FetchData(bool* pboolean,const mxArray* dataref){{{*/
|
---|
| 1772 | -void FetchData(bool* pboolean,const mxArray* dataref){
|
---|
| 1773 | -
|
---|
| 1774 | - bool* mxbool_ptr=NULL;
|
---|
| 1775 | -
|
---|
| 1776 | - if (mxIsClass(dataref,"logical")){
|
---|
| 1777 | - if(mxGetM(dataref)!=1) _error_("input data is not of size 1x1");
|
---|
| 1778 | - if(mxGetN(dataref)!=1) _error_("input data is not of size 1x1");
|
---|
| 1779 | - mxbool_ptr=mxGetLogicals(dataref);
|
---|
| 1780 | - }
|
---|
| 1781 | - else{
|
---|
| 1782 | - _error_("input data_type is not a bool!");
|
---|
| 1783 | - }
|
---|
| 1784 | -
|
---|
| 1785 | - *pboolean=*mxbool_ptr;
|
---|
| 1786 | -}
|
---|
| 1787 | -/*}}}*/
|
---|
| 1788 | -
|
---|
| 1789 | -/*ISSM objects*/
|
---|
| 1790 | -/*FUNCTION FetchData(Matrix<double>** pmatrix,const mxArray* dataref){{{*/
|
---|
| 1791 | -void FetchData(Matrix<double>** pmatrix,const mxArray* dataref){
|
---|
| 1792 | -
|
---|
| 1793 | - Matrix<double>* outmatrix=NULL;
|
---|
| 1794 | - int dummy=0;
|
---|
| 1795 | -
|
---|
| 1796 | - if (mxIsClass(dataref,"double") ){
|
---|
| 1797 | -
|
---|
| 1798 | - /*Convert matlab matrix to matrix: */
|
---|
| 1799 | - outmatrix=MatlabMatrixToMatrix(dataref);
|
---|
| 1800 | -
|
---|
| 1801 | - }
|
---|
| 1802 | - else{
|
---|
| 1803 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1804 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1805 | - }
|
---|
| 1806 | -
|
---|
| 1807 | - /*Assign output pointers:*/
|
---|
| 1808 | - *pmatrix=outmatrix;
|
---|
| 1809 | -}
|
---|
| 1810 | -/*}}}*/
|
---|
| 1811 | -/*FUNCTION FetchData(Vector<double>** pvector,const mxArray* dataref){{{*/
|
---|
| 1812 | -void FetchData(Vector<double>** pvector,const mxArray* dataref){
|
---|
| 1813 | -
|
---|
| 1814 | - Vector<double>* vector=NULL;
|
---|
| 1815 | - int dummy;
|
---|
| 1816 | -
|
---|
| 1817 | - if(mxIsEmpty(dataref)){
|
---|
| 1818 | - /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 1819 | - vector=new Vector<double>(0);
|
---|
| 1820 | - }
|
---|
| 1821 | - else if (mxIsClass(dataref,"double") ){
|
---|
| 1822 | -
|
---|
| 1823 | - /*Convert matlab vector to petsc vector: */
|
---|
| 1824 | - vector=MatlabVectorToVector(dataref);
|
---|
| 1825 | - }
|
---|
| 1826 | - else{
|
---|
| 1827 | - /*This is an error: we don't have the correct input!: */
|
---|
| 1828 | - _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 1829 | - }
|
---|
| 1830 | -
|
---|
| 1831 | - /*Assign output pointers:*/
|
---|
| 1832 | - *pvector=vector;
|
---|
| 1833 | -}
|
---|
| 1834 | -/*}}}*/
|
---|
| 1835 | -/*FUNCTION FetchData(BamgGeom** pbamggeom,const mxArray* dataref){{{*/
|
---|
| 1836 | -void FetchData(BamgGeom** pbamggeom,const mxArray* dataref){
|
---|
| 1837 | -
|
---|
| 1838 | - /*Initialize output*/
|
---|
| 1839 | - BamgGeom* bamggeom=new BamgGeom();
|
---|
| 1840 | -
|
---|
| 1841 | - /*Fetch all fields*/
|
---|
| 1842 | - FetchData(&bamggeom->Vertices,&bamggeom->VerticesSize[0],&bamggeom->VerticesSize[1],mxGetAssignedField(dataref,0,"Vertices"));
|
---|
| 1843 | - FetchData(&bamggeom->Edges, &bamggeom->EdgesSize[0], &bamggeom->EdgesSize[1], mxGetAssignedField(dataref,0,"Edges"));
|
---|
| 1844 | - FetchData(&bamggeom->Corners, &bamggeom->CornersSize[0], &bamggeom->CornersSize[1], mxGetAssignedField(dataref,0,"Corners"));
|
---|
| 1845 | - FetchData(&bamggeom->RequiredVertices,&bamggeom->RequiredVerticesSize[0],&bamggeom->RequiredVerticesSize[1],mxGetAssignedField(dataref,0,"RequiredVertices"));
|
---|
| 1846 | - FetchData(&bamggeom->RequiredEdges, &bamggeom->RequiredEdgesSize[0], &bamggeom->RequiredEdgesSize[1], mxGetAssignedField(dataref,0,"RequiredEdges"));
|
---|
| 1847 | - FetchData(&bamggeom->CrackedEdges,&bamggeom->CrackedEdgesSize[0],&bamggeom->CrackedEdgesSize[1],mxGetAssignedField(dataref,0,"CrackedEdges"));
|
---|
| 1848 | - FetchData(&bamggeom->SubDomains,&bamggeom->SubDomainsSize[0],&bamggeom->SubDomainsSize[1],mxGetAssignedField(dataref,0,"SubDomains"));
|
---|
| 1849 | -
|
---|
| 1850 | - /*Assign output pointers:*/
|
---|
| 1851 | - *pbamggeom=bamggeom;
|
---|
| 1852 | -}
|
---|
| 1853 | -/*}}}*/
|
---|
| 1854 | -/*FUNCTION FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){{{*/
|
---|
| 1855 | -void FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){
|
---|
| 1856 | -
|
---|
| 1857 | - /*Initialize output*/
|
---|
| 1858 | - BamgMesh* bamgmesh=new BamgMesh();
|
---|
| 1859 | -
|
---|
| 1860 | - /*Fetch all fields*/
|
---|
| 1861 | - FetchData(&bamgmesh->Vertices,&bamgmesh->VerticesSize[0],&bamgmesh->VerticesSize[1],mxGetAssignedField(dataref,0,"Vertices"));
|
---|
| 1862 | - FetchData(&bamgmesh->Edges, &bamgmesh->EdgesSize[0], &bamgmesh->EdgesSize[1], mxGetAssignedField(dataref,0,"Edges"));
|
---|
| 1863 | - FetchData(&bamgmesh->Triangles, &bamgmesh->TrianglesSize[0], &bamgmesh->TrianglesSize[1], mxGetAssignedField(dataref,0,"Triangles"));
|
---|
| 1864 | - FetchData(&bamgmesh->CrackedEdges,&bamgmesh->CrackedEdgesSize[0],&bamgmesh->CrackedEdgesSize[1],mxGetAssignedField(dataref,0,"CrackedEdges"));
|
---|
| 1865 | - FetchData(&bamgmesh->VerticesOnGeomEdge,&bamgmesh->VerticesOnGeomEdgeSize[0],&bamgmesh->VerticesOnGeomEdgeSize[1],mxGetAssignedField(dataref,0,"VerticesOnGeomEdge"));
|
---|
| 1866 | - FetchData(&bamgmesh->VerticesOnGeomVertex,&bamgmesh->VerticesOnGeomVertexSize[0],&bamgmesh->VerticesOnGeomVertexSize[1],mxGetAssignedField(dataref,0,"VerticesOnGeomVertex"));
|
---|
| 1867 | - FetchData(&bamgmesh->EdgesOnGeomEdge, &bamgmesh->EdgesOnGeomEdgeSize[0], &bamgmesh->EdgesOnGeomEdgeSize[1], mxGetAssignedField(dataref,0,"EdgesOnGeomEdge"));
|
---|
| 1868 | - FetchData(&bamgmesh->IssmSegments,&bamgmesh->IssmSegmentsSize[0],&bamgmesh->IssmSegmentsSize[1],mxGetAssignedField(dataref,0,"IssmSegments"));
|
---|
| 1869 | -
|
---|
| 1870 | - /*Assign output pointers:*/
|
---|
| 1871 | - *pbamgmesh=bamgmesh;
|
---|
| 1872 | -}
|
---|
| 1873 | -/*}}}*/
|
---|
| 1874 | -/*FUNCTION FetchData(BamgOpts** pbamgopts,const mxArray* dataref){{{*/
|
---|
| 1875 | -void FetchData(BamgOpts** pbamgopts,const mxArray* dataref){
|
---|
| 1876 | -
|
---|
| 1877 | - /*Initialize output*/
|
---|
| 1878 | - BamgOpts* bamgopts=new BamgOpts();
|
---|
| 1879 | -
|
---|
| 1880 | - /*Fetch all fields*/
|
---|
| 1881 | - FetchData(&bamgopts->anisomax,mxGetField(dataref,0,"anisomax"));
|
---|
| 1882 | - FetchData(&bamgopts->cutoff,mxGetField(dataref,0,"cutoff"));
|
---|
| 1883 | - FetchData(&bamgopts->coeff,mxGetField(dataref,0,"coeff"));
|
---|
| 1884 | - FetchData(&bamgopts->errg,mxGetField(dataref,0,"errg"));
|
---|
| 1885 | - FetchData(&bamgopts->gradation,mxGetField(dataref,0,"gradation"));
|
---|
| 1886 | - FetchData(&bamgopts->Hessiantype,mxGetField(dataref,0,"Hessiantype"));
|
---|
| 1887 | - FetchData(&bamgopts->MaxCornerAngle,mxGetField(dataref,0,"MaxCornerAngle"));
|
---|
| 1888 | - FetchData(&bamgopts->maxnbv,mxGetField(dataref,0,"maxnbv"));
|
---|
| 1889 | - FetchData(&bamgopts->maxsubdiv,mxGetField(dataref,0,"maxsubdiv"));
|
---|
| 1890 | - FetchData(&bamgopts->Metrictype,mxGetField(dataref,0,"Metrictype"));
|
---|
| 1891 | - FetchData(&bamgopts->nbjacobi,mxGetField(dataref,0,"nbjacobi"));
|
---|
| 1892 | - FetchData(&bamgopts->nbsmooth,mxGetField(dataref,0,"nbsmooth"));
|
---|
| 1893 | - FetchData(&bamgopts->omega,mxGetField(dataref,0,"omega"));
|
---|
| 1894 | - FetchData(&bamgopts->power,mxGetField(dataref,0,"power"));
|
---|
| 1895 | - FetchData(&bamgopts->verbose,mxGetField(dataref,0,"verbose"));
|
---|
| 1896 | -
|
---|
| 1897 | - FetchData(&bamgopts->Crack,mxGetField(dataref,0,"Crack"));
|
---|
| 1898 | - FetchData(&bamgopts->geometricalmetric,mxGetField(dataref,0,"geometricalmetric"));
|
---|
| 1899 | - FetchData(&bamgopts->KeepVertices,mxGetField(dataref,0,"KeepVertices"));
|
---|
| 1900 | - FetchData(&bamgopts->splitcorners,mxGetField(dataref,0,"splitcorners"));
|
---|
| 1901 | -
|
---|
| 1902 | - FetchData(&bamgopts->hmin,mxGetField(dataref,0,"hmin"));
|
---|
| 1903 | - FetchData(&bamgopts->hmax,mxGetField(dataref,0,"hmax"));
|
---|
| 1904 | - FetchData(&bamgopts->hminVertices,&bamgopts->hminVerticesSize[0],&bamgopts->hminVerticesSize[1],mxGetField(dataref,0,"hminVertices"));
|
---|
| 1905 | - FetchData(&bamgopts->hmaxVertices,&bamgopts->hmaxVerticesSize[0],&bamgopts->hmaxVerticesSize[1],mxGetField(dataref,0,"hmaxVertices"));
|
---|
| 1906 | - FetchData(&bamgopts->hVertices,&bamgopts->hVerticesSize[0],&bamgopts->hVerticesSize[1],mxGetField(dataref,0,"hVertices"));
|
---|
| 1907 | - FetchData(&bamgopts->metric,&bamgopts->metricSize[0],&bamgopts->metricSize[1],mxGetField(dataref,0,"metric"));
|
---|
| 1908 | - FetchData(&bamgopts->field,&bamgopts->fieldSize[0],&bamgopts->fieldSize[1],mxGetField(dataref,0,"field"));
|
---|
| 1909 | - FetchData(&bamgopts->err,&bamgopts->errSize[0],&bamgopts->errSize[1],mxGetField(dataref,0,"err"));
|
---|
| 1910 | -
|
---|
| 1911 | - /*Additional checks*/
|
---|
| 1912 | - bamgopts->Check();
|
---|
| 1913 | -
|
---|
| 1914 | - /*Assign output pointers:*/
|
---|
| 1915 | - *pbamgopts=bamgopts;
|
---|
| 1916 | -}
|
---|
| 1917 | -/*}}}*/
|
---|
| 1918 | -/*FUNCTION FetchData(Options** poptions,const mxArray** pdataref){{{*/
|
---|
| 1919 | -void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref){
|
---|
| 1920 | -
|
---|
| 1921 | - char *name = NULL;
|
---|
| 1922 | - Option *option = NULL;
|
---|
| 1923 | -
|
---|
| 1924 | - /*Initialize output*/
|
---|
| 1925 | - Options* options=new Options();
|
---|
| 1926 | -
|
---|
| 1927 | - /*Fetch all options*/
|
---|
| 1928 | - for (int i=istart; i<nrhs; i=i+2){
|
---|
| 1929 | - if (!mxIsClass(pdataref[i],"char")) _error_("Argument " << i+1 << " must be name of option");
|
---|
| 1930 | -
|
---|
| 1931 | - FetchData(&name,pdataref[i]);
|
---|
| 1932 | - if(i+1 == nrhs) _error_("Argument " << i+2 << " must exist and be value of option \"" << name << "\".");
|
---|
| 1933 | -
|
---|
| 1934 | - option=(Option*)OptionParse(name,&pdataref[i+1]);
|
---|
| 1935 | - options->AddOption(option);
|
---|
| 1936 | - option=NULL;
|
---|
| 1937 | - }
|
---|
| 1938 | -
|
---|
| 1939 | - /*Assign output pointers:*/
|
---|
| 1940 | - *poptions=options;
|
---|
| 1941 | -}
|
---|
| 1942 | -/*}}}*/
|
---|
| 1943 | -/*FUNCTION FetchData(DataSet** pcontours,const mxArray* dataref){{{*/
|
---|
| 1944 | -void FetchData(DataSet** pcontours,const mxArray* dataref){
|
---|
| 1945 | -
|
---|
| 1946 | - int numcontours,index,test1,test2;
|
---|
| 1947 | - char *contourname = NULL;
|
---|
| 1948 | - DataSet *contours = NULL;
|
---|
| 1949 | - Contour<double> *contouri = NULL;
|
---|
| 1950 | -
|
---|
| 1951 | - if (mxIsClass(dataref,"char")){
|
---|
| 1952 | - FetchData(&contourname,dataref);
|
---|
| 1953 | - contours=DomainOutlineRead<double>(contourname);
|
---|
| 1954 | - }
|
---|
| 1955 | - else if(mxIsClass(dataref,"struct")){
|
---|
| 1956 | -
|
---|
| 1957 | - contours=new DataSet(0);
|
---|
| 1958 | - numcontours=mxGetNumberOfElements(dataref);
|
---|
| 1959 | -
|
---|
| 1960 | - for(int i=0;i<numcontours;i++){
|
---|
| 1961 | -
|
---|
| 1962 | - contouri=xNew<Contour<double> >(1);
|
---|
| 1963 | -
|
---|
| 1964 | - index = mxGetFieldNumber(dataref,"nods");
|
---|
| 1965 | - if(index==-1) _error_("input structure does not have a 'nods' field");
|
---|
| 1966 | - FetchData(&contouri->nods,mxGetFieldByNumber(dataref,i,index));
|
---|
| 1967 | -
|
---|
| 1968 | - index = mxGetFieldNumber(dataref,"x");
|
---|
| 1969 | - if(index==-1) _error_("input structure does not have a 'x' field");
|
---|
| 1970 | - FetchData(&contouri->x,&test1,&test2,mxGetFieldByNumber(dataref,i,index));
|
---|
| 1971 | - if(test1!=contouri->nods || test2!=1) _error_("field x should be of size ["<<contouri->nods<<" 1]");
|
---|
| 1972 | -
|
---|
| 1973 | - index = mxGetFieldNumber(dataref,"y");
|
---|
| 1974 | - if(index==-1) _error_("input structure does not have a 'y' field");
|
---|
| 1975 | - FetchData(&contouri->y,&test1,&test2,mxGetFieldByNumber(dataref,i,index));
|
---|
| 1976 | - if(test1!=contouri->nods || test2!=1) _error_("field y should be of size ["<<contouri->nods<<" 1]");
|
---|
| 1977 | -
|
---|
| 1978 | - contours->AddObject(contouri);
|
---|
| 1979 | - }
|
---|
| 1980 | - }
|
---|
| 1981 | - else{
|
---|
| 1982 | - _error_("Contour is neither a string nor a structure and cannot be loaded ("<<mxGetClassName(dataref)<<" not supported)");
|
---|
| 1983 | - }
|
---|
| 1984 | -
|
---|
| 1985 | - /*clean-up and assign output pointer*/
|
---|
| 1986 | - xDelete<char>(contourname);
|
---|
| 1987 | - *pcontours=contours;
|
---|
| 1988 | -}
|
---|
| 1989 | -/*}}}*/
|
---|
| 1990 | Index: ../trunk-jpl/src/c/matlab/io/CheckNumMatlabArguments.cpp
|
---|
| 1991 | ===================================================================
|
---|
| 1992 | --- ../trunk-jpl/src/c/matlab/io/CheckNumMatlabArguments.cpp (revision 13748)
|
---|
| 1993 | +++ ../trunk-jpl/src/c/matlab/io/CheckNumMatlabArguments.cpp (revision 13749)
|
---|
| 1994 | @@ -1,30 +0,0 @@
|
---|
| 1995 | -/*!\file CheckNumMatlabArguments.cpp:
|
---|
| 1996 | - * \brief: check number of arguments and report an usage error message.
|
---|
| 1997 | - */
|
---|
| 1998 | -
|
---|
| 1999 | -#ifdef HAVE_CONFIG_H
|
---|
| 2000 | - #include <config.h>
|
---|
| 2001 | -#else
|
---|
| 2002 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 2003 | -#endif
|
---|
| 2004 | -
|
---|
| 2005 | -#include "../../shared/Exceptions/exceptions.h"
|
---|
| 2006 | -#include "../../include/include.h"
|
---|
| 2007 | -#include "mex.h"
|
---|
| 2008 | -
|
---|
| 2009 | -int CheckNumMatlabArguments(int nlhs,int NLHS, int nrhs,int NRHS, const char* __FUNCT__, void (*function)( void )){
|
---|
| 2010 | -
|
---|
| 2011 | - /*checks on arguments on the matlab side: */
|
---|
| 2012 | - if (nrhs==0 && nlhs==0) {
|
---|
| 2013 | - /*unless NLHS=0 and NRHS=0, we are just asking for documentation: */
|
---|
| 2014 | - if (NRHS==0 && NLHS==0)return 1;
|
---|
| 2015 | - /* special case: */
|
---|
| 2016 | - function();
|
---|
| 2017 | - _error_("usage: see above");
|
---|
| 2018 | - }
|
---|
| 2019 | - else if (nlhs!=NLHS || nrhs!=NRHS ) {
|
---|
| 2020 | - function();
|
---|
| 2021 | - _error_("usage error.");
|
---|
| 2022 | - }
|
---|
| 2023 | - return 1;
|
---|
| 2024 | -}
|
---|
| 2025 | Index: ../trunk-jpl/src/c/matlab/io/WriteMatlabData.cpp
|
---|
| 2026 | ===================================================================
|
---|
| 2027 | --- ../trunk-jpl/src/c/matlab/io/WriteMatlabData.cpp (revision 13748)
|
---|
| 2028 | +++ ../trunk-jpl/src/c/matlab/io/WriteMatlabData.cpp (revision 13749)
|
---|
| 2029 | @@ -1,390 +0,0 @@
|
---|
| 2030 | -/* \file WriteData.c:
|
---|
| 2031 | - * \brief: general interface for writing data
|
---|
| 2032 | - */
|
---|
| 2033 | -
|
---|
| 2034 | -#ifdef HAVE_CONFIG_H
|
---|
| 2035 | - #include <config.h>
|
---|
| 2036 | -#else
|
---|
| 2037 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 2038 | -#endif
|
---|
| 2039 | -
|
---|
| 2040 | -#include <mex.h>
|
---|
| 2041 | -#include "../../include/include.h"
|
---|
| 2042 | -#include "../../shared/shared.h"
|
---|
| 2043 | -#include "./matlabio.h"
|
---|
| 2044 | -
|
---|
| 2045 | -/*Primitive data types*/
|
---|
| 2046 | -/*FUNCTION WriteData(mxArray** pdataref,double* matrix, int M,int N){{{*/
|
---|
| 2047 | -void WriteData(mxArray** pdataref,double* matrix, int M,int N){
|
---|
| 2048 | -
|
---|
| 2049 | - mxArray *dataref = NULL;
|
---|
| 2050 | - double *tmatrix = NULL;
|
---|
| 2051 | -
|
---|
| 2052 | - if(matrix){
|
---|
| 2053 | - /*create the matlab matrixwith Matlab's memory manager */
|
---|
| 2054 | - tmatrix=(double*)mxMalloc(M*N*sizeof(double));
|
---|
| 2055 | - for(int i=0;i<M;i++){
|
---|
| 2056 | - for(int j=0;j<N;j++){
|
---|
| 2057 | - tmatrix[j*M+i]=matrix[i*N+j];
|
---|
| 2058 | - }
|
---|
| 2059 | - }
|
---|
| 2060 | - dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 2061 | - mxSetM(dataref,(mwSize)M);
|
---|
| 2062 | - mxSetN(dataref,(mwSize)N);
|
---|
| 2063 | - mxSetPr(dataref,(double*)tmatrix);
|
---|
| 2064 | - }
|
---|
| 2065 | - else{
|
---|
| 2066 | - dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 2067 | - }
|
---|
| 2068 | - *pdataref=dataref;
|
---|
| 2069 | -}
|
---|
| 2070 | -/*}}}*/
|
---|
| 2071 | -/*FUNCTION WriteData(mxArray** pdataref,int* matrix, int M,int N){{{*/
|
---|
| 2072 | -void WriteData(mxArray** pdataref,int* matrix, int M,int N){
|
---|
| 2073 | -
|
---|
| 2074 | - mxArray* dataref = NULL;
|
---|
| 2075 | - double* tmatrix = NULL;
|
---|
| 2076 | -
|
---|
| 2077 | - if(matrix){
|
---|
| 2078 | - /*convert to double matrix using Matlab's memory manager*/
|
---|
| 2079 | - double* tmatrix=(double*)mxMalloc(M*N*sizeof(double));
|
---|
| 2080 | - for(int i=0;i<M;i++){
|
---|
| 2081 | - for(int j=0;j<N;j++){
|
---|
| 2082 | - tmatrix[j*M+i]=(double)matrix[i*N+j];
|
---|
| 2083 | - }
|
---|
| 2084 | - }
|
---|
| 2085 | - dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 2086 | - mxSetM(dataref,(mwSize)M);
|
---|
| 2087 | - mxSetN(dataref,(mwSize)N);
|
---|
| 2088 | - mxSetPr(dataref,(double*)tmatrix);
|
---|
| 2089 | - }
|
---|
| 2090 | - else{
|
---|
| 2091 | - dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 2092 | - }
|
---|
| 2093 | - *pdataref=dataref;
|
---|
| 2094 | -}
|
---|
| 2095 | -/*}}}*/
|
---|
| 2096 | -/*FUNCTION WriteData(mxArray** pdataref,double* vector, int M){{{*/
|
---|
| 2097 | -void WriteData(mxArray** pdataref,double* vector, int M){
|
---|
| 2098 | -
|
---|
| 2099 | - mxArray* dataref = NULL;
|
---|
| 2100 | - double* vector_matlab = NULL;
|
---|
| 2101 | -
|
---|
| 2102 | - if(vector){
|
---|
| 2103 | -
|
---|
| 2104 | - /*create the matlab vector with Matlab's memory manager */
|
---|
| 2105 | - vector_matlab=(double*)mxMalloc(M*sizeof(double));
|
---|
| 2106 | - for(int i=0;i<M;i++) vector_matlab[i]=vector[i];
|
---|
| 2107 | - dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 2108 | - mxSetM(dataref,(mwSize)M);
|
---|
| 2109 | - mxSetN(dataref,(mwSize)1);
|
---|
| 2110 | - mxSetPr(dataref,vector_matlab);
|
---|
| 2111 | - }
|
---|
| 2112 | - else{
|
---|
| 2113 | - dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 2114 | - }
|
---|
| 2115 | -
|
---|
| 2116 | - *pdataref=dataref;
|
---|
| 2117 | -}
|
---|
| 2118 | -/*}}}*/
|
---|
| 2119 | -/*FUNCTION WriteData(mxArray** pdataref,double scalar){{{*/
|
---|
| 2120 | -void WriteData(mxArray** pdataref,double scalar){
|
---|
| 2121 | -
|
---|
| 2122 | - *pdataref=mxCreateDoubleScalar(scalar);
|
---|
| 2123 | -}
|
---|
| 2124 | -/*}}}*/
|
---|
| 2125 | -/*FUNCTION WriteData(mxArray** pdataref,int integer){{{*/
|
---|
| 2126 | -void WriteData(mxArray** pdataref,int integer){
|
---|
| 2127 | -
|
---|
| 2128 | - *pdataref=mxCreateDoubleScalar((double)integer);
|
---|
| 2129 | -
|
---|
| 2130 | -}
|
---|
| 2131 | -/*}}}*/
|
---|
| 2132 | -/*FUNCTION WriteData(mxArray** pdataref,int boolean){{{*/
|
---|
| 2133 | -void WriteData(mxArray** pdataref,bool boolean){
|
---|
| 2134 | -
|
---|
| 2135 | - *pdataref=mxCreateDoubleScalar((double)boolean);
|
---|
| 2136 | -
|
---|
| 2137 | -}
|
---|
| 2138 | -/*}}}*/
|
---|
| 2139 | -/*FUNCTION WriteData(mxArray** pdataref,char* string){{{*/
|
---|
| 2140 | -void WriteData(mxArray** pdataref,char* string){
|
---|
| 2141 | -
|
---|
| 2142 | - *pdataref=mxCreateString(string);
|
---|
| 2143 | -}
|
---|
| 2144 | -/*}}}*/
|
---|
| 2145 | -/*FUNCTION WriteData(mxArray** pdataref){{{*/
|
---|
| 2146 | -void WriteData(mxArray** pdataref){
|
---|
| 2147 | -
|
---|
| 2148 | - ;
|
---|
| 2149 | -
|
---|
| 2150 | -}
|
---|
| 2151 | -/*}}}*/
|
---|
| 2152 | -
|
---|
| 2153 | -/*ISSM objects*/
|
---|
| 2154 | -/*FUNCTION WriteData(mxArray** pdataref,BamgGeom* bamggeom){{{*/
|
---|
| 2155 | -void WriteData(mxArray** pdataref,BamgGeom* bamggeom){
|
---|
| 2156 | -
|
---|
| 2157 | - /*Intermediary*/
|
---|
| 2158 | - int i;
|
---|
| 2159 | - mxArray *dataref = NULL;
|
---|
| 2160 | - const int numfields = 8;
|
---|
| 2161 | - const char *fnames[numfields];
|
---|
| 2162 | - mwSize ndim = 2;
|
---|
| 2163 | - mwSize dimensions[2] = {1,1};
|
---|
| 2164 | -
|
---|
| 2165 | - /*Initialize field names*/
|
---|
| 2166 | - i=0;
|
---|
| 2167 | - fnames[i++] = "Vertices";
|
---|
| 2168 | - fnames[i++] = "Edges";
|
---|
| 2169 | - fnames[i++] = "TangentAtEdges";
|
---|
| 2170 | - fnames[i++] = "Corners";
|
---|
| 2171 | - fnames[i++] = "RequiredVertices";
|
---|
| 2172 | - fnames[i++] = "RequiredEdges";
|
---|
| 2173 | - fnames[i++] = "CrackedEdges";
|
---|
| 2174 | - fnames[i++] = "SubDomains";
|
---|
| 2175 | - _assert_(i==numfields);
|
---|
| 2176 | -
|
---|
| 2177 | - /*Initialize Matlab structure*/
|
---|
| 2178 | - dataref=mxCreateStructArray(ndim,dimensions,numfields,fnames);
|
---|
| 2179 | -
|
---|
| 2180 | - /*set each matlab each field*/
|
---|
| 2181 | - i=0;
|
---|
| 2182 | - i++; SetStructureField(dataref,"Vertices", bamggeom->VerticesSize[0], bamggeom->VerticesSize[1], bamggeom->Vertices);
|
---|
| 2183 | - i++; SetStructureField(dataref,"Edges", bamggeom->EdgesSize[0], bamggeom->EdgesSize[1], bamggeom->Edges);
|
---|
| 2184 | - i++; SetStructureField(dataref,"TangentAtEdges", bamggeom->TangentAtEdgesSize[0], bamggeom->TangentAtEdgesSize[1], bamggeom->TangentAtEdges);
|
---|
| 2185 | - i++; SetStructureField(dataref,"Corners", bamggeom->CornersSize[0], bamggeom->CornersSize[1], bamggeom->Corners);
|
---|
| 2186 | - i++; SetStructureField(dataref,"RequiredVertices",bamggeom->RequiredVerticesSize[0],bamggeom->RequiredVerticesSize[1],bamggeom->RequiredVertices);
|
---|
| 2187 | - i++; SetStructureField(dataref,"RequiredEdges", bamggeom->RequiredEdgesSize[0], bamggeom->RequiredEdgesSize[1], bamggeom->RequiredEdges);
|
---|
| 2188 | - i++; SetStructureField(dataref,"CrackedEdges", bamggeom->CrackedEdgesSize[0], bamggeom->CrackedEdgesSize[1], bamggeom->CrackedEdges);
|
---|
| 2189 | - i++; SetStructureField(dataref,"SubDomains", bamggeom->SubDomainsSize[0], bamggeom->SubDomainsSize[1], bamggeom->SubDomains);
|
---|
| 2190 | - _assert_(i==numfields);
|
---|
| 2191 | -
|
---|
| 2192 | - /*Assign output*/
|
---|
| 2193 | - *pdataref=dataref;
|
---|
| 2194 | -}
|
---|
| 2195 | -/*}}}*/
|
---|
| 2196 | -/*FUNCTION WriteData(mxArray** pdataref,BamgMesh* bamgmesh){{{*/
|
---|
| 2197 | -void WriteData(mxArray** pdataref,BamgMesh* bamgmesh){
|
---|
| 2198 | -
|
---|
| 2199 | - /*Intermediary*/
|
---|
| 2200 | - int i;
|
---|
| 2201 | - mxArray *dataref = NULL;
|
---|
| 2202 | - const int numfields = 16;
|
---|
| 2203 | - const char *fnames[numfields];
|
---|
| 2204 | - mwSize ndim = 2;
|
---|
| 2205 | - mwSize dimensions[2] = {1,1};
|
---|
| 2206 | -
|
---|
| 2207 | - /*Initialize field names*/
|
---|
| 2208 | - i=0;
|
---|
| 2209 | - fnames[i++] = "Vertices";
|
---|
| 2210 | - fnames[i++] = "Edges";
|
---|
| 2211 | - fnames[i++] = "Triangles";
|
---|
| 2212 | - fnames[i++] = "Quadrilaterals";
|
---|
| 2213 | - fnames[i++] = "IssmEdges";
|
---|
| 2214 | - fnames[i++] = "IssmSegments";
|
---|
| 2215 | - fnames[i++] = "VerticesOnGeomVertex";
|
---|
| 2216 | - fnames[i++] = "VerticesOnGeomEdge";
|
---|
| 2217 | - fnames[i++] = "EdgesOnGeomEdge";
|
---|
| 2218 | - fnames[i++] = "SubDomains";
|
---|
| 2219 | - fnames[i++] = "SubDomainsFromGeom";
|
---|
| 2220 | - fnames[i++] = "ElementConnectivity";
|
---|
| 2221 | - fnames[i++] = "NodalConnectivity";
|
---|
| 2222 | - fnames[i++] = "NodalElementConnectivity";
|
---|
| 2223 | - fnames[i++] = "CrackedVertices";
|
---|
| 2224 | - fnames[i++] = "CrackedEdges";
|
---|
| 2225 | - _assert_(i==numfields);
|
---|
| 2226 | -
|
---|
| 2227 | - /*Initialize Matlab structure*/
|
---|
| 2228 | - dataref=mxCreateStructArray(ndim,dimensions,numfields,fnames);
|
---|
| 2229 | -
|
---|
| 2230 | - /*set each matlab each field*/
|
---|
| 2231 | - i=0;
|
---|
| 2232 | - i++; SetStructureField(dataref,"Vertices",bamgmesh->VerticesSize[0], bamgmesh->VerticesSize[1],bamgmesh->Vertices);
|
---|
| 2233 | - i++; SetStructureField(dataref,"Edges", bamgmesh->EdgesSize[0],bamgmesh->EdgesSize[1], bamgmesh->Edges);
|
---|
| 2234 | - i++; SetStructureField(dataref,"Triangles", bamgmesh->TrianglesSize[0],bamgmesh->TrianglesSize[1], bamgmesh->Triangles);
|
---|
| 2235 | - i++; SetStructureField(dataref,"Quadrilaterals",bamgmesh->QuadrilateralsSize[0], bamgmesh->QuadrilateralsSize[1],bamgmesh->Quadrilaterals);
|
---|
| 2236 | - i++; SetStructureField(dataref,"IssmEdges", bamgmesh->IssmEdgesSize[0],bamgmesh->IssmEdgesSize[1], bamgmesh->IssmEdges);
|
---|
| 2237 | - i++; SetStructureField(dataref,"IssmSegments",bamgmesh->IssmSegmentsSize[0], bamgmesh->IssmSegmentsSize[1],bamgmesh->IssmSegments);
|
---|
| 2238 | - i++; SetStructureField(dataref,"VerticesOnGeomVertex",bamgmesh->VerticesOnGeomVertexSize[0],bamgmesh->VerticesOnGeomVertexSize[1], bamgmesh->VerticesOnGeomVertex);
|
---|
| 2239 | - i++; SetStructureField(dataref,"VerticesOnGeomEdge",bamgmesh->VerticesOnGeomEdgeSize[0],bamgmesh->VerticesOnGeomEdgeSize[1], bamgmesh->VerticesOnGeomEdge);
|
---|
| 2240 | - i++; SetStructureField(dataref,"EdgesOnGeomEdge", bamgmesh->EdgesOnGeomEdgeSize[0], bamgmesh->EdgesOnGeomEdgeSize[1],bamgmesh->EdgesOnGeomEdge);
|
---|
| 2241 | - i++; SetStructureField(dataref,"SubDomains",bamgmesh->SubDomainsSize[0], bamgmesh->SubDomainsSize[1],bamgmesh->SubDomains);
|
---|
| 2242 | - i++; SetStructureField(dataref,"SubDomainsFromGeom", bamgmesh->SubDomainsFromGeomSize[0], bamgmesh->SubDomainsFromGeomSize[1],bamgmesh->SubDomainsFromGeom);
|
---|
| 2243 | - i++; SetStructureField(dataref,"ElementConnectivity",bamgmesh->ElementConnectivitySize[0],bamgmesh->ElementConnectivitySize[1], bamgmesh->ElementConnectivity);
|
---|
| 2244 | - i++; SetStructureField(dataref,"NodalConnectivity",bamgmesh->NodalConnectivitySize[0],bamgmesh->NodalConnectivitySize[1], bamgmesh->NodalConnectivity);
|
---|
| 2245 | - i++; SetStructureField(dataref,"NodalElementConnectivity", bamgmesh->NodalElementConnectivitySize[0], bamgmesh->NodalElementConnectivitySize[1],bamgmesh->NodalElementConnectivity);
|
---|
| 2246 | - i++; SetStructureField(dataref,"CrackedVertices", bamgmesh->CrackedVerticesSize[0],bamgmesh->CrackedVerticesSize[1], bamgmesh->CrackedVertices);
|
---|
| 2247 | - i++; SetStructureField(dataref,"CrackedEdges",bamgmesh->CrackedEdgesSize[0], bamgmesh->CrackedEdgesSize[1],bamgmesh->CrackedEdges);
|
---|
| 2248 | - _assert_(i==numfields);
|
---|
| 2249 | -
|
---|
| 2250 | - /*Assign output*/
|
---|
| 2251 | - *pdataref=dataref;
|
---|
| 2252 | -}
|
---|
| 2253 | -/*}}}*/
|
---|
| 2254 | -/*FUNCTION WriteData(mxArray** pdataref,SeqMat<double>* matrix){{{*/
|
---|
| 2255 | -void WriteData(mxArray** pdataref,SeqMat<double>* matrix){
|
---|
| 2256 | -
|
---|
| 2257 | - int i,j;
|
---|
| 2258 | - int rows,cols;
|
---|
| 2259 | - mxArray *dataref = NULL;
|
---|
| 2260 | - double *matrix_ptr = NULL;
|
---|
| 2261 | - double *tmatrix_ptr = NULL;
|
---|
| 2262 | -
|
---|
| 2263 | - if(matrix){
|
---|
| 2264 | -
|
---|
| 2265 | - matrix_ptr=matrix->ToSerial();
|
---|
| 2266 | - matrix->GetSize(&rows,&cols);
|
---|
| 2267 | -
|
---|
| 2268 | - /*Now transpose the matrix and allocate with Matlab's memory manager: */
|
---|
| 2269 | - tmatrix_ptr=(double*)mxMalloc(rows*cols*sizeof(double));
|
---|
| 2270 | - for(i=0;i<rows;i++){
|
---|
| 2271 | - for(j=0;j<cols;j++){
|
---|
| 2272 | - tmatrix_ptr[j*rows+i]=matrix_ptr[i*cols+j];
|
---|
| 2273 | - }
|
---|
| 2274 | - }
|
---|
| 2275 | -
|
---|
| 2276 | - /*create matlab matrix: */
|
---|
| 2277 | - dataref=mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 2278 | - mxSetM(dataref,rows);
|
---|
| 2279 | - mxSetN(dataref,cols);
|
---|
| 2280 | - mxSetPr(dataref,tmatrix_ptr);
|
---|
| 2281 | -
|
---|
| 2282 | - /*Free ressources:*/
|
---|
| 2283 | - xDelete<double>(matrix_ptr);
|
---|
| 2284 | - }
|
---|
| 2285 | - else{
|
---|
| 2286 | - dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 2287 | - }
|
---|
| 2288 | -
|
---|
| 2289 | - *pdataref=dataref;
|
---|
| 2290 | -}
|
---|
| 2291 | -/*}}}*/
|
---|
| 2292 | -/*FUNCTION WriteData(mxArray** pdataref,SeqVec<double>* vector){{{*/
|
---|
| 2293 | -void WriteData(mxArray** pdataref,SeqVec<double>* vector){
|
---|
| 2294 | -
|
---|
| 2295 | - mxArray* dataref=NULL;
|
---|
| 2296 | - double* vector_ptr=NULL;
|
---|
| 2297 | - double* vector_matlab=NULL;
|
---|
| 2298 | - int rows;
|
---|
| 2299 | -
|
---|
| 2300 | - if(vector){
|
---|
| 2301 | - /*call toolkit routine: */
|
---|
| 2302 | - vector_ptr=vector->ToMPISerial();
|
---|
| 2303 | - vector->GetSize(&rows);
|
---|
| 2304 | -
|
---|
| 2305 | - /*now create the matlab vector with Matlab's memory manager */
|
---|
| 2306 | - vector_matlab=(double*)mxMalloc(rows*sizeof(double));
|
---|
| 2307 | - for(int i=0;i<rows;i++) vector_matlab[i]=vector_ptr[i];
|
---|
| 2308 | -
|
---|
| 2309 | - dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 2310 | - mxSetM(dataref,rows);
|
---|
| 2311 | - mxSetN(dataref,1);
|
---|
| 2312 | - mxSetPr(dataref,vector_matlab);
|
---|
| 2313 | - }
|
---|
| 2314 | - else{
|
---|
| 2315 | - dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 2316 | - }
|
---|
| 2317 | -
|
---|
| 2318 | - /*Clean-up and return*/
|
---|
| 2319 | - xDelete<double>(vector_ptr);
|
---|
| 2320 | - *pdataref=dataref;
|
---|
| 2321 | -}
|
---|
| 2322 | -/*}}}*/
|
---|
| 2323 | -/*FUNCTION WriteData(mxArray** pdataref,RiftStruct* riftstruct){{{*/
|
---|
| 2324 | -void WriteData(mxArray** pdataref,RiftStruct* riftstruct){
|
---|
| 2325 | -
|
---|
| 2326 | - /*Intermediary*/
|
---|
| 2327 | - int i;
|
---|
| 2328 | - mxArray *dataref = NULL;
|
---|
| 2329 | - const int numfields = 10;
|
---|
| 2330 | - const char *fnames[numfields];
|
---|
| 2331 | - mwSize ndim = 2;
|
---|
| 2332 | - mwSize dimensions[2] = {1,1};
|
---|
| 2333 | -
|
---|
| 2334 | - /*Initialize field names*/
|
---|
| 2335 | - i=0;
|
---|
| 2336 | - fnames[i++] = "numsegs";
|
---|
| 2337 | - fnames[i++] = "segments";
|
---|
| 2338 | - fnames[i++] = "pairs";
|
---|
| 2339 | - fnames[i++] = "tips";
|
---|
| 2340 | - fnames[i++] = "penaltypairs";
|
---|
| 2341 | - fnames[i++] = "fill";
|
---|
| 2342 | - fnames[i++] = "friction";
|
---|
| 2343 | - fnames[i++] = "fraction";
|
---|
| 2344 | - fnames[i++] = "fractionincrement";
|
---|
| 2345 | - fnames[i++] = "state";
|
---|
| 2346 | - _assert_(i==numfields);
|
---|
| 2347 | -
|
---|
| 2348 | - /*Initialize matlab structure of dimension numrifts*/
|
---|
| 2349 | - dimensions[0]=riftstruct->numrifts;
|
---|
| 2350 | - dataref=mxCreateStructArray(ndim,dimensions,numfields,fnames);
|
---|
| 2351 | -
|
---|
| 2352 | - /*set each matlab each field*/
|
---|
| 2353 | - for(int i=0;i<riftstruct->numrifts;i++){
|
---|
| 2354 | - SetStructureFieldi(dataref,i,"numsegs" ,riftstruct->riftsnumsegments[i]);
|
---|
| 2355 | - SetStructureFieldi(dataref,i,"segments" ,riftstruct->riftsnumsegments[i] ,3,riftstruct->riftssegments[i]);
|
---|
| 2356 | - SetStructureFieldi(dataref,i,"pairs" ,riftstruct->riftsnumpairs[i] ,2,riftstruct->riftspairs[i]);
|
---|
| 2357 | - SetStructureFieldi(dataref,i,"tips" ,1 ,2,&riftstruct->riftstips[2*i]);
|
---|
| 2358 | - SetStructureFieldi(dataref,i,"penaltypairs" ,riftstruct->riftsnumpenaltypairs[i],7,riftstruct->riftspenaltypairs[i]);
|
---|
| 2359 | - SetStructureFieldi(dataref,i,"fill" ,IceEnum);
|
---|
| 2360 | - SetStructureFieldi(dataref,i,"friction" ,0);
|
---|
| 2361 | - SetStructureFieldi(dataref,i,"fraction" ,0.);
|
---|
| 2362 | - SetStructureFieldi(dataref,i,"fractionincrement",0.1);
|
---|
| 2363 | - SetStructureFieldi(dataref,i,"state" ,riftstruct->riftsnumpenaltypairs[i],1,riftstruct->state[i]);
|
---|
| 2364 | - }
|
---|
| 2365 | -
|
---|
| 2366 | - /*Assign output*/
|
---|
| 2367 | - *pdataref=dataref;
|
---|
| 2368 | -}
|
---|
| 2369 | -/*}}}*/
|
---|
| 2370 | -
|
---|
| 2371 | -/*Toolkit*/
|
---|
| 2372 | -/*FUNCTION SetStructureField{{{*/
|
---|
| 2373 | -void SetStructureField(mxArray* dataref,const char* fieldname,int M,int N,double* fieldpointer){
|
---|
| 2374 | -
|
---|
| 2375 | - mxArray* field = NULL;
|
---|
| 2376 | -
|
---|
| 2377 | - /*Convert field*/
|
---|
| 2378 | - WriteData(&field,fieldpointer,M,N);
|
---|
| 2379 | -
|
---|
| 2380 | - /*Assign to structure*/
|
---|
| 2381 | - mxSetField(dataref,0,fieldname,field);
|
---|
| 2382 | -}
|
---|
| 2383 | -/*}}}*/
|
---|
| 2384 | -/*FUNCTION SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int M,int N,double* fieldpointer){{{*/
|
---|
| 2385 | -void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int M,int N,double* fieldpointer){
|
---|
| 2386 | -
|
---|
| 2387 | - mxArray* field = NULL;
|
---|
| 2388 | -
|
---|
| 2389 | - /*Convert field*/
|
---|
| 2390 | - WriteData(&field,fieldpointer,M,N);
|
---|
| 2391 | -
|
---|
| 2392 | - /*Assign to structure*/
|
---|
| 2393 | - mxSetField(dataref,i,fieldname,field);
|
---|
| 2394 | -}
|
---|
| 2395 | -/*}}}*/
|
---|
| 2396 | -/*FUNCTION SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int field){{{*/
|
---|
| 2397 | -void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int fieldin){
|
---|
| 2398 | -
|
---|
| 2399 | - mxArray* field = NULL;
|
---|
| 2400 | -
|
---|
| 2401 | - /*Convert field*/
|
---|
| 2402 | - WriteData(&field,fieldin);
|
---|
| 2403 | -
|
---|
| 2404 | - /*Assign to structure*/
|
---|
| 2405 | - mxSetField(dataref,i,fieldname,field);
|
---|
| 2406 | -}
|
---|
| 2407 | -/*}}}*/
|
---|
| 2408 | -/*FUNCTION SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,double field){{{*/
|
---|
| 2409 | -void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,double fieldin){
|
---|
| 2410 | -
|
---|
| 2411 | - mxArray* field = NULL;
|
---|
| 2412 | -
|
---|
| 2413 | - /*Convert field*/
|
---|
| 2414 | - WriteData(&field,fieldin);
|
---|
| 2415 | -
|
---|
| 2416 | - /*Assign to structure*/
|
---|
| 2417 | - mxSetField(dataref,i,fieldname,field);
|
---|
| 2418 | -}
|
---|
| 2419 | -/*}}}*/
|
---|
| 2420 | Index: ../trunk-jpl/src/c/matlab/io/mxGetAssignedField.cpp
|
---|
| 2421 | ===================================================================
|
---|
| 2422 | --- ../trunk-jpl/src/c/matlab/io/mxGetAssignedField.cpp (revision 13748)
|
---|
| 2423 | +++ ../trunk-jpl/src/c/matlab/io/mxGetAssignedField.cpp (revision 13749)
|
---|
| 2424 | @@ -1,45 +0,0 @@
|
---|
| 2425 | -/*!\file: mxGetAssignedField.c:
|
---|
| 2426 | - * \brief: abstract interface on parallel side for i/o, so it ressembles the serial i/o.
|
---|
| 2427 | - *
|
---|
| 2428 | - * In serial mode, this routine takes care of returning the field coming
|
---|
| 2429 | - * from the model. If largesize is 1, we are running out of core models in
|
---|
| 2430 | - * matlab, and we need to call the subsref private method from the model object
|
---|
| 2431 | - * in order to correctly load the data from disk.
|
---|
| 2432 | - */
|
---|
| 2433 | -
|
---|
| 2434 | -#ifdef HAVE_CONFIG_H
|
---|
| 2435 | -#include <config.h>
|
---|
| 2436 | -#else
|
---|
| 2437 | -#error "Cannot compile without HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 2438 | -#endif
|
---|
| 2439 | -
|
---|
| 2440 | -#include "mex.h"
|
---|
| 2441 | -
|
---|
| 2442 | -mxArray* mxGetAssignedField(const mxArray* pmxa_array,int number,const char* field){
|
---|
| 2443 | -
|
---|
| 2444 | - //output
|
---|
| 2445 | - mxArray* mxfield=NULL;
|
---|
| 2446 | -
|
---|
| 2447 | - //input
|
---|
| 2448 | - mxArray *inputs[2];
|
---|
| 2449 | - mxArray *pindex = NULL;
|
---|
| 2450 | - const char *fnames[2];
|
---|
| 2451 | - mwSize ndim = 2;
|
---|
| 2452 | - mwSize onebyone[2] = {1,1};
|
---|
| 2453 | -
|
---|
| 2454 | - //We want to call the subsasgn method, and get the returned array.This ensures that if we are running
|
---|
| 2455 | - //large sized problems, the data is truly loaded from disk by the model subsasgn class method.
|
---|
| 2456 | - inputs[0]=(mxArray*)pmxa_array; //this is the model
|
---|
| 2457 | -
|
---|
| 2458 | - //create index structure used in the assignment (index.type='.' and index.subs='x' for field x for ex)
|
---|
| 2459 | - fnames[0] = "type";
|
---|
| 2460 | - fnames[1] = "subs";
|
---|
| 2461 | - pindex=mxCreateStructArray( ndim,onebyone,2,fnames);
|
---|
| 2462 | - mxSetField( pindex, 0, "type",mxCreateString("."));
|
---|
| 2463 | - mxSetField( pindex, 0, "subs",mxCreateString(field));
|
---|
| 2464 | - inputs[1]=pindex;
|
---|
| 2465 | -
|
---|
| 2466 | - mexCallMATLAB( 1, &mxfield, 2, (mxArray**)inputs, "subsref");
|
---|
| 2467 | -
|
---|
| 2468 | - return mxfield;
|
---|
| 2469 | -}
|
---|
| 2470 | Index: ../trunk-jpl/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp
|
---|
| 2471 | ===================================================================
|
---|
| 2472 | --- ../trunk-jpl/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp (revision 13748)
|
---|
| 2473 | +++ ../trunk-jpl/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp (revision 13749)
|
---|
| 2474 | @@ -1,130 +0,0 @@
|
---|
| 2475 | -/* \file MatlabMatrixToDoubleMatrix.cpp
|
---|
| 2476 | - * \brief: convert a sparse or dense matlab matrix to a double* pointer
|
---|
| 2477 | - */
|
---|
| 2478 | -
|
---|
| 2479 | -#ifdef HAVE_CONFIG_H
|
---|
| 2480 | - #include <config.h>
|
---|
| 2481 | -#else
|
---|
| 2482 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 2483 | -#endif
|
---|
| 2484 | -
|
---|
| 2485 | -/*Matlab includes: */
|
---|
| 2486 | -#include "mex.h"
|
---|
| 2487 | -#include "../../shared/shared.h"
|
---|
| 2488 | -
|
---|
| 2489 | -int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
|
---|
| 2490 | -
|
---|
| 2491 | - int i,j,count,rows,cols;
|
---|
| 2492 | -
|
---|
| 2493 | - /*output: */
|
---|
| 2494 | - double* matrix=NULL;
|
---|
| 2495 | -
|
---|
| 2496 | - /*matlab indices: */
|
---|
| 2497 | - mwIndex* ir=NULL;
|
---|
| 2498 | - mwIndex* jc=NULL;
|
---|
| 2499 | -
|
---|
| 2500 | - /*Ok, first check if we are dealing with a sparse or full matrix: */
|
---|
| 2501 | - if (mxIsSparse(mxmatrix)){
|
---|
| 2502 | -
|
---|
| 2503 | - /*Dealing with sparse matrix: recover size first: */
|
---|
| 2504 | - double* pmxmatrix=(double*)mxGetPr(mxmatrix);
|
---|
| 2505 | - rows=mxGetM(mxmatrix);
|
---|
| 2506 | - cols=mxGetN(mxmatrix);
|
---|
| 2507 | -
|
---|
| 2508 | - if(rows*cols){
|
---|
| 2509 | - matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 2510 | -
|
---|
| 2511 | - /*Now, get ir,jc and pr: */
|
---|
| 2512 | - ir=mxGetIr(mxmatrix);
|
---|
| 2513 | - jc=mxGetJc(mxmatrix);
|
---|
| 2514 | -
|
---|
| 2515 | - /*Now, start inserting data into double* matrix: */
|
---|
| 2516 | - count=0;
|
---|
| 2517 | - for(i=0;i<cols;i++){
|
---|
| 2518 | - for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 2519 | - matrix[rows*ir[count]+i]=pmxmatrix[count];
|
---|
| 2520 | - count++;
|
---|
| 2521 | - }
|
---|
| 2522 | - }
|
---|
| 2523 | - }
|
---|
| 2524 | -
|
---|
| 2525 | - }
|
---|
| 2526 | - else if(mxIsClass(mxmatrix,"double")){
|
---|
| 2527 | - /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 2528 | - double* pmxmatrix=(double*)mxGetPr(mxmatrix);
|
---|
| 2529 | - rows=mxGetM(mxmatrix);
|
---|
| 2530 | - cols=mxGetN(mxmatrix);
|
---|
| 2531 | -
|
---|
| 2532 | - /*Create serial matrix: */
|
---|
| 2533 | - if(rows*cols){
|
---|
| 2534 | - matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 2535 | -
|
---|
| 2536 | - for(i=0;i<rows;i++){
|
---|
| 2537 | - for(j=0;j<cols;j++){
|
---|
| 2538 | - matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
|
---|
| 2539 | - }
|
---|
| 2540 | - }
|
---|
| 2541 | - }
|
---|
| 2542 | - }
|
---|
| 2543 | - else if(mxIsClass(mxmatrix,"single")){
|
---|
| 2544 | - /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 2545 | - float *pmxmatrix=(float*)mxGetPr(mxmatrix);
|
---|
| 2546 | - rows=mxGetM(mxmatrix);
|
---|
| 2547 | - cols=mxGetN(mxmatrix);
|
---|
| 2548 | -
|
---|
| 2549 | - /*Create serial matrix: */
|
---|
| 2550 | - if(rows*cols){
|
---|
| 2551 | - matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 2552 | -
|
---|
| 2553 | - for(i=0;i<rows;i++){
|
---|
| 2554 | - for(j=0;j<cols;j++){
|
---|
| 2555 | - matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
|
---|
| 2556 | - }
|
---|
| 2557 | - }
|
---|
| 2558 | - }
|
---|
| 2559 | - }
|
---|
| 2560 | - else if(mxIsClass(mxmatrix,"int16")){
|
---|
| 2561 | - /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 2562 | - short int *pmxmatrix=(short*)mxGetPr(mxmatrix);
|
---|
| 2563 | - rows=mxGetM(mxmatrix);
|
---|
| 2564 | - cols=mxGetN(mxmatrix);
|
---|
| 2565 | -
|
---|
| 2566 | - /*Create serial matrix: */
|
---|
| 2567 | - if(rows*cols){
|
---|
| 2568 | - matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 2569 | -
|
---|
| 2570 | - for(i=0;i<rows;i++){
|
---|
| 2571 | - for(j=0;j<cols;j++){
|
---|
| 2572 | - matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
|
---|
| 2573 | - }
|
---|
| 2574 | - }
|
---|
| 2575 | - }
|
---|
| 2576 | - }
|
---|
| 2577 | - else if(mxIsClass(mxmatrix,"uint8")){
|
---|
| 2578 | - /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 2579 | - char *pmxmatrix=(char*)mxGetPr(mxmatrix);
|
---|
| 2580 | - rows=mxGetM(mxmatrix);
|
---|
| 2581 | - cols=mxGetN(mxmatrix);
|
---|
| 2582 | -
|
---|
| 2583 | - /*Create serial matrix: */
|
---|
| 2584 | - if(rows*cols){
|
---|
| 2585 | - matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 2586 | -
|
---|
| 2587 | - for(i=0;i<rows;i++){
|
---|
| 2588 | - for(j=0;j<cols;j++){
|
---|
| 2589 | - matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
|
---|
| 2590 | - }
|
---|
| 2591 | - }
|
---|
| 2592 | - }
|
---|
| 2593 | - }
|
---|
| 2594 | - else{
|
---|
| 2595 | - _error_("Matlab matrix type Not implemented yet");
|
---|
| 2596 | - }
|
---|
| 2597 | -
|
---|
| 2598 | - /*Assign output pointer: */
|
---|
| 2599 | - *pmatrix=matrix;
|
---|
| 2600 | - *pmatrix_rows=rows;
|
---|
| 2601 | - *pmatrix_cols=cols;
|
---|
| 2602 | -
|
---|
| 2603 | - return 1;
|
---|
| 2604 | -}
|
---|
| 2605 | Index: ../trunk-jpl/src/c/matlab/io/MatlabVectorToVector.cpp
|
---|
| 2606 | ===================================================================
|
---|
| 2607 | --- ../trunk-jpl/src/c/matlab/io/MatlabVectorToVector.cpp (revision 13748)
|
---|
| 2608 | +++ ../trunk-jpl/src/c/matlab/io/MatlabVectorToVector.cpp (revision 13749)
|
---|
| 2609 | @@ -1,39 +0,0 @@
|
---|
| 2610 | -/*!\file MatlabVectorToVector.cpp
|
---|
| 2611 | - */
|
---|
| 2612 | -
|
---|
| 2613 | -/*Headers:*/
|
---|
| 2614 | -/*{{{*/
|
---|
| 2615 | -#ifdef HAVE_CONFIG_H
|
---|
| 2616 | - #include <config.h>
|
---|
| 2617 | -#else
|
---|
| 2618 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 2619 | -#endif
|
---|
| 2620 | -
|
---|
| 2621 | -#include <mex.h>
|
---|
| 2622 | -#include <stdio.h>
|
---|
| 2623 | -#include <string.h>
|
---|
| 2624 | -#include "./matlabio.h"
|
---|
| 2625 | -#include "../../classes/classes.h"
|
---|
| 2626 | -#include "../../shared/shared.h"
|
---|
| 2627 | -#include "../../Container/Container.h"
|
---|
| 2628 | -#include "../../include/include.h"
|
---|
| 2629 | -#include "../../toolkits/toolkits.h"
|
---|
| 2630 | -
|
---|
| 2631 | -/*}}}*/
|
---|
| 2632 | -
|
---|
| 2633 | -Vector<double>* MatlabVectorToVector(const mxArray* mxvector){
|
---|
| 2634 | -
|
---|
| 2635 | - int dummy;
|
---|
| 2636 | - Vector<double>* vector=NULL;
|
---|
| 2637 | -
|
---|
| 2638 | - /*allocate vector object: */
|
---|
| 2639 | - vector=new Vector<double>();
|
---|
| 2640 | -
|
---|
| 2641 | - #ifdef _HAVE_PETSC_
|
---|
| 2642 | - vector->pvector=MatlabVectorToPetscVec(mxvector);
|
---|
| 2643 | - #else
|
---|
| 2644 | - vector->svector=MatlabVectorToSeqVec(mxvector);
|
---|
| 2645 | - #endif
|
---|
| 2646 | -
|
---|
| 2647 | - return vector;
|
---|
| 2648 | -}
|
---|
| 2649 | Index: ../trunk-jpl/src/c/matlab/io/MatlabMatrixToPetscMat.cpp
|
---|
| 2650 | ===================================================================
|
---|
| 2651 | --- ../trunk-jpl/src/c/matlab/io/MatlabMatrixToPetscMat.cpp (revision 13748)
|
---|
| 2652 | +++ ../trunk-jpl/src/c/matlab/io/MatlabMatrixToPetscMat.cpp (revision 13749)
|
---|
| 2653 | @@ -1,123 +0,0 @@
|
---|
| 2654 | -/* \file MatlabMatrixToPetscMatrix.cpp
|
---|
| 2655 | - * \brief: convert a sparse or dense matlab matrix to a serial Petsc matrix:
|
---|
| 2656 | - */
|
---|
| 2657 | -
|
---|
| 2658 | -#ifdef HAVE_CONFIG_H
|
---|
| 2659 | - #include <config.h>
|
---|
| 2660 | -#else
|
---|
| 2661 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 2662 | -#endif
|
---|
| 2663 | -#include "../../shared/shared.h"
|
---|
| 2664 | -
|
---|
| 2665 | -/*Petsc includes: */
|
---|
| 2666 | -#include "petscmat.h"
|
---|
| 2667 | -#include "petscvec.h"
|
---|
| 2668 | -#include "petscksp.h"
|
---|
| 2669 | -
|
---|
| 2670 | -/*Matlab includes: */
|
---|
| 2671 | -#include "mex.h"
|
---|
| 2672 | -#include "matlabio.h"
|
---|
| 2673 | -
|
---|
| 2674 | -PetscMat* MatlabMatrixToPetscMat(const mxArray* mxmatrix){
|
---|
| 2675 | -
|
---|
| 2676 | - int dummy;
|
---|
| 2677 | - PetscMat* matrix=new PetscMat();
|
---|
| 2678 | -
|
---|
| 2679 | - MatlabMatrixToPetscMat(&matrix->matrix, &dummy, &dummy, mxmatrix);
|
---|
| 2680 | -
|
---|
| 2681 | - return matrix;
|
---|
| 2682 | -}
|
---|
| 2683 | -int MatlabMatrixToPetscMat(Mat* pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
|
---|
| 2684 | -
|
---|
| 2685 | - int rows, cols;
|
---|
| 2686 | - double *mxmatrix_ptr = NULL;
|
---|
| 2687 | - double *tmatrix = NULL;
|
---|
| 2688 | - int ierr;
|
---|
| 2689 | - int i,j;
|
---|
| 2690 | -
|
---|
| 2691 | - /*output: */
|
---|
| 2692 | - Mat matrix = NULL;
|
---|
| 2693 | -
|
---|
| 2694 | - /*matlab indices: */
|
---|
| 2695 | - mwIndex *ir = NULL;
|
---|
| 2696 | - mwIndex *jc = NULL;
|
---|
| 2697 | - double *pr = NULL;
|
---|
| 2698 | - int count;
|
---|
| 2699 | - int nnz;
|
---|
| 2700 | - int nz;
|
---|
| 2701 | -
|
---|
| 2702 | - /*petsc indices: */
|
---|
| 2703 | - int *idxm = NULL;
|
---|
| 2704 | - int *idxn = NULL;
|
---|
| 2705 | -
|
---|
| 2706 | - /*Ok, first check if we are dealing with a sparse or full matrix: */
|
---|
| 2707 | - if (mxIsSparse(mxmatrix)){
|
---|
| 2708 | -
|
---|
| 2709 | - /*Dealing with sparse matrix: recover size first: */
|
---|
| 2710 | - mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
|
---|
| 2711 | - rows=mxGetM(mxmatrix);
|
---|
| 2712 | - cols=mxGetN(mxmatrix);
|
---|
| 2713 | - nnz=mxGetNzmax(mxmatrix);
|
---|
| 2714 | - if(rows){
|
---|
| 2715 | - nz=(int)((double)nnz/(double)rows);
|
---|
| 2716 | - }
|
---|
| 2717 | - else{
|
---|
| 2718 | - nz=0;
|
---|
| 2719 | - }
|
---|
| 2720 | -
|
---|
| 2721 | - ierr=MatCreateSeqAIJ(PETSC_COMM_SELF,rows,cols,nz,PETSC_NULL,&matrix);CHKERRQ(ierr);
|
---|
| 2722 | -
|
---|
| 2723 | - /*Now, get ir,jc and pr: */
|
---|
| 2724 | - pr=mxGetPr(mxmatrix);
|
---|
| 2725 | - ir=mxGetIr(mxmatrix);
|
---|
| 2726 | - jc=mxGetJc(mxmatrix);
|
---|
| 2727 | -
|
---|
| 2728 | - /*Now, start inserting data into sparse matrix: */
|
---|
| 2729 | - count=0;
|
---|
| 2730 | - for(i=0;i<cols;i++){
|
---|
| 2731 | - for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 2732 | - MatSetValue(matrix,ir[count],i,pr[count],INSERT_VALUES);
|
---|
| 2733 | - count++;
|
---|
| 2734 | - }
|
---|
| 2735 | - }
|
---|
| 2736 | - }
|
---|
| 2737 | - else{
|
---|
| 2738 | - /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 2739 | - mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
|
---|
| 2740 | - rows=mxGetM(mxmatrix);
|
---|
| 2741 | - cols=mxGetN(mxmatrix);
|
---|
| 2742 | -
|
---|
| 2743 | - /*transpose, as Petsc now does not allows MAT_COLUMN_ORIENTED matrices in MatSetValues: */
|
---|
| 2744 | - tmatrix=xNew<double>(rows*cols);
|
---|
| 2745 | - for(i=0;i<cols;i++){
|
---|
| 2746 | - for(j=0;j<rows;j++){
|
---|
| 2747 | - *(tmatrix+rows*i+j)=*(mxmatrix_ptr+cols*j+i);
|
---|
| 2748 | - }
|
---|
| 2749 | - }
|
---|
| 2750 | -
|
---|
| 2751 | - /*Create serial matrix: */
|
---|
| 2752 | - ierr=MatCreateSeqDense(PETSC_COMM_SELF,rows,cols,NULL,&matrix);CHKERRQ(ierr);
|
---|
| 2753 | -
|
---|
| 2754 | - /*Insert mxmatrix_ptr values into petsc matrix: */
|
---|
| 2755 | - idxm=xNew<int>(rows);
|
---|
| 2756 | - idxn=xNew<int>(cols);
|
---|
| 2757 | -
|
---|
| 2758 | - for(i=0;i<rows;i++)idxm[i]=i;
|
---|
| 2759 | - for(i=0;i<cols;i++)idxn[i]=i;
|
---|
| 2760 | -
|
---|
| 2761 | - ierr=MatSetValues(matrix,rows,idxm,cols,idxn,tmatrix,INSERT_VALUES); CHKERRQ(ierr);
|
---|
| 2762 | -
|
---|
| 2763 | - xDelete<double>(tmatrix);
|
---|
| 2764 | - }
|
---|
| 2765 | -
|
---|
| 2766 | - /*Assemble matrix: */
|
---|
| 2767 | - MatAssemblyBegin(matrix,MAT_FINAL_ASSEMBLY);
|
---|
| 2768 | - MatAssemblyEnd(matrix,MAT_FINAL_ASSEMBLY);
|
---|
| 2769 | -
|
---|
| 2770 | - /*Assign output pointer: */
|
---|
| 2771 | - *pmatrix=matrix;
|
---|
| 2772 | - if(pmatrix_rows) *pmatrix_rows=rows;
|
---|
| 2773 | - if(pmatrix_cols) *pmatrix_cols=cols;
|
---|
| 2774 | -
|
---|
| 2775 | - return 1;
|
---|
| 2776 | -}
|
---|
| 2777 | Index: ../trunk-jpl/src/c/matlab/io/matlabio.h
|
---|
| 2778 | ===================================================================
|
---|
| 2779 | --- ../trunk-jpl/src/c/matlab/io/matlabio.h (revision 13748)
|
---|
| 2780 | +++ ../trunk-jpl/src/c/matlab/io/matlabio.h (revision 13749)
|
---|
| 2781 | @@ -1,93 +0,0 @@
|
---|
| 2782 | -/*\file matlabio.h
|
---|
| 2783 | - *\brief: I/O for ISSM in matlab mode
|
---|
| 2784 | - */
|
---|
| 2785 | -
|
---|
| 2786 | -#ifndef _MATLAB_IO_H_
|
---|
| 2787 | -#define _MATLAB_IO_H_
|
---|
| 2788 | -
|
---|
| 2789 | -#ifdef HAVE_CONFIG_H
|
---|
| 2790 | -#include <config.h>
|
---|
| 2791 | -#else
|
---|
| 2792 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 2793 | -#endif
|
---|
| 2794 | -
|
---|
| 2795 | -#include <mex.h>
|
---|
| 2796 | -#include "../../classes/classes.h"
|
---|
| 2797 | -#include "../../Container/Container.h"
|
---|
| 2798 | -#include "../../include/include.h"
|
---|
| 2799 | -
|
---|
| 2800 | -void WriteData(mxArray** pdataref,SeqMat<double>* matrix);
|
---|
| 2801 | -void WriteData(mxArray** pdataref,double* matrix, int M,int N);
|
---|
| 2802 | -void WriteData(mxArray** pdataref,int* matrix, int M,int N);
|
---|
| 2803 | -void WriteData(mxArray** pdataref,SeqVec<double>* vector);
|
---|
| 2804 | -void WriteData(mxArray** pdataref,double* vector, int M);
|
---|
| 2805 | -void WriteData(mxArray** pdataref,int integer);
|
---|
| 2806 | -void WriteData(mxArray** pdataref,bool boolean);
|
---|
| 2807 | -void WriteData(mxArray** pdataref,double scalar);
|
---|
| 2808 | -void WriteData(mxArray** pdataref,char* string);
|
---|
| 2809 | -void WriteData(mxArray** pdataref);
|
---|
| 2810 | -void WriteData(mxArray** pdataref,BamgGeom* bamggeom);
|
---|
| 2811 | -void WriteData(mxArray** pdataref,BamgMesh* bamgmesh);
|
---|
| 2812 | -void WriteData(mxArray** pdataref,RiftStruct* riftstruct);
|
---|
| 2813 | -
|
---|
| 2814 | -void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref);
|
---|
| 2815 | -void FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
|
---|
| 2816 | -void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref);
|
---|
| 2817 | -void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref);
|
---|
| 2818 | -void FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
|
---|
| 2819 | -void FetchData(Matrix<double>** pmatrix,const mxArray* dataref);
|
---|
| 2820 | -void FetchData(int** pvector,int* pM,const mxArray* dataref);
|
---|
| 2821 | -void FetchData(float** pvector,int* pM,const mxArray* dataref);
|
---|
| 2822 | -void FetchData(double** pvector,int* pM,const mxArray* dataref);
|
---|
| 2823 | -void FetchData(bool** pvector,int* pM,const mxArray* dataref);
|
---|
| 2824 | -void FetchData(Vector<double>** pvector,const mxArray* dataref);
|
---|
| 2825 | -void FetchData(char** pstring,const mxArray* dataref);
|
---|
| 2826 | -void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
|
---|
| 2827 | -void FetchData(double* pscalar,const mxArray* dataref);
|
---|
| 2828 | -void FetchData(int* pinteger,const mxArray* dataref);
|
---|
| 2829 | -void FetchData(bool* pbool,const mxArray* dataref);
|
---|
| 2830 | -void FetchData(BamgGeom** bamggeom,const mxArray* dataref);
|
---|
| 2831 | -void FetchData(BamgMesh** bamgmesh,const mxArray* dataref);
|
---|
| 2832 | -void FetchData(BamgOpts** bamgopts,const mxArray* dataref);
|
---|
| 2833 | -void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref);
|
---|
| 2834 | -void FetchData(DataSet** pcontours,const mxArray* dataref);
|
---|
| 2835 | -
|
---|
| 2836 | -Option* OptionParse(char* name, const mxArray* prhs[]);
|
---|
| 2837 | -GenericOption<double>* OptionDoubleParse( char* name, const mxArray* prhs[]);
|
---|
| 2838 | -GenericOption<double*>* OptionDoubleArrayParse( char* name, const mxArray* prhs[]);
|
---|
| 2839 | -GenericOption<bool*>* OptionLogicalParse( char* name, const mxArray* prhs[]);
|
---|
| 2840 | -GenericOption<char*>* OptionCharParse( char* name, const mxArray* prhs[]);
|
---|
| 2841 | -GenericOption<Options**>* OptionStructParse( char* name, const mxArray* prhs[]);
|
---|
| 2842 | -GenericOption<Options*>* OptionCellParse( char* name, const mxArray* prhs[]);
|
---|
| 2843 | -
|
---|
| 2844 | -mxArray* mxGetAssignedField(const mxArray* pmxa_array,int number, const char* field);
|
---|
| 2845 | -void SetStructureField(mxArray* dataref,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer);
|
---|
| 2846 | -void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer);
|
---|
| 2847 | -void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int field);
|
---|
| 2848 | -void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,double field);
|
---|
| 2849 | -int CheckNumMatlabArguments(int nlhs,int NLHS, int nrhs,int NRHS, const char* THISFUNCTION, void (*function)( void ));
|
---|
| 2850 | -
|
---|
| 2851 | -/*Matlab to Matrix routines: */
|
---|
| 2852 | -Matrix<double>* MatlabMatrixToMatrix(const mxArray* mxmatrix);
|
---|
| 2853 | -Vector<double>* MatlabVectorToVector(const mxArray* mxvector);
|
---|
| 2854 | -
|
---|
| 2855 | -/*Matlab to double* routines: */
|
---|
| 2856 | -int MatlabVectorToDoubleVector(double** pvector,int* pvector_rows,const mxArray* mxvector);
|
---|
| 2857 | -int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix);
|
---|
| 2858 | -int MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
|
---|
| 2859 | -int MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
|
---|
| 2860 | -int MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
|
---|
| 2861 | -
|
---|
| 2862 | -/*Matlab to SeqMat routines: */
|
---|
| 2863 | -SeqMat<double>* MatlabMatrixToSeqMat(const mxArray* dataref);
|
---|
| 2864 | -SeqVec<double>* MatlabVectorToSeqVec(const mxArray* dataref);
|
---|
| 2865 | -
|
---|
| 2866 | -/*Matlab to Petsc routines: */
|
---|
| 2867 | -#ifdef _HAVE_PETSC_
|
---|
| 2868 | -int MatlabMatrixToPetscMat(Mat* matrix,int* prows,int* pcols, const mxArray* mxmatrix);
|
---|
| 2869 | -PetscMat* MatlabMatrixToPetscMat(const mxArray* mxmatrix);
|
---|
| 2870 | -int MatlabVectorToPetscVec(Vec* pvector,int* pvector_rows,const mxArray* mxvector);
|
---|
| 2871 | -PetscVec* MatlabVectorToPetscVec(const mxArray* mxvector);
|
---|
| 2872 | -#endif
|
---|
| 2873 | -
|
---|
| 2874 | -#endif /* _IO_H_ */
|
---|
| 2875 | Index: ../trunk-jpl/src/c/matlab/io/MatlabVectorToSeqVec.cpp
|
---|
| 2876 | ===================================================================
|
---|
| 2877 | --- ../trunk-jpl/src/c/matlab/io/MatlabVectorToSeqVec.cpp (revision 13748)
|
---|
| 2878 | +++ ../trunk-jpl/src/c/matlab/io/MatlabVectorToSeqVec.cpp (revision 13749)
|
---|
| 2879 | @@ -1,29 +0,0 @@
|
---|
| 2880 | -/*!\file MatlabVectorToSeqVec.cpp
|
---|
| 2881 | - */
|
---|
| 2882 | -
|
---|
| 2883 | -/*Headers:*/
|
---|
| 2884 | -/*{{{*/
|
---|
| 2885 | -#ifdef HAVE_CONFIG_H
|
---|
| 2886 | - #include <config.h>
|
---|
| 2887 | -#else
|
---|
| 2888 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 2889 | -#endif
|
---|
| 2890 | -
|
---|
| 2891 | -#include <mex.h>
|
---|
| 2892 | -#include <stdio.h>
|
---|
| 2893 | -#include <string.h>
|
---|
| 2894 | -#include "../../toolkits/toolkits.h"
|
---|
| 2895 | -#include "../../shared/shared.h"
|
---|
| 2896 | -#include "./matlabio.h"
|
---|
| 2897 | -
|
---|
| 2898 | -/*}}}*/
|
---|
| 2899 | -
|
---|
| 2900 | -SeqVec<double>* MatlabVectorToSeqVec(const mxArray* dataref){
|
---|
| 2901 | -
|
---|
| 2902 | - SeqVec<double>* output=NULL;
|
---|
| 2903 | -
|
---|
| 2904 | - output=new SeqVec<double>();
|
---|
| 2905 | - MatlabVectorToDoubleVector(&output->vector,&output->M,dataref);
|
---|
| 2906 | - return output;
|
---|
| 2907 | -
|
---|
| 2908 | -}
|
---|
| 2909 | Index: ../trunk-jpl/src/c/matlab/io/MatlabNArrayToNArray.cpp
|
---|
| 2910 | ===================================================================
|
---|
| 2911 | --- ../trunk-jpl/src/c/matlab/io/MatlabNArrayToNArray.cpp (revision 13748)
|
---|
| 2912 | +++ ../trunk-jpl/src/c/matlab/io/MatlabNArrayToNArray.cpp (revision 13749)
|
---|
| 2913 | @@ -1,251 +0,0 @@
|
---|
| 2914 | -/* \file MatlabNArrayToNArray.cpp
|
---|
| 2915 | - * \brief: convert a sparse or dense matlab n-dimensional array to cpp n-dimensional array
|
---|
| 2916 | - */
|
---|
| 2917 | -
|
---|
| 2918 | -#ifdef HAVE_CONFIG_H
|
---|
| 2919 | - #include <config.h>
|
---|
| 2920 | -#else
|
---|
| 2921 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 2922 | -#endif
|
---|
| 2923 | -
|
---|
| 2924 | -#include "../../shared/shared.h"
|
---|
| 2925 | -#include "../../include/include.h"
|
---|
| 2926 | -
|
---|
| 2927 | -#include <mex.h>
|
---|
| 2928 | -
|
---|
| 2929 | -/*FUNCTION MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
|
---|
| 2930 | -int MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
|
---|
| 2931 | -
|
---|
| 2932 | - int i,j,rows,cols;
|
---|
| 2933 | - int numel,ndims;
|
---|
| 2934 | - int *size,*dims;
|
---|
| 2935 | - double* mxmatrix_ptr=NULL;
|
---|
| 2936 | - const mwSize* ipt=NULL;
|
---|
| 2937 | -
|
---|
| 2938 | - /*output: */
|
---|
| 2939 | - double* matrix=NULL;
|
---|
| 2940 | -
|
---|
| 2941 | - /*matlab indices: */
|
---|
| 2942 | - mwIndex *ir = NULL;
|
---|
| 2943 | - mwIndex *jc = NULL;
|
---|
| 2944 | - double *pr = NULL;
|
---|
| 2945 | - int count;
|
---|
| 2946 | -
|
---|
| 2947 | - /*get Matlab matrix information: */
|
---|
| 2948 | - numel=mxGetNumberOfElements(mxmatrix);
|
---|
| 2949 | - ndims=mxGetNumberOfDimensions(mxmatrix);
|
---|
| 2950 | - ipt =mxGetDimensions(mxmatrix);
|
---|
| 2951 | - size =xNew<int>(ndims);
|
---|
| 2952 | - for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
|
---|
| 2953 | -
|
---|
| 2954 | - /*Ok, first check if we are dealing with a sparse or full matrix: */
|
---|
| 2955 | - if (mxIsSparse(mxmatrix)){
|
---|
| 2956 | -
|
---|
| 2957 | - /*Dealing with sparse matrix: recover size first: */
|
---|
| 2958 | - rows = mxGetM(mxmatrix);
|
---|
| 2959 | - cols = mxGetN(mxmatrix);
|
---|
| 2960 | -
|
---|
| 2961 | - matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 2962 | -
|
---|
| 2963 | - /*Now, get ir,jc and pr: */
|
---|
| 2964 | - ir = mxGetIr(mxmatrix);
|
---|
| 2965 | - jc = mxGetJc(mxmatrix);
|
---|
| 2966 | - pr = mxGetPr(mxmatrix);
|
---|
| 2967 | -
|
---|
| 2968 | - /*Now, start inserting data into double* matrix: */
|
---|
| 2969 | - count=0;
|
---|
| 2970 | - for(i=0;i<cols;i++){
|
---|
| 2971 | - for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 2972 | - *(matrix+rows*ir[count]+i)=pr[count];
|
---|
| 2973 | - count++;
|
---|
| 2974 | - }
|
---|
| 2975 | - }
|
---|
| 2976 | -
|
---|
| 2977 | - }
|
---|
| 2978 | - else{
|
---|
| 2979 | -
|
---|
| 2980 | - /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 2981 | - mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
|
---|
| 2982 | -
|
---|
| 2983 | - /*Create serial matrix: */
|
---|
| 2984 | - matrix=xNewZeroInit<double>(numel);
|
---|
| 2985 | -
|
---|
| 2986 | - dims=xNew<int>(ndims);
|
---|
| 2987 | - for(i=0;i<numel;i++){
|
---|
| 2988 | - ColumnWiseDimsFromIndex(dims,i,size,ndims);
|
---|
| 2989 | - j = IndexFromRowWiseDims(dims,size,ndims);
|
---|
| 2990 | - matrix[j]=(double)mxmatrix_ptr[i];
|
---|
| 2991 | - }
|
---|
| 2992 | - xDelete<int>(dims);
|
---|
| 2993 | - }
|
---|
| 2994 | -
|
---|
| 2995 | - /*Assign output pointer: */
|
---|
| 2996 | - *pmatrix = matrix;
|
---|
| 2997 | - *pmatrix_numel = numel;
|
---|
| 2998 | - *pmatrix_ndims = ndims;
|
---|
| 2999 | - *pmatrix_size = size;
|
---|
| 3000 | -
|
---|
| 3001 | - return 1;
|
---|
| 3002 | -}
|
---|
| 3003 | -/*}}}*/
|
---|
| 3004 | -/*FUNCTION MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
|
---|
| 3005 | -int MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
|
---|
| 3006 | -
|
---|
| 3007 | - int i,j,rows,cols;
|
---|
| 3008 | - int numel,ndims;
|
---|
| 3009 | - int *size,*dims;
|
---|
| 3010 | - bool* mxmatrix_ptr=NULL;
|
---|
| 3011 | - const mwSize* ipt=NULL;
|
---|
| 3012 | -
|
---|
| 3013 | - /*output: */
|
---|
| 3014 | - bool* matrix=NULL;
|
---|
| 3015 | -
|
---|
| 3016 | - /*matlab indices: */
|
---|
| 3017 | - mwIndex *ir = NULL;
|
---|
| 3018 | - mwIndex *jc = NULL;
|
---|
| 3019 | - bool *pm = NULL;
|
---|
| 3020 | - int count;
|
---|
| 3021 | -
|
---|
| 3022 | - /*get Matlab matrix information: */
|
---|
| 3023 | - numel = mxGetNumberOfElements(mxmatrix);
|
---|
| 3024 | - ndims = mxGetNumberOfDimensions(mxmatrix);
|
---|
| 3025 | - ipt = mxGetDimensions(mxmatrix);
|
---|
| 3026 | - size = xNew<int>(ndims);
|
---|
| 3027 | - for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
|
---|
| 3028 | -
|
---|
| 3029 | - /*Ok, first check if we are dealing with a sparse or full matrix: */
|
---|
| 3030 | - if (mxIsSparse(mxmatrix)){
|
---|
| 3031 | -
|
---|
| 3032 | - /*Dealing with sparse matrix: recover size first: */
|
---|
| 3033 | - rows=mxGetM(mxmatrix);
|
---|
| 3034 | - cols=mxGetN(mxmatrix);
|
---|
| 3035 | - matrix=xNewZeroInit<bool>(rows*cols);
|
---|
| 3036 | -
|
---|
| 3037 | - /*Now, get ir,jc and pm: */
|
---|
| 3038 | - ir=mxGetIr(mxmatrix);
|
---|
| 3039 | - jc=mxGetJc(mxmatrix);
|
---|
| 3040 | - pm=(bool*)mxGetData(mxmatrix);
|
---|
| 3041 | -
|
---|
| 3042 | - /*Now, start inserting data into bool* matrix: */
|
---|
| 3043 | - count=0;
|
---|
| 3044 | - for(i=0;i<cols;i++){
|
---|
| 3045 | - for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 3046 | - matrix[rows*ir[count]+i]=pm[count];
|
---|
| 3047 | - count++;
|
---|
| 3048 | - }
|
---|
| 3049 | - }
|
---|
| 3050 | - }
|
---|
| 3051 | - else{
|
---|
| 3052 | -
|
---|
| 3053 | - /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 3054 | - mxmatrix_ptr=(bool*)mxGetData(mxmatrix);
|
---|
| 3055 | -
|
---|
| 3056 | - /*Create serial matrix: */
|
---|
| 3057 | - matrix=xNew<bool>(numel);
|
---|
| 3058 | - dims=xNew<int>(ndims);
|
---|
| 3059 | - for(i=0;i<numel;i++){
|
---|
| 3060 | - ColumnWiseDimsFromIndex(dims,i,size,ndims);
|
---|
| 3061 | - j=IndexFromRowWiseDims(dims,size,ndims);
|
---|
| 3062 | - matrix[j]=(bool)mxmatrix_ptr[i];
|
---|
| 3063 | - }
|
---|
| 3064 | - xDelete<int>(dims);
|
---|
| 3065 | - }
|
---|
| 3066 | -
|
---|
| 3067 | - /*Assign output pointer: */
|
---|
| 3068 | - *pmatrix = matrix;
|
---|
| 3069 | - *pmatrix_numel = numel;
|
---|
| 3070 | - *pmatrix_ndims = ndims;
|
---|
| 3071 | - *pmatrix_size = size;
|
---|
| 3072 | -
|
---|
| 3073 | - return 1;
|
---|
| 3074 | -}
|
---|
| 3075 | -/*}}}*/
|
---|
| 3076 | -/*FUNCTION MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
|
---|
| 3077 | -int MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
|
---|
| 3078 | -
|
---|
| 3079 | - int i,j,rows,cols;
|
---|
| 3080 | - int numel,ndims;
|
---|
| 3081 | - int *size , *dims;
|
---|
| 3082 | - mxChar *mxmatrix_ptr = NULL;
|
---|
| 3083 | - const mwSize *ipt = NULL;
|
---|
| 3084 | -
|
---|
| 3085 | - /*output: */
|
---|
| 3086 | - char* matrix=NULL;
|
---|
| 3087 | -
|
---|
| 3088 | - /*matlab indices: */
|
---|
| 3089 | - mwIndex *ir = NULL;
|
---|
| 3090 | - mwIndex *jc = NULL;
|
---|
| 3091 | - char *pm = NULL;
|
---|
| 3092 | - int count;
|
---|
| 3093 | -
|
---|
| 3094 | - /*get Matlab matrix information: */
|
---|
| 3095 | - numel = mxGetNumberOfElements(mxmatrix);
|
---|
| 3096 | - ndims = mxGetNumberOfDimensions(mxmatrix);
|
---|
| 3097 | - ipt = mxGetDimensions(mxmatrix);
|
---|
| 3098 | - size = xNew<int>(ndims);
|
---|
| 3099 | - for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
|
---|
| 3100 | -
|
---|
| 3101 | - /*Ok, first check if we are dealing with a sparse or full matrix: */
|
---|
| 3102 | - if (mxIsSparse(mxmatrix)){
|
---|
| 3103 | -
|
---|
| 3104 | - /*Dealing with sparse matrix: recover size first: */
|
---|
| 3105 | - rows = mxGetM(mxmatrix);
|
---|
| 3106 | - cols = mxGetN(mxmatrix);
|
---|
| 3107 | - matrix=xNew<char>(rows*cols);
|
---|
| 3108 | -
|
---|
| 3109 | - /*Now, get ir,jc and pm: */
|
---|
| 3110 | - ir = mxGetIr(mxmatrix);
|
---|
| 3111 | - jc = mxGetJc(mxmatrix);
|
---|
| 3112 | - pm = (char*)mxGetData(mxmatrix);
|
---|
| 3113 | -
|
---|
| 3114 | - /*Now, start inserting data into char* matrix: */
|
---|
| 3115 | - count=0;
|
---|
| 3116 | - for(i=0;i<cols;i++){
|
---|
| 3117 | - for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 3118 | - matrix[rows*ir[count]+i]=(char)pm[count];
|
---|
| 3119 | - count++;
|
---|
| 3120 | - }
|
---|
| 3121 | - }
|
---|
| 3122 | - }
|
---|
| 3123 | - else{
|
---|
| 3124 | - /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 3125 | - mxmatrix_ptr=mxGetChars(mxmatrix);
|
---|
| 3126 | -
|
---|
| 3127 | - /*Create serial matrix: */
|
---|
| 3128 | - matrix=xNew<char>(numel+1);
|
---|
| 3129 | - matrix[numel]='\0';
|
---|
| 3130 | -
|
---|
| 3131 | - /*looping code adapted from Matlab example explore.c: */
|
---|
| 3132 | - int elements_per_page = size[0] * size[1];
|
---|
| 3133 | - /* total_number_of_pages = size[2] x size[3] x ... x size[N-1] */
|
---|
| 3134 | - int total_number_of_pages = 1;
|
---|
| 3135 | - for (i=2; i<ndims; i++) {
|
---|
| 3136 | - total_number_of_pages *= size[i];
|
---|
| 3137 | - }
|
---|
| 3138 | -
|
---|
| 3139 | - i=0;
|
---|
| 3140 | - for (int page=0; page < total_number_of_pages; page++) {
|
---|
| 3141 | - int row;
|
---|
| 3142 | - /* On each page, walk through each row. */
|
---|
| 3143 | - for (row=0; row<size[0]; row++) {
|
---|
| 3144 | - int column;
|
---|
| 3145 | - j = (page * elements_per_page) + row;
|
---|
| 3146 | -
|
---|
| 3147 | - /* Walk along each column in the current row. */
|
---|
| 3148 | - for (column=0; column<size[1]; column++) {
|
---|
| 3149 | - *(matrix+i++)=(char)*(mxmatrix_ptr+j);
|
---|
| 3150 | - j += size[0];
|
---|
| 3151 | - }
|
---|
| 3152 | - }
|
---|
| 3153 | - }
|
---|
| 3154 | - }
|
---|
| 3155 | -
|
---|
| 3156 | - /*Assign output pointer: */
|
---|
| 3157 | - *pmatrix = matrix;
|
---|
| 3158 | - *pmatrix_numel = numel;
|
---|
| 3159 | - *pmatrix_ndims = ndims;
|
---|
| 3160 | - *pmatrix_size = size;
|
---|
| 3161 | -
|
---|
| 3162 | - return 1;
|
---|
| 3163 | -}
|
---|
| 3164 | -/*}}}*/
|
---|
| 3165 | Index: ../trunk-jpl/src/c/matlab/io/MatlabMatrixToMatrix.cpp
|
---|
| 3166 | ===================================================================
|
---|
| 3167 | --- ../trunk-jpl/src/c/matlab/io/MatlabMatrixToMatrix.cpp (revision 13748)
|
---|
| 3168 | +++ ../trunk-jpl/src/c/matlab/io/MatlabMatrixToMatrix.cpp (revision 13749)
|
---|
| 3169 | @@ -1,39 +0,0 @@
|
---|
| 3170 | -/*!\file MatlabMatrixToMatrix.cpp
|
---|
| 3171 | - */
|
---|
| 3172 | -
|
---|
| 3173 | -/*Headers:*/
|
---|
| 3174 | -/*{{{*/
|
---|
| 3175 | -#ifdef HAVE_CONFIG_H
|
---|
| 3176 | - #include <config.h>
|
---|
| 3177 | -#else
|
---|
| 3178 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 3179 | -#endif
|
---|
| 3180 | -
|
---|
| 3181 | -#include <mex.h>
|
---|
| 3182 | -#include <stdio.h>
|
---|
| 3183 | -#include <string.h>
|
---|
| 3184 | -#include "./matlabio.h"
|
---|
| 3185 | -#include "../../classes/classes.h"
|
---|
| 3186 | -#include "../../shared/shared.h"
|
---|
| 3187 | -#include "../../Container/Container.h"
|
---|
| 3188 | -#include "../../include/include.h"
|
---|
| 3189 | -#include "../../toolkits/toolkits.h"
|
---|
| 3190 | -
|
---|
| 3191 | -/*}}}*/
|
---|
| 3192 | -
|
---|
| 3193 | -Matrix<double>* MatlabMatrixToMatrix(const mxArray* mxmatrix){
|
---|
| 3194 | -
|
---|
| 3195 | - int dummy;
|
---|
| 3196 | - Matrix<double>* matrix=NULL;
|
---|
| 3197 | -
|
---|
| 3198 | - /*allocate matrix object: */
|
---|
| 3199 | - matrix=new Matrix<double>();
|
---|
| 3200 | -
|
---|
| 3201 | - #ifdef _HAVE_PETSC_
|
---|
| 3202 | - matrix->pmatrix=MatlabMatrixToPetscMat(mxmatrix);
|
---|
| 3203 | - #else
|
---|
| 3204 | - matrix->smatrix=MatlabMatrixToSeqMat(mxmatrix);
|
---|
| 3205 | - #endif
|
---|
| 3206 | -
|
---|
| 3207 | - return matrix;
|
---|
| 3208 | -}
|
---|
| 3209 | Index: ../trunk-jpl/src/c/toolkits/python/pythonincludes.h
|
---|
| 3210 | ===================================================================
|
---|
| 3211 | --- ../trunk-jpl/src/c/toolkits/python/pythonincludes.h (revision 13748)
|
---|
| 3212 | +++ ../trunk-jpl/src/c/toolkits/python/pythonincludes.h (revision 13749)
|
---|
| 3213 | @@ -1,24 +0,0 @@
|
---|
| 3214 | -/* \file pythonincludes.h
|
---|
| 3215 | - * \brief all includes for PYTHON layer
|
---|
| 3216 | - */
|
---|
| 3217 | -
|
---|
| 3218 | -#ifndef _PYTHON_INCLUDES_H_
|
---|
| 3219 | -#define _PYTHON_INCLUDES_H_
|
---|
| 3220 | -
|
---|
| 3221 | -#ifdef HAVE_CONFIG_H
|
---|
| 3222 | - #include <config.h>
|
---|
| 3223 | -#else
|
---|
| 3224 | -#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 3225 | -#endif
|
---|
| 3226 | -
|
---|
| 3227 | -#if _PYTHON_MAJOR_ == 2
|
---|
| 3228 | -#undef NPY_NO_DEPRECATED_API
|
---|
| 3229 | -#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
|
---|
| 3230 | -#else
|
---|
| 3231 | -#define NPY_NO_DEPRECATED_API
|
---|
| 3232 | -#endif
|
---|
| 3233 | -
|
---|
| 3234 | -#include "Python.h"
|
---|
| 3235 | -#include "arrayobject.h"
|
---|
| 3236 | -
|
---|
| 3237 | -#endif
|
---|
| 3238 | Index: ../trunk-jpl/src/c/toolkits/toolkits.h
|
---|
| 3239 | ===================================================================
|
---|
| 3240 | --- ../trunk-jpl/src/c/toolkits/toolkits.h (revision 13748)
|
---|
| 3241 | +++ ../trunk-jpl/src/c/toolkits/toolkits.h (revision 13749)
|
---|
| 3242 | @@ -11,10 +11,6 @@
|
---|
| 3243 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 3244 | #endif
|
---|
| 3245 |
|
---|
| 3246 | -#ifdef _HAVE_PYTHON_
|
---|
| 3247 | -#include "./python/pythonincludes.h"
|
---|
| 3248 | -#endif
|
---|
| 3249 | -
|
---|
| 3250 | #ifdef _HAVE_PETSC_
|
---|
| 3251 | #include "./petsc/petscincludes.h"
|
---|
| 3252 | #endif
|
---|
| 3253 | @@ -30,5 +26,4 @@
|
---|
| 3254 | #include "./triangle/triangleincludes.h"
|
---|
| 3255 | #include "./toolkitsenums.h"
|
---|
| 3256 | #include "./issm/issmtoolkit.h"
|
---|
| 3257 | -
|
---|
| 3258 | #endif
|
---|
| 3259 | Index: ../trunk-jpl/src/c/Makefile.am
|
---|
| 3260 | ===================================================================
|
---|
| 3261 | --- ../trunk-jpl/src/c/Makefile.am (revision 13748)
|
---|
| 3262 | +++ ../trunk-jpl/src/c/Makefile.am (revision 13749)
|
---|
| 3263 | @@ -1,4 +1,4 @@
|
---|
| 3264 | -AM_CPPFLAGS = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
|
---|
| 3265 | +AM_CPPFLAGS = @DAKOTAINCL@ @SHAPELIBINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @METISINCL@ @CHACOINCL@ @SCOTCHINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MKLINCL@ @MUMPSINCL@ @TRIANGLEINCL@ @SPAIINCL@ @HYPREINCL@ @PROMETHEUSINCL@ @SUPERLUINCL@ @SPOOLESINCL@ @PASTIXINCL@ @MLINCL@ @TAOINCL@ @ADIC2INCL@ @ADOLCINCL@ @GSLINCL@ @BOOSTINCL@
|
---|
| 3266 |
|
---|
| 3267 | EXEEXT=$(ISSMEXT)
|
---|
| 3268 |
|
---|
| 3269 | @@ -8,15 +8,6 @@
|
---|
| 3270 | if SHAREDLIBS
|
---|
| 3271 | lib_LTLIBRARIES = libISSMCore.la libISSMOverload.la libISSM.la
|
---|
| 3272 | endif
|
---|
| 3273 | -if PYTHON
|
---|
| 3274 | -lib_LIBRARIES += libISSMPython.a
|
---|
| 3275 | -endif
|
---|
| 3276 | -if MATLAB
|
---|
| 3277 | -if SHAREDLIBS
|
---|
| 3278 | -lib_LTLIBRARIES += libISSMMatlab.la
|
---|
| 3279 | -endif
|
---|
| 3280 | -lib_LIBRARIES += libISSMMatlab.a
|
---|
| 3281 | -endif
|
---|
| 3282 | if WRAPPERS
|
---|
| 3283 | if SHAREDLIBS
|
---|
| 3284 | lib_LTLIBRARIES += libISSMWrappers.la
|
---|
| 3285 | @@ -763,36 +754,6 @@
|
---|
| 3286 | metis_sources= ./toolkits/metis/patches/metispatches.h\
|
---|
| 3287 | ./toolkits/metis/patches/METIS_PartMeshNodalPatch.cpp
|
---|
| 3288 | #}}}
|
---|
| 3289 | -#Python sources {{{
|
---|
| 3290 | -python_sources= ./python/io/pythonio.h\
|
---|
| 3291 | - ./python/python-binding.h\
|
---|
| 3292 | - ./python/io/WritePythonData.cpp\
|
---|
| 3293 | - ./python/io/CheckNumPythonArguments.cpp\
|
---|
| 3294 | - ./python/io/FetchPythonData.cpp
|
---|
| 3295 | -
|
---|
| 3296 | -#}}}
|
---|
| 3297 | -#Matlab sources {{{
|
---|
| 3298 | -matlab_sources= ./toolkits/matlab/matlabincludes.h\
|
---|
| 3299 | - ./matlab/matlab-binding.h\
|
---|
| 3300 | - ./matlab/io/matlabio.h\
|
---|
| 3301 | - ./matlab/io/MatlabNArrayToNArray.cpp\
|
---|
| 3302 | - ./matlab/io/CheckNumMatlabArguments.cpp\
|
---|
| 3303 | - ./matlab/io/mxGetAssignedField.cpp\
|
---|
| 3304 | - ./matlab/io/WriteMatlabData.cpp\
|
---|
| 3305 | - ./matlab/io/FetchMatlabData.cpp\
|
---|
| 3306 | - ./matlab/io/OptionParse.cpp\
|
---|
| 3307 | - ./matlab/io/MatlabMatrixToMatrix.cpp\
|
---|
| 3308 | - ./matlab/io/MatlabVectorToVector.cpp\
|
---|
| 3309 | - ./matlab/io/MatlabVectorToDoubleVector.cpp\
|
---|
| 3310 | - ./matlab/io/MatlabMatrixToDoubleMatrix.cpp\
|
---|
| 3311 | - ./matlab/io/MatlabMatrixToSeqMat.cpp\
|
---|
| 3312 | - ./matlab/io/MatlabVectorToSeqVec.cpp
|
---|
| 3313 | -#}}}
|
---|
| 3314 | -#Matlab and Petsc sources {{{
|
---|
| 3315 | -matlabpetsc_sources= ./matlab/io/MatlabMatrixToPetscMat.cpp\
|
---|
| 3316 | - ./matlab/io/MatlabVectorToPetscVec.cpp
|
---|
| 3317 | -
|
---|
| 3318 | -#}}}
|
---|
| 3319 | #Wrappers sources{{{
|
---|
| 3320 | wrapper_sources= ./shared/Threads/issm_threads.h\
|
---|
| 3321 | ./shared/Threads/LaunchThread.cpp\
|
---|
| 3322 | @@ -944,12 +905,6 @@
|
---|
| 3323 | issm_sources += $(metis_sources)
|
---|
| 3324 | endif
|
---|
| 3325 |
|
---|
| 3326 | -if PETSC
|
---|
| 3327 | -if MATLAB
|
---|
| 3328 | -issm_sources += $(matlabpetsc_sources)
|
---|
| 3329 | -endif
|
---|
| 3330 | -endif
|
---|
| 3331 | -
|
---|
| 3332 | if KRIGING
|
---|
| 3333 | issm_sources += $(pkriging_sources)
|
---|
| 3334 | endif
|
---|
| 3335 | @@ -986,19 +941,6 @@
|
---|
| 3336 | endif
|
---|
| 3337 | endif
|
---|
| 3338 |
|
---|
| 3339 | -if PYTHON
|
---|
| 3340 | -libISSMPython_a_SOURCES = $(python_sources)
|
---|
| 3341 | -libISSMPython_a_CXXFLAGS= $(ALLCXXFLAGS)
|
---|
| 3342 | -endif
|
---|
| 3343 | -
|
---|
| 3344 | -if MATLAB
|
---|
| 3345 | -libISSMMatlab_a_SOURCES = $(matlab_sources)
|
---|
| 3346 | -libISSMMatlab_a_CXXFLAGS= $(ALLCXXFLAGS)
|
---|
| 3347 | -if SHAREDLIBS
|
---|
| 3348 | -libISSMMatlab_la_SOURCES = $(libISSMMatlab_a_SOURCES)
|
---|
| 3349 | -endif
|
---|
| 3350 | -endif
|
---|
| 3351 | -
|
---|
| 3352 | if VERSION
|
---|
| 3353 | AM_LDFLAGS =
|
---|
| 3354 | else
|
---|
| 3355 | Index: ../trunk-jpl/src/wrappers/python/include/wrapper_macros.h
|
---|
| 3356 | ===================================================================
|
---|
| 3357 | --- ../trunk-jpl/src/wrappers/python/include/wrapper_macros.h (revision 0)
|
---|
| 3358 | +++ ../trunk-jpl/src/wrappers/python/include/wrapper_macros.h (revision 13749)
|
---|
| 3359 | @@ -0,0 +1,92 @@
|
---|
| 3360 | +/* \file python_macros.h
|
---|
| 3361 | + * \brief: macros used for the python bindings
|
---|
| 3362 | + */
|
---|
| 3363 | +
|
---|
| 3364 | +#ifndef _PY_WRAPPER_MACROS_H_
|
---|
| 3365 | +#define _PY_WRAPPER_MACROS_H_
|
---|
| 3366 | +
|
---|
| 3367 | +#ifdef HAVE_CONFIG_H
|
---|
| 3368 | + #include <config.h>
|
---|
| 3369 | +#else
|
---|
| 3370 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 3371 | +#endif
|
---|
| 3372 | +
|
---|
| 3373 | +#ifdef _HAVE_PYTHON_
|
---|
| 3374 | +/* MODULEBOOT/MODULEEND {{{*/
|
---|
| 3375 | +
|
---|
| 3376 | +/*The following macros hide the error exception handling in a matlab module. Just put
|
---|
| 3377 | + * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions
|
---|
| 3378 | + * will be trapped*/
|
---|
| 3379 | +#define MODULEBOOT(); \
|
---|
| 3380 | + PyObject *output = PyTuple_New(NLHS); \
|
---|
| 3381 | + int nrhs = (int)PyTuple_Size(args); \
|
---|
| 3382 | + if(!output) return NULL;\
|
---|
| 3383 | + try{ \
|
---|
| 3384 | + IssmComm::SetComm(-1);
|
---|
| 3385 | +
|
---|
| 3386 | +#define MODULEEND(); }\
|
---|
| 3387 | + catch(ErrorException &exception){\
|
---|
| 3388 | + PyErr_SetString(PyExc_TypeError,exception.PythonReport()); \
|
---|
| 3389 | + return NULL;\
|
---|
| 3390 | + } \
|
---|
| 3391 | + catch (exception &e){\
|
---|
| 3392 | + PyErr_SetString(PyExc_TypeError,exprintf("Standard exception: %s\n",e.what()));\
|
---|
| 3393 | + return NULL;\
|
---|
| 3394 | + }\
|
---|
| 3395 | + catch(...){\
|
---|
| 3396 | + PyErr_SetString(PyExc_TypeError,"An unexpected error occurred");\
|
---|
| 3397 | + return NULL;\
|
---|
| 3398 | + }\
|
---|
| 3399 | + return output;
|
---|
| 3400 | +//}}}
|
---|
| 3401 | +#if _PYTHON_MAJOR_ >=3
|
---|
| 3402 | +/* WRAPPER 3.2 {{{*/
|
---|
| 3403 | +#define WRAPPER(modulename,...) \
|
---|
| 3404 | +\
|
---|
| 3405 | +static PyObject* modulename(PyObject* self,PyObject* args);\
|
---|
| 3406 | +static PyMethodDef modulename##_funcs[] = {\
|
---|
| 3407 | + {#modulename, (PyCFunction)modulename, METH_VARARGS, ""},\
|
---|
| 3408 | + {NULL,NULL,0,NULL}\
|
---|
| 3409 | +};\
|
---|
| 3410 | +\
|
---|
| 3411 | +static struct PyModuleDef modulename##module= {\
|
---|
| 3412 | + PyModuleDef_HEAD_INIT,\
|
---|
| 3413 | + #modulename, /* name of module */\
|
---|
| 3414 | + NULL, /* module documentation, may be NULL */\
|
---|
| 3415 | + -1, /* size of per-interpreter state of the module,\
|
---|
| 3416 | + or -1 if the module keeps state in global variables. */\
|
---|
| 3417 | + modulename##_funcs\
|
---|
| 3418 | +};\
|
---|
| 3419 | +\
|
---|
| 3420 | +PyMODINIT_FUNC PyInit_##modulename(void){\
|
---|
| 3421 | +\
|
---|
| 3422 | + import_array();\
|
---|
| 3423 | + return PyModule_Create(&modulename##module);\
|
---|
| 3424 | +}\
|
---|
| 3425 | +\
|
---|
| 3426 | +static PyObject* modulename(PyObject* self,PyObject* args)
|
---|
| 3427 | +/*}}}*/
|
---|
| 3428 | +#else
|
---|
| 3429 | +/* WRAPPER 2.7 {{{*/
|
---|
| 3430 | +#define WRAPPER(modulename,...) \
|
---|
| 3431 | +\
|
---|
| 3432 | +static PyObject* modulename(PyObject* self,PyObject* args);\
|
---|
| 3433 | +static PyMethodDef modulename##_funcs[] = {\
|
---|
| 3434 | + {#modulename, (PyCFunction)modulename, METH_VARARGS, ""},\
|
---|
| 3435 | + {NULL,NULL,0,NULL}\
|
---|
| 3436 | +};\
|
---|
| 3437 | +\
|
---|
| 3438 | +PyMODINIT_FUNC init##modulename(void){\
|
---|
| 3439 | +\
|
---|
| 3440 | + import_array();\
|
---|
| 3441 | + (void) Py_InitModule(#modulename, modulename##_funcs);\
|
---|
| 3442 | +}\
|
---|
| 3443 | +\
|
---|
| 3444 | +static PyObject* modulename(PyObject* self,PyObject* args)
|
---|
| 3445 | +/*}}}*/
|
---|
| 3446 | +#endif
|
---|
| 3447 | +/* CHECKARGUMENTS {{{*/
|
---|
| 3448 | +#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumPythonArguments(args, NRHS,functionpointer)
|
---|
| 3449 | +/*}}}*/
|
---|
| 3450 | +#endif
|
---|
| 3451 | +#endif
|
---|
| 3452 | Index: ../trunk-jpl/src/wrappers/python/io/pythonio.h
|
---|
| 3453 | ===================================================================
|
---|
| 3454 | --- ../trunk-jpl/src/wrappers/python/io/pythonio.h (revision 0)
|
---|
| 3455 | +++ ../trunk-jpl/src/wrappers/python/io/pythonio.h (revision 13749)
|
---|
| 3456 | @@ -0,0 +1,48 @@
|
---|
| 3457 | +/*\file pythonio.h
|
---|
| 3458 | + *\brief: I/O for ISSM in python mode
|
---|
| 3459 | + */
|
---|
| 3460 | +
|
---|
| 3461 | +#ifndef _PYTHON_IO_H_
|
---|
| 3462 | +#define _PYTHON_IO_H_
|
---|
| 3463 | +
|
---|
| 3464 | +#ifdef HAVE_CONFIG_H
|
---|
| 3465 | +#include <config.h>
|
---|
| 3466 | +#else
|
---|
| 3467 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 3468 | +#endif
|
---|
| 3469 | +
|
---|
| 3470 | +#include "../include/pythonincludes.h"
|
---|
| 3471 | +#include "../../c/classes/classes.h"
|
---|
| 3472 | +#include "../../c/Container/Container.h"
|
---|
| 3473 | +#include "../../c/include/include.h"
|
---|
| 3474 | +
|
---|
| 3475 | +void WriteData(PyObject* py_tuple,int index, double* matrix, int M,int N);
|
---|
| 3476 | +void WriteData(PyObject* py_tuple,int index, int integer);
|
---|
| 3477 | +void WriteData(PyObject* py_tuple,int index, char* string);
|
---|
| 3478 | +void WriteData(PyObject* py_tuple,int index);
|
---|
| 3479 | +void WriteData(PyObject* py_tuple,int index, SeqMat<double>* matrix);
|
---|
| 3480 | +void WriteData(PyObject* py_tuple,int index, SeqVec<double>* vector);
|
---|
| 3481 | +void WriteData(PyObject* py_tuple,int index, BamgGeom* bamggeom);
|
---|
| 3482 | +void WriteData(PyObject* py_tuple,int index, BamgMesh* bamgmesh);
|
---|
| 3483 | +void WriteData(PyObject* py_tuple,int index, RiftStruct* riftstruct);
|
---|
| 3484 | +
|
---|
| 3485 | +void FetchData(double** pvector,int* pM,PyObject* py_ref);
|
---|
| 3486 | +void FetchData(double** pmatrix,int* pM,int *pN,PyObject* py_array);
|
---|
| 3487 | +void FetchData(int** pmatrix,int* pM,int *pN,PyObject* py_matrix);
|
---|
| 3488 | +void FetchData(char** pstring,PyObject* py_unicode);
|
---|
| 3489 | +void FetchData(double* pscalar,PyObject* py_float);
|
---|
| 3490 | +void FetchData(int* pinteger,PyObject* py_long);
|
---|
| 3491 | +void FetchData(bool* pbool,PyObject* py_boolean);
|
---|
| 3492 | +void FetchData(BamgGeom** bamggeom,PyObject* py_dict);
|
---|
| 3493 | +void FetchData(BamgMesh** bamgmesh,PyObject* py_dict);
|
---|
| 3494 | +void FetchData(BamgOpts** bamgopts,PyObject* py_dict);
|
---|
| 3495 | +void FetchData(Options** poptions,int istart, int nrhs,PyObject* py_tuple);
|
---|
| 3496 | +void FetchData(DataSet** pcontours,PyObject* py_list);
|
---|
| 3497 | +
|
---|
| 3498 | +int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void ));
|
---|
| 3499 | +
|
---|
| 3500 | +/*Utils*/
|
---|
| 3501 | +PyObject* PyArrayFromCopiedData(int dims[2],double* data);
|
---|
| 3502 | +PyObject* PyArrayFromCopiedData(int dimi,int dimj,double* data);
|
---|
| 3503 | +
|
---|
| 3504 | +#endif /* _IO_H_ */
|
---|
| 3505 | Index: ../trunk-jpl/src/wrappers/python/io/CheckNumPythonArguments.cpp
|
---|
| 3506 | ===================================================================
|
---|
| 3507 | --- ../trunk-jpl/src/wrappers/python/io/CheckNumPythonArguments.cpp (revision 0)
|
---|
| 3508 | +++ ../trunk-jpl/src/wrappers/python/io/CheckNumPythonArguments.cpp (revision 13749)
|
---|
| 3509 | @@ -0,0 +1,29 @@
|
---|
| 3510 | +/*!\file CheckNumPythonArguments.cpp:
|
---|
| 3511 | + * \brief: check number of arguments and report an usage error message.
|
---|
| 3512 | + */
|
---|
| 3513 | +
|
---|
| 3514 | +#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
|
---|
| 3515 | +#define NO_IMPORT
|
---|
| 3516 | +
|
---|
| 3517 | +#include "./pythonio.h"
|
---|
| 3518 | +#include "../../c/shared/Exceptions/exceptions.h"
|
---|
| 3519 | +#include "../../c/include/include.h"
|
---|
| 3520 | +
|
---|
| 3521 | +int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void )){
|
---|
| 3522 | +
|
---|
| 3523 | + Py_ssize_t size=0;
|
---|
| 3524 | +
|
---|
| 3525 | + /*figure out size of tuple in input: */
|
---|
| 3526 | + size=PyTuple_Size(inputs);
|
---|
| 3527 | +
|
---|
| 3528 | + /*check on requested size: */
|
---|
| 3529 | + if (size==0){
|
---|
| 3530 | + function();
|
---|
| 3531 | + _error_("usage: see above");
|
---|
| 3532 | + }
|
---|
| 3533 | + else if (size!=NRHS ) {
|
---|
| 3534 | + function();
|
---|
| 3535 | + _error_("usage error.");
|
---|
| 3536 | + }
|
---|
| 3537 | + return 1;
|
---|
| 3538 | +}
|
---|
| 3539 | Index: ../trunk-jpl/src/wrappers/python/io/FetchPythonData.cpp
|
---|
| 3540 | ===================================================================
|
---|
| 3541 | --- ../trunk-jpl/src/wrappers/python/io/FetchPythonData.cpp (revision 0)
|
---|
| 3542 | +++ ../trunk-jpl/src/wrappers/python/io/FetchPythonData.cpp (revision 13749)
|
---|
| 3543 | @@ -0,0 +1,354 @@
|
---|
| 3544 | +/*\file FetchData.cpp:
|
---|
| 3545 | + * \brief: general I/O interface to fetch data in python
|
---|
| 3546 | + */
|
---|
| 3547 | +
|
---|
| 3548 | +#ifdef HAVE_CONFIG_H
|
---|
| 3549 | + #include <config.h>
|
---|
| 3550 | +#else
|
---|
| 3551 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 3552 | +#endif
|
---|
| 3553 | +
|
---|
| 3554 | +#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
|
---|
| 3555 | +#define NO_IMPORT
|
---|
| 3556 | +
|
---|
| 3557 | +#include "./pythonio.h"
|
---|
| 3558 | +#include "../../c/include/include.h"
|
---|
| 3559 | +#include "../../c/shared/shared.h"
|
---|
| 3560 | +
|
---|
| 3561 | +/*Primitive data types*/
|
---|
| 3562 | +/*FUNCTION FetchData(double* pscalar,PyObject* py_float){{{*/
|
---|
| 3563 | +void FetchData(double* pscalar,PyObject* py_float){
|
---|
| 3564 | +
|
---|
| 3565 | + double scalar;
|
---|
| 3566 | +
|
---|
| 3567 | + /*return internal value: */
|
---|
| 3568 | + scalar=PyFloat_AsDouble(py_float);
|
---|
| 3569 | +
|
---|
| 3570 | + /*output: */
|
---|
| 3571 | + *pscalar=scalar;
|
---|
| 3572 | +}
|
---|
| 3573 | +/*}}}*/
|
---|
| 3574 | +/*FUNCTION FetchData(int* pinteger,PyObject* py_long){{{*/
|
---|
| 3575 | +void FetchData(int* pinteger, PyObject* py_long){
|
---|
| 3576 | +
|
---|
| 3577 | + int integer;
|
---|
| 3578 | +
|
---|
| 3579 | + /*return internal value: */
|
---|
| 3580 | + integer=(int)PyLong_AsLong(py_long);
|
---|
| 3581 | +
|
---|
| 3582 | + /*output: */
|
---|
| 3583 | + *pinteger=integer;
|
---|
| 3584 | +}
|
---|
| 3585 | +/*}}}*/
|
---|
| 3586 | +/*FUNCTION FetchData(bool* pboolean,PyObject* py_boolean){{{*/
|
---|
| 3587 | +void FetchData(bool* pboolean,PyObject* py_boolean){
|
---|
| 3588 | +
|
---|
| 3589 | + bool boolean;
|
---|
| 3590 | +
|
---|
| 3591 | + /*check this is indeed a subtype of long type: */
|
---|
| 3592 | + if(!PyBool_Check(py_boolean))_error_("expecting a boolean in input!");
|
---|
| 3593 | +
|
---|
| 3594 | + /*extract boolean: */
|
---|
| 3595 | + boolean=(bool)PyLong_AsLong(py_boolean);
|
---|
| 3596 | +
|
---|
| 3597 | + /*simple copy: */
|
---|
| 3598 | + *pboolean=boolean;
|
---|
| 3599 | +
|
---|
| 3600 | +}
|
---|
| 3601 | +/*}}}*/
|
---|
| 3602 | +/*FUNCTION FetchData(double** pmatrix,int* pM, int* pN, PyObject* py_matrix){{{*/
|
---|
| 3603 | +void FetchData(double** pmatrix,int* pM,int *pN,PyObject* py_matrix){
|
---|
| 3604 | +
|
---|
| 3605 | + /*output: */
|
---|
| 3606 | + double* dmatrix=NULL;
|
---|
| 3607 | + double* matrix=NULL;
|
---|
| 3608 | + int M,N;
|
---|
| 3609 | + int ndim;
|
---|
| 3610 | + npy_intp* dims=NULL;
|
---|
| 3611 | +
|
---|
| 3612 | + /*retrive dimensions: */
|
---|
| 3613 | + ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
|
---|
| 3614 | + if(ndim!=2)_error_("expecting an MxN matrix in input!");
|
---|
| 3615 | + dims=PyArray_DIMS((PyArrayObject*)py_matrix);
|
---|
| 3616 | + M=dims[0]; N=dims[1];
|
---|
| 3617 | +
|
---|
| 3618 | + if (M && N) {
|
---|
| 3619 | + /*retrieve internal value: */
|
---|
| 3620 | + dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
|
---|
| 3621 | +
|
---|
| 3622 | + /*copy matrix: */
|
---|
| 3623 | + matrix=xNew<double>(M*N);
|
---|
| 3624 | + memcpy(matrix,dmatrix,(M*N)*sizeof(double));
|
---|
| 3625 | + }
|
---|
| 3626 | + else
|
---|
| 3627 | + matrix=NULL;
|
---|
| 3628 | +
|
---|
| 3629 | + /*output: */
|
---|
| 3630 | + if(pM)*pM=M;
|
---|
| 3631 | + if(pN)*pN=N;
|
---|
| 3632 | + if(pmatrix)*pmatrix=matrix;
|
---|
| 3633 | +}
|
---|
| 3634 | +/*}}}*/
|
---|
| 3635 | +/*FUNCTION FetchData(int** pmatrix,int* pM, int* pN, PyObject* py_matrix){{{*/
|
---|
| 3636 | +void FetchData(int** pmatrix,int* pM,int *pN,PyObject* py_matrix){
|
---|
| 3637 | +
|
---|
| 3638 | + /*output: */
|
---|
| 3639 | + double* dmatrix=NULL;
|
---|
| 3640 | + int* matrix=NULL;
|
---|
| 3641 | + int M,N;
|
---|
| 3642 | +
|
---|
| 3643 | + /*intermediary:*/
|
---|
| 3644 | + int i;
|
---|
| 3645 | + int ndim;
|
---|
| 3646 | + npy_intp* dims=NULL;
|
---|
| 3647 | +
|
---|
| 3648 | + /*retrive dimensions: */
|
---|
| 3649 | + ndim=PyArray_NDIM((const PyArrayObject*)py_matrix);
|
---|
| 3650 | + if(ndim!=2)_error_("expecting an MxN matrix in input!");
|
---|
| 3651 | + dims=PyArray_DIMS((PyArrayObject*)py_matrix);
|
---|
| 3652 | + M=dims[0]; N=dims[1];
|
---|
| 3653 | +
|
---|
| 3654 | + if (M && N) {
|
---|
| 3655 | + /*retrieve internal value: */
|
---|
| 3656 | + dmatrix=(double*)PyArray_DATA((PyArrayObject*)py_matrix);
|
---|
| 3657 | +
|
---|
| 3658 | + /*transform into integer matrix: */
|
---|
| 3659 | + matrix=xNew<int>(M*N);
|
---|
| 3660 | + for(i=0;i<M*N;i++)matrix[i]=(int)dmatrix[i];
|
---|
| 3661 | + }
|
---|
| 3662 | + else
|
---|
| 3663 | + matrix=NULL;
|
---|
| 3664 | +
|
---|
| 3665 | + /*output: */
|
---|
| 3666 | + if(pM)*pM=M;
|
---|
| 3667 | + if(pN)*pN=N;
|
---|
| 3668 | + if(pmatrix)*pmatrix=matrix;
|
---|
| 3669 | +}
|
---|
| 3670 | +/*}}}*/
|
---|
| 3671 | +/*FUNCTION FetchData(double** pvector,int* pM, PyObject* py_vector){{{*/
|
---|
| 3672 | +void FetchData(double** pvector,int* pM,PyObject* py_vector){
|
---|
| 3673 | +
|
---|
| 3674 | + /*output: */
|
---|
| 3675 | + double* dvector=NULL;
|
---|
| 3676 | + double* vector=NULL;
|
---|
| 3677 | + int M;
|
---|
| 3678 | + int ndim;
|
---|
| 3679 | + npy_intp* dims=NULL;
|
---|
| 3680 | +
|
---|
| 3681 | + /*retrive dimensions: */
|
---|
| 3682 | + ndim=PyArray_NDIM((const PyArrayObject*)py_vector);
|
---|
| 3683 | + if(ndim!=1)_error_("expecting an Mx1 vector in input!");
|
---|
| 3684 | + dims=PyArray_DIMS((PyArrayObject*)py_vector);
|
---|
| 3685 | + M=dims[0];
|
---|
| 3686 | +
|
---|
| 3687 | + if (M) {
|
---|
| 3688 | + /*retrieve internal value: */
|
---|
| 3689 | + dvector=(double*)PyArray_DATA((PyArrayObject*)py_vector);
|
---|
| 3690 | +
|
---|
| 3691 | + /*copy vector: */
|
---|
| 3692 | + vector=xNew<double>(M);
|
---|
| 3693 | + memcpy(vector,dvector,(M)*sizeof(double));
|
---|
| 3694 | + }
|
---|
| 3695 | + else
|
---|
| 3696 | + vector=NULL;
|
---|
| 3697 | +
|
---|
| 3698 | + /*output: */
|
---|
| 3699 | + if(pM)*pM=M;
|
---|
| 3700 | + if(pvector)*pvector=vector;
|
---|
| 3701 | +}
|
---|
| 3702 | +/*}}}*/
|
---|
| 3703 | +
|
---|
| 3704 | +/*ISSM objects*/
|
---|
| 3705 | +/*FUNCTION FetchData(BamgGeom** pbamggeom,PyObject* py_dict){{{*/
|
---|
| 3706 | +void FetchData(BamgGeom** pbamggeom,PyObject* py_dict){
|
---|
| 3707 | +
|
---|
| 3708 | + /*Initialize output*/
|
---|
| 3709 | + BamgGeom* bamggeom=new BamgGeom();
|
---|
| 3710 | +
|
---|
| 3711 | + /*Fetch all fields*/
|
---|
| 3712 | + FetchData(&bamggeom->Vertices,&bamggeom->VerticesSize[0],&bamggeom->VerticesSize[1],PyDict_GetItemString(py_dict,"Vertices"));
|
---|
| 3713 | + FetchData(&bamggeom->Edges, &bamggeom->EdgesSize[0], &bamggeom->EdgesSize[1], PyDict_GetItemString(py_dict,"Edges"));
|
---|
| 3714 | + FetchData(&bamggeom->Corners, &bamggeom->CornersSize[0], &bamggeom->CornersSize[1], PyDict_GetItemString(py_dict,"Corners"));
|
---|
| 3715 | + FetchData(&bamggeom->RequiredVertices,&bamggeom->RequiredVerticesSize[0],&bamggeom->RequiredVerticesSize[1],PyDict_GetItemString(py_dict,"RequiredVertices"));
|
---|
| 3716 | + FetchData(&bamggeom->RequiredEdges, &bamggeom->RequiredEdgesSize[0], &bamggeom->RequiredEdgesSize[1], PyDict_GetItemString(py_dict,"RequiredEdges"));
|
---|
| 3717 | + FetchData(&bamggeom->CrackedEdges,&bamggeom->CrackedEdgesSize[0],&bamggeom->CrackedEdgesSize[1],PyDict_GetItemString(py_dict,"CrackedEdges"));
|
---|
| 3718 | + FetchData(&bamggeom->SubDomains,&bamggeom->SubDomainsSize[0],&bamggeom->SubDomainsSize[1],PyDict_GetItemString(py_dict,"SubDomains"));
|
---|
| 3719 | +
|
---|
| 3720 | + /*Assign output pointers:*/
|
---|
| 3721 | + *pbamggeom=bamggeom;
|
---|
| 3722 | +}
|
---|
| 3723 | +/*}}}*/
|
---|
| 3724 | +/*FUNCTION FetchData(BamgMesh** pbamgmesh,PyObject* py_dict){{{*/
|
---|
| 3725 | +void FetchData(BamgMesh** pbamgmesh,PyObject* py_dict){
|
---|
| 3726 | +
|
---|
| 3727 | + /*Initialize output*/
|
---|
| 3728 | + BamgMesh* bamgmesh=new BamgMesh();
|
---|
| 3729 | +
|
---|
| 3730 | + /*Fetch all fields*/
|
---|
| 3731 | + FetchData(&bamgmesh->Vertices,&bamgmesh->VerticesSize[0],&bamgmesh->VerticesSize[1],PyDict_GetItemString(py_dict,"Vertices"));
|
---|
| 3732 | + FetchData(&bamgmesh->Edges, &bamgmesh->EdgesSize[0], &bamgmesh->EdgesSize[1], PyDict_GetItemString(py_dict,"Edges"));
|
---|
| 3733 | + FetchData(&bamgmesh->Triangles, &bamgmesh->TrianglesSize[0], &bamgmesh->TrianglesSize[1], PyDict_GetItemString(py_dict,"Triangles"));
|
---|
| 3734 | + FetchData(&bamgmesh->CrackedEdges,&bamgmesh->CrackedEdgesSize[0],&bamgmesh->CrackedEdgesSize[1],PyDict_GetItemString(py_dict,"CrackedEdges"));
|
---|
| 3735 | + FetchData(&bamgmesh->VerticesOnGeomEdge,&bamgmesh->VerticesOnGeomEdgeSize[0],&bamgmesh->VerticesOnGeomEdgeSize[1],PyDict_GetItemString(py_dict,"VerticesOnGeomEdge"));
|
---|
| 3736 | + FetchData(&bamgmesh->VerticesOnGeomVertex,&bamgmesh->VerticesOnGeomVertexSize[0],&bamgmesh->VerticesOnGeomVertexSize[1],PyDict_GetItemString(py_dict,"VerticesOnGeomVertex"));
|
---|
| 3737 | + FetchData(&bamgmesh->EdgesOnGeomEdge, &bamgmesh->EdgesOnGeomEdgeSize[0], &bamgmesh->EdgesOnGeomEdgeSize[1], PyDict_GetItemString(py_dict,"EdgesOnGeomEdge"));
|
---|
| 3738 | + FetchData(&bamgmesh->IssmSegments,&bamgmesh->IssmSegmentsSize[0],&bamgmesh->IssmSegmentsSize[1],PyDict_GetItemString(py_dict,"IssmSegments"));
|
---|
| 3739 | +
|
---|
| 3740 | + /*Assign output pointers:*/
|
---|
| 3741 | + *pbamgmesh=bamgmesh;
|
---|
| 3742 | +}
|
---|
| 3743 | +/*}}}*/
|
---|
| 3744 | +/*FUNCTION FetchData(BamgOpts** pbamgopts,PyObject* py_dict){{{*/
|
---|
| 3745 | +void FetchData(BamgOpts** pbamgopts,PyObject* py_dict){
|
---|
| 3746 | +
|
---|
| 3747 | + /*Initialize output*/
|
---|
| 3748 | + BamgOpts* bamgopts=new BamgOpts();
|
---|
| 3749 | +
|
---|
| 3750 | + /*Fetch all fields*/
|
---|
| 3751 | + FetchData(&bamgopts->anisomax,PyDict_GetItemString(py_dict,"anisomax"));
|
---|
| 3752 | + FetchData(&bamgopts->cutoff,PyDict_GetItemString(py_dict,"cutoff"));
|
---|
| 3753 | + FetchData(&bamgopts->coeff,PyDict_GetItemString(py_dict,"coeff"));
|
---|
| 3754 | + FetchData(&bamgopts->errg,PyDict_GetItemString(py_dict,"errg"));
|
---|
| 3755 | + FetchData(&bamgopts->gradation,PyDict_GetItemString(py_dict,"gradation"));
|
---|
| 3756 | + FetchData(&bamgopts->Hessiantype,PyDict_GetItemString(py_dict,"Hessiantype"));
|
---|
| 3757 | + FetchData(&bamgopts->MaxCornerAngle,PyDict_GetItemString(py_dict,"MaxCornerAngle"));
|
---|
| 3758 | + FetchData(&bamgopts->maxnbv,PyDict_GetItemString(py_dict,"maxnbv"));
|
---|
| 3759 | + FetchData(&bamgopts->maxsubdiv,PyDict_GetItemString(py_dict,"maxsubdiv"));
|
---|
| 3760 | + FetchData(&bamgopts->Metrictype,PyDict_GetItemString(py_dict,"Metrictype"));
|
---|
| 3761 | + FetchData(&bamgopts->nbjacobi,PyDict_GetItemString(py_dict,"nbjacobi"));
|
---|
| 3762 | + FetchData(&bamgopts->nbsmooth,PyDict_GetItemString(py_dict,"nbsmooth"));
|
---|
| 3763 | + FetchData(&bamgopts->omega,PyDict_GetItemString(py_dict,"omega"));
|
---|
| 3764 | + FetchData(&bamgopts->power,PyDict_GetItemString(py_dict,"power"));
|
---|
| 3765 | + FetchData(&bamgopts->verbose,PyDict_GetItemString(py_dict,"verbose"));
|
---|
| 3766 | +
|
---|
| 3767 | + FetchData(&bamgopts->Crack,PyDict_GetItemString(py_dict,"Crack"));
|
---|
| 3768 | + FetchData(&bamgopts->geometricalmetric,PyDict_GetItemString(py_dict,"geometricalmetric"));
|
---|
| 3769 | + FetchData(&bamgopts->KeepVertices,PyDict_GetItemString(py_dict,"KeepVertices"));
|
---|
| 3770 | + FetchData(&bamgopts->splitcorners,PyDict_GetItemString(py_dict,"splitcorners"));
|
---|
| 3771 | +
|
---|
| 3772 | + FetchData(&bamgopts->hmin,PyDict_GetItemString(py_dict,"hmin"));
|
---|
| 3773 | + FetchData(&bamgopts->hmax,PyDict_GetItemString(py_dict,"hmax"));
|
---|
| 3774 | + FetchData(&bamgopts->hminVertices,&bamgopts->hminVerticesSize[0],&bamgopts->hminVerticesSize[1],PyDict_GetItemString(py_dict,"hminVertices"));
|
---|
| 3775 | + FetchData(&bamgopts->hmaxVertices,&bamgopts->hmaxVerticesSize[0],&bamgopts->hmaxVerticesSize[1],PyDict_GetItemString(py_dict,"hmaxVertices"));
|
---|
| 3776 | + FetchData(&bamgopts->hVertices,&bamgopts->hVerticesSize[0],&bamgopts->hVerticesSize[1],PyDict_GetItemString(py_dict,"hVertices"));
|
---|
| 3777 | + FetchData(&bamgopts->metric,&bamgopts->metricSize[0],&bamgopts->metricSize[1],PyDict_GetItemString(py_dict,"metric"));
|
---|
| 3778 | + FetchData(&bamgopts->field,&bamgopts->fieldSize[0],&bamgopts->fieldSize[1],PyDict_GetItemString(py_dict,"field"));
|
---|
| 3779 | + FetchData(&bamgopts->err,&bamgopts->errSize[0],&bamgopts->errSize[1],PyDict_GetItemString(py_dict,"err"));
|
---|
| 3780 | +
|
---|
| 3781 | + /*Additional checks*/
|
---|
| 3782 | + bamgopts->Check();
|
---|
| 3783 | +
|
---|
| 3784 | + /*Assign output pointers:*/
|
---|
| 3785 | + *pbamgopts=bamgopts;
|
---|
| 3786 | +}
|
---|
| 3787 | +/*}}}*/
|
---|
| 3788 | +/*FUNCTION FetchData(Options** poptions,int istart, int nrhs,PyObject* py_tuple){{{*/
|
---|
| 3789 | +void FetchData(Options** poptions,int istart, int nrhs,PyObject* py_tuple){
|
---|
| 3790 | +
|
---|
| 3791 | + char *name = NULL;
|
---|
| 3792 | + Option *option = NULL;
|
---|
| 3793 | +
|
---|
| 3794 | + /*Initialize output*/
|
---|
| 3795 | + Options* options=new Options();
|
---|
| 3796 | +
|
---|
| 3797 | + /*Fetch all options*/
|
---|
| 3798 | + for (int i=istart; i<nrhs; i=i+2){
|
---|
| 3799 | + if (!PyString_Check(PyTuple_GetItem(py_tuple,(Py_ssize_t)i))) _error_("Argument " << i+1 << " must be name of option");
|
---|
| 3800 | +
|
---|
| 3801 | + FetchData(&name,PyTuple_GetItem(py_tuple,(Py_ssize_t)i));
|
---|
| 3802 | + if(i+1 == nrhs) _error_("Argument " << i+2 << " must exist and be value of option \"" << name << "\".");
|
---|
| 3803 | +
|
---|
| 3804 | + _pprintLine_("FetchData for Options not implemented yet, ignoring option \"" << name << "\"!");
|
---|
| 3805 | +
|
---|
| 3806 | +// option=(Option*)OptionParse(name,&PyTuple_GetItem(py_tuple,(Py_ssize_t)(i+1)));
|
---|
| 3807 | +// options->AddOption(option);
|
---|
| 3808 | +// option=NULL;
|
---|
| 3809 | + }
|
---|
| 3810 | +
|
---|
| 3811 | + /*Assign output pointers:*/
|
---|
| 3812 | + *poptions=options;
|
---|
| 3813 | +}
|
---|
| 3814 | +/*}}}*/
|
---|
| 3815 | +/*FUNCTION FetchData(DataSet** pcontours,PyObject* py_list){{{*/
|
---|
| 3816 | +void FetchData(DataSet** pcontours,PyObject* py_list){
|
---|
| 3817 | +
|
---|
| 3818 | + int numcontours,test1,test2;
|
---|
| 3819 | + char *contourname = NULL;
|
---|
| 3820 | + DataSet *contours = NULL;
|
---|
| 3821 | + Contour<double> *contouri = NULL;
|
---|
| 3822 | + PyObject *py_dicti = NULL;
|
---|
| 3823 | + PyObject *py_item = NULL;
|
---|
| 3824 | +
|
---|
| 3825 | + if (PyString_Check(py_list)){
|
---|
| 3826 | + FetchData(&contourname,py_list);
|
---|
| 3827 | + contours=DomainOutlineRead<double>(contourname);
|
---|
| 3828 | + }
|
---|
| 3829 | + else if(PyList_Check(py_list)){
|
---|
| 3830 | +
|
---|
| 3831 | + contours=new DataSet(0);
|
---|
| 3832 | + numcontours=(int)PyList_Size(py_list);
|
---|
| 3833 | +
|
---|
| 3834 | + for(int i=0;i<numcontours;i++){
|
---|
| 3835 | +
|
---|
| 3836 | + contouri=xNew<Contour<double> >(1);
|
---|
| 3837 | + py_dicti=PyList_GetItem(py_list,(Py_ssize_t)i);
|
---|
| 3838 | +
|
---|
| 3839 | + py_item = PyDict_GetItemString(py_dicti,"nods");
|
---|
| 3840 | + if(!py_item) _error_("input structure does not have a 'nods' field");
|
---|
| 3841 | + FetchData(&contouri->nods,py_item);
|
---|
| 3842 | +
|
---|
| 3843 | + py_item = PyDict_GetItemString(py_dicti,"x");
|
---|
| 3844 | + if(!py_item) _error_("input structure does not have a 'x' field");
|
---|
| 3845 | + FetchData(&contouri->x,&test1,&test2,py_item);
|
---|
| 3846 | + if(test1!=contouri->nods || test2!=1) _error_("field x should be of size ["<<contouri->nods<<" 1]");
|
---|
| 3847 | +
|
---|
| 3848 | + py_item = PyDict_GetItemString(py_dicti,"y");
|
---|
| 3849 | + if(!py_item) _error_("input structure does not have a 'y' field");
|
---|
| 3850 | + FetchData(&contouri->y,&test1,&test2,py_item);
|
---|
| 3851 | + if(test1!=contouri->nods || test2!=1) _error_("field y should be of size ["<<contouri->nods<<" 1]");
|
---|
| 3852 | +
|
---|
| 3853 | + contours->AddObject(contouri);
|
---|
| 3854 | + }
|
---|
| 3855 | + }
|
---|
| 3856 | + else{
|
---|
| 3857 | + _error_("Contour is neither a string nor a structure and cannot be loaded");
|
---|
| 3858 | + }
|
---|
| 3859 | +
|
---|
| 3860 | + /*clean-up and assign output pointer*/
|
---|
| 3861 | + xDelete<char>(contourname);
|
---|
| 3862 | + *pcontours=contours;
|
---|
| 3863 | +}
|
---|
| 3864 | +/*}}}*/
|
---|
| 3865 | +
|
---|
| 3866 | +/*Python version dependent: */
|
---|
| 3867 | +#if _PYTHON_MAJOR_ >= 3
|
---|
| 3868 | +/*FUNCTION FetchData(char** pstring,PyObject* py_unicode){{{*/
|
---|
| 3869 | +void FetchData(char** pstring,PyObject* py_unicode){
|
---|
| 3870 | +
|
---|
| 3871 | + PyObject* py_bytes;
|
---|
| 3872 | + char* string=NULL;
|
---|
| 3873 | +
|
---|
| 3874 | + /*convert to bytes format: */
|
---|
| 3875 | + PyUnicode_FSConverter(py_unicode,&py_bytes);
|
---|
| 3876 | +
|
---|
| 3877 | + /*convert from bytes to string: */
|
---|
| 3878 | + string=PyBytes_AS_STRING(py_bytes);
|
---|
| 3879 | +
|
---|
| 3880 | + *pstring=string;
|
---|
| 3881 | +}
|
---|
| 3882 | +/*}}}*/
|
---|
| 3883 | +#else
|
---|
| 3884 | +/*FUNCTION FetchData(char** pstring,PyObject* py_string){{{*/
|
---|
| 3885 | +void FetchData(char** pstring,PyObject* py_string){
|
---|
| 3886 | +
|
---|
| 3887 | + char* string=NULL;
|
---|
| 3888 | +
|
---|
| 3889 | + /*extract internal string: */
|
---|
| 3890 | + string=PyString_AsString(py_string);
|
---|
| 3891 | +
|
---|
| 3892 | + /*copy string (note strlen does not include trailing NULL): */
|
---|
| 3893 | + *pstring=xNew<char>(strlen(string)+1);
|
---|
| 3894 | + memcpy(*pstring,string,(strlen(string)+1)*sizeof(char));
|
---|
| 3895 | +}
|
---|
| 3896 | +/*}}}*/
|
---|
| 3897 | +#endif
|
---|
| 3898 | Index: ../trunk-jpl/src/wrappers/python/io/WritePythonData.cpp
|
---|
| 3899 | ===================================================================
|
---|
| 3900 | --- ../trunk-jpl/src/wrappers/python/io/WritePythonData.cpp (revision 0)
|
---|
| 3901 | +++ ../trunk-jpl/src/wrappers/python/io/WritePythonData.cpp (revision 13749)
|
---|
| 3902 | @@ -0,0 +1,194 @@
|
---|
| 3903 | +/* \file WriteData.c:
|
---|
| 3904 | + * \brief: general interface for writing data
|
---|
| 3905 | + */
|
---|
| 3906 | +
|
---|
| 3907 | +#ifdef HAVE_CONFIG_H
|
---|
| 3908 | + #include <config.h>
|
---|
| 3909 | +#else
|
---|
| 3910 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 3911 | +#endif
|
---|
| 3912 | +
|
---|
| 3913 | +#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
|
---|
| 3914 | +#define NO_IMPORT
|
---|
| 3915 | +
|
---|
| 3916 | +#include "./pythonio.h"
|
---|
| 3917 | +#include "../../c/include/include.h"
|
---|
| 3918 | +#include "../../c/Container/Container.h"
|
---|
| 3919 | +#include "../../c/shared/shared.h"
|
---|
| 3920 | +#include "../../c/EnumDefinitions/EnumDefinitions.h"
|
---|
| 3921 | +
|
---|
| 3922 | +/*Primitive data types*/
|
---|
| 3923 | +/*FUNCTION WriteData(PyObject* py_tuple,int index,int integer){{{*/
|
---|
| 3924 | +void WriteData(PyObject* py_tuple, int index, int integer){
|
---|
| 3925 | +
|
---|
| 3926 | + PyTuple_SetItem(py_tuple, index, PyInt_FromSsize_t((Py_ssize_t)integer));
|
---|
| 3927 | +
|
---|
| 3928 | +}/*}}}*/
|
---|
| 3929 | +/*FUNCTION WriteData(PyObject* py_tuple,int index,char* string){{{*/
|
---|
| 3930 | +void WriteData(PyObject* py_tuple, int index, char* string){
|
---|
| 3931 | +
|
---|
| 3932 | + PyTuple_SetItem(py_tuple, index, PyUnicode_FromString(string));
|
---|
| 3933 | +
|
---|
| 3934 | +}/*}}}*/
|
---|
| 3935 | +/*FUNCTION WriteData(PyObject* py_tuple,int index, double* matrix, int M, int N){{{*/
|
---|
| 3936 | +void WriteData(PyObject* tuple, int index, double* matrix, int M,int N){
|
---|
| 3937 | +
|
---|
| 3938 | + npy_intp dims[2]={0,0};
|
---|
| 3939 | + PyObject* array=NULL;
|
---|
| 3940 | +
|
---|
| 3941 | + dims[0]=(npy_intp)M;
|
---|
| 3942 | + dims[1]=(npy_intp)N;
|
---|
| 3943 | + array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,matrix);
|
---|
| 3944 | +
|
---|
| 3945 | + PyTuple_SetItem(tuple, index, array);
|
---|
| 3946 | +}/*}}}*/
|
---|
| 3947 | +/*FUNCTION WriteData(PyObject* py_tuple,int index){{{*/
|
---|
| 3948 | +void WriteData(PyObject* py_tuple, int index){
|
---|
| 3949 | +
|
---|
| 3950 | + PyTuple_SetItem(py_tuple, index, Py_None);
|
---|
| 3951 | +
|
---|
| 3952 | +}/*}}}*/
|
---|
| 3953 | +
|
---|
| 3954 | +/*ISSM objects*/
|
---|
| 3955 | +/*FUNCTION WriteData(PyObject* py_tuple,int index,BamgGeom* bamggeom){{{*/
|
---|
| 3956 | +void WriteData(PyObject* py_tuple,int index,BamgGeom* bamggeom){
|
---|
| 3957 | +
|
---|
| 3958 | + PyObject* dict=NULL;
|
---|
| 3959 | +
|
---|
| 3960 | + dict=PyDict_New();
|
---|
| 3961 | +
|
---|
| 3962 | + PyDict_SetItemString(dict,"Vertices",PyArrayFromCopiedData(bamggeom->VerticesSize,bamggeom->Vertices));
|
---|
| 3963 | + PyDict_SetItemString(dict,"Edges",PyArrayFromCopiedData(bamggeom->EdgesSize,bamggeom->Edges));
|
---|
| 3964 | + PyDict_SetItemString(dict,"TangentAtEdges",PyArrayFromCopiedData(bamggeom->TangentAtEdgesSize,bamggeom->TangentAtEdges));
|
---|
| 3965 | + PyDict_SetItemString(dict,"Corners",PyArrayFromCopiedData(bamggeom->CornersSize,bamggeom->Corners));
|
---|
| 3966 | + PyDict_SetItemString(dict,"RequiredVertices",PyArrayFromCopiedData(bamggeom->RequiredVerticesSize,bamggeom->RequiredVertices));
|
---|
| 3967 | + PyDict_SetItemString(dict,"RequiredEdges",PyArrayFromCopiedData(bamggeom->RequiredEdgesSize,bamggeom->RequiredEdges));
|
---|
| 3968 | + PyDict_SetItemString(dict,"CrackedEdges",PyArrayFromCopiedData(bamggeom->CrackedEdgesSize,bamggeom->CrackedEdges));
|
---|
| 3969 | + PyDict_SetItemString(dict,"SubDomains",PyArrayFromCopiedData(bamggeom->SubDomainsSize,bamggeom->SubDomains));
|
---|
| 3970 | +
|
---|
| 3971 | + PyTuple_SetItem(py_tuple, index, dict);
|
---|
| 3972 | +}
|
---|
| 3973 | +/*}}}*/
|
---|
| 3974 | +/*FUNCTION WriteData(PyObject* py_tuple,int index,BamgMesh* bamgmesh){{{*/
|
---|
| 3975 | +void WriteData(PyObject* py_tuple,int index,BamgMesh* bamgmesh){
|
---|
| 3976 | +
|
---|
| 3977 | + PyObject* dict=NULL;
|
---|
| 3978 | +
|
---|
| 3979 | + dict=PyDict_New();
|
---|
| 3980 | +
|
---|
| 3981 | + PyDict_SetItemString(dict,"Vertices",PyArrayFromCopiedData(bamgmesh->VerticesSize,bamgmesh->Vertices));
|
---|
| 3982 | + PyDict_SetItemString(dict,"Edges",PyArrayFromCopiedData(bamgmesh->EdgesSize,bamgmesh->Edges));
|
---|
| 3983 | + PyDict_SetItemString(dict,"Triangles",PyArrayFromCopiedData(bamgmesh->TrianglesSize,bamgmesh->Triangles));
|
---|
| 3984 | + PyDict_SetItemString(dict,"Quadrilaterals",PyArrayFromCopiedData(bamgmesh->QuadrilateralsSize,bamgmesh->Quadrilaterals));
|
---|
| 3985 | + PyDict_SetItemString(dict,"IssmEdges",PyArrayFromCopiedData(bamgmesh->IssmEdgesSize,bamgmesh->IssmEdges));
|
---|
| 3986 | + PyDict_SetItemString(dict,"IssmSegments",PyArrayFromCopiedData(bamgmesh->IssmSegmentsSize,bamgmesh->IssmSegments));
|
---|
| 3987 | + PyDict_SetItemString(dict,"VerticesOnGeomVertex",PyArrayFromCopiedData(bamgmesh->VerticesOnGeomVertexSize,bamgmesh->VerticesOnGeomVertex));
|
---|
| 3988 | + PyDict_SetItemString(dict,"VerticesOnGeomEdge",PyArrayFromCopiedData(bamgmesh->VerticesOnGeomEdgeSize,bamgmesh->VerticesOnGeomEdge));
|
---|
| 3989 | + PyDict_SetItemString(dict,"EdgesOnGeomEdge",PyArrayFromCopiedData(bamgmesh->EdgesOnGeomEdgeSize,bamgmesh->EdgesOnGeomEdge));
|
---|
| 3990 | + PyDict_SetItemString(dict,"SubDomains",PyArrayFromCopiedData(bamgmesh->SubDomainsSize,bamgmesh->SubDomains));
|
---|
| 3991 | + PyDict_SetItemString(dict,"SubDomainsFromGeom",PyArrayFromCopiedData(bamgmesh->SubDomainsFromGeomSize,bamgmesh->SubDomainsFromGeom));
|
---|
| 3992 | + PyDict_SetItemString(dict,"ElementConnectivity",PyArrayFromCopiedData(bamgmesh->ElementConnectivitySize,bamgmesh->ElementConnectivity));
|
---|
| 3993 | + PyDict_SetItemString(dict,"NodalConnectivity",PyArrayFromCopiedData(bamgmesh->NodalConnectivitySize,bamgmesh->NodalConnectivity));
|
---|
| 3994 | + PyDict_SetItemString(dict,"NodalElementConnectivity",PyArrayFromCopiedData(bamgmesh->NodalElementConnectivitySize,bamgmesh->NodalElementConnectivity));
|
---|
| 3995 | + PyDict_SetItemString(dict,"CrackedVertices",PyArrayFromCopiedData(bamgmesh->CrackedVerticesSize,bamgmesh->CrackedVertices));
|
---|
| 3996 | + PyDict_SetItemString(dict,"CrackedEdges",PyArrayFromCopiedData(bamgmesh->CrackedEdgesSize,bamgmesh->CrackedEdges));
|
---|
| 3997 | +
|
---|
| 3998 | + PyTuple_SetItem(py_tuple, index, dict);
|
---|
| 3999 | +}
|
---|
| 4000 | +/*}}}*/
|
---|
| 4001 | +/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqMat<double>* matrix){{{*/
|
---|
| 4002 | +void WriteData(PyObject* py_tuple,int index,SeqMat<double>* matrix){
|
---|
| 4003 | +
|
---|
| 4004 | + int M,N;
|
---|
| 4005 | + double* buffer=NULL;
|
---|
| 4006 | + npy_intp dims[2]={0,0};
|
---|
| 4007 | + PyObject* array=NULL;
|
---|
| 4008 | +
|
---|
| 4009 | + buffer=matrix->ToSerial();
|
---|
| 4010 | + matrix->GetSize(&M,&N);
|
---|
| 4011 | + dims[0]=(npy_intp)M;
|
---|
| 4012 | + dims[1]=(npy_intp)N;
|
---|
| 4013 | + array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,buffer);
|
---|
| 4014 | +
|
---|
| 4015 | + PyTuple_SetItem(py_tuple, index, array);
|
---|
| 4016 | +
|
---|
| 4017 | +}/*}}}*/
|
---|
| 4018 | +/*FUNCTION WriteData(PyObject* py_tuple,int index,SeqVec<double>* vector){{{*/
|
---|
| 4019 | +void WriteData(PyObject* py_tuple,int index,SeqVec<double>* vector){
|
---|
| 4020 | +
|
---|
| 4021 | + int M;
|
---|
| 4022 | + double* buffer=NULL;
|
---|
| 4023 | + npy_intp dim=10;
|
---|
| 4024 | + PyObject* array=NULL;
|
---|
| 4025 | +
|
---|
| 4026 | + buffer=vector->ToMPISerial();
|
---|
| 4027 | + vector->GetSize(&M);
|
---|
| 4028 | + dim=(npy_intp)M;
|
---|
| 4029 | + array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE,buffer);
|
---|
| 4030 | +
|
---|
| 4031 | + PyTuple_SetItem(py_tuple, index, array);
|
---|
| 4032 | +}
|
---|
| 4033 | +/*}}}*/
|
---|
| 4034 | +/*FUNCTION WriteData(PyObject* py_tuple,int index,RiftStruct* riftstruct){{{*/
|
---|
| 4035 | +void WriteData(PyObject* py_tuple,int index,RiftStruct* riftstruct){
|
---|
| 4036 | +
|
---|
| 4037 | + int i;
|
---|
| 4038 | + PyObject* list=NULL;
|
---|
| 4039 | + PyObject* dict=NULL;
|
---|
| 4040 | +
|
---|
| 4041 | + list=PyList_New((Py_ssize_t)0);
|
---|
| 4042 | +
|
---|
| 4043 | + for (i=0; i<riftstruct->numrifts; i++) {
|
---|
| 4044 | + dict=PyDict_New();
|
---|
| 4045 | +
|
---|
| 4046 | + PyDict_SetItemString(dict,"numsegs" ,PyInt_FromSsize_t((Py_ssize_t)riftstruct->riftsnumsegments[i]));
|
---|
| 4047 | + PyDict_SetItemString(dict,"segments" ,PyArrayFromCopiedData(riftstruct->riftsnumsegments[i] ,3,riftstruct->riftssegments[i]));
|
---|
| 4048 | + PyDict_SetItemString(dict,"pairs" ,PyArrayFromCopiedData(riftstruct->riftsnumpairs[i] ,2,riftstruct->riftspairs[i]));
|
---|
| 4049 | + PyDict_SetItemString(dict,"tips" ,PyArrayFromCopiedData(1 ,2,&riftstruct->riftstips[2*i]));
|
---|
| 4050 | + PyDict_SetItemString(dict,"penaltypairs" ,PyArrayFromCopiedData(riftstruct->riftsnumpenaltypairs[i],7,riftstruct->riftspenaltypairs[i]));
|
---|
| 4051 | + PyDict_SetItemString(dict,"fill" ,PyInt_FromSsize_t((Py_ssize_t)IceEnum));
|
---|
| 4052 | + PyDict_SetItemString(dict,"friction" ,PyInt_FromSsize_t((Py_ssize_t)0));
|
---|
| 4053 | + PyDict_SetItemString(dict,"fraction" ,PyFloat_FromDouble(0.));
|
---|
| 4054 | + PyDict_SetItemString(dict,"fractionincrement",PyFloat_FromDouble(0.1));
|
---|
| 4055 | + PyDict_SetItemString(dict,"state" ,PyArrayFromCopiedData(riftstruct->riftsnumpenaltypairs[i],1,riftstruct->state[i]));
|
---|
| 4056 | +
|
---|
| 4057 | + PyList_Append(list, dict);
|
---|
| 4058 | + }
|
---|
| 4059 | +
|
---|
| 4060 | + PyTuple_SetItem(py_tuple, index, list);
|
---|
| 4061 | +}
|
---|
| 4062 | +/*}}}*/
|
---|
| 4063 | +
|
---|
| 4064 | +/*Utils*/
|
---|
| 4065 | +/*FUNCTION PyArrayFromCopiedData(int dims[2],double* data){{{*/
|
---|
| 4066 | +PyObject* PyArrayFromCopiedData(int dims[2],double* data){
|
---|
| 4067 | +
|
---|
| 4068 | + double* pydata;
|
---|
| 4069 | + npy_intp pydims[2]={0,0};
|
---|
| 4070 | +
|
---|
| 4071 | + /* note that PyArray_SimpleNewFromData does not copy the data, so that when the original
|
---|
| 4072 | + object (e.g. bamggeom,bamgmesh) is deleted, the data is gone. */
|
---|
| 4073 | +
|
---|
| 4074 | + pydims[0]=(npy_intp)dims[0];
|
---|
| 4075 | + pydims[1]=(npy_intp)dims[1];
|
---|
| 4076 | + pydata=xNew<IssmDouble>(dims[0]*dims[1]);
|
---|
| 4077 | + memcpy(pydata,data,dims[0]*dims[1]*sizeof(double));
|
---|
| 4078 | + return PyArray_SimpleNewFromData(2,pydims,NPY_DOUBLE,pydata);
|
---|
| 4079 | +}
|
---|
| 4080 | +/*}}}*/
|
---|
| 4081 | +/*FUNCTION PyArrayFromCopiedData(int dimi,int dimj,double* data){{{*/
|
---|
| 4082 | +PyObject* PyArrayFromCopiedData(int dimi,int dimj,double* data){
|
---|
| 4083 | +
|
---|
| 4084 | + double* pydata;
|
---|
| 4085 | + npy_intp pydims[2]={0,0};
|
---|
| 4086 | +
|
---|
| 4087 | + /* note that PyArray_SimpleNewFromData does not copy the data, so that when the original
|
---|
| 4088 | + object (e.g. bamggeom,bamgmesh) is deleted, the data is gone. */
|
---|
| 4089 | +
|
---|
| 4090 | + pydims[0]=(npy_intp)dimi;
|
---|
| 4091 | + pydims[1]=(npy_intp)dimj;
|
---|
| 4092 | + pydata=xNew<IssmDouble>(dimi*dimj);
|
---|
| 4093 | + memcpy(pydata,data,dimi*dimj*sizeof(double));
|
---|
| 4094 | + return PyArray_SimpleNewFromData(2,pydims,NPY_DOUBLE,pydata);
|
---|
| 4095 | +}
|
---|
| 4096 | +/*}}}*/
|
---|
| 4097 | Index: ../trunk-jpl/src/wrappers/python/Makefile.am
|
---|
| 4098 | ===================================================================
|
---|
| 4099 | --- ../trunk-jpl/src/wrappers/python/Makefile.am (revision 13748)
|
---|
| 4100 | +++ ../trunk-jpl/src/wrappers/python/Makefile.am (revision 13749)
|
---|
| 4101 | @@ -1,7 +1,28 @@
|
---|
| 4102 | -AM_CPPFLAGS = @DAKOTAINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
|
---|
| 4103 | +AM_CPPFLAGS = @DAKOTAINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@
|
---|
| 4104 |
|
---|
| 4105 | EXEEXT=$(PYTHONWRAPPEREXT)
|
---|
| 4106 |
|
---|
| 4107 | +#python io{{{
|
---|
| 4108 | +lib_LIBRARIES = libISSMPython.a
|
---|
| 4109 | +if SHAREDLIBS
|
---|
| 4110 | +lib_LTLIBRARIES = libISSMPython.la
|
---|
| 4111 | +else
|
---|
| 4112 | + lib_LTLIBRARIES =
|
---|
| 4113 | +endif
|
---|
| 4114 | +
|
---|
| 4115 | +io_sources= ./include/pythonincludes.h\
|
---|
| 4116 | + ./io/pythonio.h\
|
---|
| 4117 | + ./io/WritePythonData.cpp\
|
---|
| 4118 | + ./io/CheckNumPythonArguments.cpp\
|
---|
| 4119 | + ./io/FetchPythonData.cpp
|
---|
| 4120 | +
|
---|
| 4121 | +ALLCXXFLAGS= -fPIC -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_ $(CXXFLAGS) $(CXXOPTFLAGS)
|
---|
| 4122 | +libISSMPython_a_SOURCES = $(io_sources)
|
---|
| 4123 | +libISSMPython_a_CXXFLAGS= $(ALLCXXFLAGS)
|
---|
| 4124 | +if SHAREDLIBS
|
---|
| 4125 | +libISSMPython_la_SOURCES = $(io_sources)
|
---|
| 4126 | +endif
|
---|
| 4127 | +#}}}
|
---|
| 4128 | #Wrappers {{{
|
---|
| 4129 | if WRAPPERS
|
---|
| 4130 | lib_LTLIBRARIES = BamgConvertMesh.la\
|
---|
| 4131 | @@ -37,9 +58,9 @@
|
---|
| 4132 | AM_LDFLAGS += -avoid-version
|
---|
| 4133 | endif
|
---|
| 4134 | if SHAREDLIBS
|
---|
| 4135 | -deps += ../../c/libISSMPython.la
|
---|
| 4136 | +deps += ./libISSMPython.la
|
---|
| 4137 | else
|
---|
| 4138 | -deps += ../../c/libISSMPython.a
|
---|
| 4139 | +deps += ./libISSMPython.a
|
---|
| 4140 | AM_LDFLAGS += --no-warnings
|
---|
| 4141 | endif
|
---|
| 4142 |
|
---|
| 4143 | Index: ../trunk-jpl/src/wrappers/Scotch/Scotch.h
|
---|
| 4144 | ===================================================================
|
---|
| 4145 | --- ../trunk-jpl/src/wrappers/Scotch/Scotch.h (revision 13748)
|
---|
| 4146 | +++ ../trunk-jpl/src/wrappers/Scotch/Scotch.h (revision 13749)
|
---|
| 4147 | @@ -12,7 +12,7 @@
|
---|
| 4148 | #include "../../c/modules/modules.h"
|
---|
| 4149 | #include "../../c/Container/Container.h"
|
---|
| 4150 | #include "../../c/shared/shared.h"
|
---|
| 4151 | -#include "../../c/issm-binding.h"
|
---|
| 4152 | +#include "../bindings.h"
|
---|
| 4153 |
|
---|
| 4154 | #undef __FUNCT__
|
---|
| 4155 | #define __FUNCT__ "Scotch"
|
---|
| 4156 | Index: ../trunk-jpl/src/wrappers/NodeConnectivity/NodeConnectivity.h
|
---|
| 4157 | ===================================================================
|
---|
| 4158 | --- ../trunk-jpl/src/wrappers/NodeConnectivity/NodeConnectivity.h (revision 13748)
|
---|
| 4159 | +++ ../trunk-jpl/src/wrappers/NodeConnectivity/NodeConnectivity.h (revision 13749)
|
---|
| 4160 | @@ -26,7 +26,7 @@
|
---|
| 4161 | #include "../../c/modules/modules.h"
|
---|
| 4162 | #include "../../c/Container/Container.h"
|
---|
| 4163 | #include "../../c/shared/shared.h"
|
---|
| 4164 | -#include "../../c/issm-binding.h"
|
---|
| 4165 | +#include "../bindings.h"
|
---|
| 4166 | #include "../../c/io/io.h"
|
---|
| 4167 | #include "../../c/EnumDefinitions/EnumDefinitions.h"
|
---|
| 4168 |
|
---|
| 4169 | Index: ../trunk-jpl/src/wrappers/BamgConvertMesh/BamgConvertMesh.h
|
---|
| 4170 | ===================================================================
|
---|
| 4171 | --- ../trunk-jpl/src/wrappers/BamgConvertMesh/BamgConvertMesh.h (revision 13748)
|
---|
| 4172 | +++ ../trunk-jpl/src/wrappers/BamgConvertMesh/BamgConvertMesh.h (revision 13749)
|
---|
| 4173 | @@ -20,7 +20,7 @@
|
---|
| 4174 | #include "../../c/modules/modules.h"
|
---|
| 4175 | #include "../../c/Container/Container.h"
|
---|
| 4176 | #include "../../c/shared/shared.h"
|
---|
| 4177 | -#include "../../c/issm-binding.h"
|
---|
| 4178 | +#include "../bindings.h"
|
---|
| 4179 | #include "../../c/io/io.h"
|
---|
| 4180 |
|
---|
| 4181 | #undef __FUNCT__
|
---|
| 4182 | Index: ../trunk-jpl/src/wrappers/KMLOverlay/KMLOverlay.h
|
---|
| 4183 | ===================================================================
|
---|
| 4184 | --- ../trunk-jpl/src/wrappers/KMLOverlay/KMLOverlay.h (revision 13748)
|
---|
| 4185 | +++ ../trunk-jpl/src/wrappers/KMLOverlay/KMLOverlay.h (revision 13749)
|
---|
| 4186 | @@ -20,7 +20,7 @@
|
---|
| 4187 | #include "../../c/modules/modules.h"
|
---|
| 4188 | #include "../../c/Container/Container.h"
|
---|
| 4189 | #include "../../c/shared/shared.h"
|
---|
| 4190 | -#include "../../c/issm-binding.h"
|
---|
| 4191 | +#include "../bindings.h"
|
---|
| 4192 |
|
---|
| 4193 | #undef __FUNCT__
|
---|
| 4194 | #define __FUNCT__ "KMLOverlay"
|
---|
| 4195 | Index: ../trunk-jpl/src/wrappers/ContourToNodes/ContourToNodes.h
|
---|
| 4196 | ===================================================================
|
---|
| 4197 | --- ../trunk-jpl/src/wrappers/ContourToNodes/ContourToNodes.h (revision 13748)
|
---|
| 4198 | +++ ../trunk-jpl/src/wrappers/ContourToNodes/ContourToNodes.h (revision 13749)
|
---|
| 4199 | @@ -20,7 +20,7 @@
|
---|
| 4200 | #include "../../c/modules/modules.h"
|
---|
| 4201 | #include "../../c/Container/Container.h"
|
---|
| 4202 | #include "../../c/shared/shared.h"
|
---|
| 4203 | -#include "../../c/issm-binding.h"
|
---|
| 4204 | +#include "../bindings.h"
|
---|
| 4205 |
|
---|
| 4206 | #undef __FUNCT__
|
---|
| 4207 | #define __FUNCT__ "ContourToNodes"
|
---|
| 4208 | Index: ../trunk-jpl/src/wrappers/HoleFiller/HoleFiller.h
|
---|
| 4209 | ===================================================================
|
---|
| 4210 | --- ../trunk-jpl/src/wrappers/HoleFiller/HoleFiller.h (revision 13748)
|
---|
| 4211 | +++ ../trunk-jpl/src/wrappers/HoleFiller/HoleFiller.h (revision 13749)
|
---|
| 4212 | @@ -20,7 +20,7 @@
|
---|
| 4213 | #include "../../c/modules/modules.h"
|
---|
| 4214 | #include "../../c/Container/Container.h"
|
---|
| 4215 | #include "../../c/shared/shared.h"
|
---|
| 4216 | -#include "../../c/issm-binding.h"
|
---|
| 4217 | +#include "../bindings.h"
|
---|
| 4218 |
|
---|
| 4219 | #undef __FUNCT__
|
---|
| 4220 | #define __FUNCT__ "HoleFiller"
|
---|
| 4221 | Index: ../trunk-jpl/src/wrappers/MeshProfileIntersection/MeshProfileIntersection.h
|
---|
| 4222 | ===================================================================
|
---|
| 4223 | --- ../trunk-jpl/src/wrappers/MeshProfileIntersection/MeshProfileIntersection.h (revision 13748)
|
---|
| 4224 | +++ ../trunk-jpl/src/wrappers/MeshProfileIntersection/MeshProfileIntersection.h (revision 13749)
|
---|
| 4225 | @@ -20,7 +20,7 @@
|
---|
| 4226 | #include "../../c/modules/modules.h"
|
---|
| 4227 | #include "../../c/Container/Container.h"
|
---|
| 4228 | #include "../../c/shared/shared.h"
|
---|
| 4229 | -#include "../../c/issm-binding.h"
|
---|
| 4230 | +#include "../bindings.h"
|
---|
| 4231 |
|
---|
| 4232 | #undef __FUNCT__
|
---|
| 4233 | #define __FUNCT__ "MeshProfileIntersection"
|
---|
| 4234 | Index: ../trunk-jpl/src/wrappers/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h
|
---|
| 4235 | ===================================================================
|
---|
| 4236 | --- ../trunk-jpl/src/wrappers/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h (revision 13748)
|
---|
| 4237 | +++ ../trunk-jpl/src/wrappers/InterpFromMeshToMesh3d/InterpFromMeshToMesh3d.h (revision 13749)
|
---|
| 4238 | @@ -20,7 +20,7 @@
|
---|
| 4239 | #include "../../c/modules/modules.h"
|
---|
| 4240 | #include "../../c/Container/Container.h"
|
---|
| 4241 | #include "../../c/shared/shared.h"
|
---|
| 4242 | -#include "../../c/issm-binding.h"
|
---|
| 4243 | +#include "../bindings.h"
|
---|
| 4244 |
|
---|
| 4245 | #undef __FUNCT__
|
---|
| 4246 | #define __FUNCT__ "InterpFromMeshToMesh3d"
|
---|
| 4247 | Index: ../trunk-jpl/src/wrappers/Ll2xy/Ll2xy.h
|
---|
| 4248 | ===================================================================
|
---|
| 4249 | --- ../trunk-jpl/src/wrappers/Ll2xy/Ll2xy.h (revision 13748)
|
---|
| 4250 | +++ ../trunk-jpl/src/wrappers/Ll2xy/Ll2xy.h (revision 13749)
|
---|
| 4251 | @@ -20,7 +20,7 @@
|
---|
| 4252 | #include "../../c/modules/modules.h"
|
---|
| 4253 | #include "../../c/Container/Container.h"
|
---|
| 4254 | #include "../../c/shared/shared.h"
|
---|
| 4255 | -#include "../../c/issm-binding.h"
|
---|
| 4256 | +#include "../bindings.h"
|
---|
| 4257 |
|
---|
| 4258 | #undef __FUNCT__
|
---|
| 4259 | #define __FUNCT__ "Ll2xy"
|
---|
| 4260 | Index: ../trunk-jpl/src/wrappers/BamgMesher/BamgMesher.h
|
---|
| 4261 | ===================================================================
|
---|
| 4262 | --- ../trunk-jpl/src/wrappers/BamgMesher/BamgMesher.h (revision 13748)
|
---|
| 4263 | +++ ../trunk-jpl/src/wrappers/BamgMesher/BamgMesher.h (revision 13749)
|
---|
| 4264 | @@ -20,7 +20,7 @@
|
---|
| 4265 | #include "../../c/modules/modules.h"
|
---|
| 4266 | #include "../../c/Container/Container.h"
|
---|
| 4267 | #include "../../c/shared/shared.h"
|
---|
| 4268 | -#include "../../c/issm-binding.h"
|
---|
| 4269 | +#include "../bindings.h"
|
---|
| 4270 |
|
---|
| 4271 | #undef __FUNCT__
|
---|
| 4272 | #define __FUNCT__ "BamgMesher"
|
---|
| 4273 | Index: ../trunk-jpl/src/wrappers/InterpFromGridToMesh/InterpFromGridToMesh.h
|
---|
| 4274 | ===================================================================
|
---|
| 4275 | --- ../trunk-jpl/src/wrappers/InterpFromGridToMesh/InterpFromGridToMesh.h (revision 13748)
|
---|
| 4276 | +++ ../trunk-jpl/src/wrappers/InterpFromGridToMesh/InterpFromGridToMesh.h (revision 13749)
|
---|
| 4277 | @@ -20,7 +20,7 @@
|
---|
| 4278 | #include "../../c/modules/modules.h"
|
---|
| 4279 | #include "../../c/Container/Container.h"
|
---|
| 4280 | #include "../../c/shared/shared.h"
|
---|
| 4281 | -#include "../../c/issm-binding.h"
|
---|
| 4282 | +#include "../bindings.h"
|
---|
| 4283 |
|
---|
| 4284 | #undef __FUNCT__
|
---|
| 4285 | #define __FUNCT__ "InterpFromGridToMesh"
|
---|
| 4286 | Index: ../trunk-jpl/src/wrappers/InterpFromMeshToGrid/InterpFromMeshToGrid.h
|
---|
| 4287 | ===================================================================
|
---|
| 4288 | --- ../trunk-jpl/src/wrappers/InterpFromMeshToGrid/InterpFromMeshToGrid.h (revision 13748)
|
---|
| 4289 | +++ ../trunk-jpl/src/wrappers/InterpFromMeshToGrid/InterpFromMeshToGrid.h (revision 13749)
|
---|
| 4290 | @@ -20,7 +20,7 @@
|
---|
| 4291 | #include "../../c/modules/modules.h"
|
---|
| 4292 | #include "../../c/Container/Container.h"
|
---|
| 4293 | #include "../../c/shared/shared.h"
|
---|
| 4294 | -#include "../../c/issm-binding.h"
|
---|
| 4295 | +#include "../bindings.h"
|
---|
| 4296 |
|
---|
| 4297 | #undef __FUNCT__
|
---|
| 4298 | #define __FUNCT__ "InterpFromMeshToGrid"
|
---|
| 4299 | Index: ../trunk-jpl/src/wrappers/KMLFileRead/KMLFileRead.h
|
---|
| 4300 | ===================================================================
|
---|
| 4301 | --- ../trunk-jpl/src/wrappers/KMLFileRead/KMLFileRead.h (revision 13748)
|
---|
| 4302 | +++ ../trunk-jpl/src/wrappers/KMLFileRead/KMLFileRead.h (revision 13749)
|
---|
| 4303 | @@ -20,7 +20,7 @@
|
---|
| 4304 | #include "../../c/modules/modules.h"
|
---|
| 4305 | #include "../../c/Container/Container.h"
|
---|
| 4306 | #include "../../c/shared/shared.h"
|
---|
| 4307 | -#include "../../c/issm-binding.h"
|
---|
| 4308 | +#include "../bindings.h"
|
---|
| 4309 |
|
---|
| 4310 | #undef __FUNCT__
|
---|
| 4311 | #define __FUNCT__ "KMLFileRead"
|
---|
| 4312 | Index: ../trunk-jpl/src/wrappers/Shp2Kml/Shp2Kml.h
|
---|
| 4313 | ===================================================================
|
---|
| 4314 | --- ../trunk-jpl/src/wrappers/Shp2Kml/Shp2Kml.h (revision 13748)
|
---|
| 4315 | +++ ../trunk-jpl/src/wrappers/Shp2Kml/Shp2Kml.h (revision 13749)
|
---|
| 4316 | @@ -20,7 +20,7 @@
|
---|
| 4317 | #include "../../c/modules/modules.h"
|
---|
| 4318 | #include "../../c/Container/Container.h"
|
---|
| 4319 | #include "../../c/shared/shared.h"
|
---|
| 4320 | -#include "../../c/issm-binding.h"
|
---|
| 4321 | +#include "../bindings.h"
|
---|
| 4322 |
|
---|
| 4323 | #undef __FUNCT__
|
---|
| 4324 | #define __FUNCT__ "Shp2Kml"
|
---|
| 4325 | Index: ../trunk-jpl/src/wrappers/AverageFilter/AverageFilter.h
|
---|
| 4326 | ===================================================================
|
---|
| 4327 | --- ../trunk-jpl/src/wrappers/AverageFilter/AverageFilter.h (revision 13748)
|
---|
| 4328 | +++ ../trunk-jpl/src/wrappers/AverageFilter/AverageFilter.h (revision 13749)
|
---|
| 4329 | @@ -20,7 +20,7 @@
|
---|
| 4330 | #include "../../c/modules/modules.h"
|
---|
| 4331 | #include "../../c/Container/Container.h"
|
---|
| 4332 | #include "../../c/shared/shared.h"
|
---|
| 4333 | -#include "../../c/issm-binding.h"
|
---|
| 4334 | +#include "../bindings.h"
|
---|
| 4335 |
|
---|
| 4336 | #undef __FUNCT__
|
---|
| 4337 | #define __FUNCT__ "AverageFilter"
|
---|
| 4338 | Index: ../trunk-jpl/src/wrappers/TriMeshProcessRifts/TriMeshProcessRifts.h
|
---|
| 4339 | ===================================================================
|
---|
| 4340 | --- ../trunk-jpl/src/wrappers/TriMeshProcessRifts/TriMeshProcessRifts.h (revision 13748)
|
---|
| 4341 | +++ ../trunk-jpl/src/wrappers/TriMeshProcessRifts/TriMeshProcessRifts.h (revision 13749)
|
---|
| 4342 | @@ -20,7 +20,7 @@
|
---|
| 4343 | #include "../../c/modules/modules.h"
|
---|
| 4344 | #include "../../c/Container/Container.h"
|
---|
| 4345 | #include "../../c/shared/shared.h"
|
---|
| 4346 | -#include "../../c/issm-binding.h"
|
---|
| 4347 | +#include "../bindings.h"
|
---|
| 4348 |
|
---|
| 4349 | #undef __FUNCT__
|
---|
| 4350 | #define __FUNCT__ "TriMeshProcessRifts"
|
---|
| 4351 | Index: ../trunk-jpl/src/wrappers/Exp2Kml/Exp2Kml.h
|
---|
| 4352 | ===================================================================
|
---|
| 4353 | --- ../trunk-jpl/src/wrappers/Exp2Kml/Exp2Kml.h (revision 13748)
|
---|
| 4354 | +++ ../trunk-jpl/src/wrappers/Exp2Kml/Exp2Kml.h (revision 13749)
|
---|
| 4355 | @@ -20,7 +20,7 @@
|
---|
| 4356 | #include "../../c/modules/modules.h"
|
---|
| 4357 | #include "../../c/Container/Container.h"
|
---|
| 4358 | #include "../../c/shared/shared.h"
|
---|
| 4359 | -#include "../../c/issm-binding.h"
|
---|
| 4360 | +#include "../bindings.h"
|
---|
| 4361 |
|
---|
| 4362 | #undef __FUNCT__
|
---|
| 4363 | #define __FUNCT__ "Exp2Kml"
|
---|
| 4364 | Index: ../trunk-jpl/src/wrappers/Kml2Exp/Kml2Exp.h
|
---|
| 4365 | ===================================================================
|
---|
| 4366 | --- ../trunk-jpl/src/wrappers/Kml2Exp/Kml2Exp.h (revision 13748)
|
---|
| 4367 | +++ ../trunk-jpl/src/wrappers/Kml2Exp/Kml2Exp.h (revision 13749)
|
---|
| 4368 | @@ -20,7 +20,7 @@
|
---|
| 4369 | #include "../../c/modules/modules.h"
|
---|
| 4370 | #include "../../c/Container/Container.h"
|
---|
| 4371 | #include "../../c/shared/shared.h"
|
---|
| 4372 | -#include "../../c/issm-binding.h"
|
---|
| 4373 | +#include "../bindings.h"
|
---|
| 4374 |
|
---|
| 4375 | #undef __FUNCT__
|
---|
| 4376 | #define __FUNCT__ "Kml2Exp"
|
---|
| 4377 | Index: ../trunk-jpl/src/wrappers/PointCloudFindNeighbors/PointCloudFindNeighbors.h
|
---|
| 4378 | ===================================================================
|
---|
| 4379 | --- ../trunk-jpl/src/wrappers/PointCloudFindNeighbors/PointCloudFindNeighbors.h (revision 13748)
|
---|
| 4380 | +++ ../trunk-jpl/src/wrappers/PointCloudFindNeighbors/PointCloudFindNeighbors.h (revision 13749)
|
---|
| 4381 | @@ -20,7 +20,7 @@
|
---|
| 4382 | #include "../../c/modules/modules.h"
|
---|
| 4383 | #include "../../c/Container/Container.h"
|
---|
| 4384 | #include "../../c/shared/shared.h"
|
---|
| 4385 | -#include "../../c/issm-binding.h"
|
---|
| 4386 | +#include "../bindings.h"
|
---|
| 4387 |
|
---|
| 4388 | #undef __FUNCT__
|
---|
| 4389 | #define __FUNCT__ "PointCloudFindNeighbors"
|
---|
| 4390 | Index: ../trunk-jpl/src/wrappers/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h
|
---|
| 4391 | ===================================================================
|
---|
| 4392 | --- ../trunk-jpl/src/wrappers/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h (revision 13748)
|
---|
| 4393 | +++ ../trunk-jpl/src/wrappers/PropagateFlagsFromConnectivity/PropagateFlagsFromConnectivity.h (revision 13749)
|
---|
| 4394 | @@ -20,7 +20,7 @@
|
---|
| 4395 | #include "../../c/modules/modules.h"
|
---|
| 4396 | #include "../../c/Container/Container.h"
|
---|
| 4397 | #include "../../c/shared/shared.h"
|
---|
| 4398 | -#include "../../c/issm-binding.h"
|
---|
| 4399 | +#include "../bindings.h"
|
---|
| 4400 |
|
---|
| 4401 | #undef __FUNCT__
|
---|
| 4402 | #define __FUNCT__ "PropagateFlagsFromConnectivity"
|
---|
| 4403 | Index: ../trunk-jpl/src/wrappers/include/issm-binding.h
|
---|
| 4404 | ===================================================================
|
---|
| 4405 | --- ../trunk-jpl/src/wrappers/include/issm-binding.h (revision 0)
|
---|
| 4406 | +++ ../trunk-jpl/src/wrappers/include/issm-binding.h (revision 13749)
|
---|
| 4407 | @@ -0,0 +1,18 @@
|
---|
| 4408 | +#ifndef _ISSM_BINDING_H_
|
---|
| 4409 | +#define _ISSM_BINDING_H_
|
---|
| 4410 | +
|
---|
| 4411 | +#ifdef HAVE_CONFIG_H
|
---|
| 4412 | + #include <config.h>
|
---|
| 4413 | +#else
|
---|
| 4414 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 4415 | +#endif
|
---|
| 4416 | +
|
---|
| 4417 | +#ifdef _HAVE_MATLAB_MODULES_
|
---|
| 4418 | +#include "../matlab/include/matlab-macros.h"
|
---|
| 4419 | +#endif
|
---|
| 4420 | +
|
---|
| 4421 | +#ifdef _HAVE_PYTHON_MODULES_
|
---|
| 4422 | +#include "../python/include/python-macros.h"
|
---|
| 4423 | +#endif
|
---|
| 4424 | +
|
---|
| 4425 | +#endif
|
---|
| 4426 | Index: ../trunk-jpl/src/wrappers/bindings.h
|
---|
| 4427 | ===================================================================
|
---|
| 4428 | --- ../trunk-jpl/src/wrappers/bindings.h (revision 0)
|
---|
| 4429 | +++ ../trunk-jpl/src/wrappers/bindings.h (revision 13749)
|
---|
| 4430 | @@ -0,0 +1,22 @@
|
---|
| 4431 | +#ifndef _BINDINGS_H_
|
---|
| 4432 | +#define _BINDINGS_H_
|
---|
| 4433 | +
|
---|
| 4434 | +#ifdef HAVE_CONFIG_H
|
---|
| 4435 | + #include <config.h>
|
---|
| 4436 | +#else
|
---|
| 4437 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 4438 | +#endif
|
---|
| 4439 | +
|
---|
| 4440 | +#ifdef _HAVE_MATLAB_MODULES_
|
---|
| 4441 | +#include "./matlab/include/matlabincludes.h"
|
---|
| 4442 | +#include "./matlab/include/wrapper_macros.h"
|
---|
| 4443 | +#include "./matlab/io/matlabio.h"
|
---|
| 4444 | +#endif
|
---|
| 4445 | +
|
---|
| 4446 | +#ifdef _HAVE_PYTHON_MODULES_
|
---|
| 4447 | +#include "./python/include/pythonincludes.h"
|
---|
| 4448 | +#include "./python/include/wrapper_macros.h"
|
---|
| 4449 | +#include "./python/io/pythonio.h"
|
---|
| 4450 | +#endif
|
---|
| 4451 | +
|
---|
| 4452 | +#endif
|
---|
| 4453 | Index: ../trunk-jpl/src/wrappers/TriaSearch/TriaSearch.h
|
---|
| 4454 | ===================================================================
|
---|
| 4455 | --- ../trunk-jpl/src/wrappers/TriaSearch/TriaSearch.h (revision 13748)
|
---|
| 4456 | +++ ../trunk-jpl/src/wrappers/TriaSearch/TriaSearch.h (revision 13749)
|
---|
| 4457 | @@ -19,7 +19,7 @@
|
---|
| 4458 | #include "../../c/modules/modules.h"
|
---|
| 4459 | #include "../../c/Container/Container.h"
|
---|
| 4460 | #include "../../c/shared/shared.h"
|
---|
| 4461 | -#include "../../c/issm-binding.h"
|
---|
| 4462 | +#include "../bindings.h"
|
---|
| 4463 |
|
---|
| 4464 | #undef __FUNCT__
|
---|
| 4465 | #define __FUNCT__ "TriaSearch"
|
---|
| 4466 | Index: ../trunk-jpl/src/wrappers/InternalFront/InternalFront.h
|
---|
| 4467 | ===================================================================
|
---|
| 4468 | --- ../trunk-jpl/src/wrappers/InternalFront/InternalFront.h (revision 13748)
|
---|
| 4469 | +++ ../trunk-jpl/src/wrappers/InternalFront/InternalFront.h (revision 13749)
|
---|
| 4470 | @@ -18,7 +18,7 @@
|
---|
| 4471 |
|
---|
| 4472 | #include "../../c/include/globals.h"
|
---|
| 4473 | #include "../../c/shared/shared.h"
|
---|
| 4474 | -#include "../../c/issm-binding.h"
|
---|
| 4475 | +#include "../bindings.h"
|
---|
| 4476 | #include "../../c/io/io.h"
|
---|
| 4477 |
|
---|
| 4478 | #undef __FUNCT__
|
---|
| 4479 | Index: ../trunk-jpl/src/wrappers/MeshPartition/MeshPartition.h
|
---|
| 4480 | ===================================================================
|
---|
| 4481 | --- ../trunk-jpl/src/wrappers/MeshPartition/MeshPartition.h (revision 13748)
|
---|
| 4482 | +++ ../trunk-jpl/src/wrappers/MeshPartition/MeshPartition.h (revision 13749)
|
---|
| 4483 | @@ -20,7 +20,7 @@
|
---|
| 4484 | #include "../../c/modules/modules.h"
|
---|
| 4485 | #include "../../c/Container/Container.h"
|
---|
| 4486 | #include "../../c/shared/shared.h"
|
---|
| 4487 | -#include "../../c/issm-binding.h"
|
---|
| 4488 | +#include "../bindings.h"
|
---|
| 4489 |
|
---|
| 4490 | #undef __FUNCT__
|
---|
| 4491 | #define __FUNCT__ "MeshPartition"
|
---|
| 4492 | Index: ../trunk-jpl/src/wrappers/InterpFromMesh2d/InterpFromMesh2d.h
|
---|
| 4493 | ===================================================================
|
---|
| 4494 | --- ../trunk-jpl/src/wrappers/InterpFromMesh2d/InterpFromMesh2d.h (revision 13748)
|
---|
| 4495 | +++ ../trunk-jpl/src/wrappers/InterpFromMesh2d/InterpFromMesh2d.h (revision 13749)
|
---|
| 4496 | @@ -20,7 +20,7 @@
|
---|
| 4497 | #include "../../c/modules/modules.h"
|
---|
| 4498 | #include "../../c/Container/Container.h"
|
---|
| 4499 | #include "../../c/shared/shared.h"
|
---|
| 4500 | -#include "../../c/issm-binding.h"
|
---|
| 4501 | +#include "../bindings.h"
|
---|
| 4502 |
|
---|
| 4503 | #undef __FUNCT__
|
---|
| 4504 | #define __FUNCT__ "InterpFromMesh2d"
|
---|
| 4505 | Index: ../trunk-jpl/src/wrappers/ElementConnectivity/ElementConnectivity.h
|
---|
| 4506 | ===================================================================
|
---|
| 4507 | --- ../trunk-jpl/src/wrappers/ElementConnectivity/ElementConnectivity.h (revision 13748)
|
---|
| 4508 | +++ ../trunk-jpl/src/wrappers/ElementConnectivity/ElementConnectivity.h (revision 13749)
|
---|
| 4509 | @@ -23,7 +23,7 @@
|
---|
| 4510 | #include "../../c/modules/modules.h"
|
---|
| 4511 | #include "../../c/Container/Container.h"
|
---|
| 4512 | #include "../../c/shared/shared.h"
|
---|
| 4513 | -#include "../../c/issm-binding.h"
|
---|
| 4514 | +#include "../bindings.h"
|
---|
| 4515 | #include "../../c/io/io.h"
|
---|
| 4516 | #include "../../c/EnumDefinitions/EnumDefinitions.h"
|
---|
| 4517 |
|
---|
| 4518 | Index: ../trunk-jpl/src/wrappers/Kriging/Kriging.h
|
---|
| 4519 | ===================================================================
|
---|
| 4520 | --- ../trunk-jpl/src/wrappers/Kriging/Kriging.h (revision 13748)
|
---|
| 4521 | +++ ../trunk-jpl/src/wrappers/Kriging/Kriging.h (revision 13749)
|
---|
| 4522 | @@ -19,7 +19,7 @@
|
---|
| 4523 | #include "../../c/include/globals.h"
|
---|
| 4524 | #include "../../c/modules/modules.h"
|
---|
| 4525 | #include "../../c/shared/shared.h"
|
---|
| 4526 | -#include "../../c/issm-binding.h"
|
---|
| 4527 | +#include "../bindings.h"
|
---|
| 4528 |
|
---|
| 4529 | #undef __FUNCT__
|
---|
| 4530 | #define __FUNCT__ "Kriging"
|
---|
| 4531 | Index: ../trunk-jpl/src/wrappers/EnumToString/EnumToString.h
|
---|
| 4532 | ===================================================================
|
---|
| 4533 | --- ../trunk-jpl/src/wrappers/EnumToString/EnumToString.h (revision 13748)
|
---|
| 4534 | +++ ../trunk-jpl/src/wrappers/EnumToString/EnumToString.h (revision 13749)
|
---|
| 4535 | @@ -21,7 +21,7 @@
|
---|
| 4536 | #include "../../c/modules/modules.h"
|
---|
| 4537 | #include "../../c/Container/Container.h"
|
---|
| 4538 | #include "../../c/shared/shared.h"
|
---|
| 4539 | -#include "../../c/issm-binding.h"
|
---|
| 4540 | +#include "../bindings.h"
|
---|
| 4541 |
|
---|
| 4542 | #undef __FUNCT__
|
---|
| 4543 | #define __FUNCT__ "EnumToString"
|
---|
| 4544 | Index: ../trunk-jpl/src/wrappers/StringToEnum/StringToEnum.h
|
---|
| 4545 | ===================================================================
|
---|
| 4546 | --- ../trunk-jpl/src/wrappers/StringToEnum/StringToEnum.h (revision 13748)
|
---|
| 4547 | +++ ../trunk-jpl/src/wrappers/StringToEnum/StringToEnum.h (revision 13749)
|
---|
| 4548 | @@ -21,7 +21,7 @@
|
---|
| 4549 | #include "../../c/modules/modules.h"
|
---|
| 4550 | #include "../../c/Container/Container.h"
|
---|
| 4551 | #include "../../c/shared/shared.h"
|
---|
| 4552 | -#include "../../c/issm-binding.h"
|
---|
| 4553 | +#include "../bindings.h"
|
---|
| 4554 |
|
---|
| 4555 | #undef __FUNCT__
|
---|
| 4556 | #define __FUNCT__ "StringToEnum"
|
---|
| 4557 | Index: ../trunk-jpl/src/wrappers/matlab/include/wrapper_macros.h
|
---|
| 4558 | ===================================================================
|
---|
| 4559 | --- ../trunk-jpl/src/wrappers/matlab/include/wrapper_macros.h (revision 0)
|
---|
| 4560 | +++ ../trunk-jpl/src/wrappers/matlab/include/wrapper_macros.h (revision 13749)
|
---|
| 4561 | @@ -0,0 +1,42 @@
|
---|
| 4562 | +/* \file matlab macros.h
|
---|
| 4563 | + * \brief: macros used for the matlab bindings
|
---|
| 4564 | + */
|
---|
| 4565 | +
|
---|
| 4566 | +#ifndef _MATLAB_MACROS_H_
|
---|
| 4567 | +#define _MATLAB_MACROS_H_
|
---|
| 4568 | +
|
---|
| 4569 | +#ifdef HAVE_CONFIG_H
|
---|
| 4570 | + #include <config.h>
|
---|
| 4571 | +#else
|
---|
| 4572 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 4573 | +#endif
|
---|
| 4574 | +
|
---|
| 4575 | +#ifdef _HAVE_MATLAB_
|
---|
| 4576 | +/* MODULEBOOT/MODULEEND {{{*/
|
---|
| 4577 | +
|
---|
| 4578 | +/*The following macros hide the error exception handling in a matlab module. Just put
|
---|
| 4579 | + * MODULEBOOT(); and MODULEEND(); at the beginning and end of a module, and c++ exceptions
|
---|
| 4580 | + * will be trapped*/
|
---|
| 4581 | +#define MODULEBOOT(); try{ \
|
---|
| 4582 | + IssmComm::SetComm(-1);
|
---|
| 4583 | +
|
---|
| 4584 | +#define MODULEEND(); }\
|
---|
| 4585 | + catch(ErrorException &exception){\
|
---|
| 4586 | + mexErrMsgTxt(exception.MatlabReport()); \
|
---|
| 4587 | + }\
|
---|
| 4588 | + catch (exception &e){\
|
---|
| 4589 | + mexErrMsgTxt(exprintf("Standard exception: %s\n",e.what()));\
|
---|
| 4590 | + }\
|
---|
| 4591 | + catch(...){\
|
---|
| 4592 | + mexErrMsgTxt("An unexpected error occurred");\
|
---|
| 4593 | + }
|
---|
| 4594 | +/*}}}*/
|
---|
| 4595 | +/* WRAPPER {{{*/
|
---|
| 4596 | +#define WRAPPER(modulename,...) void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
|
---|
| 4597 | +/*}}}*/
|
---|
| 4598 | +/* CHECKARGUMENTS {{{*/
|
---|
| 4599 | +#define CHECKARGUMENTS(NLHS,NRHS,functionpointer) CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,functionpointer)
|
---|
| 4600 | +/*}}}*/
|
---|
| 4601 | +#endif
|
---|
| 4602 | +
|
---|
| 4603 | +#endif
|
---|
| 4604 | Index: ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToSeqMat.cpp
|
---|
| 4605 | ===================================================================
|
---|
| 4606 | --- ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToSeqMat.cpp (revision 0)
|
---|
| 4607 | +++ ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToSeqMat.cpp (revision 13749)
|
---|
| 4608 | @@ -0,0 +1,25 @@
|
---|
| 4609 | +/*!\file MatlabMatrixToSeqMat.cpp
|
---|
| 4610 | + */
|
---|
| 4611 | +
|
---|
| 4612 | +/*Headers:*/
|
---|
| 4613 | +#ifdef HAVE_CONFIG_H
|
---|
| 4614 | + #include <config.h>
|
---|
| 4615 | +#else
|
---|
| 4616 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 4617 | +#endif
|
---|
| 4618 | +
|
---|
| 4619 | +#include <stdio.h>
|
---|
| 4620 | +#include <string.h>
|
---|
| 4621 | +#include "./matlabio.h"
|
---|
| 4622 | +#include "../../c/toolkits/toolkits.h"
|
---|
| 4623 | +#include "../../c/shared/shared.h"
|
---|
| 4624 | +
|
---|
| 4625 | +SeqMat<double>* MatlabMatrixToSeqMat(const mxArray* dataref){
|
---|
| 4626 | +
|
---|
| 4627 | + SeqMat<double>* output=NULL;
|
---|
| 4628 | +
|
---|
| 4629 | + output=new SeqMat<double>();
|
---|
| 4630 | + MatlabMatrixToDoubleMatrix(&output->matrix,&output->M,&output->N,dataref);
|
---|
| 4631 | + return output;
|
---|
| 4632 | +
|
---|
| 4633 | +}
|
---|
| 4634 | Index: ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToPetscVec.cpp
|
---|
| 4635 | ===================================================================
|
---|
| 4636 | --- ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToPetscVec.cpp (revision 0)
|
---|
| 4637 | +++ ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToPetscVec.cpp (revision 13749)
|
---|
| 4638 | @@ -0,0 +1,106 @@
|
---|
| 4639 | +/* \file MatlabVectorToPetscVector.cpp
|
---|
| 4640 | + * \brief: convert a sparse or dense matlab vector to a serial Petsc vector:
|
---|
| 4641 | + */
|
---|
| 4642 | +
|
---|
| 4643 | +#ifdef HAVE_CONFIG_H
|
---|
| 4644 | + #include <config.h>
|
---|
| 4645 | +#else
|
---|
| 4646 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 4647 | +#endif
|
---|
| 4648 | +
|
---|
| 4649 | +/*Petsc includes: */
|
---|
| 4650 | +#include <petscmat.h>
|
---|
| 4651 | +#include <petscvec.h>
|
---|
| 4652 | +#include <petscksp.h>
|
---|
| 4653 | +
|
---|
| 4654 | +/*Matlab includes: */
|
---|
| 4655 | +#include "./matlabio.h"
|
---|
| 4656 | +#include "../../c/shared/shared.h"
|
---|
| 4657 | +
|
---|
| 4658 | +PetscVec* MatlabVectorToPetscVec(const mxArray* mxvector){
|
---|
| 4659 | +
|
---|
| 4660 | + int dummy;
|
---|
| 4661 | + PetscVec* vector=new PetscVec();
|
---|
| 4662 | +
|
---|
| 4663 | + MatlabVectorToPetscVec(&vector->vector,&dummy, mxvector);
|
---|
| 4664 | +
|
---|
| 4665 | + return vector;
|
---|
| 4666 | +}
|
---|
| 4667 | +
|
---|
| 4668 | +int MatlabVectorToPetscVec(Vec* pvector,int* pvector_rows,const mxArray* mxvector){
|
---|
| 4669 | +
|
---|
| 4670 | + int rows, cols;
|
---|
| 4671 | + double* mxvector_ptr=NULL;
|
---|
| 4672 | + int ierr;
|
---|
| 4673 | + int i,j;
|
---|
| 4674 | +
|
---|
| 4675 | + /*output: */
|
---|
| 4676 | + Vec vector=NULL;
|
---|
| 4677 | +
|
---|
| 4678 | + /*matlab indices: */
|
---|
| 4679 | + mwIndex* ir=NULL;
|
---|
| 4680 | + mwIndex* jc=NULL;
|
---|
| 4681 | + double* pr=NULL;
|
---|
| 4682 | + int count;
|
---|
| 4683 | + int nnz;
|
---|
| 4684 | + int nz;
|
---|
| 4685 | +
|
---|
| 4686 | + /*petsc indices: */
|
---|
| 4687 | + int* idxm=NULL;
|
---|
| 4688 | +
|
---|
| 4689 | + /*Ok, first check if we are dealing with a sparse or full vector: */
|
---|
| 4690 | + if (mxIsSparse(mxvector)){
|
---|
| 4691 | +
|
---|
| 4692 | + /*Dealing with sparse vector: recover size first: */
|
---|
| 4693 | + mxvector_ptr=(double*)mxGetPr(mxvector);
|
---|
| 4694 | + rows=mxGetM(mxvector);
|
---|
| 4695 | + cols=mxGetN(mxvector);
|
---|
| 4696 | + nnz=mxGetNzmax(mxvector);
|
---|
| 4697 | + nz=(int)((double)nnz/(double)rows);
|
---|
| 4698 | +
|
---|
| 4699 | + ierr=VecCreateSeq(PETSC_COMM_SELF,rows,&vector);CHKERRQ(ierr);
|
---|
| 4700 | +
|
---|
| 4701 | + /*Now, get ir,jc and pr: */
|
---|
| 4702 | + pr=mxGetPr(mxvector);
|
---|
| 4703 | + ir=mxGetIr(mxvector);
|
---|
| 4704 | + jc=mxGetJc(mxvector);
|
---|
| 4705 | +
|
---|
| 4706 | + /*Now, start inserting data into sparse vector: */
|
---|
| 4707 | + count=0;
|
---|
| 4708 | + for(i=0;i<cols;i++){
|
---|
| 4709 | + for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 4710 | + VecSetValue(vector,ir[count],pr[count],INSERT_VALUES);
|
---|
| 4711 | + count++;
|
---|
| 4712 | + }
|
---|
| 4713 | + }
|
---|
| 4714 | +
|
---|
| 4715 | + }
|
---|
| 4716 | + else{
|
---|
| 4717 | +
|
---|
| 4718 | + /*Dealing with dense vector: recover pointer and size: */
|
---|
| 4719 | + mxvector_ptr=(double*)mxGetPr(mxvector);
|
---|
| 4720 | + rows=mxGetM(mxvector);
|
---|
| 4721 | + cols=mxGetN(mxvector);
|
---|
| 4722 | +
|
---|
| 4723 | + /*Create serial vector: */
|
---|
| 4724 | + ierr=VecCreateSeq(PETSC_COMM_SELF,rows,&vector);CHKERRQ(ierr);
|
---|
| 4725 | +
|
---|
| 4726 | + /*Insert mxvector_ptr values into petsc vector: */
|
---|
| 4727 | + idxm=xNew<int>(rows);
|
---|
| 4728 | +
|
---|
| 4729 | + for(i=0;i<rows;i++)idxm[i]=i;
|
---|
| 4730 | +
|
---|
| 4731 | + ierr=VecSetValues(vector,rows,idxm,mxvector_ptr,INSERT_VALUES);CHKERRQ(ierr);
|
---|
| 4732 | +
|
---|
| 4733 | + }
|
---|
| 4734 | +
|
---|
| 4735 | + /*Assemble vector: */
|
---|
| 4736 | + VecAssemblyBegin(vector);
|
---|
| 4737 | + VecAssemblyEnd(vector);
|
---|
| 4738 | +
|
---|
| 4739 | + /*Assign output pointer: */
|
---|
| 4740 | + *pvector=vector;
|
---|
| 4741 | + *pvector_rows=rows;
|
---|
| 4742 | +
|
---|
| 4743 | + return 1;
|
---|
| 4744 | +}
|
---|
| 4745 | Index: ../trunk-jpl/src/wrappers/matlab/io/OptionParse.cpp
|
---|
| 4746 | ===================================================================
|
---|
| 4747 | --- ../trunk-jpl/src/wrappers/matlab/io/OptionParse.cpp (revision 0)
|
---|
| 4748 | +++ ../trunk-jpl/src/wrappers/matlab/io/OptionParse.cpp (revision 13749)
|
---|
| 4749 | @@ -0,0 +1,201 @@
|
---|
| 4750 | +/*\file OptionParse.c
|
---|
| 4751 | + *\brief: functions to parse the mex options.
|
---|
| 4752 | + */
|
---|
| 4753 | +#ifdef HAVE_CONFIG_H
|
---|
| 4754 | + #include <config.h>
|
---|
| 4755 | +#else
|
---|
| 4756 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 4757 | +#endif
|
---|
| 4758 | +
|
---|
| 4759 | +#include <cstring>
|
---|
| 4760 | +#include "./matlabio.h"
|
---|
| 4761 | +#include "../../c/shared/shared.h"
|
---|
| 4762 | +#include "../../c/io/io.h"
|
---|
| 4763 | +
|
---|
| 4764 | +GenericOption<double>* OptionDoubleParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 4765 | +
|
---|
| 4766 | + GenericOption<double> *odouble = NULL;
|
---|
| 4767 | +
|
---|
| 4768 | + /*check and parse the name */
|
---|
| 4769 | + odouble=new GenericOption<double>();
|
---|
| 4770 | + odouble->name =xNew<char>(strlen(name)+1);
|
---|
| 4771 | + memcpy(odouble->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 4772 | + FetchData(&odouble->value,prhs[0]);
|
---|
| 4773 | + odouble->numel=1;
|
---|
| 4774 | + odouble->ndims=1;
|
---|
| 4775 | + odouble->size=NULL;
|
---|
| 4776 | +
|
---|
| 4777 | + return(odouble);
|
---|
| 4778 | +}/*}}}*/
|
---|
| 4779 | +GenericOption<double*>* OptionDoubleArrayParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 4780 | +
|
---|
| 4781 | + GenericOption<double*> *odouble = NULL;
|
---|
| 4782 | +
|
---|
| 4783 | + /*check and parse the name */
|
---|
| 4784 | + odouble=new GenericOption<double*>();
|
---|
| 4785 | + odouble->name =xNew<char>(strlen(name)+1);
|
---|
| 4786 | + memcpy(odouble->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 4787 | +
|
---|
| 4788 | + /*check and parse the value */
|
---|
| 4789 | + if (!mxIsClass(prhs[0],"double")){
|
---|
| 4790 | + _error_("Value of option \"" << odouble->name << "\" must be class \"double\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
|
---|
| 4791 | + }
|
---|
| 4792 | + FetchData(&odouble->value,&odouble->numel,&odouble->ndims,&odouble->size,prhs[0]);
|
---|
| 4793 | +
|
---|
| 4794 | + return(odouble);
|
---|
| 4795 | +}/*}}}*/
|
---|
| 4796 | +GenericOption<bool*>* OptionLogicalParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 4797 | +
|
---|
| 4798 | + GenericOption<bool*> *ological = NULL;
|
---|
| 4799 | +
|
---|
| 4800 | + /*check and parse the name */
|
---|
| 4801 | + ological=new GenericOption<bool*>();
|
---|
| 4802 | + ological->name =xNew<char>(strlen(name)+1);
|
---|
| 4803 | + memcpy(ological->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 4804 | +
|
---|
| 4805 | + /*check and parse the value */
|
---|
| 4806 | + if (!mxIsClass(prhs[0],"logical")){
|
---|
| 4807 | + _error_("Value of option \"" << ological->name << "\" must be class \"logical\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
|
---|
| 4808 | + }
|
---|
| 4809 | + FetchData(&ological->value,&ological->numel,&ological->ndims,&ological->size,prhs[0]);
|
---|
| 4810 | +
|
---|
| 4811 | + return(ological);
|
---|
| 4812 | +}/*}}}*/
|
---|
| 4813 | +GenericOption<char*>* OptionCharParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 4814 | +
|
---|
| 4815 | + GenericOption<char*> *ochar = NULL;
|
---|
| 4816 | +
|
---|
| 4817 | + /*check and parse the name */
|
---|
| 4818 | + ochar=new GenericOption<char*>();
|
---|
| 4819 | + ochar->name =xNew<char>(strlen(name)+1);
|
---|
| 4820 | + memcpy(ochar->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 4821 | +
|
---|
| 4822 | + /*check and parse the value */
|
---|
| 4823 | + if (!mxIsClass(prhs[0],"char")){
|
---|
| 4824 | + _error_("Value of option \"" << ochar->name << "\" must be class \"char\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
|
---|
| 4825 | + }
|
---|
| 4826 | + FetchData(&ochar->value,&ochar->numel,&ochar->ndims,&ochar->size,prhs[0]);
|
---|
| 4827 | +
|
---|
| 4828 | + return(ochar);
|
---|
| 4829 | +}/*}}}*/
|
---|
| 4830 | +GenericOption<Options**>* OptionStructParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 4831 | +
|
---|
| 4832 | + int i;
|
---|
| 4833 | + char namei[161];
|
---|
| 4834 | + Option* option = NULL;
|
---|
| 4835 | + GenericOption<Options**> *ostruct = NULL;
|
---|
| 4836 | + const mwSize *ipt = NULL;
|
---|
| 4837 | + const mxArray *structi;
|
---|
| 4838 | + mwIndex sindex;
|
---|
| 4839 | +
|
---|
| 4840 | + /*check and parse the name */
|
---|
| 4841 | + ostruct=new GenericOption<Options**>();
|
---|
| 4842 | + ostruct->name =xNew<char>(strlen(name)+1);
|
---|
| 4843 | + memcpy(ostruct->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 4844 | +
|
---|
| 4845 | + /*check and parse the value */
|
---|
| 4846 | + if (!mxIsClass(prhs[0],"struct")){
|
---|
| 4847 | + _error_("Value of option \"" << ostruct->name << "\" must be class \"struct\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
|
---|
| 4848 | + }
|
---|
| 4849 | + ostruct->numel=mxGetNumberOfElements(prhs[0]);
|
---|
| 4850 | + ostruct->ndims=mxGetNumberOfDimensions(prhs[0]);
|
---|
| 4851 | + ipt =mxGetDimensions(prhs[0]);
|
---|
| 4852 | + ostruct->size =xNew<int>(ostruct->ndims);
|
---|
| 4853 | + for (i=0; i<ostruct->ndims; i++) ostruct->size[i]=(int)ipt[i];
|
---|
| 4854 | + if (ostruct->numel) ostruct->value=xNew<Options*>(ostruct->numel);
|
---|
| 4855 | +
|
---|
| 4856 | + /*loop through and process each element of the struct array */
|
---|
| 4857 | + for (sindex=0; sindex<ostruct->numel; sindex++) {
|
---|
| 4858 | + ostruct->value[sindex]=new Options;
|
---|
| 4859 | +
|
---|
| 4860 | + /*loop through and process each field for the element */
|
---|
| 4861 | + for (i=0; i<mxGetNumberOfFields(prhs[0]); i++) {
|
---|
| 4862 | + sprintf(namei,"%s.%s",name,mxGetFieldNameByNumber(prhs[0],i));
|
---|
| 4863 | + structi=mxGetFieldByNumber(prhs[0],sindex,i);
|
---|
| 4864 | +
|
---|
| 4865 | + option=(Option*)OptionParse(namei,&structi);
|
---|
| 4866 | + ostruct->value[sindex]->AddObject((Object*)option);
|
---|
| 4867 | + option=NULL;
|
---|
| 4868 | + }
|
---|
| 4869 | + }
|
---|
| 4870 | +
|
---|
| 4871 | + return(ostruct);
|
---|
| 4872 | +}/*}}}*/
|
---|
| 4873 | +GenericOption<Options*>* OptionCellParse( char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 4874 | +
|
---|
| 4875 | + int i;
|
---|
| 4876 | + int *dims;
|
---|
| 4877 | + char namei[161];
|
---|
| 4878 | + char cstr[81];
|
---|
| 4879 | + GenericOption<Options*> *ocell = NULL;
|
---|
| 4880 | + Option *option = NULL;
|
---|
| 4881 | + const mwSize *ipt = NULL;
|
---|
| 4882 | + const mxArray *celli;
|
---|
| 4883 | + mwIndex cindex;
|
---|
| 4884 | +
|
---|
| 4885 | + /*check and parse the name */
|
---|
| 4886 | + ocell=new GenericOption<Options*>();
|
---|
| 4887 | + ocell->name =xNew<char>(strlen(name)+1);
|
---|
| 4888 | + memcpy(ocell->name,name,(strlen(name)+1)*sizeof(char));
|
---|
| 4889 | +
|
---|
| 4890 | + /*check and parse the value */
|
---|
| 4891 | + if (!mxIsClass(prhs[0],"cell")){
|
---|
| 4892 | + _error_("Value of option \"" << ocell->name << "\" must be class \"cell\", not class \"" << mxGetClassName(prhs[0]) <<"\".");
|
---|
| 4893 | + }
|
---|
| 4894 | +
|
---|
| 4895 | + ocell->numel=mxGetNumberOfElements(prhs[0]);
|
---|
| 4896 | + ocell->ndims=mxGetNumberOfDimensions(prhs[0]);
|
---|
| 4897 | + ipt =mxGetDimensions(prhs[0]);
|
---|
| 4898 | + ocell->size =xNew<int>(ocell->ndims);
|
---|
| 4899 | + for (i=0; i<ocell->ndims; i++) ocell->size[i]=(int)ipt[i];
|
---|
| 4900 | + ocell->value=new Options;
|
---|
| 4901 | +
|
---|
| 4902 | + /*loop through and process each element of the cell array */
|
---|
| 4903 | + dims=xNew<int>(ocell->ndims);
|
---|
| 4904 | + for (cindex=0; cindex<ocell->numel; cindex++) {
|
---|
| 4905 | + ColumnWiseDimsFromIndex(dims,(int)cindex,ocell->size,ocell->ndims);
|
---|
| 4906 | + StringFromDims(cstr,dims,ocell->ndims);
|
---|
| 4907 | + #ifdef _INTEL_WIN_
|
---|
| 4908 | + _snprintf(namei,161,"%s%s",name,cstr);
|
---|
| 4909 | + #else
|
---|
| 4910 | + snprintf(namei,161,"%s%s",name,cstr);
|
---|
| 4911 | + #endif
|
---|
| 4912 | + celli=mxGetCell(prhs[0],cindex);
|
---|
| 4913 | +
|
---|
| 4914 | + option=(Option*)OptionParse(namei,&celli);
|
---|
| 4915 | + ocell->value->AddObject((Object*)option);
|
---|
| 4916 | + option=NULL;
|
---|
| 4917 | + }
|
---|
| 4918 | + xDelete<int>(dims);
|
---|
| 4919 | +
|
---|
| 4920 | + return(ocell);
|
---|
| 4921 | +}/*}}}*/
|
---|
| 4922 | +Option* OptionParse(char* name, const mxArray* prhs[]){ /*{{{*/
|
---|
| 4923 | +
|
---|
| 4924 | + Option *option = NULL;
|
---|
| 4925 | + mxArray *lhs[1];
|
---|
| 4926 | +
|
---|
| 4927 | + /*parse the value according to the matlab data type */
|
---|
| 4928 | + if (mxIsClass(prhs[0],"double") && (mxGetNumberOfElements(prhs[0])==1))
|
---|
| 4929 | + option=(Option*)OptionDoubleParse(name,prhs);
|
---|
| 4930 | + else if(mxIsClass(prhs[0],"double") && (mxGetNumberOfElements(prhs[0])!=1))
|
---|
| 4931 | + option=(Option*)OptionDoubleArrayParse(name,prhs);
|
---|
| 4932 | + else if(mxIsClass(prhs[0],"logical"))
|
---|
| 4933 | + option=(Option*)OptionLogicalParse(name,prhs);
|
---|
| 4934 | + else if(mxIsClass(prhs[0],"char"))
|
---|
| 4935 | + option=(Option*)OptionCharParse(name,prhs);
|
---|
| 4936 | + else if(mxIsClass(prhs[0],"struct"))
|
---|
| 4937 | + option=(Option*)OptionStructParse(name,prhs);
|
---|
| 4938 | + else if(mxIsClass(prhs[0],"cell"))
|
---|
| 4939 | + option=(Option*)OptionCellParse(name,prhs);
|
---|
| 4940 | + else {
|
---|
| 4941 | + _pprintLine_(" Converting value of option \"" << name << "\" from unrecognized class \"" << mxGetClassName(prhs[0]) << "\" to class \"" << "struct" << "\".");
|
---|
| 4942 | + if (!mexCallMATLAB(1,lhs,1,(mxArray**)prhs,"struct")) {
|
---|
| 4943 | + option=(Option*)OptionStructParse(name,(const mxArray**)lhs);
|
---|
| 4944 | + mxDestroyArray(lhs[0]);
|
---|
| 4945 | + }
|
---|
| 4946 | + else _error_("Second argument value of option \""<< name <<"\" is of unrecognized class \""<< mxGetClassName(prhs[0]) <<"\".");
|
---|
| 4947 | + }
|
---|
| 4948 | +
|
---|
| 4949 | + return(option);
|
---|
| 4950 | +}/*}}}*/
|
---|
| 4951 | Index: ../trunk-jpl/src/wrappers/matlab/io/CheckNumMatlabArguments.cpp
|
---|
| 4952 | ===================================================================
|
---|
| 4953 | --- ../trunk-jpl/src/wrappers/matlab/io/CheckNumMatlabArguments.cpp (revision 0)
|
---|
| 4954 | +++ ../trunk-jpl/src/wrappers/matlab/io/CheckNumMatlabArguments.cpp (revision 13749)
|
---|
| 4955 | @@ -0,0 +1,23 @@
|
---|
| 4956 | +/*!\file CheckNumMatlabArguments.cpp:
|
---|
| 4957 | + * \brief: check number of arguments and report an usage error message.
|
---|
| 4958 | + */
|
---|
| 4959 | +
|
---|
| 4960 | +#include "./matlabio.h"
|
---|
| 4961 | +#include "../../c/shared/Exceptions/exceptions.h"
|
---|
| 4962 | +
|
---|
| 4963 | +int CheckNumMatlabArguments(int nlhs,int NLHS, int nrhs,int NRHS, const char* THISFUNCTION, void (*function)( void )){
|
---|
| 4964 | +
|
---|
| 4965 | + /*checks on arguments on the matlab side: */
|
---|
| 4966 | + if (nrhs==0 && nlhs==0) {
|
---|
| 4967 | + /*unless NLHS=0 and NRHS=0, we are just asking for documentation: */
|
---|
| 4968 | + if (NRHS==0 && NLHS==0)return 1;
|
---|
| 4969 | + /* special case: */
|
---|
| 4970 | + function();
|
---|
| 4971 | + _error_("usage: see above");
|
---|
| 4972 | + }
|
---|
| 4973 | + else if (nlhs!=NLHS || nrhs!=NRHS ) {
|
---|
| 4974 | + function();
|
---|
| 4975 | + _error_("usage error.");
|
---|
| 4976 | + }
|
---|
| 4977 | + return 1;
|
---|
| 4978 | +}
|
---|
| 4979 | Index: ../trunk-jpl/src/wrappers/matlab/io/FetchMatlabData.cpp
|
---|
| 4980 | ===================================================================
|
---|
| 4981 | --- ../trunk-jpl/src/wrappers/matlab/io/FetchMatlabData.cpp (revision 0)
|
---|
| 4982 | +++ ../trunk-jpl/src/wrappers/matlab/io/FetchMatlabData.cpp (revision 13749)
|
---|
| 4983 | @@ -0,0 +1,691 @@
|
---|
| 4984 | +/*\file FetchData.cpp:
|
---|
| 4985 | + * \brief: general I/O interface to fetch data in matlab
|
---|
| 4986 | + */
|
---|
| 4987 | +
|
---|
| 4988 | +#ifdef HAVE_CONFIG_H
|
---|
| 4989 | + #include <config.h>
|
---|
| 4990 | +#else
|
---|
| 4991 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 4992 | +#endif
|
---|
| 4993 | +
|
---|
| 4994 | +#include "./matlabio.h"
|
---|
| 4995 | +#include "../../c/shared/shared.h"
|
---|
| 4996 | +
|
---|
| 4997 | +/*Primitive data types*/
|
---|
| 4998 | +/*FUNCTION FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
|
---|
| 4999 | +void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref){
|
---|
| 5000 | +
|
---|
| 5001 | + double* outmatrix=NULL;
|
---|
| 5002 | + int outmatrix_rows,outmatrix_cols;
|
---|
| 5003 | +
|
---|
| 5004 | + if(mxIsEmpty(dataref) ){
|
---|
| 5005 | + /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 5006 | + outmatrix_rows=0;
|
---|
| 5007 | + outmatrix_cols=0;
|
---|
| 5008 | + outmatrix=NULL;
|
---|
| 5009 | + }
|
---|
| 5010 | + else if( mxIsClass(dataref,"double") ||
|
---|
| 5011 | + mxIsClass(dataref,"single") ||
|
---|
| 5012 | + mxIsClass(dataref,"int16") ||
|
---|
| 5013 | + mxIsClass(dataref,"int8") ||
|
---|
| 5014 | + mxIsClass(dataref,"uint8")){
|
---|
| 5015 | + /*Check dataref is not pointing to NaN: */
|
---|
| 5016 | + if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
|
---|
| 5017 | + outmatrix_rows=0;
|
---|
| 5018 | + outmatrix_cols=0;
|
---|
| 5019 | + outmatrix=NULL;
|
---|
| 5020 | + }
|
---|
| 5021 | + else{
|
---|
| 5022 | + if(!mxIsClass(dataref,"double") && !mxIsClass(dataref,"single")){
|
---|
| 5023 | + _printLine_("Warning: converting matlab data from '" << mxGetClassName(dataref) << "' to 'double'");
|
---|
| 5024 | + }
|
---|
| 5025 | + /*Convert matlab matrix to double* matrix: */
|
---|
| 5026 | + MatlabMatrixToDoubleMatrix(&outmatrix,&outmatrix_rows,&outmatrix_cols,dataref);
|
---|
| 5027 | + }
|
---|
| 5028 | + }
|
---|
| 5029 | + else{
|
---|
| 5030 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5031 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5032 | + }
|
---|
| 5033 | +
|
---|
| 5034 | + /*Assign output pointers:*/
|
---|
| 5035 | + *pmatrix=outmatrix;
|
---|
| 5036 | + if (pM)*pM=outmatrix_rows;
|
---|
| 5037 | + if (pN)*pN=outmatrix_cols;
|
---|
| 5038 | +
|
---|
| 5039 | +}
|
---|
| 5040 | +/*}}}*/
|
---|
| 5041 | +/*FUNCTION FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
|
---|
| 5042 | +void FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
|
---|
| 5043 | +
|
---|
| 5044 | + int outmatrix_numel,outmatrix_ndims;
|
---|
| 5045 | + double *outmatrix = NULL;
|
---|
| 5046 | + int *outmatrix_size = NULL;
|
---|
| 5047 | +
|
---|
| 5048 | + if(mxIsEmpty(dataref) ){
|
---|
| 5049 | + /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 5050 | + outmatrix_numel = 0;
|
---|
| 5051 | + outmatrix_ndims = 0;
|
---|
| 5052 | + outmatrix_size = NULL;
|
---|
| 5053 | + outmatrix = NULL;
|
---|
| 5054 | + }
|
---|
| 5055 | + else if( mxIsClass(dataref,"double") ||
|
---|
| 5056 | + mxIsClass(dataref,"single") ||
|
---|
| 5057 | + mxIsClass(dataref,"int16") ||
|
---|
| 5058 | + mxIsClass(dataref,"int8") ||
|
---|
| 5059 | + mxIsClass(dataref,"uint8")){
|
---|
| 5060 | +
|
---|
| 5061 | + /*Check dataref is not pointing to NaN: */
|
---|
| 5062 | + if (mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1)){
|
---|
| 5063 | + outmatrix_numel = 0;
|
---|
| 5064 | + outmatrix_ndims = 0;
|
---|
| 5065 | + outmatrix_size = NULL;
|
---|
| 5066 | + outmatrix = NULL;
|
---|
| 5067 | + }
|
---|
| 5068 | + else{
|
---|
| 5069 | + if(!mxIsClass(dataref,"double") && !mxIsClass(dataref,"single")){
|
---|
| 5070 | + _printLine_("Warning: converting matlab data from '" << mxGetClassName(dataref) << "' to 'double'");
|
---|
| 5071 | + }
|
---|
| 5072 | + /*Convert matlab n-dim array to double* matrix: */
|
---|
| 5073 | + MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
|
---|
| 5074 | + }
|
---|
| 5075 | + }
|
---|
| 5076 | + else{
|
---|
| 5077 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5078 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5079 | + }
|
---|
| 5080 | +
|
---|
| 5081 | + /*Assign output pointers:*/
|
---|
| 5082 | + *pmatrix=outmatrix;
|
---|
| 5083 | + if (pnumel)*pnumel=outmatrix_numel;
|
---|
| 5084 | + if (pndims)*pndims=outmatrix_ndims;
|
---|
| 5085 | + if (psize )*psize =outmatrix_size;
|
---|
| 5086 | + else xDelete<int>(outmatrix_size);
|
---|
| 5087 | +
|
---|
| 5088 | +}
|
---|
| 5089 | +/*}}}*/
|
---|
| 5090 | +/*FUNCTION FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
|
---|
| 5091 | +void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){
|
---|
| 5092 | +
|
---|
| 5093 | + int i,outmatrix_rows,outmatrix_cols;
|
---|
| 5094 | + double *doublematrix=NULL;
|
---|
| 5095 | + int *outmatrix=NULL;
|
---|
| 5096 | +
|
---|
| 5097 | + if(mxIsEmpty(dataref) ){
|
---|
| 5098 | + /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 5099 | + outmatrix_rows=0;
|
---|
| 5100 | + outmatrix_cols=0;
|
---|
| 5101 | + outmatrix=NULL;
|
---|
| 5102 | + }
|
---|
| 5103 | + else if( mxIsClass(dataref,"double") ||
|
---|
| 5104 | + mxIsClass(dataref,"single") ||
|
---|
| 5105 | + mxIsClass(dataref,"int16") ||
|
---|
| 5106 | + mxIsClass(dataref,"int8") ||
|
---|
| 5107 | + mxIsClass(dataref,"uint8")){
|
---|
| 5108 | +
|
---|
| 5109 | + /*Check dataref is not pointing to NaN: */
|
---|
| 5110 | + if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
|
---|
| 5111 | + outmatrix_rows=0;
|
---|
| 5112 | + outmatrix_cols=0;
|
---|
| 5113 | + outmatrix=NULL;
|
---|
| 5114 | + }
|
---|
| 5115 | + else{
|
---|
| 5116 | + if(!mxIsClass(dataref,"double") && !mxIsClass(dataref,"single")){
|
---|
| 5117 | + _printLine_("Warning: converting matlab data from '" << mxGetClassName(dataref) << "' to 'double'");
|
---|
| 5118 | + }
|
---|
| 5119 | + /*Convert matlab matrix to double* matrix: */
|
---|
| 5120 | + MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref);
|
---|
| 5121 | +
|
---|
| 5122 | + /*Convert double matrix into integer matrix: */
|
---|
| 5123 | + outmatrix=xNew<int>(outmatrix_rows*outmatrix_cols);
|
---|
| 5124 | + for(i=0;i<outmatrix_rows*outmatrix_cols;i++)outmatrix[i]=(int)doublematrix[i];
|
---|
| 5125 | + }
|
---|
| 5126 | + }
|
---|
| 5127 | + else{
|
---|
| 5128 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5129 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5130 | + }
|
---|
| 5131 | +
|
---|
| 5132 | + /*Assign output pointers:*/
|
---|
| 5133 | + *pmatrix=outmatrix;
|
---|
| 5134 | + if (pM)*pM=outmatrix_rows;
|
---|
| 5135 | + if (pN)*pN=outmatrix_cols;
|
---|
| 5136 | +}
|
---|
| 5137 | +/*}}}*/
|
---|
| 5138 | +/*FUNCTION FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){{{*/
|
---|
| 5139 | +void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){
|
---|
| 5140 | +
|
---|
| 5141 | + int i,outmatrix_rows,outmatrix_cols;
|
---|
| 5142 | + double *doublematrix=NULL;
|
---|
| 5143 | + bool *outmatrix=NULL;
|
---|
| 5144 | +
|
---|
| 5145 | + if(mxIsEmpty(dataref) ){
|
---|
| 5146 | + /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 5147 | + outmatrix_rows=0;
|
---|
| 5148 | + outmatrix_cols=0;
|
---|
| 5149 | + outmatrix=NULL;
|
---|
| 5150 | + }
|
---|
| 5151 | + else if (mxIsClass(dataref,"double") ){
|
---|
| 5152 | +
|
---|
| 5153 | + /*Check dataref is not pointing to NaN: */
|
---|
| 5154 | + if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){
|
---|
| 5155 | + outmatrix_rows=0;
|
---|
| 5156 | + outmatrix_cols=0;
|
---|
| 5157 | + outmatrix=NULL;
|
---|
| 5158 | + }
|
---|
| 5159 | + else{
|
---|
| 5160 | +
|
---|
| 5161 | + /*Convert matlab matrix to double* matrix: */
|
---|
| 5162 | + MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref);
|
---|
| 5163 | +
|
---|
| 5164 | + /*Convert double matrix into integer matrix: */
|
---|
| 5165 | + outmatrix=xNew<bool>(outmatrix_rows*outmatrix_cols);
|
---|
| 5166 | + for(i=0;i<outmatrix_rows;i++)outmatrix[i]=(bool)doublematrix[i];
|
---|
| 5167 | + }
|
---|
| 5168 | + }
|
---|
| 5169 | + else{
|
---|
| 5170 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5171 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5172 | + }
|
---|
| 5173 | +
|
---|
| 5174 | + /*Assign output pointers:*/
|
---|
| 5175 | + *pmatrix=outmatrix;
|
---|
| 5176 | + if (pM)*pM=outmatrix_rows;
|
---|
| 5177 | + if (pN)*pN=outmatrix_cols;
|
---|
| 5178 | +}
|
---|
| 5179 | +/*}}}*/
|
---|
| 5180 | +/*FUNCTION FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
|
---|
| 5181 | +void FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
|
---|
| 5182 | +
|
---|
| 5183 | + int i;
|
---|
| 5184 | + int outmatrix_numel,outmatrix_ndims;
|
---|
| 5185 | + int* outmatrix_size=NULL;
|
---|
| 5186 | + double* doublematrix=NULL;
|
---|
| 5187 | + bool* outmatrix=NULL;
|
---|
| 5188 | +
|
---|
| 5189 | + if(mxIsEmpty(dataref) ){
|
---|
| 5190 | + /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 5191 | + outmatrix_numel=0;
|
---|
| 5192 | + outmatrix_ndims=0;
|
---|
| 5193 | + outmatrix_size =NULL;
|
---|
| 5194 | + outmatrix=NULL;
|
---|
| 5195 | + }
|
---|
| 5196 | + else if (mxIsClass(dataref,"logical") ){
|
---|
| 5197 | +
|
---|
| 5198 | + /*Check dataref is not pointing to NaN: */
|
---|
| 5199 | + if ( mxIsNaN(*((bool*)mxGetData(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
|
---|
| 5200 | + outmatrix_numel=0;
|
---|
| 5201 | + outmatrix_ndims=0;
|
---|
| 5202 | + outmatrix_size =NULL;
|
---|
| 5203 | + outmatrix=NULL;
|
---|
| 5204 | + }
|
---|
| 5205 | + else{
|
---|
| 5206 | +
|
---|
| 5207 | + /*Convert matlab n-dim array to bool* matrix: */
|
---|
| 5208 | + MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
|
---|
| 5209 | + }
|
---|
| 5210 | + }
|
---|
| 5211 | + else if (mxIsClass(dataref,"double") ){
|
---|
| 5212 | +
|
---|
| 5213 | + /*Check dataref is not pointing to NaN: */
|
---|
| 5214 | + if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetNumberOfElements(dataref)==1) ){
|
---|
| 5215 | + outmatrix_numel=0;
|
---|
| 5216 | + outmatrix_ndims=0;
|
---|
| 5217 | + outmatrix_size =NULL;
|
---|
| 5218 | + outmatrix=NULL;
|
---|
| 5219 | + }
|
---|
| 5220 | + else{
|
---|
| 5221 | +
|
---|
| 5222 | + /*Convert matlab n-dim array to double* matrix: */
|
---|
| 5223 | + MatlabNArrayToNArray(&doublematrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
|
---|
| 5224 | +
|
---|
| 5225 | + /*Convert double matrix into bool matrix: */
|
---|
| 5226 | + outmatrix=xNew<bool>(outmatrix_numel);
|
---|
| 5227 | + for(i=0;i<outmatrix_numel;i++)outmatrix[i]=(bool)doublematrix[i];
|
---|
| 5228 | + xDelete<double>(doublematrix);
|
---|
| 5229 | + }
|
---|
| 5230 | + }
|
---|
| 5231 | + else{
|
---|
| 5232 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5233 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5234 | + }
|
---|
| 5235 | +
|
---|
| 5236 | + /*Assign output pointers:*/
|
---|
| 5237 | + *pmatrix=outmatrix;
|
---|
| 5238 | + if (pnumel)*pnumel=outmatrix_numel;
|
---|
| 5239 | + if (pndims)*pndims=outmatrix_ndims;
|
---|
| 5240 | + if (psize )*psize =outmatrix_size;
|
---|
| 5241 | + else xDelete<int>(outmatrix_size);
|
---|
| 5242 | +
|
---|
| 5243 | +}
|
---|
| 5244 | +/*}}}*/
|
---|
| 5245 | +/*FUNCTION FetchData(double** pvector,int* pM,const mxArray* dataref){{{*/
|
---|
| 5246 | +void FetchData(double** pvector,int* pM,const mxArray* dataref){
|
---|
| 5247 | +
|
---|
| 5248 | + double* outvector=NULL;
|
---|
| 5249 | + int outvector_rows;
|
---|
| 5250 | +
|
---|
| 5251 | + if(mxIsEmpty(dataref)){
|
---|
| 5252 | + /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 5253 | + outvector_rows=0;
|
---|
| 5254 | + outvector=NULL;
|
---|
| 5255 | + }
|
---|
| 5256 | + else if (mxIsClass(dataref,"double") ){
|
---|
| 5257 | +
|
---|
| 5258 | + /*Convert matlab vector to double* vector: */
|
---|
| 5259 | + MatlabVectorToDoubleVector(&outvector,&outvector_rows,dataref);
|
---|
| 5260 | +
|
---|
| 5261 | + }
|
---|
| 5262 | + else{
|
---|
| 5263 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5264 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5265 | + }
|
---|
| 5266 | +
|
---|
| 5267 | + /*Assign output pointers:*/
|
---|
| 5268 | + *pvector=outvector;
|
---|
| 5269 | + if (pM)*pM=outvector_rows;
|
---|
| 5270 | +}
|
---|
| 5271 | +/*}}}*/
|
---|
| 5272 | +/*FUNCTION FetchData(int** pvector,int* pM,const mxArray* dataref){{{*/
|
---|
| 5273 | +void FetchData(int** pvector,int* pM,const mxArray* dataref){
|
---|
| 5274 | +
|
---|
| 5275 | + int i;
|
---|
| 5276 | + double *doublevector = NULL;
|
---|
| 5277 | + int *outvector = NULL;
|
---|
| 5278 | + int outvector_rows;
|
---|
| 5279 | +
|
---|
| 5280 | + if(mxIsEmpty(dataref)){
|
---|
| 5281 | + /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 5282 | + outvector_rows=0;
|
---|
| 5283 | + outvector=NULL;
|
---|
| 5284 | + }
|
---|
| 5285 | + else if (mxIsClass(dataref,"double") ){
|
---|
| 5286 | +
|
---|
| 5287 | + /*Convert matlab vector to double* vector: */
|
---|
| 5288 | + MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
|
---|
| 5289 | +
|
---|
| 5290 | + /*Convert double vector into integer vector: */
|
---|
| 5291 | + outvector=xNew<int>(outvector_rows);
|
---|
| 5292 | + for(i=0;i<outvector_rows;i++)outvector[i]=(int)doublevector[i];
|
---|
| 5293 | + }
|
---|
| 5294 | + else{
|
---|
| 5295 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5296 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5297 | + }
|
---|
| 5298 | +
|
---|
| 5299 | + /*Assign output pointers:*/
|
---|
| 5300 | + *pvector=outvector;
|
---|
| 5301 | + if (pM)*pM=outvector_rows;
|
---|
| 5302 | +}
|
---|
| 5303 | +/*}}}*/
|
---|
| 5304 | +/*FUNCTION FetchData(bool** pvector,int* pM,const mxArray* dataref){{{*/
|
---|
| 5305 | +void FetchData(bool** pvector,int* pM,const mxArray* dataref){
|
---|
| 5306 | +
|
---|
| 5307 | + int i;
|
---|
| 5308 | + double *doublevector = NULL;
|
---|
| 5309 | + bool *outvector = NULL;
|
---|
| 5310 | + int outvector_rows;
|
---|
| 5311 | +
|
---|
| 5312 | + if(mxIsEmpty(dataref)){
|
---|
| 5313 | + /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 5314 | + outvector_rows=0;
|
---|
| 5315 | + outvector=NULL;
|
---|
| 5316 | + }
|
---|
| 5317 | + else if (mxIsClass(dataref,"double") ){
|
---|
| 5318 | +
|
---|
| 5319 | + /*Convert matlab vector to double* vector: */
|
---|
| 5320 | + MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
|
---|
| 5321 | +
|
---|
| 5322 | + /*Convert double vector into integer vector: */
|
---|
| 5323 | + outvector=xNew<bool>(outvector_rows);
|
---|
| 5324 | + for(i=0;i<outvector_rows;i++)outvector[i]=(bool)doublevector[i];
|
---|
| 5325 | + }
|
---|
| 5326 | + else{
|
---|
| 5327 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5328 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5329 | + }
|
---|
| 5330 | +
|
---|
| 5331 | + /*Assign output pointers:*/
|
---|
| 5332 | + *pvector=outvector;
|
---|
| 5333 | + if (pM)*pM=outvector_rows;
|
---|
| 5334 | +}
|
---|
| 5335 | +/*}}}*/
|
---|
| 5336 | +/*FUNCTION FetchData(float** pvector,int* pM,const mxArray* dataref){{{*/
|
---|
| 5337 | +void FetchData(float** pvector,int* pM,const mxArray* dataref){
|
---|
| 5338 | +
|
---|
| 5339 | + int i;
|
---|
| 5340 | + double *doublevector = NULL;
|
---|
| 5341 | + float *outvector = NULL;
|
---|
| 5342 | + int outvector_rows;
|
---|
| 5343 | +
|
---|
| 5344 | + if(mxIsEmpty(dataref)){
|
---|
| 5345 | + /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 5346 | + outvector_rows=0;
|
---|
| 5347 | + outvector=NULL;
|
---|
| 5348 | + }
|
---|
| 5349 | + else if (mxIsClass(dataref,"double") ){
|
---|
| 5350 | +
|
---|
| 5351 | + /*Convert matlab vector to double* vector: */
|
---|
| 5352 | + MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
|
---|
| 5353 | +
|
---|
| 5354 | + /*Convert double vector into float vector: */
|
---|
| 5355 | + outvector=xNew<float>(outvector_rows);
|
---|
| 5356 | + for(i=0;i<outvector_rows;i++)outvector[i]=(float)doublevector[i];
|
---|
| 5357 | + }
|
---|
| 5358 | + else{
|
---|
| 5359 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5360 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5361 | + }
|
---|
| 5362 | +
|
---|
| 5363 | + /*Assign output pointers:*/
|
---|
| 5364 | + *pvector=outvector;
|
---|
| 5365 | + if (pM)*pM=outvector_rows;
|
---|
| 5366 | +}
|
---|
| 5367 | +/*}}}*/
|
---|
| 5368 | +/*FUNCTION FetchData(char** pstring,const mxArray* dataref){{{*/
|
---|
| 5369 | +void FetchData(char** pstring,const mxArray* dataref){
|
---|
| 5370 | +
|
---|
| 5371 | + char* outstring=NULL;
|
---|
| 5372 | +
|
---|
| 5373 | + /*Ok, the string should be coming directly from the matlab workspace: */
|
---|
| 5374 | + if (!mxIsClass(dataref,"char")){
|
---|
| 5375 | + _error_("input data_type is not a string!");
|
---|
| 5376 | + }
|
---|
| 5377 | + else{
|
---|
| 5378 | + /*Recover the string:*/
|
---|
| 5379 | + int stringlen;
|
---|
| 5380 | +
|
---|
| 5381 | + stringlen = mxGetM(dataref)*mxGetN(dataref)+1;
|
---|
| 5382 | + outstring =xNew<char>(stringlen);
|
---|
| 5383 | + mxGetString(dataref,outstring,stringlen);
|
---|
| 5384 | + }
|
---|
| 5385 | +
|
---|
| 5386 | + /*Assign output pointers:*/
|
---|
| 5387 | + *pstring=outstring;
|
---|
| 5388 | +}/*}}}*/
|
---|
| 5389 | +/*FUNCTION FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/
|
---|
| 5390 | +void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){
|
---|
| 5391 | +
|
---|
| 5392 | + int outmatrix_numel,outmatrix_ndims;
|
---|
| 5393 | + int* outmatrix_size=NULL;
|
---|
| 5394 | + char* outmatrix=NULL;
|
---|
| 5395 | +
|
---|
| 5396 | + if(mxIsEmpty(dataref) ){
|
---|
| 5397 | + /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 5398 | + outmatrix_numel=0;
|
---|
| 5399 | + outmatrix_ndims=0;
|
---|
| 5400 | + outmatrix_size =NULL;
|
---|
| 5401 | + outmatrix=NULL;
|
---|
| 5402 | + }
|
---|
| 5403 | + else if (mxIsClass(dataref,"char") ){
|
---|
| 5404 | +
|
---|
| 5405 | + /*Convert matlab n-dim array to char* matrix: */
|
---|
| 5406 | + MatlabNArrayToNArray(&outmatrix,&outmatrix_numel,&outmatrix_ndims,&outmatrix_size,dataref);
|
---|
| 5407 | + }
|
---|
| 5408 | + else{
|
---|
| 5409 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5410 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5411 | + }
|
---|
| 5412 | +
|
---|
| 5413 | + /*Assign output pointers:*/
|
---|
| 5414 | + *pmatrix=outmatrix;
|
---|
| 5415 | + if (pnumel)*pnumel=outmatrix_numel;
|
---|
| 5416 | + if (pndims)*pndims=outmatrix_ndims;
|
---|
| 5417 | + if (psize )*psize =outmatrix_size;
|
---|
| 5418 | + else xDelete<int>(outmatrix_size);
|
---|
| 5419 | +
|
---|
| 5420 | +}
|
---|
| 5421 | +/*}}}*/
|
---|
| 5422 | +/*FUNCTION FetchData(double* pscalar,const mxArray* dataref){{{*/
|
---|
| 5423 | +void FetchData(double* pscalar,const mxArray* dataref){
|
---|
| 5424 | +
|
---|
| 5425 | + double scalar;
|
---|
| 5426 | +
|
---|
| 5427 | + if (!mxIsClass(dataref,"double")){
|
---|
| 5428 | + _error_("input data_type is not a double!");
|
---|
| 5429 | + }
|
---|
| 5430 | + else{
|
---|
| 5431 | + /*Recover the double: */
|
---|
| 5432 | + scalar=mxGetScalar(dataref);
|
---|
| 5433 | + }
|
---|
| 5434 | +
|
---|
| 5435 | + /*Assign output pointers:*/
|
---|
| 5436 | + *pscalar=scalar;
|
---|
| 5437 | +}
|
---|
| 5438 | +/*}}}*/
|
---|
| 5439 | +/*FUNCTION FetchData(int* pinteger,const mxArray* dataref){{{*/
|
---|
| 5440 | +void FetchData(int* pinteger,const mxArray* dataref){
|
---|
| 5441 | +
|
---|
| 5442 | + int integer;
|
---|
| 5443 | +
|
---|
| 5444 | + if (!mxIsClass(dataref,"double")){
|
---|
| 5445 | + _error_("input data_type is not a scalar!");
|
---|
| 5446 | + }
|
---|
| 5447 | + else{
|
---|
| 5448 | + /*Recover the double: */
|
---|
| 5449 | + integer=(int)mxGetScalar(dataref);
|
---|
| 5450 | + }
|
---|
| 5451 | +
|
---|
| 5452 | + /*Assign output pointers:*/
|
---|
| 5453 | + *pinteger=integer;
|
---|
| 5454 | +}
|
---|
| 5455 | +/*}}}*/
|
---|
| 5456 | +/*FUNCTION FetchData(bool* pboolean,const mxArray* dataref){{{*/
|
---|
| 5457 | +void FetchData(bool* pboolean,const mxArray* dataref){
|
---|
| 5458 | +
|
---|
| 5459 | + bool* mxbool_ptr=NULL;
|
---|
| 5460 | +
|
---|
| 5461 | + if (mxIsClass(dataref,"logical")){
|
---|
| 5462 | + if(mxGetM(dataref)!=1) _error_("input data is not of size 1x1");
|
---|
| 5463 | + if(mxGetN(dataref)!=1) _error_("input data is not of size 1x1");
|
---|
| 5464 | + mxbool_ptr=mxGetLogicals(dataref);
|
---|
| 5465 | + }
|
---|
| 5466 | + else{
|
---|
| 5467 | + _error_("input data_type is not a bool!");
|
---|
| 5468 | + }
|
---|
| 5469 | +
|
---|
| 5470 | + *pboolean=*mxbool_ptr;
|
---|
| 5471 | +}
|
---|
| 5472 | +/*}}}*/
|
---|
| 5473 | +
|
---|
| 5474 | +/*ISSM objects*/
|
---|
| 5475 | +/*FUNCTION FetchData(Matrix<double>** pmatrix,const mxArray* dataref){{{*/
|
---|
| 5476 | +void FetchData(Matrix<double>** pmatrix,const mxArray* dataref){
|
---|
| 5477 | +
|
---|
| 5478 | + Matrix<double>* outmatrix=NULL;
|
---|
| 5479 | + int dummy=0;
|
---|
| 5480 | +
|
---|
| 5481 | + if (mxIsClass(dataref,"double") ){
|
---|
| 5482 | +
|
---|
| 5483 | + /*Convert matlab matrix to matrix: */
|
---|
| 5484 | + outmatrix=MatlabMatrixToMatrix(dataref);
|
---|
| 5485 | +
|
---|
| 5486 | + }
|
---|
| 5487 | + else{
|
---|
| 5488 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5489 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5490 | + }
|
---|
| 5491 | +
|
---|
| 5492 | + /*Assign output pointers:*/
|
---|
| 5493 | + *pmatrix=outmatrix;
|
---|
| 5494 | +}
|
---|
| 5495 | +/*}}}*/
|
---|
| 5496 | +/*FUNCTION FetchData(Vector<double>** pvector,const mxArray* dataref){{{*/
|
---|
| 5497 | +void FetchData(Vector<double>** pvector,const mxArray* dataref){
|
---|
| 5498 | +
|
---|
| 5499 | + Vector<double>* vector=NULL;
|
---|
| 5500 | + int dummy;
|
---|
| 5501 | +
|
---|
| 5502 | + if(mxIsEmpty(dataref)){
|
---|
| 5503 | + /*Nothing to pick up. Just initialize matrix pointer to NULL: */
|
---|
| 5504 | + vector=new Vector<double>(0);
|
---|
| 5505 | + }
|
---|
| 5506 | + else if (mxIsClass(dataref,"double") ){
|
---|
| 5507 | +
|
---|
| 5508 | + /*Convert matlab vector to petsc vector: */
|
---|
| 5509 | + vector=MatlabVectorToVector(dataref);
|
---|
| 5510 | + }
|
---|
| 5511 | + else{
|
---|
| 5512 | + /*This is an error: we don't have the correct input!: */
|
---|
| 5513 | + _error_("Input parameter of class " << mxGetClassName(dataref) << " not supported yet");
|
---|
| 5514 | + }
|
---|
| 5515 | +
|
---|
| 5516 | + /*Assign output pointers:*/
|
---|
| 5517 | + *pvector=vector;
|
---|
| 5518 | +}
|
---|
| 5519 | +/*}}}*/
|
---|
| 5520 | +/*FUNCTION FetchData(BamgGeom** pbamggeom,const mxArray* dataref){{{*/
|
---|
| 5521 | +void FetchData(BamgGeom** pbamggeom,const mxArray* dataref){
|
---|
| 5522 | +
|
---|
| 5523 | + /*Initialize output*/
|
---|
| 5524 | + BamgGeom* bamggeom=new BamgGeom();
|
---|
| 5525 | +
|
---|
| 5526 | + /*Fetch all fields*/
|
---|
| 5527 | + FetchData(&bamggeom->Vertices,&bamggeom->VerticesSize[0],&bamggeom->VerticesSize[1],mxGetAssignedField(dataref,0,"Vertices"));
|
---|
| 5528 | + FetchData(&bamggeom->Edges, &bamggeom->EdgesSize[0], &bamggeom->EdgesSize[1], mxGetAssignedField(dataref,0,"Edges"));
|
---|
| 5529 | + FetchData(&bamggeom->Corners, &bamggeom->CornersSize[0], &bamggeom->CornersSize[1], mxGetAssignedField(dataref,0,"Corners"));
|
---|
| 5530 | + FetchData(&bamggeom->RequiredVertices,&bamggeom->RequiredVerticesSize[0],&bamggeom->RequiredVerticesSize[1],mxGetAssignedField(dataref,0,"RequiredVertices"));
|
---|
| 5531 | + FetchData(&bamggeom->RequiredEdges, &bamggeom->RequiredEdgesSize[0], &bamggeom->RequiredEdgesSize[1], mxGetAssignedField(dataref,0,"RequiredEdges"));
|
---|
| 5532 | + FetchData(&bamggeom->CrackedEdges,&bamggeom->CrackedEdgesSize[0],&bamggeom->CrackedEdgesSize[1],mxGetAssignedField(dataref,0,"CrackedEdges"));
|
---|
| 5533 | + FetchData(&bamggeom->SubDomains,&bamggeom->SubDomainsSize[0],&bamggeom->SubDomainsSize[1],mxGetAssignedField(dataref,0,"SubDomains"));
|
---|
| 5534 | +
|
---|
| 5535 | + /*Assign output pointers:*/
|
---|
| 5536 | + *pbamggeom=bamggeom;
|
---|
| 5537 | +}
|
---|
| 5538 | +/*}}}*/
|
---|
| 5539 | +/*FUNCTION FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){{{*/
|
---|
| 5540 | +void FetchData(BamgMesh** pbamgmesh,const mxArray* dataref){
|
---|
| 5541 | +
|
---|
| 5542 | + /*Initialize output*/
|
---|
| 5543 | + BamgMesh* bamgmesh=new BamgMesh();
|
---|
| 5544 | +
|
---|
| 5545 | + /*Fetch all fields*/
|
---|
| 5546 | + FetchData(&bamgmesh->Vertices,&bamgmesh->VerticesSize[0],&bamgmesh->VerticesSize[1],mxGetAssignedField(dataref,0,"Vertices"));
|
---|
| 5547 | + FetchData(&bamgmesh->Edges, &bamgmesh->EdgesSize[0], &bamgmesh->EdgesSize[1], mxGetAssignedField(dataref,0,"Edges"));
|
---|
| 5548 | + FetchData(&bamgmesh->Triangles, &bamgmesh->TrianglesSize[0], &bamgmesh->TrianglesSize[1], mxGetAssignedField(dataref,0,"Triangles"));
|
---|
| 5549 | + FetchData(&bamgmesh->CrackedEdges,&bamgmesh->CrackedEdgesSize[0],&bamgmesh->CrackedEdgesSize[1],mxGetAssignedField(dataref,0,"CrackedEdges"));
|
---|
| 5550 | + FetchData(&bamgmesh->VerticesOnGeomEdge,&bamgmesh->VerticesOnGeomEdgeSize[0],&bamgmesh->VerticesOnGeomEdgeSize[1],mxGetAssignedField(dataref,0,"VerticesOnGeomEdge"));
|
---|
| 5551 | + FetchData(&bamgmesh->VerticesOnGeomVertex,&bamgmesh->VerticesOnGeomVertexSize[0],&bamgmesh->VerticesOnGeomVertexSize[1],mxGetAssignedField(dataref,0,"VerticesOnGeomVertex"));
|
---|
| 5552 | + FetchData(&bamgmesh->EdgesOnGeomEdge, &bamgmesh->EdgesOnGeomEdgeSize[0], &bamgmesh->EdgesOnGeomEdgeSize[1], mxGetAssignedField(dataref,0,"EdgesOnGeomEdge"));
|
---|
| 5553 | + FetchData(&bamgmesh->IssmSegments,&bamgmesh->IssmSegmentsSize[0],&bamgmesh->IssmSegmentsSize[1],mxGetAssignedField(dataref,0,"IssmSegments"));
|
---|
| 5554 | +
|
---|
| 5555 | + /*Assign output pointers:*/
|
---|
| 5556 | + *pbamgmesh=bamgmesh;
|
---|
| 5557 | +}
|
---|
| 5558 | +/*}}}*/
|
---|
| 5559 | +/*FUNCTION FetchData(BamgOpts** pbamgopts,const mxArray* dataref){{{*/
|
---|
| 5560 | +void FetchData(BamgOpts** pbamgopts,const mxArray* dataref){
|
---|
| 5561 | +
|
---|
| 5562 | + /*Initialize output*/
|
---|
| 5563 | + BamgOpts* bamgopts=new BamgOpts();
|
---|
| 5564 | +
|
---|
| 5565 | + /*Fetch all fields*/
|
---|
| 5566 | + FetchData(&bamgopts->anisomax,mxGetField(dataref,0,"anisomax"));
|
---|
| 5567 | + FetchData(&bamgopts->cutoff,mxGetField(dataref,0,"cutoff"));
|
---|
| 5568 | + FetchData(&bamgopts->coeff,mxGetField(dataref,0,"coeff"));
|
---|
| 5569 | + FetchData(&bamgopts->errg,mxGetField(dataref,0,"errg"));
|
---|
| 5570 | + FetchData(&bamgopts->gradation,mxGetField(dataref,0,"gradation"));
|
---|
| 5571 | + FetchData(&bamgopts->Hessiantype,mxGetField(dataref,0,"Hessiantype"));
|
---|
| 5572 | + FetchData(&bamgopts->MaxCornerAngle,mxGetField(dataref,0,"MaxCornerAngle"));
|
---|
| 5573 | + FetchData(&bamgopts->maxnbv,mxGetField(dataref,0,"maxnbv"));
|
---|
| 5574 | + FetchData(&bamgopts->maxsubdiv,mxGetField(dataref,0,"maxsubdiv"));
|
---|
| 5575 | + FetchData(&bamgopts->Metrictype,mxGetField(dataref,0,"Metrictype"));
|
---|
| 5576 | + FetchData(&bamgopts->nbjacobi,mxGetField(dataref,0,"nbjacobi"));
|
---|
| 5577 | + FetchData(&bamgopts->nbsmooth,mxGetField(dataref,0,"nbsmooth"));
|
---|
| 5578 | + FetchData(&bamgopts->omega,mxGetField(dataref,0,"omega"));
|
---|
| 5579 | + FetchData(&bamgopts->power,mxGetField(dataref,0,"power"));
|
---|
| 5580 | + FetchData(&bamgopts->verbose,mxGetField(dataref,0,"verbose"));
|
---|
| 5581 | +
|
---|
| 5582 | + FetchData(&bamgopts->Crack,mxGetField(dataref,0,"Crack"));
|
---|
| 5583 | + FetchData(&bamgopts->geometricalmetric,mxGetField(dataref,0,"geometricalmetric"));
|
---|
| 5584 | + FetchData(&bamgopts->KeepVertices,mxGetField(dataref,0,"KeepVertices"));
|
---|
| 5585 | + FetchData(&bamgopts->splitcorners,mxGetField(dataref,0,"splitcorners"));
|
---|
| 5586 | +
|
---|
| 5587 | + FetchData(&bamgopts->hmin,mxGetField(dataref,0,"hmin"));
|
---|
| 5588 | + FetchData(&bamgopts->hmax,mxGetField(dataref,0,"hmax"));
|
---|
| 5589 | + FetchData(&bamgopts->hminVertices,&bamgopts->hminVerticesSize[0],&bamgopts->hminVerticesSize[1],mxGetField(dataref,0,"hminVertices"));
|
---|
| 5590 | + FetchData(&bamgopts->hmaxVertices,&bamgopts->hmaxVerticesSize[0],&bamgopts->hmaxVerticesSize[1],mxGetField(dataref,0,"hmaxVertices"));
|
---|
| 5591 | + FetchData(&bamgopts->hVertices,&bamgopts->hVerticesSize[0],&bamgopts->hVerticesSize[1],mxGetField(dataref,0,"hVertices"));
|
---|
| 5592 | + FetchData(&bamgopts->metric,&bamgopts->metricSize[0],&bamgopts->metricSize[1],mxGetField(dataref,0,"metric"));
|
---|
| 5593 | + FetchData(&bamgopts->field,&bamgopts->fieldSize[0],&bamgopts->fieldSize[1],mxGetField(dataref,0,"field"));
|
---|
| 5594 | + FetchData(&bamgopts->err,&bamgopts->errSize[0],&bamgopts->errSize[1],mxGetField(dataref,0,"err"));
|
---|
| 5595 | +
|
---|
| 5596 | + /*Additional checks*/
|
---|
| 5597 | + bamgopts->Check();
|
---|
| 5598 | +
|
---|
| 5599 | + /*Assign output pointers:*/
|
---|
| 5600 | + *pbamgopts=bamgopts;
|
---|
| 5601 | +}
|
---|
| 5602 | +/*}}}*/
|
---|
| 5603 | +/*FUNCTION FetchData(Options** poptions,const mxArray** pdataref){{{*/
|
---|
| 5604 | +void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref){
|
---|
| 5605 | +
|
---|
| 5606 | + char *name = NULL;
|
---|
| 5607 | + Option *option = NULL;
|
---|
| 5608 | +
|
---|
| 5609 | + /*Initialize output*/
|
---|
| 5610 | + Options* options=new Options();
|
---|
| 5611 | +
|
---|
| 5612 | + /*Fetch all options*/
|
---|
| 5613 | + for (int i=istart; i<nrhs; i=i+2){
|
---|
| 5614 | + if (!mxIsClass(pdataref[i],"char")) _error_("Argument " << i+1 << " must be name of option");
|
---|
| 5615 | +
|
---|
| 5616 | + FetchData(&name,pdataref[i]);
|
---|
| 5617 | + if(i+1 == nrhs) _error_("Argument " << i+2 << " must exist and be value of option \"" << name << "\".");
|
---|
| 5618 | +
|
---|
| 5619 | + option=(Option*)OptionParse(name,&pdataref[i+1]);
|
---|
| 5620 | + options->AddOption(option);
|
---|
| 5621 | + option=NULL;
|
---|
| 5622 | + }
|
---|
| 5623 | +
|
---|
| 5624 | + /*Assign output pointers:*/
|
---|
| 5625 | + *poptions=options;
|
---|
| 5626 | +}
|
---|
| 5627 | +/*}}}*/
|
---|
| 5628 | +/*FUNCTION FetchData(DataSet** pcontours,const mxArray* dataref){{{*/
|
---|
| 5629 | +void FetchData(DataSet** pcontours,const mxArray* dataref){
|
---|
| 5630 | +
|
---|
| 5631 | + int numcontours,index,test1,test2;
|
---|
| 5632 | + char *contourname = NULL;
|
---|
| 5633 | + DataSet *contours = NULL;
|
---|
| 5634 | + Contour<double> *contouri = NULL;
|
---|
| 5635 | +
|
---|
| 5636 | + if (mxIsClass(dataref,"char")){
|
---|
| 5637 | + FetchData(&contourname,dataref);
|
---|
| 5638 | + contours=DomainOutlineRead<double>(contourname);
|
---|
| 5639 | + }
|
---|
| 5640 | + else if(mxIsClass(dataref,"struct")){
|
---|
| 5641 | +
|
---|
| 5642 | + contours=new DataSet(0);
|
---|
| 5643 | + numcontours=mxGetNumberOfElements(dataref);
|
---|
| 5644 | +
|
---|
| 5645 | + for(int i=0;i<numcontours;i++){
|
---|
| 5646 | +
|
---|
| 5647 | + contouri=xNew<Contour<double> >(1);
|
---|
| 5648 | +
|
---|
| 5649 | + index = mxGetFieldNumber(dataref,"nods");
|
---|
| 5650 | + if(index==-1) _error_("input structure does not have a 'nods' field");
|
---|
| 5651 | + FetchData(&contouri->nods,mxGetFieldByNumber(dataref,i,index));
|
---|
| 5652 | +
|
---|
| 5653 | + index = mxGetFieldNumber(dataref,"x");
|
---|
| 5654 | + if(index==-1) _error_("input structure does not have a 'x' field");
|
---|
| 5655 | + FetchData(&contouri->x,&test1,&test2,mxGetFieldByNumber(dataref,i,index));
|
---|
| 5656 | + if(test1!=contouri->nods || test2!=1) _error_("field x should be of size ["<<contouri->nods<<" 1]");
|
---|
| 5657 | +
|
---|
| 5658 | + index = mxGetFieldNumber(dataref,"y");
|
---|
| 5659 | + if(index==-1) _error_("input structure does not have a 'y' field");
|
---|
| 5660 | + FetchData(&contouri->y,&test1,&test2,mxGetFieldByNumber(dataref,i,index));
|
---|
| 5661 | + if(test1!=contouri->nods || test2!=1) _error_("field y should be of size ["<<contouri->nods<<" 1]");
|
---|
| 5662 | +
|
---|
| 5663 | + contours->AddObject(contouri);
|
---|
| 5664 | + }
|
---|
| 5665 | + }
|
---|
| 5666 | + else{
|
---|
| 5667 | + _error_("Contour is neither a string nor a structure and cannot be loaded ("<<mxGetClassName(dataref)<<" not supported)");
|
---|
| 5668 | + }
|
---|
| 5669 | +
|
---|
| 5670 | + /*clean-up and assign output pointer*/
|
---|
| 5671 | + xDelete<char>(contourname);
|
---|
| 5672 | + *pcontours=contours;
|
---|
| 5673 | +}
|
---|
| 5674 | +/*}}}*/
|
---|
| 5675 | Index: ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToDoubleVector.cpp
|
---|
| 5676 | ===================================================================
|
---|
| 5677 | --- ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToDoubleVector.cpp (revision 0)
|
---|
| 5678 | +++ ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToDoubleVector.cpp (revision 13749)
|
---|
| 5679 | @@ -0,0 +1,93 @@
|
---|
| 5680 | +/* \file MatlabVectorToDoubleVector.cpp
|
---|
| 5681 | + * \brief: convert a sparse or dense matlab vector to a serial vector:
|
---|
| 5682 | + */
|
---|
| 5683 | +
|
---|
| 5684 | +#ifdef HAVE_CONFIG_H
|
---|
| 5685 | + #include <config.h>
|
---|
| 5686 | +#else
|
---|
| 5687 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 5688 | +#endif
|
---|
| 5689 | +
|
---|
| 5690 | +#include <string.h>
|
---|
| 5691 | +
|
---|
| 5692 | +/*Matlab includes: */
|
---|
| 5693 | +#include "./matlabio.h"
|
---|
| 5694 | +#include "../../c/shared/shared.h"
|
---|
| 5695 | +
|
---|
| 5696 | +int MatlabVectorToDoubleVector(double** pvector,int* pvector_rows,const mxArray* mxvector){
|
---|
| 5697 | +
|
---|
| 5698 | + int rows,cols;
|
---|
| 5699 | + double* mxvector_ptr=NULL;
|
---|
| 5700 | + int ierr;
|
---|
| 5701 | + int i,j;
|
---|
| 5702 | +
|
---|
| 5703 | + /*output: */
|
---|
| 5704 | + double* vector=NULL;
|
---|
| 5705 | +
|
---|
| 5706 | + /*matlab indices: */
|
---|
| 5707 | + mwIndex* ir=NULL;
|
---|
| 5708 | + mwIndex* jc=NULL;
|
---|
| 5709 | + double* pr=NULL;
|
---|
| 5710 | + int count;
|
---|
| 5711 | + int nnz;
|
---|
| 5712 | + int nz;
|
---|
| 5713 | +
|
---|
| 5714 | + /*Ok, first check if we are dealing with a sparse or full vector: */
|
---|
| 5715 | + if (mxIsSparse(mxvector)){
|
---|
| 5716 | +
|
---|
| 5717 | + /*Dealing with sparse vector: recover size first: */
|
---|
| 5718 | + mxvector_ptr=(double*)mxGetPr(mxvector);
|
---|
| 5719 | + rows=mxGetM(mxvector);
|
---|
| 5720 | + cols=mxGetN(mxvector);
|
---|
| 5721 | + nnz=mxGetNzmax(mxvector);
|
---|
| 5722 | +
|
---|
| 5723 | + /*Check that input is actualy a vector*/
|
---|
| 5724 | + if (cols!=1) _error_("input vector of size " << rows << "x" << cols << " should have only one column");
|
---|
| 5725 | +
|
---|
| 5726 | + nz=(int)((double)nnz/(double)rows);
|
---|
| 5727 | +
|
---|
| 5728 | + if(rows){
|
---|
| 5729 | + vector=xNewZeroInit<double>(rows);
|
---|
| 5730 | +
|
---|
| 5731 | + /*Now, get ir,jc and pr: */
|
---|
| 5732 | + pr=mxGetPr(mxvector);
|
---|
| 5733 | + ir=mxGetIr(mxvector);
|
---|
| 5734 | + jc=mxGetJc(mxvector);
|
---|
| 5735 | +
|
---|
| 5736 | + /*Now, start inserting data into sparse vector: */
|
---|
| 5737 | + count=0;
|
---|
| 5738 | + for(i=0;i<cols;i++){
|
---|
| 5739 | + for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 5740 | + vector[ir[count]]=pr[count];
|
---|
| 5741 | + count++;
|
---|
| 5742 | + }
|
---|
| 5743 | + }
|
---|
| 5744 | + }
|
---|
| 5745 | +
|
---|
| 5746 | + }
|
---|
| 5747 | + else{
|
---|
| 5748 | +
|
---|
| 5749 | + /*Dealing with dense vector: recover pointer and size: */
|
---|
| 5750 | + mxvector_ptr=(double*)mxGetPr(mxvector);
|
---|
| 5751 | + rows=mxGetM(mxvector);
|
---|
| 5752 | + cols=mxGetN(mxvector);
|
---|
| 5753 | +
|
---|
| 5754 | + /*Check that input is actualy a vector*/
|
---|
| 5755 | + if (cols!=1) _error_("input vector of size " << rows << "x" << cols << " should have only one column");
|
---|
| 5756 | +
|
---|
| 5757 | + /*allocate and memcpy*/
|
---|
| 5758 | + if(rows){
|
---|
| 5759 | + vector=xNew<double>(rows);
|
---|
| 5760 | + memcpy(vector,mxvector_ptr,rows*sizeof(double));
|
---|
| 5761 | + }
|
---|
| 5762 | + else{
|
---|
| 5763 | + vector=NULL;
|
---|
| 5764 | + }
|
---|
| 5765 | + }
|
---|
| 5766 | +
|
---|
| 5767 | + /*Assign output pointer: */
|
---|
| 5768 | + *pvector=vector;
|
---|
| 5769 | + *pvector_rows=rows;
|
---|
| 5770 | +
|
---|
| 5771 | + return 1;
|
---|
| 5772 | +}
|
---|
| 5773 | Index: ../trunk-jpl/src/wrappers/matlab/io/WriteMatlabData.cpp
|
---|
| 5774 | ===================================================================
|
---|
| 5775 | --- ../trunk-jpl/src/wrappers/matlab/io/WriteMatlabData.cpp (revision 0)
|
---|
| 5776 | +++ ../trunk-jpl/src/wrappers/matlab/io/WriteMatlabData.cpp (revision 13749)
|
---|
| 5777 | @@ -0,0 +1,388 @@
|
---|
| 5778 | +/* \file WriteData.c:
|
---|
| 5779 | + * \brief: general interface for writing data
|
---|
| 5780 | + */
|
---|
| 5781 | +
|
---|
| 5782 | +#ifdef HAVE_CONFIG_H
|
---|
| 5783 | + #include <config.h>
|
---|
| 5784 | +#else
|
---|
| 5785 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 5786 | +#endif
|
---|
| 5787 | +
|
---|
| 5788 | +#include "./matlabio.h"
|
---|
| 5789 | +#include "../../c/shared/shared.h"
|
---|
| 5790 | +
|
---|
| 5791 | +/*Primitive data types*/
|
---|
| 5792 | +/*FUNCTION WriteData(mxArray** pdataref,double* matrix, int M,int N){{{*/
|
---|
| 5793 | +void WriteData(mxArray** pdataref,double* matrix, int M,int N){
|
---|
| 5794 | +
|
---|
| 5795 | + mxArray *dataref = NULL;
|
---|
| 5796 | + double *tmatrix = NULL;
|
---|
| 5797 | +
|
---|
| 5798 | + if(matrix){
|
---|
| 5799 | + /*create the matlab matrixwith Matlab's memory manager */
|
---|
| 5800 | + tmatrix=(double*)mxMalloc(M*N*sizeof(double));
|
---|
| 5801 | + for(int i=0;i<M;i++){
|
---|
| 5802 | + for(int j=0;j<N;j++){
|
---|
| 5803 | + tmatrix[j*M+i]=matrix[i*N+j];
|
---|
| 5804 | + }
|
---|
| 5805 | + }
|
---|
| 5806 | + dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 5807 | + mxSetM(dataref,(mwSize)M);
|
---|
| 5808 | + mxSetN(dataref,(mwSize)N);
|
---|
| 5809 | + mxSetPr(dataref,(double*)tmatrix);
|
---|
| 5810 | + }
|
---|
| 5811 | + else{
|
---|
| 5812 | + dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 5813 | + }
|
---|
| 5814 | + *pdataref=dataref;
|
---|
| 5815 | +}
|
---|
| 5816 | +/*}}}*/
|
---|
| 5817 | +/*FUNCTION WriteData(mxArray** pdataref,int* matrix, int M,int N){{{*/
|
---|
| 5818 | +void WriteData(mxArray** pdataref,int* matrix, int M,int N){
|
---|
| 5819 | +
|
---|
| 5820 | + mxArray* dataref = NULL;
|
---|
| 5821 | + double* tmatrix = NULL;
|
---|
| 5822 | +
|
---|
| 5823 | + if(matrix){
|
---|
| 5824 | + /*convert to double matrix using Matlab's memory manager*/
|
---|
| 5825 | + double* tmatrix=(double*)mxMalloc(M*N*sizeof(double));
|
---|
| 5826 | + for(int i=0;i<M;i++){
|
---|
| 5827 | + for(int j=0;j<N;j++){
|
---|
| 5828 | + tmatrix[j*M+i]=(double)matrix[i*N+j];
|
---|
| 5829 | + }
|
---|
| 5830 | + }
|
---|
| 5831 | + dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 5832 | + mxSetM(dataref,(mwSize)M);
|
---|
| 5833 | + mxSetN(dataref,(mwSize)N);
|
---|
| 5834 | + mxSetPr(dataref,(double*)tmatrix);
|
---|
| 5835 | + }
|
---|
| 5836 | + else{
|
---|
| 5837 | + dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 5838 | + }
|
---|
| 5839 | + *pdataref=dataref;
|
---|
| 5840 | +}
|
---|
| 5841 | +/*}}}*/
|
---|
| 5842 | +/*FUNCTION WriteData(mxArray** pdataref,double* vector, int M){{{*/
|
---|
| 5843 | +void WriteData(mxArray** pdataref,double* vector, int M){
|
---|
| 5844 | +
|
---|
| 5845 | + mxArray* dataref = NULL;
|
---|
| 5846 | + double* vector_matlab = NULL;
|
---|
| 5847 | +
|
---|
| 5848 | + if(vector){
|
---|
| 5849 | +
|
---|
| 5850 | + /*create the matlab vector with Matlab's memory manager */
|
---|
| 5851 | + vector_matlab=(double*)mxMalloc(M*sizeof(double));
|
---|
| 5852 | + for(int i=0;i<M;i++) vector_matlab[i]=vector[i];
|
---|
| 5853 | + dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 5854 | + mxSetM(dataref,(mwSize)M);
|
---|
| 5855 | + mxSetN(dataref,(mwSize)1);
|
---|
| 5856 | + mxSetPr(dataref,vector_matlab);
|
---|
| 5857 | + }
|
---|
| 5858 | + else{
|
---|
| 5859 | + dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 5860 | + }
|
---|
| 5861 | +
|
---|
| 5862 | + *pdataref=dataref;
|
---|
| 5863 | +}
|
---|
| 5864 | +/*}}}*/
|
---|
| 5865 | +/*FUNCTION WriteData(mxArray** pdataref,double scalar){{{*/
|
---|
| 5866 | +void WriteData(mxArray** pdataref,double scalar){
|
---|
| 5867 | +
|
---|
| 5868 | + *pdataref=mxCreateDoubleScalar(scalar);
|
---|
| 5869 | +}
|
---|
| 5870 | +/*}}}*/
|
---|
| 5871 | +/*FUNCTION WriteData(mxArray** pdataref,int integer){{{*/
|
---|
| 5872 | +void WriteData(mxArray** pdataref,int integer){
|
---|
| 5873 | +
|
---|
| 5874 | + *pdataref=mxCreateDoubleScalar((double)integer);
|
---|
| 5875 | +
|
---|
| 5876 | +}
|
---|
| 5877 | +/*}}}*/
|
---|
| 5878 | +/*FUNCTION WriteData(mxArray** pdataref,int boolean){{{*/
|
---|
| 5879 | +void WriteData(mxArray** pdataref,bool boolean){
|
---|
| 5880 | +
|
---|
| 5881 | + *pdataref=mxCreateDoubleScalar((double)boolean);
|
---|
| 5882 | +
|
---|
| 5883 | +}
|
---|
| 5884 | +/*}}}*/
|
---|
| 5885 | +/*FUNCTION WriteData(mxArray** pdataref,char* string){{{*/
|
---|
| 5886 | +void WriteData(mxArray** pdataref,char* string){
|
---|
| 5887 | +
|
---|
| 5888 | + *pdataref=mxCreateString(string);
|
---|
| 5889 | +}
|
---|
| 5890 | +/*}}}*/
|
---|
| 5891 | +/*FUNCTION WriteData(mxArray** pdataref){{{*/
|
---|
| 5892 | +void WriteData(mxArray** pdataref){
|
---|
| 5893 | +
|
---|
| 5894 | + ;
|
---|
| 5895 | +
|
---|
| 5896 | +}
|
---|
| 5897 | +/*}}}*/
|
---|
| 5898 | +
|
---|
| 5899 | +/*ISSM objects*/
|
---|
| 5900 | +/*FUNCTION WriteData(mxArray** pdataref,BamgGeom* bamggeom){{{*/
|
---|
| 5901 | +void WriteData(mxArray** pdataref,BamgGeom* bamggeom){
|
---|
| 5902 | +
|
---|
| 5903 | + /*Intermediary*/
|
---|
| 5904 | + int i;
|
---|
| 5905 | + mxArray *dataref = NULL;
|
---|
| 5906 | + const int numfields = 8;
|
---|
| 5907 | + const char *fnames[numfields];
|
---|
| 5908 | + mwSize ndim = 2;
|
---|
| 5909 | + mwSize dimensions[2] = {1,1};
|
---|
| 5910 | +
|
---|
| 5911 | + /*Initialize field names*/
|
---|
| 5912 | + i=0;
|
---|
| 5913 | + fnames[i++] = "Vertices";
|
---|
| 5914 | + fnames[i++] = "Edges";
|
---|
| 5915 | + fnames[i++] = "TangentAtEdges";
|
---|
| 5916 | + fnames[i++] = "Corners";
|
---|
| 5917 | + fnames[i++] = "RequiredVertices";
|
---|
| 5918 | + fnames[i++] = "RequiredEdges";
|
---|
| 5919 | + fnames[i++] = "CrackedEdges";
|
---|
| 5920 | + fnames[i++] = "SubDomains";
|
---|
| 5921 | + _assert_(i==numfields);
|
---|
| 5922 | +
|
---|
| 5923 | + /*Initialize Matlab structure*/
|
---|
| 5924 | + dataref=mxCreateStructArray(ndim,dimensions,numfields,fnames);
|
---|
| 5925 | +
|
---|
| 5926 | + /*set each matlab each field*/
|
---|
| 5927 | + i=0;
|
---|
| 5928 | + i++; SetStructureField(dataref,"Vertices", bamggeom->VerticesSize[0], bamggeom->VerticesSize[1], bamggeom->Vertices);
|
---|
| 5929 | + i++; SetStructureField(dataref,"Edges", bamggeom->EdgesSize[0], bamggeom->EdgesSize[1], bamggeom->Edges);
|
---|
| 5930 | + i++; SetStructureField(dataref,"TangentAtEdges", bamggeom->TangentAtEdgesSize[0], bamggeom->TangentAtEdgesSize[1], bamggeom->TangentAtEdges);
|
---|
| 5931 | + i++; SetStructureField(dataref,"Corners", bamggeom->CornersSize[0], bamggeom->CornersSize[1], bamggeom->Corners);
|
---|
| 5932 | + i++; SetStructureField(dataref,"RequiredVertices",bamggeom->RequiredVerticesSize[0],bamggeom->RequiredVerticesSize[1],bamggeom->RequiredVertices);
|
---|
| 5933 | + i++; SetStructureField(dataref,"RequiredEdges", bamggeom->RequiredEdgesSize[0], bamggeom->RequiredEdgesSize[1], bamggeom->RequiredEdges);
|
---|
| 5934 | + i++; SetStructureField(dataref,"CrackedEdges", bamggeom->CrackedEdgesSize[0], bamggeom->CrackedEdgesSize[1], bamggeom->CrackedEdges);
|
---|
| 5935 | + i++; SetStructureField(dataref,"SubDomains", bamggeom->SubDomainsSize[0], bamggeom->SubDomainsSize[1], bamggeom->SubDomains);
|
---|
| 5936 | + _assert_(i==numfields);
|
---|
| 5937 | +
|
---|
| 5938 | + /*Assign output*/
|
---|
| 5939 | + *pdataref=dataref;
|
---|
| 5940 | +}
|
---|
| 5941 | +/*}}}*/
|
---|
| 5942 | +/*FUNCTION WriteData(mxArray** pdataref,BamgMesh* bamgmesh){{{*/
|
---|
| 5943 | +void WriteData(mxArray** pdataref,BamgMesh* bamgmesh){
|
---|
| 5944 | +
|
---|
| 5945 | + /*Intermediary*/
|
---|
| 5946 | + int i;
|
---|
| 5947 | + mxArray *dataref = NULL;
|
---|
| 5948 | + const int numfields = 16;
|
---|
| 5949 | + const char *fnames[numfields];
|
---|
| 5950 | + mwSize ndim = 2;
|
---|
| 5951 | + mwSize dimensions[2] = {1,1};
|
---|
| 5952 | +
|
---|
| 5953 | + /*Initialize field names*/
|
---|
| 5954 | + i=0;
|
---|
| 5955 | + fnames[i++] = "Vertices";
|
---|
| 5956 | + fnames[i++] = "Edges";
|
---|
| 5957 | + fnames[i++] = "Triangles";
|
---|
| 5958 | + fnames[i++] = "Quadrilaterals";
|
---|
| 5959 | + fnames[i++] = "IssmEdges";
|
---|
| 5960 | + fnames[i++] = "IssmSegments";
|
---|
| 5961 | + fnames[i++] = "VerticesOnGeomVertex";
|
---|
| 5962 | + fnames[i++] = "VerticesOnGeomEdge";
|
---|
| 5963 | + fnames[i++] = "EdgesOnGeomEdge";
|
---|
| 5964 | + fnames[i++] = "SubDomains";
|
---|
| 5965 | + fnames[i++] = "SubDomainsFromGeom";
|
---|
| 5966 | + fnames[i++] = "ElementConnectivity";
|
---|
| 5967 | + fnames[i++] = "NodalConnectivity";
|
---|
| 5968 | + fnames[i++] = "NodalElementConnectivity";
|
---|
| 5969 | + fnames[i++] = "CrackedVertices";
|
---|
| 5970 | + fnames[i++] = "CrackedEdges";
|
---|
| 5971 | + _assert_(i==numfields);
|
---|
| 5972 | +
|
---|
| 5973 | + /*Initialize Matlab structure*/
|
---|
| 5974 | + dataref=mxCreateStructArray(ndim,dimensions,numfields,fnames);
|
---|
| 5975 | +
|
---|
| 5976 | + /*set each matlab each field*/
|
---|
| 5977 | + i=0;
|
---|
| 5978 | + i++; SetStructureField(dataref,"Vertices",bamgmesh->VerticesSize[0], bamgmesh->VerticesSize[1],bamgmesh->Vertices);
|
---|
| 5979 | + i++; SetStructureField(dataref,"Edges", bamgmesh->EdgesSize[0],bamgmesh->EdgesSize[1], bamgmesh->Edges);
|
---|
| 5980 | + i++; SetStructureField(dataref,"Triangles", bamgmesh->TrianglesSize[0],bamgmesh->TrianglesSize[1], bamgmesh->Triangles);
|
---|
| 5981 | + i++; SetStructureField(dataref,"Quadrilaterals",bamgmesh->QuadrilateralsSize[0], bamgmesh->QuadrilateralsSize[1],bamgmesh->Quadrilaterals);
|
---|
| 5982 | + i++; SetStructureField(dataref,"IssmEdges", bamgmesh->IssmEdgesSize[0],bamgmesh->IssmEdgesSize[1], bamgmesh->IssmEdges);
|
---|
| 5983 | + i++; SetStructureField(dataref,"IssmSegments",bamgmesh->IssmSegmentsSize[0], bamgmesh->IssmSegmentsSize[1],bamgmesh->IssmSegments);
|
---|
| 5984 | + i++; SetStructureField(dataref,"VerticesOnGeomVertex",bamgmesh->VerticesOnGeomVertexSize[0],bamgmesh->VerticesOnGeomVertexSize[1], bamgmesh->VerticesOnGeomVertex);
|
---|
| 5985 | + i++; SetStructureField(dataref,"VerticesOnGeomEdge",bamgmesh->VerticesOnGeomEdgeSize[0],bamgmesh->VerticesOnGeomEdgeSize[1], bamgmesh->VerticesOnGeomEdge);
|
---|
| 5986 | + i++; SetStructureField(dataref,"EdgesOnGeomEdge", bamgmesh->EdgesOnGeomEdgeSize[0], bamgmesh->EdgesOnGeomEdgeSize[1],bamgmesh->EdgesOnGeomEdge);
|
---|
| 5987 | + i++; SetStructureField(dataref,"SubDomains",bamgmesh->SubDomainsSize[0], bamgmesh->SubDomainsSize[1],bamgmesh->SubDomains);
|
---|
| 5988 | + i++; SetStructureField(dataref,"SubDomainsFromGeom", bamgmesh->SubDomainsFromGeomSize[0], bamgmesh->SubDomainsFromGeomSize[1],bamgmesh->SubDomainsFromGeom);
|
---|
| 5989 | + i++; SetStructureField(dataref,"ElementConnectivity",bamgmesh->ElementConnectivitySize[0],bamgmesh->ElementConnectivitySize[1], bamgmesh->ElementConnectivity);
|
---|
| 5990 | + i++; SetStructureField(dataref,"NodalConnectivity",bamgmesh->NodalConnectivitySize[0],bamgmesh->NodalConnectivitySize[1], bamgmesh->NodalConnectivity);
|
---|
| 5991 | + i++; SetStructureField(dataref,"NodalElementConnectivity", bamgmesh->NodalElementConnectivitySize[0], bamgmesh->NodalElementConnectivitySize[1],bamgmesh->NodalElementConnectivity);
|
---|
| 5992 | + i++; SetStructureField(dataref,"CrackedVertices", bamgmesh->CrackedVerticesSize[0],bamgmesh->CrackedVerticesSize[1], bamgmesh->CrackedVertices);
|
---|
| 5993 | + i++; SetStructureField(dataref,"CrackedEdges",bamgmesh->CrackedEdgesSize[0], bamgmesh->CrackedEdgesSize[1],bamgmesh->CrackedEdges);
|
---|
| 5994 | + _assert_(i==numfields);
|
---|
| 5995 | +
|
---|
| 5996 | + /*Assign output*/
|
---|
| 5997 | + *pdataref=dataref;
|
---|
| 5998 | +}
|
---|
| 5999 | +/*}}}*/
|
---|
| 6000 | +/*FUNCTION WriteData(mxArray** pdataref,SeqMat<double>* matrix){{{*/
|
---|
| 6001 | +void WriteData(mxArray** pdataref,SeqMat<double>* matrix){
|
---|
| 6002 | +
|
---|
| 6003 | + int i,j;
|
---|
| 6004 | + int rows,cols;
|
---|
| 6005 | + mxArray *dataref = NULL;
|
---|
| 6006 | + double *matrix_ptr = NULL;
|
---|
| 6007 | + double *tmatrix_ptr = NULL;
|
---|
| 6008 | +
|
---|
| 6009 | + if(matrix){
|
---|
| 6010 | +
|
---|
| 6011 | + matrix_ptr=matrix->ToSerial();
|
---|
| 6012 | + matrix->GetSize(&rows,&cols);
|
---|
| 6013 | +
|
---|
| 6014 | + /*Now transpose the matrix and allocate with Matlab's memory manager: */
|
---|
| 6015 | + tmatrix_ptr=(double*)mxMalloc(rows*cols*sizeof(double));
|
---|
| 6016 | + for(i=0;i<rows;i++){
|
---|
| 6017 | + for(j=0;j<cols;j++){
|
---|
| 6018 | + tmatrix_ptr[j*rows+i]=matrix_ptr[i*cols+j];
|
---|
| 6019 | + }
|
---|
| 6020 | + }
|
---|
| 6021 | +
|
---|
| 6022 | + /*create matlab matrix: */
|
---|
| 6023 | + dataref=mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 6024 | + mxSetM(dataref,rows);
|
---|
| 6025 | + mxSetN(dataref,cols);
|
---|
| 6026 | + mxSetPr(dataref,tmatrix_ptr);
|
---|
| 6027 | +
|
---|
| 6028 | + /*Free ressources:*/
|
---|
| 6029 | + xDelete<double>(matrix_ptr);
|
---|
| 6030 | + }
|
---|
| 6031 | + else{
|
---|
| 6032 | + dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 6033 | + }
|
---|
| 6034 | +
|
---|
| 6035 | + *pdataref=dataref;
|
---|
| 6036 | +}
|
---|
| 6037 | +/*}}}*/
|
---|
| 6038 | +/*FUNCTION WriteData(mxArray** pdataref,SeqVec<double>* vector){{{*/
|
---|
| 6039 | +void WriteData(mxArray** pdataref,SeqVec<double>* vector){
|
---|
| 6040 | +
|
---|
| 6041 | + mxArray* dataref=NULL;
|
---|
| 6042 | + double* vector_ptr=NULL;
|
---|
| 6043 | + double* vector_matlab=NULL;
|
---|
| 6044 | + int rows;
|
---|
| 6045 | +
|
---|
| 6046 | + if(vector){
|
---|
| 6047 | + /*call toolkit routine: */
|
---|
| 6048 | + vector_ptr=vector->ToMPISerial();
|
---|
| 6049 | + vector->GetSize(&rows);
|
---|
| 6050 | +
|
---|
| 6051 | + /*now create the matlab vector with Matlab's memory manager */
|
---|
| 6052 | + vector_matlab=(double*)mxMalloc(rows*sizeof(double));
|
---|
| 6053 | + for(int i=0;i<rows;i++) vector_matlab[i]=vector_ptr[i];
|
---|
| 6054 | +
|
---|
| 6055 | + dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 6056 | + mxSetM(dataref,rows);
|
---|
| 6057 | + mxSetN(dataref,1);
|
---|
| 6058 | + mxSetPr(dataref,vector_matlab);
|
---|
| 6059 | + }
|
---|
| 6060 | + else{
|
---|
| 6061 | + dataref = mxCreateDoubleMatrix(0,0,mxREAL);
|
---|
| 6062 | + }
|
---|
| 6063 | +
|
---|
| 6064 | + /*Clean-up and return*/
|
---|
| 6065 | + xDelete<double>(vector_ptr);
|
---|
| 6066 | + *pdataref=dataref;
|
---|
| 6067 | +}
|
---|
| 6068 | +/*}}}*/
|
---|
| 6069 | +/*FUNCTION WriteData(mxArray** pdataref,RiftStruct* riftstruct){{{*/
|
---|
| 6070 | +void WriteData(mxArray** pdataref,RiftStruct* riftstruct){
|
---|
| 6071 | +
|
---|
| 6072 | + /*Intermediary*/
|
---|
| 6073 | + int i;
|
---|
| 6074 | + mxArray *dataref = NULL;
|
---|
| 6075 | + const int numfields = 10;
|
---|
| 6076 | + const char *fnames[numfields];
|
---|
| 6077 | + mwSize ndim = 2;
|
---|
| 6078 | + mwSize dimensions[2] = {1,1};
|
---|
| 6079 | +
|
---|
| 6080 | + /*Initialize field names*/
|
---|
| 6081 | + i=0;
|
---|
| 6082 | + fnames[i++] = "numsegs";
|
---|
| 6083 | + fnames[i++] = "segments";
|
---|
| 6084 | + fnames[i++] = "pairs";
|
---|
| 6085 | + fnames[i++] = "tips";
|
---|
| 6086 | + fnames[i++] = "penaltypairs";
|
---|
| 6087 | + fnames[i++] = "fill";
|
---|
| 6088 | + fnames[i++] = "friction";
|
---|
| 6089 | + fnames[i++] = "fraction";
|
---|
| 6090 | + fnames[i++] = "fractionincrement";
|
---|
| 6091 | + fnames[i++] = "state";
|
---|
| 6092 | + _assert_(i==numfields);
|
---|
| 6093 | +
|
---|
| 6094 | + /*Initialize matlab structure of dimension numrifts*/
|
---|
| 6095 | + dimensions[0]=riftstruct->numrifts;
|
---|
| 6096 | + dataref=mxCreateStructArray(ndim,dimensions,numfields,fnames);
|
---|
| 6097 | +
|
---|
| 6098 | + /*set each matlab each field*/
|
---|
| 6099 | + for(int i=0;i<riftstruct->numrifts;i++){
|
---|
| 6100 | + SetStructureFieldi(dataref,i,"numsegs" ,riftstruct->riftsnumsegments[i]);
|
---|
| 6101 | + SetStructureFieldi(dataref,i,"segments" ,riftstruct->riftsnumsegments[i] ,3,riftstruct->riftssegments[i]);
|
---|
| 6102 | + SetStructureFieldi(dataref,i,"pairs" ,riftstruct->riftsnumpairs[i] ,2,riftstruct->riftspairs[i]);
|
---|
| 6103 | + SetStructureFieldi(dataref,i,"tips" ,1 ,2,&riftstruct->riftstips[2*i]);
|
---|
| 6104 | + SetStructureFieldi(dataref,i,"penaltypairs" ,riftstruct->riftsnumpenaltypairs[i],7,riftstruct->riftspenaltypairs[i]);
|
---|
| 6105 | + SetStructureFieldi(dataref,i,"fill" ,IceEnum);
|
---|
| 6106 | + SetStructureFieldi(dataref,i,"friction" ,0);
|
---|
| 6107 | + SetStructureFieldi(dataref,i,"fraction" ,0.);
|
---|
| 6108 | + SetStructureFieldi(dataref,i,"fractionincrement",0.1);
|
---|
| 6109 | + SetStructureFieldi(dataref,i,"state" ,riftstruct->riftsnumpenaltypairs[i],1,riftstruct->state[i]);
|
---|
| 6110 | + }
|
---|
| 6111 | +
|
---|
| 6112 | + /*Assign output*/
|
---|
| 6113 | + *pdataref=dataref;
|
---|
| 6114 | +}
|
---|
| 6115 | +/*}}}*/
|
---|
| 6116 | +
|
---|
| 6117 | +/*Toolkit*/
|
---|
| 6118 | +/*FUNCTION SetStructureField{{{*/
|
---|
| 6119 | +void SetStructureField(mxArray* dataref,const char* fieldname,int M,int N,double* fieldpointer){
|
---|
| 6120 | +
|
---|
| 6121 | + mxArray* field = NULL;
|
---|
| 6122 | +
|
---|
| 6123 | + /*Convert field*/
|
---|
| 6124 | + WriteData(&field,fieldpointer,M,N);
|
---|
| 6125 | +
|
---|
| 6126 | + /*Assign to structure*/
|
---|
| 6127 | + mxSetField(dataref,0,fieldname,field);
|
---|
| 6128 | +}
|
---|
| 6129 | +/*}}}*/
|
---|
| 6130 | +/*FUNCTION SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int M,int N,double* fieldpointer){{{*/
|
---|
| 6131 | +void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int M,int N,double* fieldpointer){
|
---|
| 6132 | +
|
---|
| 6133 | + mxArray* field = NULL;
|
---|
| 6134 | +
|
---|
| 6135 | + /*Convert field*/
|
---|
| 6136 | + WriteData(&field,fieldpointer,M,N);
|
---|
| 6137 | +
|
---|
| 6138 | + /*Assign to structure*/
|
---|
| 6139 | + mxSetField(dataref,i,fieldname,field);
|
---|
| 6140 | +}
|
---|
| 6141 | +/*}}}*/
|
---|
| 6142 | +/*FUNCTION SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int field){{{*/
|
---|
| 6143 | +void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int fieldin){
|
---|
| 6144 | +
|
---|
| 6145 | + mxArray* field = NULL;
|
---|
| 6146 | +
|
---|
| 6147 | + /*Convert field*/
|
---|
| 6148 | + WriteData(&field,fieldin);
|
---|
| 6149 | +
|
---|
| 6150 | + /*Assign to structure*/
|
---|
| 6151 | + mxSetField(dataref,i,fieldname,field);
|
---|
| 6152 | +}
|
---|
| 6153 | +/*}}}*/
|
---|
| 6154 | +/*FUNCTION SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,double field){{{*/
|
---|
| 6155 | +void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,double fieldin){
|
---|
| 6156 | +
|
---|
| 6157 | + mxArray* field = NULL;
|
---|
| 6158 | +
|
---|
| 6159 | + /*Convert field*/
|
---|
| 6160 | + WriteData(&field,fieldin);
|
---|
| 6161 | +
|
---|
| 6162 | + /*Assign to structure*/
|
---|
| 6163 | + mxSetField(dataref,i,fieldname,field);
|
---|
| 6164 | +}
|
---|
| 6165 | +/*}}}*/
|
---|
| 6166 | Index: ../trunk-jpl/src/wrappers/matlab/io/mxGetAssignedField.cpp
|
---|
| 6167 | ===================================================================
|
---|
| 6168 | --- ../trunk-jpl/src/wrappers/matlab/io/mxGetAssignedField.cpp (revision 0)
|
---|
| 6169 | +++ ../trunk-jpl/src/wrappers/matlab/io/mxGetAssignedField.cpp (revision 13749)
|
---|
| 6170 | @@ -0,0 +1,39 @@
|
---|
| 6171 | +/*!\file: mxGetAssignedField.c:
|
---|
| 6172 | + * \brief: abstract interface on parallel side for i/o, so it ressembles the serial i/o.
|
---|
| 6173 | + *
|
---|
| 6174 | + * In serial mode, this routine takes care of returning the field coming
|
---|
| 6175 | + * from the model. If largesize is 1, we are running out of core models in
|
---|
| 6176 | + * matlab, and we need to call the subsref private method from the model object
|
---|
| 6177 | + * in order to correctly load the data from disk.
|
---|
| 6178 | + */
|
---|
| 6179 | +
|
---|
| 6180 | +#include "./matlabio.h"
|
---|
| 6181 | +
|
---|
| 6182 | +mxArray* mxGetAssignedField(const mxArray* pmxa_array,int number,const char* field){
|
---|
| 6183 | +
|
---|
| 6184 | + //output
|
---|
| 6185 | + mxArray* mxfield=NULL;
|
---|
| 6186 | +
|
---|
| 6187 | + //input
|
---|
| 6188 | + mxArray *inputs[2];
|
---|
| 6189 | + mxArray *pindex = NULL;
|
---|
| 6190 | + const char *fnames[2];
|
---|
| 6191 | + mwSize ndim = 2;
|
---|
| 6192 | + mwSize onebyone[2] = {1,1};
|
---|
| 6193 | +
|
---|
| 6194 | + //We want to call the subsasgn method, and get the returned array.This ensures that if we are running
|
---|
| 6195 | + //large sized problems, the data is truly loaded from disk by the model subsasgn class method.
|
---|
| 6196 | + inputs[0]=(mxArray*)pmxa_array; //this is the model
|
---|
| 6197 | +
|
---|
| 6198 | + //create index structure used in the assignment (index.type='.' and index.subs='x' for field x for ex)
|
---|
| 6199 | + fnames[0] = "type";
|
---|
| 6200 | + fnames[1] = "subs";
|
---|
| 6201 | + pindex=mxCreateStructArray( ndim,onebyone,2,fnames);
|
---|
| 6202 | + mxSetField( pindex, 0, "type",mxCreateString("."));
|
---|
| 6203 | + mxSetField( pindex, 0, "subs",mxCreateString(field));
|
---|
| 6204 | + inputs[1]=pindex;
|
---|
| 6205 | +
|
---|
| 6206 | + mexCallMATLAB( 1, &mxfield, 2, (mxArray**)inputs, "subsref");
|
---|
| 6207 | +
|
---|
| 6208 | + return mxfield;
|
---|
| 6209 | +}
|
---|
| 6210 | Index: ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToDoubleMatrix.cpp
|
---|
| 6211 | ===================================================================
|
---|
| 6212 | --- ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToDoubleMatrix.cpp (revision 0)
|
---|
| 6213 | +++ ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToDoubleMatrix.cpp (revision 13749)
|
---|
| 6214 | @@ -0,0 +1,130 @@
|
---|
| 6215 | +/* \file MatlabMatrixToDoubleMatrix.cpp
|
---|
| 6216 | + * \brief: convert a sparse or dense matlab matrix to a double* pointer
|
---|
| 6217 | + */
|
---|
| 6218 | +
|
---|
| 6219 | +#ifdef HAVE_CONFIG_H
|
---|
| 6220 | + #include <config.h>
|
---|
| 6221 | +#else
|
---|
| 6222 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 6223 | +#endif
|
---|
| 6224 | +
|
---|
| 6225 | +/*Matlab includes: */
|
---|
| 6226 | +#include "./matlabio.h"
|
---|
| 6227 | +#include "../../c/shared/shared.h"
|
---|
| 6228 | +
|
---|
| 6229 | +int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
|
---|
| 6230 | +
|
---|
| 6231 | + int i,j,count,rows,cols;
|
---|
| 6232 | +
|
---|
| 6233 | + /*output: */
|
---|
| 6234 | + double* matrix=NULL;
|
---|
| 6235 | +
|
---|
| 6236 | + /*matlab indices: */
|
---|
| 6237 | + mwIndex* ir=NULL;
|
---|
| 6238 | + mwIndex* jc=NULL;
|
---|
| 6239 | +
|
---|
| 6240 | + /*Ok, first check if we are dealing with a sparse or full matrix: */
|
---|
| 6241 | + if (mxIsSparse(mxmatrix)){
|
---|
| 6242 | +
|
---|
| 6243 | + /*Dealing with sparse matrix: recover size first: */
|
---|
| 6244 | + double* pmxmatrix=(double*)mxGetPr(mxmatrix);
|
---|
| 6245 | + rows=mxGetM(mxmatrix);
|
---|
| 6246 | + cols=mxGetN(mxmatrix);
|
---|
| 6247 | +
|
---|
| 6248 | + if(rows*cols){
|
---|
| 6249 | + matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 6250 | +
|
---|
| 6251 | + /*Now, get ir,jc and pr: */
|
---|
| 6252 | + ir=mxGetIr(mxmatrix);
|
---|
| 6253 | + jc=mxGetJc(mxmatrix);
|
---|
| 6254 | +
|
---|
| 6255 | + /*Now, start inserting data into double* matrix: */
|
---|
| 6256 | + count=0;
|
---|
| 6257 | + for(i=0;i<cols;i++){
|
---|
| 6258 | + for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 6259 | + matrix[rows*ir[count]+i]=pmxmatrix[count];
|
---|
| 6260 | + count++;
|
---|
| 6261 | + }
|
---|
| 6262 | + }
|
---|
| 6263 | + }
|
---|
| 6264 | +
|
---|
| 6265 | + }
|
---|
| 6266 | + else if(mxIsClass(mxmatrix,"double")){
|
---|
| 6267 | + /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 6268 | + double* pmxmatrix=(double*)mxGetPr(mxmatrix);
|
---|
| 6269 | + rows=mxGetM(mxmatrix);
|
---|
| 6270 | + cols=mxGetN(mxmatrix);
|
---|
| 6271 | +
|
---|
| 6272 | + /*Create serial matrix: */
|
---|
| 6273 | + if(rows*cols){
|
---|
| 6274 | + matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 6275 | +
|
---|
| 6276 | + for(i=0;i<rows;i++){
|
---|
| 6277 | + for(j=0;j<cols;j++){
|
---|
| 6278 | + matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
|
---|
| 6279 | + }
|
---|
| 6280 | + }
|
---|
| 6281 | + }
|
---|
| 6282 | + }
|
---|
| 6283 | + else if(mxIsClass(mxmatrix,"single")){
|
---|
| 6284 | + /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 6285 | + float *pmxmatrix=(float*)mxGetPr(mxmatrix);
|
---|
| 6286 | + rows=mxGetM(mxmatrix);
|
---|
| 6287 | + cols=mxGetN(mxmatrix);
|
---|
| 6288 | +
|
---|
| 6289 | + /*Create serial matrix: */
|
---|
| 6290 | + if(rows*cols){
|
---|
| 6291 | + matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 6292 | +
|
---|
| 6293 | + for(i=0;i<rows;i++){
|
---|
| 6294 | + for(j=0;j<cols;j++){
|
---|
| 6295 | + matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
|
---|
| 6296 | + }
|
---|
| 6297 | + }
|
---|
| 6298 | + }
|
---|
| 6299 | + }
|
---|
| 6300 | + else if(mxIsClass(mxmatrix,"int16")){
|
---|
| 6301 | + /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 6302 | + short int *pmxmatrix=(short*)mxGetPr(mxmatrix);
|
---|
| 6303 | + rows=mxGetM(mxmatrix);
|
---|
| 6304 | + cols=mxGetN(mxmatrix);
|
---|
| 6305 | +
|
---|
| 6306 | + /*Create serial matrix: */
|
---|
| 6307 | + if(rows*cols){
|
---|
| 6308 | + matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 6309 | +
|
---|
| 6310 | + for(i=0;i<rows;i++){
|
---|
| 6311 | + for(j=0;j<cols;j++){
|
---|
| 6312 | + matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
|
---|
| 6313 | + }
|
---|
| 6314 | + }
|
---|
| 6315 | + }
|
---|
| 6316 | + }
|
---|
| 6317 | + else if(mxIsClass(mxmatrix,"uint8")){
|
---|
| 6318 | + /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 6319 | + char *pmxmatrix=(char*)mxGetPr(mxmatrix);
|
---|
| 6320 | + rows=mxGetM(mxmatrix);
|
---|
| 6321 | + cols=mxGetN(mxmatrix);
|
---|
| 6322 | +
|
---|
| 6323 | + /*Create serial matrix: */
|
---|
| 6324 | + if(rows*cols){
|
---|
| 6325 | + matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 6326 | +
|
---|
| 6327 | + for(i=0;i<rows;i++){
|
---|
| 6328 | + for(j=0;j<cols;j++){
|
---|
| 6329 | + matrix[cols*i+j]=(double)pmxmatrix[rows*j+i];
|
---|
| 6330 | + }
|
---|
| 6331 | + }
|
---|
| 6332 | + }
|
---|
| 6333 | + }
|
---|
| 6334 | + else{
|
---|
| 6335 | + _error_("Matlab matrix type Not implemented yet");
|
---|
| 6336 | + }
|
---|
| 6337 | +
|
---|
| 6338 | + /*Assign output pointer: */
|
---|
| 6339 | + *pmatrix=matrix;
|
---|
| 6340 | + *pmatrix_rows=rows;
|
---|
| 6341 | + *pmatrix_cols=cols;
|
---|
| 6342 | +
|
---|
| 6343 | + return 1;
|
---|
| 6344 | +}
|
---|
| 6345 | Index: ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToPetscMat.cpp
|
---|
| 6346 | ===================================================================
|
---|
| 6347 | --- ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToPetscMat.cpp (revision 0)
|
---|
| 6348 | +++ ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToPetscMat.cpp (revision 13749)
|
---|
| 6349 | @@ -0,0 +1,122 @@
|
---|
| 6350 | +/* \file MatlabMatrixToPetscMatrix.cpp
|
---|
| 6351 | + * \brief: convert a sparse or dense matlab matrix to a serial Petsc matrix:
|
---|
| 6352 | + */
|
---|
| 6353 | +
|
---|
| 6354 | +#ifdef HAVE_CONFIG_H
|
---|
| 6355 | + #include <config.h>
|
---|
| 6356 | +#else
|
---|
| 6357 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 6358 | +#endif
|
---|
| 6359 | +#include "../../c/shared/shared.h"
|
---|
| 6360 | +
|
---|
| 6361 | +/*Petsc includes: */
|
---|
| 6362 | +#include <petscmat.h>
|
---|
| 6363 | +#include <petscvec.h>
|
---|
| 6364 | +#include <petscksp.h>
|
---|
| 6365 | +
|
---|
| 6366 | +/*Matlab includes: */
|
---|
| 6367 | +#include "./matlabio.h"
|
---|
| 6368 | +
|
---|
| 6369 | +PetscMat* MatlabMatrixToPetscMat(const mxArray* mxmatrix){
|
---|
| 6370 | +
|
---|
| 6371 | + int dummy;
|
---|
| 6372 | + PetscMat* matrix=new PetscMat();
|
---|
| 6373 | +
|
---|
| 6374 | + MatlabMatrixToPetscMat(&matrix->matrix, &dummy, &dummy, mxmatrix);
|
---|
| 6375 | +
|
---|
| 6376 | + return matrix;
|
---|
| 6377 | +}
|
---|
| 6378 | +int MatlabMatrixToPetscMat(Mat* pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){
|
---|
| 6379 | +
|
---|
| 6380 | + int rows, cols;
|
---|
| 6381 | + double *mxmatrix_ptr = NULL;
|
---|
| 6382 | + double *tmatrix = NULL;
|
---|
| 6383 | + int ierr;
|
---|
| 6384 | + int i,j;
|
---|
| 6385 | +
|
---|
| 6386 | + /*output: */
|
---|
| 6387 | + Mat matrix = NULL;
|
---|
| 6388 | +
|
---|
| 6389 | + /*matlab indices: */
|
---|
| 6390 | + mwIndex *ir = NULL;
|
---|
| 6391 | + mwIndex *jc = NULL;
|
---|
| 6392 | + double *pr = NULL;
|
---|
| 6393 | + int count;
|
---|
| 6394 | + int nnz;
|
---|
| 6395 | + int nz;
|
---|
| 6396 | +
|
---|
| 6397 | + /*petsc indices: */
|
---|
| 6398 | + int *idxm = NULL;
|
---|
| 6399 | + int *idxn = NULL;
|
---|
| 6400 | +
|
---|
| 6401 | + /*Ok, first check if we are dealing with a sparse or full matrix: */
|
---|
| 6402 | + if (mxIsSparse(mxmatrix)){
|
---|
| 6403 | +
|
---|
| 6404 | + /*Dealing with sparse matrix: recover size first: */
|
---|
| 6405 | + mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
|
---|
| 6406 | + rows=mxGetM(mxmatrix);
|
---|
| 6407 | + cols=mxGetN(mxmatrix);
|
---|
| 6408 | + nnz=mxGetNzmax(mxmatrix);
|
---|
| 6409 | + if(rows){
|
---|
| 6410 | + nz=(int)((double)nnz/(double)rows);
|
---|
| 6411 | + }
|
---|
| 6412 | + else{
|
---|
| 6413 | + nz=0;
|
---|
| 6414 | + }
|
---|
| 6415 | +
|
---|
| 6416 | + ierr=MatCreateSeqAIJ(PETSC_COMM_SELF,rows,cols,nz,PETSC_NULL,&matrix);CHKERRQ(ierr);
|
---|
| 6417 | +
|
---|
| 6418 | + /*Now, get ir,jc and pr: */
|
---|
| 6419 | + pr=mxGetPr(mxmatrix);
|
---|
| 6420 | + ir=mxGetIr(mxmatrix);
|
---|
| 6421 | + jc=mxGetJc(mxmatrix);
|
---|
| 6422 | +
|
---|
| 6423 | + /*Now, start inserting data into sparse matrix: */
|
---|
| 6424 | + count=0;
|
---|
| 6425 | + for(i=0;i<cols;i++){
|
---|
| 6426 | + for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 6427 | + MatSetValue(matrix,ir[count],i,pr[count],INSERT_VALUES);
|
---|
| 6428 | + count++;
|
---|
| 6429 | + }
|
---|
| 6430 | + }
|
---|
| 6431 | + }
|
---|
| 6432 | + else{
|
---|
| 6433 | + /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 6434 | + mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
|
---|
| 6435 | + rows=mxGetM(mxmatrix);
|
---|
| 6436 | + cols=mxGetN(mxmatrix);
|
---|
| 6437 | +
|
---|
| 6438 | + /*transpose, as Petsc now does not allows MAT_COLUMN_ORIENTED matrices in MatSetValues: */
|
---|
| 6439 | + tmatrix=xNew<double>(rows*cols);
|
---|
| 6440 | + for(i=0;i<cols;i++){
|
---|
| 6441 | + for(j=0;j<rows;j++){
|
---|
| 6442 | + *(tmatrix+rows*i+j)=*(mxmatrix_ptr+cols*j+i);
|
---|
| 6443 | + }
|
---|
| 6444 | + }
|
---|
| 6445 | +
|
---|
| 6446 | + /*Create serial matrix: */
|
---|
| 6447 | + ierr=MatCreateSeqDense(PETSC_COMM_SELF,rows,cols,NULL,&matrix);CHKERRQ(ierr);
|
---|
| 6448 | +
|
---|
| 6449 | + /*Insert mxmatrix_ptr values into petsc matrix: */
|
---|
| 6450 | + idxm=xNew<int>(rows);
|
---|
| 6451 | + idxn=xNew<int>(cols);
|
---|
| 6452 | +
|
---|
| 6453 | + for(i=0;i<rows;i++)idxm[i]=i;
|
---|
| 6454 | + for(i=0;i<cols;i++)idxn[i]=i;
|
---|
| 6455 | +
|
---|
| 6456 | + ierr=MatSetValues(matrix,rows,idxm,cols,idxn,tmatrix,INSERT_VALUES); CHKERRQ(ierr);
|
---|
| 6457 | +
|
---|
| 6458 | + xDelete<double>(tmatrix);
|
---|
| 6459 | + }
|
---|
| 6460 | +
|
---|
| 6461 | + /*Assemble matrix: */
|
---|
| 6462 | + MatAssemblyBegin(matrix,MAT_FINAL_ASSEMBLY);
|
---|
| 6463 | + MatAssemblyEnd(matrix,MAT_FINAL_ASSEMBLY);
|
---|
| 6464 | +
|
---|
| 6465 | + /*Assign output pointer: */
|
---|
| 6466 | + *pmatrix=matrix;
|
---|
| 6467 | + if(pmatrix_rows) *pmatrix_rows=rows;
|
---|
| 6468 | + if(pmatrix_cols) *pmatrix_cols=cols;
|
---|
| 6469 | +
|
---|
| 6470 | + return 1;
|
---|
| 6471 | +}
|
---|
| 6472 | Index: ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToVector.cpp
|
---|
| 6473 | ===================================================================
|
---|
| 6474 | --- ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToVector.cpp (revision 0)
|
---|
| 6475 | +++ ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToVector.cpp (revision 13749)
|
---|
| 6476 | @@ -0,0 +1,31 @@
|
---|
| 6477 | +/*!\file MatlabVectorToVector.cpp
|
---|
| 6478 | + */
|
---|
| 6479 | +
|
---|
| 6480 | +/*Headers:*/
|
---|
| 6481 | +#ifdef HAVE_CONFIG_H
|
---|
| 6482 | + #include <config.h>
|
---|
| 6483 | +#else
|
---|
| 6484 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 6485 | +#endif
|
---|
| 6486 | +#include <stdio.h>
|
---|
| 6487 | +#include <string.h>
|
---|
| 6488 | +#include "./matlabio.h"
|
---|
| 6489 | +#include "../../c/shared/shared.h"
|
---|
| 6490 | +#include "../../c/toolkits/toolkits.h"
|
---|
| 6491 | +
|
---|
| 6492 | +Vector<double>* MatlabVectorToVector(const mxArray* mxvector){
|
---|
| 6493 | +
|
---|
| 6494 | + int dummy;
|
---|
| 6495 | + Vector<double>* vector=NULL;
|
---|
| 6496 | +
|
---|
| 6497 | + /*allocate vector object: */
|
---|
| 6498 | + vector=new Vector<double>();
|
---|
| 6499 | +
|
---|
| 6500 | + #ifdef _HAVE_PETSC_
|
---|
| 6501 | + vector->pvector=MatlabVectorToPetscVec(mxvector);
|
---|
| 6502 | + #else
|
---|
| 6503 | + vector->svector=MatlabVectorToSeqVec(mxvector);
|
---|
| 6504 | + #endif
|
---|
| 6505 | +
|
---|
| 6506 | + return vector;
|
---|
| 6507 | +}
|
---|
| 6508 | Index: ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToMatrix.cpp
|
---|
| 6509 | ===================================================================
|
---|
| 6510 | --- ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToMatrix.cpp (revision 0)
|
---|
| 6511 | +++ ../trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToMatrix.cpp (revision 13749)
|
---|
| 6512 | @@ -0,0 +1,31 @@
|
---|
| 6513 | +/*!\file MatlabMatrixToMatrix.cpp
|
---|
| 6514 | + */
|
---|
| 6515 | +
|
---|
| 6516 | +#ifdef HAVE_CONFIG_H
|
---|
| 6517 | + #include <config.h>
|
---|
| 6518 | +#else
|
---|
| 6519 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 6520 | +#endif
|
---|
| 6521 | +
|
---|
| 6522 | +#include <stdio.h>
|
---|
| 6523 | +#include <string.h>
|
---|
| 6524 | +#include "./matlabio.h"
|
---|
| 6525 | +#include "../../c/shared/shared.h"
|
---|
| 6526 | +#include "../../c/toolkits/toolkits.h"
|
---|
| 6527 | +
|
---|
| 6528 | +Matrix<double>* MatlabMatrixToMatrix(const mxArray* mxmatrix){
|
---|
| 6529 | +
|
---|
| 6530 | + int dummy;
|
---|
| 6531 | + Matrix<double>* matrix=NULL;
|
---|
| 6532 | +
|
---|
| 6533 | + /*allocate matrix object: */
|
---|
| 6534 | + matrix=new Matrix<double>();
|
---|
| 6535 | +
|
---|
| 6536 | + #ifdef _HAVE_PETSC_
|
---|
| 6537 | + matrix->pmatrix=MatlabMatrixToPetscMat(mxmatrix);
|
---|
| 6538 | + #else
|
---|
| 6539 | + matrix->smatrix=MatlabMatrixToSeqMat(mxmatrix);
|
---|
| 6540 | + #endif
|
---|
| 6541 | +
|
---|
| 6542 | + return matrix;
|
---|
| 6543 | +}
|
---|
| 6544 | Index: ../trunk-jpl/src/wrappers/matlab/io/MatlabNArrayToNArray.cpp
|
---|
| 6545 | ===================================================================
|
---|
| 6546 | --- ../trunk-jpl/src/wrappers/matlab/io/MatlabNArrayToNArray.cpp (revision 0)
|
---|
| 6547 | +++ ../trunk-jpl/src/wrappers/matlab/io/MatlabNArrayToNArray.cpp (revision 13749)
|
---|
| 6548 | @@ -0,0 +1,250 @@
|
---|
| 6549 | +/* \file MatlabNArrayToNArray.cpp
|
---|
| 6550 | + * \brief: convert a sparse or dense matlab n-dimensional array to cpp n-dimensional array
|
---|
| 6551 | + */
|
---|
| 6552 | +
|
---|
| 6553 | +#ifdef HAVE_CONFIG_H
|
---|
| 6554 | + #include <config.h>
|
---|
| 6555 | +#else
|
---|
| 6556 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 6557 | +#endif
|
---|
| 6558 | +
|
---|
| 6559 | +#include "./matlabio.h"
|
---|
| 6560 | +#include "../../c/shared/shared.h"
|
---|
| 6561 | +#include "../../c/include/include.h"
|
---|
| 6562 | +
|
---|
| 6563 | +/*FUNCTION MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
|
---|
| 6564 | +int MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
|
---|
| 6565 | +
|
---|
| 6566 | + int i,j,rows,cols;
|
---|
| 6567 | + int numel,ndims;
|
---|
| 6568 | + int *size,*dims;
|
---|
| 6569 | + double* mxmatrix_ptr=NULL;
|
---|
| 6570 | + const mwSize* ipt=NULL;
|
---|
| 6571 | +
|
---|
| 6572 | + /*output: */
|
---|
| 6573 | + double* matrix=NULL;
|
---|
| 6574 | +
|
---|
| 6575 | + /*matlab indices: */
|
---|
| 6576 | + mwIndex *ir = NULL;
|
---|
| 6577 | + mwIndex *jc = NULL;
|
---|
| 6578 | + double *pr = NULL;
|
---|
| 6579 | + int count;
|
---|
| 6580 | +
|
---|
| 6581 | + /*get Matlab matrix information: */
|
---|
| 6582 | + numel=mxGetNumberOfElements(mxmatrix);
|
---|
| 6583 | + ndims=mxGetNumberOfDimensions(mxmatrix);
|
---|
| 6584 | + ipt =mxGetDimensions(mxmatrix);
|
---|
| 6585 | + size =xNew<int>(ndims);
|
---|
| 6586 | + for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
|
---|
| 6587 | +
|
---|
| 6588 | + /*Ok, first check if we are dealing with a sparse or full matrix: */
|
---|
| 6589 | + if (mxIsSparse(mxmatrix)){
|
---|
| 6590 | +
|
---|
| 6591 | + /*Dealing with sparse matrix: recover size first: */
|
---|
| 6592 | + rows = mxGetM(mxmatrix);
|
---|
| 6593 | + cols = mxGetN(mxmatrix);
|
---|
| 6594 | +
|
---|
| 6595 | + matrix=xNewZeroInit<double>(rows*cols);
|
---|
| 6596 | +
|
---|
| 6597 | + /*Now, get ir,jc and pr: */
|
---|
| 6598 | + ir = mxGetIr(mxmatrix);
|
---|
| 6599 | + jc = mxGetJc(mxmatrix);
|
---|
| 6600 | + pr = mxGetPr(mxmatrix);
|
---|
| 6601 | +
|
---|
| 6602 | + /*Now, start inserting data into double* matrix: */
|
---|
| 6603 | + count=0;
|
---|
| 6604 | + for(i=0;i<cols;i++){
|
---|
| 6605 | + for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 6606 | + *(matrix+rows*ir[count]+i)=pr[count];
|
---|
| 6607 | + count++;
|
---|
| 6608 | + }
|
---|
| 6609 | + }
|
---|
| 6610 | +
|
---|
| 6611 | + }
|
---|
| 6612 | + else{
|
---|
| 6613 | +
|
---|
| 6614 | + /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 6615 | + mxmatrix_ptr=(double*)mxGetPr(mxmatrix);
|
---|
| 6616 | +
|
---|
| 6617 | + /*Create serial matrix: */
|
---|
| 6618 | + matrix=xNewZeroInit<double>(numel);
|
---|
| 6619 | +
|
---|
| 6620 | + dims=xNew<int>(ndims);
|
---|
| 6621 | + for(i=0;i<numel;i++){
|
---|
| 6622 | + ColumnWiseDimsFromIndex(dims,i,size,ndims);
|
---|
| 6623 | + j = IndexFromRowWiseDims(dims,size,ndims);
|
---|
| 6624 | + matrix[j]=(double)mxmatrix_ptr[i];
|
---|
| 6625 | + }
|
---|
| 6626 | + xDelete<int>(dims);
|
---|
| 6627 | + }
|
---|
| 6628 | +
|
---|
| 6629 | + /*Assign output pointer: */
|
---|
| 6630 | + *pmatrix = matrix;
|
---|
| 6631 | + *pmatrix_numel = numel;
|
---|
| 6632 | + *pmatrix_ndims = ndims;
|
---|
| 6633 | + *pmatrix_size = size;
|
---|
| 6634 | +
|
---|
| 6635 | + return 1;
|
---|
| 6636 | +}
|
---|
| 6637 | +/*}}}*/
|
---|
| 6638 | +/*FUNCTION MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
|
---|
| 6639 | +int MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
|
---|
| 6640 | +
|
---|
| 6641 | + int i,j,rows,cols;
|
---|
| 6642 | + int numel,ndims;
|
---|
| 6643 | + int *size,*dims;
|
---|
| 6644 | + bool* mxmatrix_ptr=NULL;
|
---|
| 6645 | + const mwSize* ipt=NULL;
|
---|
| 6646 | +
|
---|
| 6647 | + /*output: */
|
---|
| 6648 | + bool* matrix=NULL;
|
---|
| 6649 | +
|
---|
| 6650 | + /*matlab indices: */
|
---|
| 6651 | + mwIndex *ir = NULL;
|
---|
| 6652 | + mwIndex *jc = NULL;
|
---|
| 6653 | + bool *pm = NULL;
|
---|
| 6654 | + int count;
|
---|
| 6655 | +
|
---|
| 6656 | + /*get Matlab matrix information: */
|
---|
| 6657 | + numel = mxGetNumberOfElements(mxmatrix);
|
---|
| 6658 | + ndims = mxGetNumberOfDimensions(mxmatrix);
|
---|
| 6659 | + ipt = mxGetDimensions(mxmatrix);
|
---|
| 6660 | + size = xNew<int>(ndims);
|
---|
| 6661 | + for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
|
---|
| 6662 | +
|
---|
| 6663 | + /*Ok, first check if we are dealing with a sparse or full matrix: */
|
---|
| 6664 | + if (mxIsSparse(mxmatrix)){
|
---|
| 6665 | +
|
---|
| 6666 | + /*Dealing with sparse matrix: recover size first: */
|
---|
| 6667 | + rows=mxGetM(mxmatrix);
|
---|
| 6668 | + cols=mxGetN(mxmatrix);
|
---|
| 6669 | + matrix=xNewZeroInit<bool>(rows*cols);
|
---|
| 6670 | +
|
---|
| 6671 | + /*Now, get ir,jc and pm: */
|
---|
| 6672 | + ir=mxGetIr(mxmatrix);
|
---|
| 6673 | + jc=mxGetJc(mxmatrix);
|
---|
| 6674 | + pm=(bool*)mxGetData(mxmatrix);
|
---|
| 6675 | +
|
---|
| 6676 | + /*Now, start inserting data into bool* matrix: */
|
---|
| 6677 | + count=0;
|
---|
| 6678 | + for(i=0;i<cols;i++){
|
---|
| 6679 | + for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 6680 | + matrix[rows*ir[count]+i]=pm[count];
|
---|
| 6681 | + count++;
|
---|
| 6682 | + }
|
---|
| 6683 | + }
|
---|
| 6684 | + }
|
---|
| 6685 | + else{
|
---|
| 6686 | +
|
---|
| 6687 | + /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 6688 | + mxmatrix_ptr=(bool*)mxGetData(mxmatrix);
|
---|
| 6689 | +
|
---|
| 6690 | + /*Create serial matrix: */
|
---|
| 6691 | + matrix=xNew<bool>(numel);
|
---|
| 6692 | + dims=xNew<int>(ndims);
|
---|
| 6693 | + for(i=0;i<numel;i++){
|
---|
| 6694 | + ColumnWiseDimsFromIndex(dims,i,size,ndims);
|
---|
| 6695 | + j=IndexFromRowWiseDims(dims,size,ndims);
|
---|
| 6696 | + matrix[j]=(bool)mxmatrix_ptr[i];
|
---|
| 6697 | + }
|
---|
| 6698 | + xDelete<int>(dims);
|
---|
| 6699 | + }
|
---|
| 6700 | +
|
---|
| 6701 | + /*Assign output pointer: */
|
---|
| 6702 | + *pmatrix = matrix;
|
---|
| 6703 | + *pmatrix_numel = numel;
|
---|
| 6704 | + *pmatrix_ndims = ndims;
|
---|
| 6705 | + *pmatrix_size = size;
|
---|
| 6706 | +
|
---|
| 6707 | + return 1;
|
---|
| 6708 | +}
|
---|
| 6709 | +/*}}}*/
|
---|
| 6710 | +/*FUNCTION MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){{{*/
|
---|
| 6711 | +int MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix){
|
---|
| 6712 | +
|
---|
| 6713 | + int i,j,rows,cols;
|
---|
| 6714 | + int numel,ndims;
|
---|
| 6715 | + int *size , *dims;
|
---|
| 6716 | + mxChar *mxmatrix_ptr = NULL;
|
---|
| 6717 | + const mwSize *ipt = NULL;
|
---|
| 6718 | +
|
---|
| 6719 | + /*output: */
|
---|
| 6720 | + char* matrix=NULL;
|
---|
| 6721 | +
|
---|
| 6722 | + /*matlab indices: */
|
---|
| 6723 | + mwIndex *ir = NULL;
|
---|
| 6724 | + mwIndex *jc = NULL;
|
---|
| 6725 | + char *pm = NULL;
|
---|
| 6726 | + int count;
|
---|
| 6727 | +
|
---|
| 6728 | + /*get Matlab matrix information: */
|
---|
| 6729 | + numel = mxGetNumberOfElements(mxmatrix);
|
---|
| 6730 | + ndims = mxGetNumberOfDimensions(mxmatrix);
|
---|
| 6731 | + ipt = mxGetDimensions(mxmatrix);
|
---|
| 6732 | + size = xNew<int>(ndims);
|
---|
| 6733 | + for (i=0;i<ndims;i++) size[i]=(int)ipt[i];
|
---|
| 6734 | +
|
---|
| 6735 | + /*Ok, first check if we are dealing with a sparse or full matrix: */
|
---|
| 6736 | + if (mxIsSparse(mxmatrix)){
|
---|
| 6737 | +
|
---|
| 6738 | + /*Dealing with sparse matrix: recover size first: */
|
---|
| 6739 | + rows = mxGetM(mxmatrix);
|
---|
| 6740 | + cols = mxGetN(mxmatrix);
|
---|
| 6741 | + matrix=xNew<char>(rows*cols);
|
---|
| 6742 | +
|
---|
| 6743 | + /*Now, get ir,jc and pm: */
|
---|
| 6744 | + ir = mxGetIr(mxmatrix);
|
---|
| 6745 | + jc = mxGetJc(mxmatrix);
|
---|
| 6746 | + pm = (char*)mxGetData(mxmatrix);
|
---|
| 6747 | +
|
---|
| 6748 | + /*Now, start inserting data into char* matrix: */
|
---|
| 6749 | + count=0;
|
---|
| 6750 | + for(i=0;i<cols;i++){
|
---|
| 6751 | + for(j=0;j<(jc[i+1]-jc[i]);j++){
|
---|
| 6752 | + matrix[rows*ir[count]+i]=(char)pm[count];
|
---|
| 6753 | + count++;
|
---|
| 6754 | + }
|
---|
| 6755 | + }
|
---|
| 6756 | + }
|
---|
| 6757 | + else{
|
---|
| 6758 | + /*Dealing with dense matrix: recover pointer and size: */
|
---|
| 6759 | + mxmatrix_ptr=mxGetChars(mxmatrix);
|
---|
| 6760 | +
|
---|
| 6761 | + /*Create serial matrix: */
|
---|
| 6762 | + matrix=xNew<char>(numel+1);
|
---|
| 6763 | + matrix[numel]='\0';
|
---|
| 6764 | +
|
---|
| 6765 | + /*looping code adapted from Matlab example explore.c: */
|
---|
| 6766 | + int elements_per_page = size[0] * size[1];
|
---|
| 6767 | + /* total_number_of_pages = size[2] x size[3] x ... x size[N-1] */
|
---|
| 6768 | + int total_number_of_pages = 1;
|
---|
| 6769 | + for (i=2; i<ndims; i++) {
|
---|
| 6770 | + total_number_of_pages *= size[i];
|
---|
| 6771 | + }
|
---|
| 6772 | +
|
---|
| 6773 | + i=0;
|
---|
| 6774 | + for (int page=0; page < total_number_of_pages; page++) {
|
---|
| 6775 | + int row;
|
---|
| 6776 | + /* On each page, walk through each row. */
|
---|
| 6777 | + for (row=0; row<size[0]; row++) {
|
---|
| 6778 | + int column;
|
---|
| 6779 | + j = (page * elements_per_page) + row;
|
---|
| 6780 | +
|
---|
| 6781 | + /* Walk along each column in the current row. */
|
---|
| 6782 | + for (column=0; column<size[1]; column++) {
|
---|
| 6783 | + *(matrix+i++)=(char)*(mxmatrix_ptr+j);
|
---|
| 6784 | + j += size[0];
|
---|
| 6785 | + }
|
---|
| 6786 | + }
|
---|
| 6787 | + }
|
---|
| 6788 | + }
|
---|
| 6789 | +
|
---|
| 6790 | + /*Assign output pointer: */
|
---|
| 6791 | + *pmatrix = matrix;
|
---|
| 6792 | + *pmatrix_numel = numel;
|
---|
| 6793 | + *pmatrix_ndims = ndims;
|
---|
| 6794 | + *pmatrix_size = size;
|
---|
| 6795 | +
|
---|
| 6796 | + return 1;
|
---|
| 6797 | +}
|
---|
| 6798 | +/*}}}*/
|
---|
| 6799 | Index: ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToSeqVec.cpp
|
---|
| 6800 | ===================================================================
|
---|
| 6801 | --- ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToSeqVec.cpp (revision 0)
|
---|
| 6802 | +++ ../trunk-jpl/src/wrappers/matlab/io/MatlabVectorToSeqVec.cpp (revision 13749)
|
---|
| 6803 | @@ -0,0 +1,20 @@
|
---|
| 6804 | +/*!\file MatlabVectorToSeqVec.cpp
|
---|
| 6805 | + */
|
---|
| 6806 | +
|
---|
| 6807 | +/*Headers:*/
|
---|
| 6808 | +#include <mex.h>
|
---|
| 6809 | +#include <stdio.h>
|
---|
| 6810 | +#include <string.h>
|
---|
| 6811 | +#include "./matlabio.h"
|
---|
| 6812 | +#include "../../c/toolkits/toolkits.h"
|
---|
| 6813 | +#include "../../c/shared/shared.h"
|
---|
| 6814 | +
|
---|
| 6815 | +SeqVec<double>* MatlabVectorToSeqVec(const mxArray* dataref){
|
---|
| 6816 | +
|
---|
| 6817 | + SeqVec<double>* output=NULL;
|
---|
| 6818 | +
|
---|
| 6819 | + output=new SeqVec<double>();
|
---|
| 6820 | + MatlabVectorToDoubleVector(&output->vector,&output->M,dataref);
|
---|
| 6821 | + return output;
|
---|
| 6822 | +
|
---|
| 6823 | +}
|
---|
| 6824 | Index: ../trunk-jpl/src/wrappers/matlab/io/matlabio.h
|
---|
| 6825 | ===================================================================
|
---|
| 6826 | --- ../trunk-jpl/src/wrappers/matlab/io/matlabio.h (revision 0)
|
---|
| 6827 | +++ ../trunk-jpl/src/wrappers/matlab/io/matlabio.h (revision 13749)
|
---|
| 6828 | @@ -0,0 +1,93 @@
|
---|
| 6829 | +/*\file matlabio.h
|
---|
| 6830 | + *\brief: I/O for ISSM in matlab mode
|
---|
| 6831 | + */
|
---|
| 6832 | +
|
---|
| 6833 | +#ifndef _MATLAB_IO_H_
|
---|
| 6834 | +#define _MATLAB_IO_H_
|
---|
| 6835 | +
|
---|
| 6836 | +#ifdef HAVE_CONFIG_H
|
---|
| 6837 | +#include <config.h>
|
---|
| 6838 | +#else
|
---|
| 6839 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 6840 | +#endif
|
---|
| 6841 | +
|
---|
| 6842 | +#include "../include/matlabincludes.h"
|
---|
| 6843 | +#include "../../c/classes/classes.h"
|
---|
| 6844 | +#include "../../c/Container/Container.h"
|
---|
| 6845 | +#include "../../c/include/include.h"
|
---|
| 6846 | +
|
---|
| 6847 | +void WriteData(mxArray** pdataref,SeqMat<double>* matrix);
|
---|
| 6848 | +void WriteData(mxArray** pdataref,double* matrix, int M,int N);
|
---|
| 6849 | +void WriteData(mxArray** pdataref,int* matrix, int M,int N);
|
---|
| 6850 | +void WriteData(mxArray** pdataref,SeqVec<double>* vector);
|
---|
| 6851 | +void WriteData(mxArray** pdataref,double* vector, int M);
|
---|
| 6852 | +void WriteData(mxArray** pdataref,int integer);
|
---|
| 6853 | +void WriteData(mxArray** pdataref,bool boolean);
|
---|
| 6854 | +void WriteData(mxArray** pdataref,double scalar);
|
---|
| 6855 | +void WriteData(mxArray** pdataref,char* string);
|
---|
| 6856 | +void WriteData(mxArray** pdataref);
|
---|
| 6857 | +void WriteData(mxArray** pdataref,BamgGeom* bamggeom);
|
---|
| 6858 | +void WriteData(mxArray** pdataref,BamgMesh* bamgmesh);
|
---|
| 6859 | +void WriteData(mxArray** pdataref,RiftStruct* riftstruct);
|
---|
| 6860 | +
|
---|
| 6861 | +void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref);
|
---|
| 6862 | +void FetchData(double** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
|
---|
| 6863 | +void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref);
|
---|
| 6864 | +void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref);
|
---|
| 6865 | +void FetchData(bool** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
|
---|
| 6866 | +void FetchData(Matrix<double>** pmatrix,const mxArray* dataref);
|
---|
| 6867 | +void FetchData(int** pvector,int* pM,const mxArray* dataref);
|
---|
| 6868 | +void FetchData(float** pvector,int* pM,const mxArray* dataref);
|
---|
| 6869 | +void FetchData(double** pvector,int* pM,const mxArray* dataref);
|
---|
| 6870 | +void FetchData(bool** pvector,int* pM,const mxArray* dataref);
|
---|
| 6871 | +void FetchData(Vector<double>** pvector,const mxArray* dataref);
|
---|
| 6872 | +void FetchData(char** pstring,const mxArray* dataref);
|
---|
| 6873 | +void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref);
|
---|
| 6874 | +void FetchData(double* pscalar,const mxArray* dataref);
|
---|
| 6875 | +void FetchData(int* pinteger,const mxArray* dataref);
|
---|
| 6876 | +void FetchData(bool* pbool,const mxArray* dataref);
|
---|
| 6877 | +void FetchData(BamgGeom** bamggeom,const mxArray* dataref);
|
---|
| 6878 | +void FetchData(BamgMesh** bamgmesh,const mxArray* dataref);
|
---|
| 6879 | +void FetchData(BamgOpts** bamgopts,const mxArray* dataref);
|
---|
| 6880 | +void FetchData(Options** poptions,int istart, int nrhs,const mxArray** pdataref);
|
---|
| 6881 | +void FetchData(DataSet** pcontours,const mxArray* dataref);
|
---|
| 6882 | +
|
---|
| 6883 | +Option* OptionParse(char* name, const mxArray* prhs[]);
|
---|
| 6884 | +GenericOption<double>* OptionDoubleParse( char* name, const mxArray* prhs[]);
|
---|
| 6885 | +GenericOption<double*>* OptionDoubleArrayParse( char* name, const mxArray* prhs[]);
|
---|
| 6886 | +GenericOption<bool*>* OptionLogicalParse( char* name, const mxArray* prhs[]);
|
---|
| 6887 | +GenericOption<char*>* OptionCharParse( char* name, const mxArray* prhs[]);
|
---|
| 6888 | +GenericOption<Options**>* OptionStructParse( char* name, const mxArray* prhs[]);
|
---|
| 6889 | +GenericOption<Options*>* OptionCellParse( char* name, const mxArray* prhs[]);
|
---|
| 6890 | +
|
---|
| 6891 | +mxArray* mxGetAssignedField(const mxArray* pmxa_array,int number, const char* field);
|
---|
| 6892 | +void SetStructureField(mxArray* dataref,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer);
|
---|
| 6893 | +void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int fieldrows,int fieldcols,double* fieldpointer);
|
---|
| 6894 | +void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,int field);
|
---|
| 6895 | +void SetStructureFieldi(mxArray* dataref,int i,const char* fieldname,double field);
|
---|
| 6896 | +int CheckNumMatlabArguments(int nlhs,int NLHS, int nrhs,int NRHS, const char* THISFUNCTION, void (*function)( void ));
|
---|
| 6897 | +
|
---|
| 6898 | +/*Matlab to Matrix routines: */
|
---|
| 6899 | +Matrix<double>* MatlabMatrixToMatrix(const mxArray* mxmatrix);
|
---|
| 6900 | +Vector<double>* MatlabVectorToVector(const mxArray* mxvector);
|
---|
| 6901 | +
|
---|
| 6902 | +/*Matlab to double* routines: */
|
---|
| 6903 | +int MatlabVectorToDoubleVector(double** pvector,int* pvector_rows,const mxArray* mxvector);
|
---|
| 6904 | +int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix);
|
---|
| 6905 | +int MatlabNArrayToNArray(double** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
|
---|
| 6906 | +int MatlabNArrayToNArray(bool** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
|
---|
| 6907 | +int MatlabNArrayToNArray(char** pmatrix,int* pmatrix_numel,int* pmatrix_ndims,int** pmatrix_size,const mxArray* mxmatrix);
|
---|
| 6908 | +
|
---|
| 6909 | +/*Matlab to SeqMat routines: */
|
---|
| 6910 | +SeqMat<double>* MatlabMatrixToSeqMat(const mxArray* dataref);
|
---|
| 6911 | +SeqVec<double>* MatlabVectorToSeqVec(const mxArray* dataref);
|
---|
| 6912 | +
|
---|
| 6913 | +/*Matlab to Petsc routines: */
|
---|
| 6914 | +#ifdef _HAVE_PETSC_
|
---|
| 6915 | +int MatlabMatrixToPetscMat(Mat* matrix,int* prows,int* pcols, const mxArray* mxmatrix);
|
---|
| 6916 | +PetscMat* MatlabMatrixToPetscMat(const mxArray* mxmatrix);
|
---|
| 6917 | +int MatlabVectorToPetscVec(Vec* pvector,int* pvector_rows,const mxArray* mxvector);
|
---|
| 6918 | +PetscVec* MatlabVectorToPetscVec(const mxArray* mxvector);
|
---|
| 6919 | +#endif
|
---|
| 6920 | +
|
---|
| 6921 | +#endif /* _IO_H_ */
|
---|
| 6922 | Index: ../trunk-jpl/src/wrappers/matlab/Makefile.am
|
---|
| 6923 | ===================================================================
|
---|
| 6924 | --- ../trunk-jpl/src/wrappers/matlab/Makefile.am (revision 13748)
|
---|
| 6925 | +++ ../trunk-jpl/src/wrappers/matlab/Makefile.am (revision 13749)
|
---|
| 6926 | @@ -1,10 +1,40 @@
|
---|
| 6927 | -AM_CPPFLAGS = @DAKOTAINCL@ @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@ @BOOSTINCL@ @PYTHONINCL@ @PYTHON_NUMPYINCL@ @ADOLCINCL@
|
---|
| 6928 | +AM_CPPFLAGS = @DAKOTAINCL@ @MATLABINCL@ @PETSCINCL@ @MPIINCL@ @SPOOLESINCL@ @METISINCL@ @TRIANGLEINCL@ @CHACOINCL@ @SCOTCHINCL@ @SHAPELIBINCL@
|
---|
| 6929 |
|
---|
| 6930 | EXEEXT=$(MATLABWRAPPEREXT)
|
---|
| 6931 |
|
---|
| 6932 | +#matlab io{{{
|
---|
| 6933 | +lib_LIBRARIES = libISSMMatlab.a
|
---|
| 6934 | +if SHAREDLIBS
|
---|
| 6935 | +lib_LTLIBRARIES = libISSMMatlab.la
|
---|
| 6936 | +else
|
---|
| 6937 | +lib_LTLIBRARIES =
|
---|
| 6938 | +endif
|
---|
| 6939 | +
|
---|
| 6940 | +io_sources= ./include/matlabincludes.h\
|
---|
| 6941 | + ./io/matlabio.h\
|
---|
| 6942 | + ./io/MatlabNArrayToNArray.cpp\
|
---|
| 6943 | + ./io/CheckNumMatlabArguments.cpp\
|
---|
| 6944 | + ./io/mxGetAssignedField.cpp\
|
---|
| 6945 | + ./io/WriteMatlabData.cpp\
|
---|
| 6946 | + ./io/FetchMatlabData.cpp\
|
---|
| 6947 | + ./io/OptionParse.cpp\
|
---|
| 6948 | + ./io/MatlabMatrixToMatrix.cpp\
|
---|
| 6949 | + ./io/MatlabVectorToVector.cpp\
|
---|
| 6950 | + ./io/MatlabVectorToDoubleVector.cpp\
|
---|
| 6951 | + ./io/MatlabMatrixToDoubleMatrix.cpp\
|
---|
| 6952 | + ./io/MatlabMatrixToSeqMat.cpp\
|
---|
| 6953 | + ./io/MatlabVectorToSeqVec.cpp
|
---|
| 6954 | +
|
---|
| 6955 | +ALLCXXFLAGS= -fPIC -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_ $(CXXFLAGS) $(CXXOPTFLAGS)
|
---|
| 6956 | +libISSMMatlab_a_SOURCES = $(io_sources)
|
---|
| 6957 | +libISSMMatlab_a_CXXFLAGS= $(ALLCXXFLAGS)
|
---|
| 6958 | +if SHAREDLIBS
|
---|
| 6959 | +libISSMMatlab_la_SOURCES = $(io_sources)
|
---|
| 6960 | +endif
|
---|
| 6961 | +#}}}
|
---|
| 6962 | #Wrappers {{{
|
---|
| 6963 | if WRAPPERS
|
---|
| 6964 | -lib_LTLIBRARIES = AverageFilter.la\
|
---|
| 6965 | +lib_LTLIBRARIES += AverageFilter.la\
|
---|
| 6966 | BamgMesher.la\
|
---|
| 6967 | BamgConvertMesh.la\
|
---|
| 6968 | BamgTriangulate.la\
|
---|
| 6969 | @@ -45,7 +75,6 @@
|
---|
| 6970 | Kml2Exp.la
|
---|
| 6971 | endif
|
---|
| 6972 | endif
|
---|
| 6973 | -
|
---|
| 6974 | #}}}
|
---|
| 6975 | #Flags and libraries {{{
|
---|
| 6976 | #if SHAREDLIBS
|
---|
| 6977 | @@ -67,9 +96,9 @@
|
---|
| 6978 | AM_LDFLAGS += -avoid-version
|
---|
| 6979 | endif
|
---|
| 6980 | if SHAREDLIBS
|
---|
| 6981 | -deps += ../../c/libISSMMatlab.la
|
---|
| 6982 | +deps += ./libISSMMatlab.la
|
---|
| 6983 | else
|
---|
| 6984 | -deps += ../../c/libISSMMatlab.a
|
---|
| 6985 | +deps += ./libISSMMatlab.a
|
---|
| 6986 | AM_LDFLAGS += --no-warnings
|
---|
| 6987 | endif
|
---|
| 6988 |
|
---|
| 6989 | Index: ../trunk-jpl/src/wrappers/BamgTriangulate/BamgTriangulate.h
|
---|
| 6990 | ===================================================================
|
---|
| 6991 | --- ../trunk-jpl/src/wrappers/BamgTriangulate/BamgTriangulate.h (revision 13748)
|
---|
| 6992 | +++ ../trunk-jpl/src/wrappers/BamgTriangulate/BamgTriangulate.h (revision 13749)
|
---|
| 6993 | @@ -20,7 +20,7 @@
|
---|
| 6994 | #include "../../c/modules/modules.h"
|
---|
| 6995 | #include "../../c/Container/Container.h"
|
---|
| 6996 | #include "../../c/shared/shared.h"
|
---|
| 6997 | -#include "../../c/issm-binding.h"
|
---|
| 6998 | +#include "../bindings.h"
|
---|
| 6999 |
|
---|
| 7000 | #undef __FUNCT__
|
---|
| 7001 | #define __FUNCT__ "BamgTriangulate"
|
---|
| 7002 | Index: ../trunk-jpl/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
|
---|
| 7003 | ===================================================================
|
---|
| 7004 | --- ../trunk-jpl/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h (revision 13748)
|
---|
| 7005 | +++ ../trunk-jpl/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h (revision 13749)
|
---|
| 7006 | @@ -23,7 +23,7 @@
|
---|
| 7007 | #include "../../c/modules/modules.h"
|
---|
| 7008 | #include "../../c/Container/Container.h"
|
---|
| 7009 | #include "../../c/shared/shared.h"
|
---|
| 7010 | -#include "../../c/issm-binding.h"
|
---|
| 7011 | +#include "../bindings.h"
|
---|
| 7012 | #include "../../c/io/io.h"
|
---|
| 7013 | #include "../../c/EnumDefinitions/EnumDefinitions.h"
|
---|
| 7014 |
|
---|
| 7015 | Index: ../trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.h
|
---|
| 7016 | ===================================================================
|
---|
| 7017 | --- ../trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.h (revision 13748)
|
---|
| 7018 | +++ ../trunk-jpl/src/wrappers/ContourToMesh/ContourToMesh.h (revision 13749)
|
---|
| 7019 | @@ -23,7 +23,7 @@
|
---|
| 7020 | #include "../../c/modules/modules.h"
|
---|
| 7021 | #include "../../c/Container/Container.h"
|
---|
| 7022 | #include "../../c/shared/shared.h"
|
---|
| 7023 | -#include "../../c/issm-binding.h"
|
---|
| 7024 | +#include "../bindings.h"
|
---|
| 7025 | #include "../../c/io/io.h"
|
---|
| 7026 | #include "../../c/EnumDefinitions/EnumDefinitions.h"
|
---|
| 7027 |
|
---|
| 7028 | Index: ../trunk-jpl/src/wrappers/Xy2ll/Xy2ll.h
|
---|
| 7029 | ===================================================================
|
---|
| 7030 | --- ../trunk-jpl/src/wrappers/Xy2ll/Xy2ll.h (revision 13748)
|
---|
| 7031 | +++ ../trunk-jpl/src/wrappers/Xy2ll/Xy2ll.h (revision 13749)
|
---|
| 7032 | @@ -20,7 +20,7 @@
|
---|
| 7033 | #include "../../c/modules/modules.h"
|
---|
| 7034 | #include "../../c/Container/Container.h"
|
---|
| 7035 | #include "../../c/shared/shared.h"
|
---|
| 7036 | -#include "../../c/issm-binding.h"
|
---|
| 7037 | +#include "../bindings.h"
|
---|
| 7038 |
|
---|
| 7039 | #undef __FUNCT__
|
---|
| 7040 | #define __FUNCT__ "Xy2ll"
|
---|
| 7041 | Index: ../trunk-jpl/src/wrappers/KMLMeshWrite/KMLMeshWrite.h
|
---|
| 7042 | ===================================================================
|
---|
| 7043 | --- ../trunk-jpl/src/wrappers/KMLMeshWrite/KMLMeshWrite.h (revision 13748)
|
---|
| 7044 | +++ ../trunk-jpl/src/wrappers/KMLMeshWrite/KMLMeshWrite.h (revision 13749)
|
---|
| 7045 | @@ -20,7 +20,7 @@
|
---|
| 7046 | #include "../../c/modules/modules.h"
|
---|
| 7047 | #include "../../c/Container/Container.h"
|
---|
| 7048 | #include "../../c/shared/shared.h"
|
---|
| 7049 | -#include "../../c/issm-binding.h"
|
---|
| 7050 | +#include "../bindings.h"
|
---|
| 7051 |
|
---|
| 7052 | #undef __FUNCT__
|
---|
| 7053 | #define __FUNCT__ "KMLMeshWrite"
|
---|
| 7054 | Index: ../trunk-jpl/src/wrappers/TriMesh/TriMesh.h
|
---|
| 7055 | ===================================================================
|
---|
| 7056 | --- ../trunk-jpl/src/wrappers/TriMesh/TriMesh.h (revision 13748)
|
---|
| 7057 | +++ ../trunk-jpl/src/wrappers/TriMesh/TriMesh.h (revision 13749)
|
---|
| 7058 | @@ -23,7 +23,7 @@
|
---|
| 7059 | #include "../../c/modules/modules.h"
|
---|
| 7060 | #include "../../c/Container/Container.h"
|
---|
| 7061 | #include "../../c/shared/shared.h"
|
---|
| 7062 | -#include "../../c/issm-binding.h"
|
---|
| 7063 | +#include "../bindings.h"
|
---|
| 7064 | #include "../../c/io/io.h"
|
---|
| 7065 | #include "../../c/EnumDefinitions/EnumDefinitions.h"
|
---|
| 7066 |
|
---|
| 7067 | Index: ../trunk-jpl/src/wrappers/Chaco/Chaco.h
|
---|
| 7068 | ===================================================================
|
---|
| 7069 | --- ../trunk-jpl/src/wrappers/Chaco/Chaco.h (revision 13748)
|
---|
| 7070 | +++ ../trunk-jpl/src/wrappers/Chaco/Chaco.h (revision 13749)
|
---|
| 7071 | @@ -24,7 +24,7 @@
|
---|
| 7072 | #include "../../c/modules/modules.h"
|
---|
| 7073 | #include "../../c/Container/Container.h"
|
---|
| 7074 | #include "../../c/shared/shared.h"
|
---|
| 7075 | -#include "../../c/issm-binding.h"
|
---|
| 7076 | +#include "../bindings.h"
|
---|
| 7077 |
|
---|
| 7078 | #undef __FUNCT__
|
---|
| 7079 | #define __FUNCT__ "Chaco"
|
---|