├── Demo.py ├── Output ├── 6barca.png ├── 6code.png ├── Markcode.png ├── Walken.png ├── Zackstone.png ├── apple.png └── jole.png ├── README.md ├── TextureTransfer └── for_testing │ ├── Makefile │ ├── TextureTransfer.cpp │ ├── TextureTransfer.exports │ ├── TextureTransfer.h │ ├── TextureTransfer.so │ ├── exe │ ├── mat.h │ ├── matrix.h │ ├── mccExcludedFiles.log │ ├── mclbase.h │ ├── mclcppclass.h │ ├── mclmcr.h │ ├── mclmcrrt.h │ ├── readme.txt │ ├── requiredMCRProducts.txt │ └── tmwtypes.h ├── cut.py ├── find_mindelta.py ├── get_ssd.py └── texture_transfer.py /Demo.py: -------------------------------------------------------------------------------- 1 | from smop.core import * 2 | import numpy as np 3 | import cv2 4 | import scipy 5 | from scipy import ndimage 6 | from texture_transfer import texture_transfer 7 | 8 | texture=cv2.imread('../MyTextures/Orange.png') 9 | target= cv2.imread('../Targetimages/data/apple.png') 10 | 11 | # texture = scipy.misc.imresize(texture, 0.7) 12 | texture = cv2.normalize(texture.astype('float'), None, 0.0, 1.0, cv2.NORM_MINMAX) 13 | # target = scipy.misc.imresize(target, 1) 14 | target = cv2.normalize(target.astype('float'), None, 0.0, 1.0, cv2.NORM_MINMAX) 15 | 16 | # texture=double(texture) 17 | patchsize=10 18 | overlap=3 19 | tol=0.1 20 | 21 | print size(texture) , size(target) 22 | 23 | imout3 = texture_transfer(texture,target,patchsize,overlap,tol) 24 | 25 | imout3 = imout3 * 255; 26 | 27 | cv2.imwrite( "./OUTImage.png", imout3 ); 28 | 29 | # imwrite(imout3,'0014_helix.png') 30 | -------------------------------------------------------------------------------- /Output/6barca.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vikasTmz/Texturize/d12ceb17e24a226e6de6f264f155e98f4a38300c/Output/6barca.png -------------------------------------------------------------------------------- /Output/6code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vikasTmz/Texturize/d12ceb17e24a226e6de6f264f155e98f4a38300c/Output/6code.png -------------------------------------------------------------------------------- /Output/Markcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vikasTmz/Texturize/d12ceb17e24a226e6de6f264f155e98f4a38300c/Output/Markcode.png -------------------------------------------------------------------------------- /Output/Walken.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vikasTmz/Texturize/d12ceb17e24a226e6de6f264f155e98f4a38300c/Output/Walken.png -------------------------------------------------------------------------------- /Output/Zackstone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vikasTmz/Texturize/d12ceb17e24a226e6de6f264f155e98f4a38300c/Output/Zackstone.png -------------------------------------------------------------------------------- /Output/apple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vikasTmz/Texturize/d12ceb17e24a226e6de6f264f155e98f4a38300c/Output/apple.png -------------------------------------------------------------------------------- /Output/jole.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vikasTmz/Texturize/d12ceb17e24a226e6de6f264f155e98f4a38300c/Output/jole.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ImageQuilting 2 | Image Quilting for Texture Transfer 3 | 4 | # Examples 5 | ![Example 1](Output/Markcode.png?raw=true "Example 1") 6 | ![Example 2](Output/Zackstone.png?raw=true "Example 2") 7 | ![Example 3](Output/jole.png?raw=true "Example 3") 8 | ![Example 4](Output/6code.png?raw=true "Example 4") 9 | ![Example 5](Output/Walken.png?raw=true "Example 5") 10 | ![Example 6](Output/6barca.png?raw=true "Example 6") 11 | ![Example 7](Output/apple.png?raw=true "Example 7") 12 | 13 | 14 | ## References 15 | - Image Quilting for Texture Synthesis and Transfer(Alexei A. Efros, William T. Freeman) 16 | - link : http://graphics.cs.cmu.edu/people/efros/research/quilting/quilting.pdf 17 | -------------------------------------------------------------------------------- /TextureTransfer/for_testing/Makefile: -------------------------------------------------------------------------------- 1 | CC = g++ 2 | CFLAGS = -Wall 3 | PROG = exe 4 | 5 | MATLABROOT = "/usr/local/MATLAB/MATLAB_Production_Server/R2015a" 6 | 7 | SRCS = TextureTransfer.cpp 8 | LIBS = -I/usr/local/MATLAB/MATLAB_Production_Server/R2015a/extern/include/ -L${MATLABROOT}/extern/lib/glnxa64/ -I"/usr/local/MATLAB/MATLAB_Production_Server/R2015a/simulink/include" -I"/usr/local/MATLAB/MATLAB_Production_Server/R2015a/extern/include/cpp" -fPIC -ansi -pthread -O -DNDEBUG -shared -O -L"/usr/local/MATLAB/MATLAB_Production_Server/R2015a/runtime/glnxa64" -lm -lmwmclmcrrt 9 | 10 | 11 | all: $(PROG) 12 | 13 | $(PROG): $(SRCS) 14 | $(CC) $(CFLAGS) -o $(PROG) $(SRCS) $(LIBS) 15 | 16 | clean: 17 | rm -f $(PROG) -------------------------------------------------------------------------------- /TextureTransfer/for_testing/TextureTransfer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // MATLAB Compiler: 6.0 (R2015a) 3 | // Date: Sat Dec 3 21:27:28 2016 4 | // Arguments: "-B" "macro_default" "-W" "cpplib:TextureTransfer" "-T" 5 | // "link:lib" "-d" 6 | // "/home/vikas/Documents/MATLAB/ImageQuilting/TextureTransfer/for_testing" 7 | // "-v" "/home/vikas/Documents/MATLAB/ImageQuilting/cut.m" 8 | // "/home/vikas/Documents/MATLAB/ImageQuilting/Demo.m" 9 | // "/home/vikas/Documents/MATLAB/ImageQuilting/find_mindelta.m" 10 | // "/home/vikas/Documents/MATLAB/ImageQuilting/get_ssd.m" 11 | // "/home/vikas/Documents/MATLAB/ImageQuilting/texture_transfer.m" 12 | // 13 | 14 | #include 15 | #define EXPORTING_TextureTransfer 1 16 | #include "TextureTransfer.h" 17 | 18 | static HMCRINSTANCE _mcr_inst = NULL; 19 | 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | static int mclDefaultPrintHandler(const char *s) 26 | { 27 | return mclWrite(1 /* stdout */, s, sizeof(char)*strlen(s)); 28 | } 29 | 30 | #ifdef __cplusplus 31 | } /* End extern "C" block */ 32 | #endif 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | static int mclDefaultErrorHandler(const char *s) 39 | { 40 | int written = 0; 41 | size_t len = 0; 42 | len = strlen(s); 43 | written = mclWrite(2 /* stderr */, s, sizeof(char)*len); 44 | if (len > 0 && s[ len-1 ] != '\n') 45 | written += mclWrite(2 /* stderr */, "\n", sizeof(char)); 46 | return written; 47 | } 48 | 49 | #ifdef __cplusplus 50 | } /* End extern "C" block */ 51 | #endif 52 | 53 | /* This symbol is defined in shared libraries. Define it here 54 | * (to nothing) in case this isn't a shared library. 55 | */ 56 | #ifndef LIB_TextureTransfer_C_API 57 | #define LIB_TextureTransfer_C_API /* No special import/export declaration */ 58 | #endif 59 | 60 | LIB_TextureTransfer_C_API 61 | bool MW_CALL_CONV TextureTransferInitializeWithHandlers( 62 | mclOutputHandlerFcn error_handler, 63 | mclOutputHandlerFcn print_handler) 64 | { 65 | int bResult = 0; 66 | if (_mcr_inst != NULL) 67 | return true; 68 | if (!mclmcrInitialize()) 69 | return false; 70 | { 71 | mclCtfStream ctfStream = 72 | mclGetEmbeddedCtfStream((void *)(TextureTransferInitializeWithHandlers)); 73 | if (ctfStream) { 74 | bResult = mclInitializeComponentInstanceEmbedded( &_mcr_inst, 75 | error_handler, 76 | print_handler, 77 | ctfStream); 78 | mclDestroyStream(ctfStream); 79 | } else { 80 | bResult = 0; 81 | } 82 | } 83 | if (!bResult) 84 | return false; 85 | return true; 86 | } 87 | 88 | LIB_TextureTransfer_C_API 89 | bool MW_CALL_CONV TextureTransferInitialize(void) 90 | { 91 | return TextureTransferInitializeWithHandlers(mclDefaultErrorHandler, 92 | mclDefaultPrintHandler); 93 | } 94 | 95 | LIB_TextureTransfer_C_API 96 | void MW_CALL_CONV TextureTransferTerminate(void) 97 | { 98 | if (_mcr_inst != NULL) 99 | mclTerminateInstance(&_mcr_inst); 100 | } 101 | 102 | LIB_TextureTransfer_C_API 103 | void MW_CALL_CONV TextureTransferPrintStackTrace(void) 104 | { 105 | char** stackTrace; 106 | int stackDepth = mclGetStackTrace(&stackTrace); 107 | int i; 108 | for(i=0; i logic. 32 | */ 33 | 34 | #ifdef EXPORTING_TextureTransfer 35 | #define PUBLIC_TextureTransfer_C_API __global 36 | #else 37 | #define PUBLIC_TextureTransfer_C_API /* No import statement needed. */ 38 | #endif 39 | 40 | #define LIB_TextureTransfer_C_API PUBLIC_TextureTransfer_C_API 41 | 42 | #elif defined(_HPUX_SOURCE) 43 | 44 | #ifdef EXPORTING_TextureTransfer 45 | #define PUBLIC_TextureTransfer_C_API __declspec(dllexport) 46 | #else 47 | #define PUBLIC_TextureTransfer_C_API __declspec(dllimport) 48 | #endif 49 | 50 | #define LIB_TextureTransfer_C_API PUBLIC_TextureTransfer_C_API 51 | 52 | 53 | #else 54 | 55 | #define LIB_TextureTransfer_C_API 56 | 57 | #endif 58 | 59 | /* This symbol is defined in shared libraries. Define it here 60 | * (to nothing) in case this isn't a shared library. 61 | */ 62 | #ifndef LIB_TextureTransfer_C_API 63 | #define LIB_TextureTransfer_C_API /* No special import/export declaration */ 64 | #endif 65 | 66 | extern LIB_TextureTransfer_C_API 67 | bool MW_CALL_CONV TextureTransferInitializeWithHandlers( 68 | mclOutputHandlerFcn error_handler, 69 | mclOutputHandlerFcn print_handler); 70 | 71 | extern LIB_TextureTransfer_C_API 72 | bool MW_CALL_CONV TextureTransferInitialize(void); 73 | 74 | extern LIB_TextureTransfer_C_API 75 | void MW_CALL_CONV TextureTransferTerminate(void); 76 | 77 | 78 | 79 | extern LIB_TextureTransfer_C_API 80 | void MW_CALL_CONV TextureTransferPrintStackTrace(void); 81 | 82 | extern LIB_TextureTransfer_C_API 83 | bool MW_CALL_CONV mlxCut(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]); 84 | 85 | extern LIB_TextureTransfer_C_API 86 | bool MW_CALL_CONV mlxDemo(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]); 87 | 88 | extern LIB_TextureTransfer_C_API 89 | bool MW_CALL_CONV mlxFind_mindelta(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]); 90 | 91 | extern LIB_TextureTransfer_C_API 92 | bool MW_CALL_CONV mlxGet_ssd(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]); 93 | 94 | extern LIB_TextureTransfer_C_API 95 | bool MW_CALL_CONV mlxTexture_transfer(int nlhs, mxArray *plhs[], int nrhs, mxArray 96 | *prhs[]); 97 | 98 | 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | 103 | #ifdef __cplusplus 104 | 105 | /* On Windows, use __declspec to control the exported API */ 106 | #if defined(_MSC_VER) || defined(__BORLANDC__) 107 | 108 | #ifdef EXPORTING_TextureTransfer 109 | #define PUBLIC_TextureTransfer_CPP_API __declspec(dllexport) 110 | #else 111 | #define PUBLIC_TextureTransfer_CPP_API __declspec(dllimport) 112 | #endif 113 | 114 | #define LIB_TextureTransfer_CPP_API PUBLIC_TextureTransfer_CPP_API 115 | 116 | #else 117 | 118 | #if !defined(LIB_TextureTransfer_CPP_API) 119 | #if defined(LIB_TextureTransfer_C_API) 120 | #define LIB_TextureTransfer_CPP_API LIB_TextureTransfer_C_API 121 | #else 122 | #define LIB_TextureTransfer_CPP_API /* empty! */ 123 | #endif 124 | #endif 125 | 126 | #endif 127 | 128 | extern LIB_TextureTransfer_CPP_API void MW_CALL_CONV cut(int nargout, mwArray& imout, const mwArray& sample, const mwArray& patchsize, const mwArray& overlap, const mwArray& imout_in1, const mwArray& samplepos, const mwArray& imoutpos); 129 | 130 | extern LIB_TextureTransfer_CPP_API void MW_CALL_CONV Demo(int nargout, mwArray& imout3); 131 | 132 | extern LIB_TextureTransfer_CPP_API void MW_CALL_CONV find_mindelta(int nargout, mwArray& mintexturepos, const mwArray& texture, const mwArray& target, const mwArray& targetpos, const mwArray& patchsize, const mwArray& tol); 133 | 134 | extern LIB_TextureTransfer_CPP_API void MW_CALL_CONV get_ssd(int nargout, mwArray& cost, const mwArray& texture, const mwArray& texturepos1, const mwArray& texturepos2, const mwArray& targetposnew, const mwArray& patchsize); 135 | 136 | extern LIB_TextureTransfer_CPP_API void MW_CALL_CONV texture_transfer(int nargout, mwArray& imout, const mwArray& texture, const mwArray& target, const mwArray& patchsize, const mwArray& overlap, const mwArray& tol); 137 | 138 | #endif 139 | #endif 140 | -------------------------------------------------------------------------------- /TextureTransfer/for_testing/TextureTransfer.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vikasTmz/Texturize/d12ceb17e24a226e6de6f264f155e98f4a38300c/TextureTransfer/for_testing/TextureTransfer.so -------------------------------------------------------------------------------- /TextureTransfer/for_testing/exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vikasTmz/Texturize/d12ceb17e24a226e6de6f264f155e98f4a38300c/TextureTransfer/for_testing/exe -------------------------------------------------------------------------------- /TextureTransfer/for_testing/mat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1984-2014 The MathWorks, Inc. 3 | * All Rights Reserved. 4 | */ 5 | 6 | #if defined(_MSC_VER) 7 | # pragma once 8 | #endif 9 | #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) 10 | # pragma once 11 | #endif 12 | 13 | #ifndef mat_published_c_api_h 14 | #define mat_published_c_api_h 15 | 16 | #ifndef EXTERN_C 17 | # ifdef __cplusplus 18 | # define EXTERN_C extern "C" 19 | # else 20 | # define EXTERN_C extern 21 | # endif 22 | #endif 23 | 24 | #ifndef LIBMAT_API 25 | # define LIBMAT_API 26 | #endif 27 | 28 | #include /* for FILE */ 29 | 30 | #include "matrix.h" /* for mxArray */ 31 | 32 | /** 33 | * \file 34 | * \ingroup mat_pub_C_api 35 | */ 36 | 37 | 38 | /* incomplete typedef for MATFile */ 39 | #ifdef __cplusplus 40 | class MATFile; 41 | #else 42 | typedef struct MatFile_tag MATFile; 43 | #endif 44 | 45 | #ifndef LIBMAT_API_OFFERS_ERROR_ENUMS 46 | typedef int matError; 47 | #endif 48 | 49 | /* 50 | * Open a MAT-file "filename" using mode "mode". Return 51 | * a pointer to a MATFile for use with other MAT API functions. 52 | * 53 | * Current valid entries for "mode" are 54 | * "r" == read only. 55 | * "w" == write only (deletes any existing file with name ). 56 | * "w4" == as "w", but create a MATLAB 4.0 MAT-file. 57 | * "w7.3" == as "w", but create a MATLAB 7.3 MAT-file. 58 | * "u" == update. Read and write allowed, existing file is not deleted. 59 | * 60 | * Return NULL if an error occurs. 61 | */ 62 | EXTERN_C LIBMAT_API MATFile* matOpen(const char *filename, const char * mode); 63 | 64 | 65 | /* 66 | * Close a MAT-file opened with matOpen. 67 | * The pointer-to-MATfile argument is invalid, once matClose returns. 68 | * Return zero for success, EOF on error. 69 | */ 70 | EXTERN_C LIBMAT_API matError matClose(MATFile *pMF); 71 | 72 | 73 | /* 74 | * Return the ANSI C FILE pointer obtained when the MAT-file was opened. 75 | * Warning: the FILE pointer may be NULL in the case of a MAT file format 76 | * that does not allow access to the raw file pointer. 77 | */ 78 | EXTERN_C LIBMAT_API FILE * matGetFp(MATFile *pMF); 79 | 80 | 81 | /* 82 | * Write array value with the specified name to the MAT-file, deleting any 83 | * previously existing variable with that name in the MAT-file. 84 | * 85 | * Return zero for success, nonzero for error. 86 | */ 87 | EXTERN_C LIBMAT_API matError matPutVariable(MATFile * pMF, const char * name, const mxArray * pA); 88 | 89 | 90 | /* 91 | * Write array value with the specified name to the MAT-file pMF, deleting any 92 | * previously existing variable in the MAT-file with the same name. 93 | * 94 | * The variable will be written such that when the MATLAB LOAD command 95 | * loads the variable, it will automatically place it in the 96 | * global workspace and establish a link to it in the local 97 | * workspace (as if the command "global " had been 98 | * issued after the variable was loaded.) 99 | * 100 | * Return zero for success, nonzero for error. 101 | */ 102 | EXTERN_C LIBMAT_API matError matPutVariableAsGlobal(MATFile * pMF, const char * name, const mxArray * pA); 103 | 104 | 105 | /* 106 | * Read the array value for the specified variable name from a MAT-file. 107 | * 108 | * Return NULL if an error occurs. 109 | */ 110 | EXTERN_C LIBMAT_API mxArray * matGetVariable(MATFile * pMF, const char * name); 111 | 112 | 113 | /* 114 | * Read the next array value from the current file location of the MAT-file 115 | * pMF. This function should only be used in conjunction with 116 | * matOpen and matClose. Passing pMF to any other API functions 117 | * will cause matGetNextVariable() to work incorrectly. 118 | * 119 | * Return NULL if an error occurs. 120 | */ 121 | EXTERN_C LIBMAT_API mxArray * matGetNextVariable(MATFile *pMF, const char **nameptr); 122 | 123 | 124 | /* 125 | * Read the array header of the next array value in a MAT-file. 126 | * This function should only be used in conjunction with 127 | * matOpen and matClose. Passing pMF to any other API functions 128 | * will cause matGetNextVariableInfo to work incorrectly. 129 | * 130 | * See the description of matGetVariableInfo() for the definition 131 | * and valid uses of an array header. 132 | * 133 | * Return NULL if an error occurs. 134 | */ 135 | EXTERN_C LIBMAT_API mxArray * matGetNextVariableInfo(MATFile *pMF, const char **nameptr); 136 | 137 | 138 | /* 139 | * Read the array header for the variable with the specified name from 140 | * the MAT-file. 141 | * 142 | * An array header contains all the same information as an 143 | * array, except that the pr, pi, ir, and jc data structures are 144 | * not allocated for non-recursive data types. That is, 145 | * Cells, structures, and objects contain pointers to other 146 | * array headers, but numeric, string, and sparse arrays do not 147 | * contain valid data in their pr, pi, ir, or jc fields. 148 | * 149 | * The purpose of an array header is to gain fast access to 150 | * information about an array without reading all the array's 151 | * actual data. Thus, functions such as mxGetM, mxGetN, and mxGetClassID 152 | * can be used with array headers, but mxGetPr, mxGetPi, mxGetIr, mxGetJc, 153 | * mxSetPr, mxSetPi, mxSetIr, and mxSetJc cannot. 154 | * 155 | * An array header should NEVER be returned to MATLAB (for example via the 156 | * MEX API), or any other non-matrix access API function that expects a 157 | * full mxArray (examples include engPutVariable(), matPutVariable(), and 158 | * mexPutVariable()). 159 | * 160 | * Return NULL if an error occurs. 161 | */ 162 | EXTERN_C LIBMAT_API mxArray * matGetVariableInfo(MATFile *pMF, const char * name); 163 | 164 | 165 | /* 166 | * Remove a variable with with the specified name from the MAT-file pMF. 167 | * 168 | * Return zero on success, non-zero on error. 169 | */ 170 | EXTERN_C LIBMAT_API matError matDeleteVariable(MATFile *pMF, const char *name); 171 | 172 | 173 | /* 174 | * Get a list of the names of the arrays in a MAT-file. 175 | * The array of strings returned by this function contains "num" 176 | * entries. It is allocated with one call to mxCalloc, and so 177 | * can (must) be freed with one call to mxFree. 178 | * 179 | * If there are no arrays in the MAT-file, return value 180 | * is NULL and num is set to zero. If an error occurs, 181 | * return value is NULL and num is set to a negative number. 182 | */ 183 | EXTERN_C LIBMAT_API char ** matGetDir(MATFile * pMF, int *num); 184 | 185 | #endif /* mat_published_c_api_h */ 186 | -------------------------------------------------------------------------------- /TextureTransfer/for_testing/matrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PUBLISHed header for the libmx library. 3 | * 4 | * Copyright 1984-2013 The MathWorks, Inc. 5 | * All Rights Reserved. 6 | */ 7 | 8 | /* 9 | * NOTE: The contents of this header are ultimately PUBLISHED in 10 | * extern/include/matrix.h. 11 | */ 12 | 13 | #if defined(_MSC_VER) 14 | # pragma once 15 | #endif 16 | #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) 17 | # pragma once 18 | #endif 19 | 20 | #ifndef MATRIX_DEVELOPER_API_HPP 21 | #ifndef matrix_h 22 | #define matrix_h 23 | #include 24 | #include 25 | #include "tmwtypes.h" 26 | 27 | /* we can't see these definitions, which are stored in package.h, so we 28 | duplicate them here. */ 29 | #ifdef _MSC_VER 30 | #define MATRIX_DLL_EXPORT_SYM __declspec(dllexport) 31 | #define MATRIX_DLL_IMPORT_SYM __declspec(dllimport) 32 | #elif __GNUC__ >= 4 33 | #define MATRIX_DLL_EXPORT_SYM __attribute__ ((visibility("default"))) 34 | #define MATRIX_DLL_IMPORT_SYM __attribute__ ((visibility("default"))) 35 | #else 36 | #define MATRIX_DLL_EXPORT_SYM 37 | #define MATRIX_DLL_IMPORT_SYM 38 | #endif 39 | 40 | /** 41 | * Define symbol access for symbols exported from the libmwmatrix dll. 42 | */ 43 | #if defined(BUILDING_PUBLISHED_API_CPP) 44 | #define LIBMMWMATRIX_PUBLISHED_API MATRIX_DLL_EXPORT_SYM 45 | #else 46 | #if defined(export_matrix_h) 47 | /* we are a C file coming through /src/include/matrix.h */ 48 | #define LIBMMWMATRIX_PUBLISHED_API MATRIX_DLL_IMPORT_SYM 49 | #else 50 | /* We are a C mex file coming through /extern/include/matrix.h 51 | * LIBMMWMATRIX_PUBLISHED_API is empty to match definitions in mex.h. 52 | */ 53 | #ifdef LIBMMWMATRIX_PUBLISHED_API 54 | #undef LIBMMWMATRIX_PUBLISHED_API 55 | #endif 56 | #define LIBMMWMATRIX_PUBLISHED_API 57 | #endif /* export_matrix_h */ 58 | #endif /* BUILDING_PUPLISHED_API_CPP */ 59 | 60 | #ifdef __cplusplus 61 | #define LIBMMWMATRIX_PUBLISHED_API_EXTERN_C extern "C" LIBMMWMATRIX_PUBLISHED_API 62 | #else 63 | #define LIBMMWMATRIX_PUBLISHED_API_EXTERN_C extern LIBMMWMATRIX_PUBLISHED_API 64 | #endif 65 | 66 | 67 | /* Version 7.4.0 */ 68 | #define MX_API_VER 0x07040000 69 | 70 | 71 | /* On linux function symbol names are chosen at link time. Thus on linux 72 | * we need to strip _730 from function declarations. On windows and mac 73 | * we chose proper function name at compilation time. 74 | */ 75 | 76 | #if !defined(MX_COMPAT_32) && !defined(BUILDING_PUBLISHED_API_CPP) && defined(__linux__) 77 | 78 | #ifdef __cplusplus 79 | extern "C" { 80 | #endif 81 | 82 | #ifndef mxSetProperty_730 83 | # define mxSetProperty_730 mxSetProperty 84 | #endif 85 | 86 | #ifndef mxGetProperty_730 87 | # define mxGetProperty_730 mxGetProperty 88 | #endif 89 | 90 | #ifndef mxSetField_730 91 | # define mxSetField_730 mxSetField 92 | #endif 93 | 94 | #ifndef mxSetFieldByNumber_730 95 | # define mxSetFieldByNumber_730 mxSetFieldByNumber 96 | #endif 97 | 98 | #ifndef mxGetFieldByNumber_730 99 | # define mxGetFieldByNumber_730 mxGetFieldByNumber 100 | #endif 101 | 102 | #ifndef mxGetField_730 103 | # define mxGetField_730 mxGetField 104 | #endif 105 | 106 | #ifndef mxCreateStructMatrix_730 107 | # define mxCreateStructMatrix_730 mxCreateStructMatrix 108 | #endif 109 | 110 | #ifndef mxCreateCellMatrix_730 111 | # define mxCreateCellMatrix_730 mxCreateCellMatrix 112 | #endif 113 | 114 | #ifndef mxCreateCharMatrixFromStrings_730 115 | # define mxCreateCharMatrixFromStrings_730 mxCreateCharMatrixFromStrings 116 | #endif 117 | 118 | #ifndef mxGetString_730 119 | # define mxGetString_730 mxGetString 120 | #endif 121 | 122 | #ifndef mxGetNumberOfDimensions_730 123 | # define mxGetNumberOfDimensions_730 mxGetNumberOfDimensions 124 | #endif 125 | 126 | #ifndef mxGetDimensions_730 127 | # define mxGetDimensions_730 mxGetDimensions 128 | #endif 129 | 130 | #ifndef mxSetDimensions_730 131 | # define mxSetDimensions_730 mxSetDimensions 132 | #endif 133 | 134 | #ifndef mxSetIr_730 135 | # define mxSetIr_730 mxSetIr 136 | #endif 137 | 138 | #ifndef mxGetIr_730 139 | # define mxGetIr_730 mxGetIr 140 | #endif 141 | 142 | #ifndef mxSetJc_730 143 | # define mxSetJc_730 mxSetJc 144 | #endif 145 | 146 | #ifndef mxGetJc_730 147 | # define mxGetJc_730 mxGetJc 148 | #endif 149 | 150 | #ifndef mxCreateStructArray_730 151 | # define mxCreateStructArray_730 mxCreateStructArray 152 | #endif 153 | 154 | #ifndef mxCreateCharArray_730 155 | # define mxCreateCharArray_730 mxCreateCharArray 156 | #endif 157 | 158 | #ifndef mxCreateNumericArray_730 159 | # define mxCreateNumericArray_730 mxCreateNumericArray 160 | #endif 161 | 162 | #ifndef mxCreateCellArray_730 163 | # define mxCreateCellArray_730 mxCreateCellArray 164 | #endif 165 | 166 | #ifndef mxCreateLogicalArray_730 167 | # define mxCreateLogicalArray_730 mxCreateLogicalArray 168 | #endif 169 | 170 | #ifndef mxGetCell_730 171 | # define mxGetCell_730 mxGetCell 172 | #endif 173 | 174 | #ifndef mxSetCell_730 175 | # define mxSetCell_730 mxSetCell 176 | #endif 177 | 178 | #ifndef mxSetNzmax_730 179 | # define mxSetNzmax_730 mxSetNzmax 180 | #endif 181 | 182 | #ifndef mxSetN_730 183 | # define mxSetN_730 mxSetN 184 | #endif 185 | 186 | #ifndef mxSetM_730 187 | # define mxSetM_730 mxSetM 188 | #endif 189 | 190 | #ifndef mxGetNzmax_730 191 | # define mxGetNzmax_730 mxGetNzmax 192 | #endif 193 | 194 | #ifndef mxCreateDoubleMatrix_730 195 | # define mxCreateDoubleMatrix_730 mxCreateDoubleMatrix 196 | #endif 197 | 198 | #ifndef mxCreateNumericMatrix_730 199 | # define mxCreateNumericMatrix_730 mxCreateNumericMatrix 200 | #endif 201 | 202 | #ifndef mxCreateLogicalMatrix_730 203 | # define mxCreateLogicalMatrix_730 mxCreateLogicalMatrix 204 | #endif 205 | 206 | #ifndef mxCreateSparse_730 207 | # define mxCreateSparse_730 mxCreateSparse 208 | #endif 209 | 210 | #ifndef mxCreateSparseLogicalMatrix_730 211 | # define mxCreateSparseLogicalMatrix_730 mxCreateSparseLogicalMatrix 212 | #endif 213 | 214 | #ifndef mxGetNChars_730 215 | # define mxGetNChars_730 mxGetNChars 216 | #endif 217 | 218 | #ifndef mxCreateStringFromNChars_730 219 | # define mxCreateStringFromNChars_730 mxCreateStringFromNChars 220 | #endif 221 | 222 | #ifndef mxCalcSingleSubscript_730 223 | # define mxCalcSingleSubscript_730 mxCalcSingleSubscript 224 | #endif 225 | 226 | #ifndef mxGetDimensions_fcn_730 227 | # define mxGetDimensions_fcn_730 mxGetDimensions 228 | #endif 229 | 230 | #ifdef __cplusplus 231 | } 232 | #endif 233 | 234 | #endif /* !defined(MX_COMPAT_32) && !defined(BUILDING_PUBLISHED_API_CPP) && defined(__linux__) */ 235 | 236 | 237 | #ifndef MATHWORKS_MATRIX_DETAIL_PUBLISHED_FWD_DECLS_HPP 238 | #define MATHWORKS_MATRIX_DETAIL_PUBLISHED_FWD_DECLS_HPP 239 | 240 | 241 | 242 | /* 243 | * Forward declaration for mxArray 244 | */ 245 | typedef struct mxArray_tag mxArray; 246 | 247 | /* 248 | * Type representing the signature for MEX functions. 249 | */ 250 | typedef void (*mxFunctionPtr) (int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]); 251 | 252 | /* 253 | * Maximum mxArray name length 254 | */ 255 | #define mxMAXNAM TMW_NAME_LENGTH_MAX 256 | 257 | /* 258 | * Logical type 259 | */ 260 | typedef bool mxLogical; 261 | 262 | /* 263 | * Typedef required for Unicode support in MATLAB 264 | */ 265 | typedef CHAR16_T mxChar; 266 | 267 | /* 268 | * Enumeration corresponding to all the valid mxArray types. 269 | */ 270 | typedef enum 271 | { 272 | mxUNKNOWN_CLASS = 0, 273 | mxCELL_CLASS, 274 | mxSTRUCT_CLASS, 275 | mxLOGICAL_CLASS, 276 | mxCHAR_CLASS, 277 | mxVOID_CLASS, 278 | mxDOUBLE_CLASS, 279 | mxSINGLE_CLASS, 280 | mxINT8_CLASS, 281 | mxUINT8_CLASS, 282 | mxINT16_CLASS, 283 | mxUINT16_CLASS, 284 | mxINT32_CLASS, 285 | mxUINT32_CLASS, 286 | mxINT64_CLASS, 287 | mxUINT64_CLASS, 288 | mxFUNCTION_CLASS, 289 | mxOPAQUE_CLASS, 290 | mxOBJECT_CLASS, /* keep the last real item in the list */ 291 | #if defined(_LP64) || defined(_WIN64) 292 | mxINDEX_CLASS = mxUINT64_CLASS, 293 | #else 294 | mxINDEX_CLASS = mxUINT32_CLASS, 295 | #endif 296 | /* TEMPORARY AND NASTY HACK UNTIL mxSPARSE_CLASS IS COMPLETELY ELIMINATED */ 297 | mxSPARSE_CLASS = mxVOID_CLASS /* OBSOLETE! DO NOT USE */ 298 | } 299 | mxClassID; 300 | 301 | /* 302 | * Indicates whether floating-point mxArrays are real or complex. 303 | */ 304 | typedef enum 305 | { 306 | mxREAL, 307 | mxCOMPLEX 308 | } 309 | mxComplexity; 310 | 311 | #endif /* MATHWORKS_MATRIX_DETAIL_PUBLISHED_FWD_DECLS_HPP */ 312 | 313 | /* 314 | * allocate memory, notifying registered listener 315 | */ 316 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void *mxMalloc( 317 | size_t n /* number of bytes */ 318 | ); 319 | 320 | 321 | /* 322 | * allocate cleared memory, notifying registered listener. 323 | */ 324 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void *mxCalloc( 325 | size_t n, /* number of objects */ 326 | size_t size /* size of objects */ 327 | ); 328 | 329 | 330 | /* 331 | * free memory, notifying registered listener. 332 | */ 333 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxFree(void *ptr) /* pointer to memory to be freed */; 334 | 335 | 336 | /* 337 | * reallocate memory, notifying registered listener. 338 | */ 339 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void *mxRealloc(void *ptr, size_t size); 340 | 341 | /* 342 | * Get number of dimensions in array 343 | */ 344 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C size_t mxGetNumberOfDimensions_730(const mxArray *pa); 345 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxGetNumberOfDimensions_700(const mxArray *pa); 346 | 347 | 348 | /* 349 | * Get pointer to dimension array 350 | */ 351 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C const size_t *mxGetDimensions_730(const mxArray *pa); 352 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C const int *mxGetDimensions_700(const mxArray *pa); 353 | /* 354 | * Get row dimension 355 | */ 356 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C size_t mxGetM(const mxArray *pa); 357 | 358 | /* 359 | * Get row data pointer for sparse numeric array 360 | */ 361 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C size_t *mxGetIr_730(const mxArray *pa); 362 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int *mxGetIr_700(const mxArray *pa); 363 | 364 | 365 | /* 366 | * Get column data pointer for sparse numeric array 367 | */ 368 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C size_t *mxGetJc_730(const mxArray *pa); 369 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int *mxGetJc_700(const mxArray *pa); 370 | 371 | /* 372 | * Get maximum nonzero elements for sparse numeric array 373 | */ 374 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C size_t mxGetNzmax_730(const mxArray *pa); 375 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxGetNzmax_700(const mxArray *pa); 376 | 377 | 378 | /* 379 | * Set maximum nonzero elements for numeric array 380 | */ 381 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetNzmax_730(mxArray *pa, size_t nzmax); 382 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetNzmax_700(mxArray *pa, int nzmax); 383 | 384 | /* 385 | * Return pointer to the nth field name 386 | */ 387 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C const char *mxGetFieldNameByNumber(const mxArray *pa, int n); 388 | 389 | /* 390 | * Return a pointer to the contents of the named field for 391 | * the ith element (zero based). 392 | */ 393 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxGetFieldByNumber_730(const mxArray *pa, size_t i, int fieldnum); 394 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxGetFieldByNumber_700(const mxArray *pa, int i, int fieldnum); 395 | 396 | /* 397 | * Get a pointer to the specified cell element. 398 | */ 399 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxGetCell_730(const mxArray *pa, size_t i); 400 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxGetCell_700(const mxArray *pa, int i); 401 | 402 | /* 403 | * Return the class (catergory) of data that the array holds. 404 | */ 405 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxClassID mxGetClassID(const mxArray *pa); 406 | 407 | /* 408 | * Get pointer to data 409 | */ 410 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void *mxGetData( 411 | const mxArray *pa /* pointer to array */ 412 | ); 413 | 414 | /* 415 | * Set pointer to data 416 | */ 417 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetData( 418 | mxArray *pa, /* pointer to array */ 419 | void *newdata /* pointer to data */ 420 | ); 421 | 422 | /* 423 | * Determine whether the specified array contains numeric (as opposed 424 | * to cell or struct) data. 425 | */ 426 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsNumeric(const mxArray *pa); 427 | 428 | /* 429 | * Determine whether the given array is a cell array. 430 | */ 431 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsCell(const mxArray *pa); 432 | 433 | /* 434 | * Determine whether the given array's logical flag is on. 435 | */ 436 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsLogical(const mxArray *pa); 437 | 438 | /* 439 | * Determine whether the given array's scalar flag is on. 440 | */ 441 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsScalar(const mxArray *pa); 442 | 443 | /* 444 | * Determine whether the given array contains character data. 445 | */ 446 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsChar(const mxArray *pa); 447 | 448 | /* 449 | * Determine whether the given array is a structure array. 450 | */ 451 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsStruct(const mxArray *pa); 452 | 453 | 454 | /* 455 | * Determine whether the given array is an opaque array. 456 | */ 457 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsOpaque(const mxArray *pa); 458 | 459 | 460 | /* 461 | * Returns true if specified array is a function object. 462 | */ 463 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsFunctionHandle(const mxArray *pa); 464 | 465 | 466 | /* 467 | * This function is deprecated and is preserved only for backward compatibility. 468 | * DO NOT USE if possible. 469 | * Is array user defined MATLAB v5 object 470 | */ 471 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsObject( 472 | const mxArray *pa /* pointer to array */ 473 | ); 474 | 475 | 476 | /* 477 | * Get imaginary data pointer for numeric array 478 | */ 479 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void *mxGetImagData( 480 | const mxArray *pa /* pointer to array */ 481 | ); 482 | 483 | /* 484 | * Set imaginary data pointer for numeric array 485 | */ 486 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetImagData( 487 | mxArray *pa, /* pointer to array */ 488 | void *newdata /* imaginary data array pointer */ 489 | ); 490 | 491 | /* 492 | * Determine whether the given array contains complex data. 493 | */ 494 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsComplex(const mxArray *pa); 495 | 496 | 497 | /* 498 | * Determine whether the given array is a sparse (as opposed to full). 499 | */ 500 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsSparse(const mxArray *pa); 501 | 502 | /* 503 | * Determine whether the specified array represents its data as 504 | * double-precision floating-point numbers. 505 | */ 506 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsDouble(const mxArray *pa); 507 | 508 | /* 509 | * Determine whether the specified array represents its data as 510 | * single-precision floating-point numbers. 511 | */ 512 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsSingle(const mxArray *pa); 513 | 514 | 515 | /* 516 | * Determine whether the specified array represents its data as 517 | * signed 8-bit integers. 518 | */ 519 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsInt8(const mxArray *pa); 520 | 521 | 522 | /* 523 | * Determine whether the specified array represents its data as 524 | * unsigned 8-bit integers. 525 | */ 526 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsUint8(const mxArray *pa); 527 | 528 | 529 | /* 530 | * Determine whether the specified array represents its data as 531 | * signed 16-bit integers. 532 | */ 533 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsInt16(const mxArray *pa); 534 | 535 | 536 | /* 537 | * Determine whether the specified array represents its data as 538 | * unsigned 16-bit integers. 539 | */ 540 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsUint16(const mxArray *pa); 541 | 542 | 543 | /* 544 | * Determine whether the specified array represents its data as 545 | * signed 32-bit integers. 546 | */ 547 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsInt32(const mxArray *pa); 548 | 549 | 550 | /* 551 | * Determine whether the specified array represents its data as 552 | * unsigned 32-bit integers. 553 | */ 554 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsUint32(const mxArray *pa); 555 | 556 | 557 | /* 558 | * Determine whether the specified array represents its data as 559 | * signed 64-bit integers. 560 | */ 561 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsInt64(const mxArray *pa); 562 | 563 | 564 | /* 565 | * Determine whether the specified array represents its data as 566 | * unsigned 64-bit integers. 567 | */ 568 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsUint64(const mxArray *pa); 569 | 570 | /* 571 | * Get number of elements in array 572 | */ 573 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C size_t mxGetNumberOfElements( 574 | const mxArray *pa /* pointer to array */ 575 | ); 576 | 577 | /* 578 | * Get real data pointer for numeric array 579 | */ 580 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C double *mxGetPr( 581 | const mxArray *pa /* pointer to array */ 582 | ); 583 | 584 | /* 585 | * Set real data pointer for numeric array 586 | */ 587 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetPr( 588 | mxArray *pa, /* pointer to array */ 589 | double *pr /* real data array pointer */ 590 | ); 591 | 592 | /* 593 | * Get imaginary data pointer for numeric array 594 | */ 595 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C double *mxGetPi( 596 | const mxArray *pa /* pointer to array */ 597 | ); 598 | 599 | /* 600 | * Set imaginary data pointer for numeric array 601 | */ 602 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetPi( 603 | mxArray *pa, /* pointer to array */ 604 | double *pi /* imaginary data array pointer */ 605 | ); 606 | 607 | /* 608 | * Get string array data 609 | */ 610 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxChar *mxGetChars( 611 | const mxArray *pa /* pointer to array */ 612 | ); 613 | 614 | 615 | /* 616 | * Get 8 bits of user data stored in the mxArray header. NOTE: This state 617 | * of these bits are not guaranteed to be preserved after API function 618 | * calls. 619 | */ 620 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxGetUserBits( 621 | const mxArray *pa /* pointer to array */ 622 | ); 623 | 624 | 625 | /* 626 | * Set 8 bits of user data stored in the mxArray header. NOTE: This state 627 | * of these bits are not guaranteed to be preserved after API function 628 | * calls. 629 | */ 630 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetUserBits( 631 | mxArray *pa, /* pointer to array */ 632 | int value 633 | ); 634 | 635 | 636 | /* 637 | * Get the real component of the specified array's first data element. 638 | */ 639 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C double mxGetScalar(const mxArray *pa); 640 | 641 | /* 642 | * Inform Watcom compilers that scalar double return values 643 | * will be in the FPU register. 644 | */ 645 | #ifdef __WATCOMC__ 646 | #pragma aux mxGetScalar value [8087]; 647 | #endif 648 | 649 | 650 | /* 651 | * Is the isFromGlobalWorkspace bit set? 652 | */ 653 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsFromGlobalWS(const mxArray *pa); 654 | 655 | 656 | /* 657 | * Set the isFromGlobalWorkspace bit. 658 | */ 659 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetFromGlobalWS(mxArray *pa, bool global); 660 | 661 | 662 | /* 663 | * Set row dimension 664 | */ 665 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetM_730(mxArray *pa, size_t m); 666 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetM_700(mxArray *pa, int m); 667 | 668 | 669 | /* 670 | * Get column dimension 671 | */ 672 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C size_t mxGetN(const mxArray *pa); 673 | 674 | 675 | 676 | /* 677 | * Is array empty 678 | */ 679 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsEmpty( 680 | const mxArray *pa /* pointer to array */ 681 | ); 682 | /* 683 | * Get the index to the named field. 684 | */ 685 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxGetFieldNumber(const mxArray *pa, const char *name); 686 | 687 | /* 688 | * Set row data pointer for numeric array 689 | */ 690 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetIr_730(mxArray *pa, size_t *newir); 691 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetIr_700(mxArray *pa, int *newir); 692 | 693 | /* 694 | * Set column data pointer for numeric array 695 | */ 696 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetJc_730(mxArray *pa, size_t *newjc); 697 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetJc_700(mxArray *pa, int *newjc); 698 | 699 | /* 700 | * Get array data element size 701 | */ 702 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C size_t mxGetElementSize(const mxArray *pa); 703 | 704 | /* 705 | * Return the offset (in number of elements) from the beginning of 706 | * the array to a given subscript. 707 | */ 708 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C size_t mxCalcSingleSubscript_730(const mxArray *pa, size_t nsubs, const size_t *subs); 709 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxCalcSingleSubscript_700(const mxArray *pa, int nsubs, const int *subs); 710 | 711 | /* 712 | * Get number of structure fields in array 713 | * Returns 0 if mxArray is non-struct. 714 | */ 715 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxGetNumberOfFields( 716 | const mxArray *pa /* pointer to array */ 717 | ); 718 | 719 | /* 720 | * Set an element in a cell array to the specified value. 721 | */ 722 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetCell_730(mxArray *pa, size_t i, mxArray *value); 723 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetCell_700(mxArray *pa, int i, mxArray *value); 724 | 725 | /* 726 | * Set pa[i][fieldnum] = value 727 | */ 728 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetFieldByNumber_730(mxArray *pa, size_t i, int fieldnum, mxArray *value); 729 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetFieldByNumber_700(mxArray *pa, int i, int fieldnum, mxArray *value); 730 | 731 | /* 732 | * Return a pointer to the contents of the named field for the ith 733 | * element (zero based). Returns NULL on no such field or if the 734 | * field itself is NULL 735 | */ 736 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxGetField_730(const mxArray *pa, size_t i, const char *fieldname); 737 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxGetField_700(const mxArray *pa, int i, const char *fieldname); 738 | 739 | 740 | /* 741 | * Sets the contents of the named field for the ith element (zero based). 742 | * The input 'value' is stored in the input array 'pa' - no copy is made. 743 | */ 744 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetField_730(mxArray *pa, size_t i, const char *fieldname, mxArray *value); 745 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetField_700(mxArray *pa, int i, const char *fieldname, mxArray *value); 746 | 747 | 748 | /* 749 | * mxGetProperty returns the value of a property for a given object and index. 750 | * The property must be public. 751 | * 752 | * If the given property name doesn't exist, isn't public, or the object isn't 753 | * the right type, then mxGetProperty returns NULL. 754 | */ 755 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxGetProperty_730(const mxArray *pa, const size_t i, const char *propname); 756 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxGetProperty_700(const mxArray *pa, const int i, const char *propname); 757 | 758 | 759 | /* 760 | * mxSetProperty sets the value of a property for a given object and index. 761 | * The property must be public. 762 | * 763 | */ 764 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetProperty_730(mxArray *pa, size_t i, const char *propname, const mxArray *value); 765 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetProperty_700(mxArray *pa, int i, const char *propname, const mxArray *value); 766 | 767 | 768 | /* 769 | * Return the name of an array's class. 770 | */ 771 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C const char *mxGetClassName(const mxArray *pa); 772 | 773 | 774 | /* 775 | * Determine whether an array is a member of the specified class. 776 | */ 777 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsClass(const mxArray *pa, const char *name); 778 | 779 | /* 780 | * Create a numeric matrix and initialize all its data elements to 0. 781 | * In standalone mode, out-of-memory will mean a NULL pointer is returned. 782 | */ 783 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateNumericMatrix_730(size_t m, size_t n, mxClassID classid, mxComplexity flag); 784 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateNumericMatrix_700(int m, int n, mxClassID classid, mxComplexity flag); 785 | 786 | /* 787 | * Create an uninitialized numeric matrix. 788 | * The resulting array must be freed with mxDestroyArray. 789 | */ 790 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateUninitNumericMatrix(size_t m, size_t n, mxClassID classid, mxComplexity flag); 791 | 792 | /* 793 | * Create an uninitialized numeric array. 794 | * The resulting array must be freed with mxDestroyArray. 795 | */ 796 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateUninitNumericArray (size_t ndim, size_t *dims, mxClassID classid, mxComplexity flag); 797 | 798 | /* 799 | * Set column dimension 800 | */ 801 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetN_730(mxArray *pa, size_t n); 802 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxSetN_700(mxArray *pa, int n); 803 | 804 | 805 | /* 806 | * Set dimension array and number of dimensions. Returns 0 on success and 1 807 | * if there was not enough memory available to reallocate the dimensions array. 808 | */ 809 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxSetDimensions_730(mxArray *pa, const size_t *pdims, size_t ndims); 810 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxSetDimensions_700(mxArray *pa, const int *pdims, int ndims); 811 | 812 | /* 813 | * mxArray destructor 814 | */ 815 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxDestroyArray(mxArray *pa); 816 | 817 | /* 818 | * Create a numeric array and initialize all its data elements to 0. 819 | * 820 | * Similar to mxCreateNumericMatrix, in a standalone application, 821 | * out-of-memory will mean a NULL pointer is returned. 822 | */ 823 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateNumericArray_730(size_t ndim, const size_t *dims, mxClassID classid, mxComplexity flag); 824 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateNumericArray_700(int ndim, const int *dims, mxClassID classid, mxComplexity flag); 825 | 826 | /* 827 | * Create an N-Dimensional array to hold string data; 828 | * initialize all elements to 0. 829 | */ 830 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateCharArray_730(size_t ndim, const size_t *dims); 831 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateCharArray_700(int ndim, const int *dims); 832 | 833 | /* 834 | * Create a two-dimensional array to hold double-precision 835 | * floating-point data; initialize each data element to 0. 836 | */ 837 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateDoubleMatrix_730(size_t m, size_t n, mxComplexity flag); 838 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateDoubleMatrix_700(int m, int n, mxComplexity flag); 839 | 840 | 841 | /* 842 | * Get a properly typed pointer to the elements of a logical array. 843 | */ 844 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxLogical *mxGetLogicals(const mxArray *pa); 845 | 846 | 847 | /* 848 | * Create a logical array and initialize its data elements to false. 849 | */ 850 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateLogicalArray_730(size_t ndim, const size_t *dims); 851 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateLogicalArray_700(int ndim, const int *dims); 852 | 853 | /* 854 | * Create a two-dimensional array to hold logical data and 855 | * initializes each data element to false. 856 | */ 857 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateLogicalMatrix_730(size_t m, size_t n); 858 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateLogicalMatrix_700(int m, int n); 859 | 860 | /* 861 | * Create a logical scalar mxArray having the specified value. 862 | */ 863 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateLogicalScalar(bool value); 864 | 865 | 866 | /* 867 | * Returns true if we have a valid logical scalar mxArray. 868 | */ 869 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsLogicalScalar(const mxArray *pa); 870 | 871 | 872 | /* 873 | * Returns true if the logical scalar value is true. 874 | */ 875 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsLogicalScalarTrue(const mxArray *pa); 876 | 877 | 878 | /* 879 | * Create a double-precision scalar mxArray initialized to the 880 | * value specified 881 | */ 882 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateDoubleScalar(double value); 883 | 884 | 885 | /* 886 | * Create a 2-Dimensional sparse array. 887 | * 888 | * Z = mxCreateSparse(m,n,nzmax,cmplx_flag); 889 | * An m-by-n, real or complex, sparse matrix with room for nzmax nonzeros. 890 | * Use this to allocate storage for a sparse matrix. 891 | * It allocates the structure, allocates the pr, pi, ir and jc arrays, 892 | * and sets all the fields, which may be changed later. 893 | * Avoids the question of malloc(0) by replacing nzmax = 0 with nzmax = 1. 894 | * Also sets Z->pr[0] = 0.0 so that the scalar sparse(0.0) acts like 0.0. 895 | * 896 | * Notice that the value of m is almost irrelevant. It is only stored in 897 | * the mxSetM field of the matrix structure. It does not affect the amount 898 | * of storage required by sparse matrices, or the amount of time required 899 | * by sparse algorithms. Consequently, m can be "infinite". The result 900 | * is a semi-infinite matrix with a finite number of columns and a finite, 901 | * but unspecified, number of nonzero rows. 902 | */ 903 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateSparse_730(size_t m, size_t n, size_t nzmax, mxComplexity flag); 904 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateSparse_700(int m, int n, int nzmax, mxComplexity flag); 905 | 906 | 907 | /* 908 | * Create a 2-D sparse logical array 909 | */ 910 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateSparseLogicalMatrix_730(size_t m, size_t n, size_t nzmax); 911 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateSparseLogicalMatrix_700(int m, int n, int nzmax); 912 | 913 | 914 | /* 915 | * Copies characters from a MATLAB array to a char array 916 | * This function will attempt to perform null termination if it is possible. 917 | * nChars is the number of bytes in the output buffer 918 | */ 919 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxGetNChars_730(const mxArray *pa, char *buf, size_t nChars); 920 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxGetNChars_700(const mxArray *pa, char *buf, int nChars); 921 | 922 | 923 | /* 924 | * Converts a string array to a C-style string. The C-style string is in the 925 | * local codepage encoding. If the conversion for the entire Unicode string 926 | * cannot fit into the supplied character buffer, then the conversion includes 927 | * the last whole codepoint that will fit into the buffer. The string is thus 928 | * truncated at the greatest possible whole codepoint and does not split code- 929 | * points. 930 | */ 931 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxGetString_730(const mxArray *pa, char *buf, size_t buflen); 932 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxGetString_700(const mxArray *pa, char *buf, int buflen); 933 | 934 | 935 | /* 936 | * Create a NULL terminated C string from an mxArray of type mxCHAR_CLASS 937 | * Supports multibyte character sets. The resulting string must be freed 938 | * with mxFree. Returns NULL on out of memory or non-character arrays. 939 | */ 940 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C char *mxArrayToString(const mxArray *pa); 941 | 942 | /* 943 | * Create a NULL terminated C string from an mxArray of type mxCHAR_CLASS 944 | * The C style string is in UTF-8 encoding. The resulting 945 | * string must be freed with mxFree. Returns NULL on out of memory or 946 | * non-character arrays. 947 | */ 948 | 949 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C char *mxArrayToUTF8String(mxArray const *pa); 950 | 951 | 952 | /** 953 | * Create a 1-by-n string array initialized to str. The supplied string is 954 | * presumed to be in the local codepage encoding. The character data format 955 | * in the mxArray will be UTF-16. 956 | */ 957 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateStringFromNChars_730(const char *str, size_t n); 958 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateStringFromNChars_700(const char *str, int n); 959 | 960 | 961 | /* 962 | * Create a 1-by-n string array initialized to null terminated string 963 | * where n is the length of the string. 964 | */ 965 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateString(const char *str); 966 | 967 | /* 968 | * Create a string array initialized to the strings in str. 969 | */ 970 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateCharMatrixFromStrings_730(size_t m, const char **str); 971 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateCharMatrixFromStrings_700(int m, const char **str); 972 | 973 | /* 974 | * Create a 2-Dimensional cell array, with each cell initialized 975 | * to NULL. 976 | */ 977 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateCellMatrix_730(size_t m, size_t n); 978 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateCellMatrix_700(int m, int n); 979 | 980 | 981 | /* 982 | * Create an N-Dimensional cell array, with each cell initialized 983 | * to NULL. 984 | */ 985 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateCellArray_730(size_t ndim, const size_t *dims); 986 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateCellArray_700(int ndim, const int *dims); 987 | 988 | /* 989 | * Create a 2-Dimensional structure array having the specified fields; 990 | * initialize all values to NULL. 991 | */ 992 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateStructMatrix_730(size_t m, size_t n, int nfields, const char **fieldnames); 993 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateStructMatrix_700(int m, int n, int nfields, const char **fieldnames); 994 | 995 | 996 | /* 997 | * Create an N-Dimensional structure array having the specified fields; 998 | * initialize all values to NULL. 999 | */ 1000 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateStructArray_730(size_t ndim, const size_t *dims, int nfields, 1001 | const char **fieldnames); 1002 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxCreateStructArray_700(int ndim, const int *dims, int nfields, 1003 | const char **fieldnames); 1004 | 1005 | /* 1006 | * Make a deep copy of an array, return a pointer to the copy. 1007 | */ 1008 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *mxDuplicateArray(const mxArray *in); 1009 | 1010 | 1011 | /* 1012 | * Set classname of an unvalidated object array. It is illegal to 1013 | * call this function on a previously validated object array. 1014 | * Return 0 for success, 1 for failure. 1015 | */ 1016 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxSetClassName(mxArray *pa, const char *classname); 1017 | 1018 | 1019 | /* 1020 | * Add a field to a structure array. Returns field number on success or -1 1021 | * if inputs are invalid or an out of memory condition occurs. 1022 | */ 1023 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C int mxAddField(mxArray *pa, const char *fieldname); 1024 | 1025 | 1026 | /* 1027 | * Remove a field from a structure array. Does nothing if no such field exists. 1028 | * Does not destroy the field itself. 1029 | */ 1030 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mxRemoveField(mxArray *pa, int field); 1031 | 1032 | 1033 | /* 1034 | * Function for obtaining MATLAB's concept of EPS 1035 | */ 1036 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C double mxGetEps(void); 1037 | 1038 | 1039 | /* 1040 | * Function for obtaining MATLAB's concept of INF (Used in MEX-File callback). 1041 | */ 1042 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C double mxGetInf(void); 1043 | 1044 | 1045 | /* 1046 | * Function for obtaining MATLAB's concept of NaN (Used in MEX-File callback). 1047 | */ 1048 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C double mxGetNaN(void); 1049 | 1050 | 1051 | /* 1052 | * Inform Watcom compilers that scalar double return values 1053 | * will be in the FPU register. 1054 | */ 1055 | #ifdef __WATCOMC__ 1056 | #pragma aux mxGetEps value [8087]; 1057 | #pragma aux mxGetInf value [8087]; 1058 | #pragma aux mxGetNaN value [8087]; 1059 | #endif 1060 | 1061 | 1062 | /* 1063 | * test for finiteness in a machine-independent manner 1064 | */ 1065 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsFinite( 1066 | double x /* value to test */ 1067 | ); 1068 | 1069 | 1070 | /* 1071 | * test for infinity in a machine-independent manner 1072 | */ 1073 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsInf( 1074 | double x /* value to test */ 1075 | ); 1076 | 1077 | 1078 | /* 1079 | * test for NaN in a machine-independent manner 1080 | */ 1081 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C bool mxIsNaN( 1082 | double x /* value to test */ 1083 | ); 1084 | 1085 | 1086 | #ifndef mxassert_h 1087 | #define mxassert_h 1088 | /* 1089 | mxAssert(int expression, char *error_message) 1090 | --------------------------------------------- 1091 | 1092 | Similar to ANSI C's assert() macro, the mxAssert macro checks the 1093 | value of an assertion, continuing execution only if the assertion 1094 | holds. If 'expression' evaluates to be true, then the mxAssert does 1095 | nothing. If, however, 'expression' is false, then mxAssert prints an 1096 | error message to the MATLAB Command Window, consisting of the failed 1097 | assertion's expression, the file name and line number where the failed 1098 | assertion occurred, and the string 'error_message'. 'error_message' 1099 | allows the user to specify a more understandable description of why 1100 | the assertion failed. (Use an empty string if no extra description 1101 | should follow the failed assertion message.) After a failed 1102 | assertion, control returns to the MATLAB command line. 1103 | 1104 | mxAssertS, (the S for Simple), takes the same inputs as mxAssert. It 1105 | does not print the text of the failed assertion, only the file and 1106 | line where the assertion failed, and the explanatory error_message. 1107 | 1108 | Note that script MEX will turn off these assertions when building 1109 | optimized MEX-functions, so they should be used for debugging 1110 | purposes only. 1111 | */ 1112 | 1113 | #ifdef MATLAB_MEX_FILE 1114 | # ifndef NDEBUG 1115 | 1116 | LIBMMWMATRIX_PUBLISHED_API_EXTERN_C void mexPrintAssertion(const char *test, 1117 | const char *fname, 1118 | int linenum, 1119 | const char *message); 1120 | 1121 | 1122 | # define mxAssert(test, message) ( (test) ? (void) 0 : mexPrintAssertion(#test, __FILE__, __LINE__, message)) 1123 | # define mxAssertS(test, message) ( (test) ? (void) 0 : mexPrintAssertion("", __FILE__, __LINE__, message)) 1124 | # else 1125 | # define mxAssert(test, message) ((void) 0) 1126 | # define mxAssertS(test, message) ((void) 0) 1127 | # endif 1128 | #else 1129 | # include 1130 | # define mxAssert(test, message) assert(test) 1131 | # define mxAssertS(test, message) assert(test) 1132 | #endif 1133 | 1134 | #endif /* mxassert_h */ 1135 | 1136 | #if !defined(BUILDING_PUBLISHED_API_CPP) && !defined(BUILDING_LIBMX) 1137 | 1138 | /* 1139 | * PUBLISHED APIs with changes in MATLAB 7.3 1140 | */ 1141 | 1142 | #if !defined(MX_COMPAT_32) && !defined(__linux__) 1143 | 1144 | #ifdef __cplusplus 1145 | extern "C" { 1146 | #endif 1147 | 1148 | #ifndef mxSetProperty 1149 | # define mxSetProperty mxSetProperty_730 1150 | #endif 1151 | 1152 | #ifndef mxGetProperty 1153 | # define mxGetProperty mxGetProperty_730 1154 | #endif 1155 | 1156 | #ifndef mxSetField 1157 | # define mxSetField mxSetField_730 1158 | #endif 1159 | 1160 | #ifndef mxSetFieldByNumber 1161 | # define mxSetFieldByNumber mxSetFieldByNumber_730 1162 | #endif 1163 | 1164 | #ifndef mxGetFieldByNumber 1165 | # define mxGetFieldByNumber mxGetFieldByNumber_730 1166 | #endif 1167 | 1168 | #ifndef mxGetField 1169 | # define mxGetField mxGetField_730 1170 | #endif 1171 | 1172 | #ifndef mxCreateStructMatrix 1173 | # define mxCreateStructMatrix mxCreateStructMatrix_730 1174 | #endif 1175 | 1176 | #ifndef mxCreateCellMatrix 1177 | # define mxCreateCellMatrix mxCreateCellMatrix_730 1178 | #endif 1179 | 1180 | #ifndef mxCreateCharMatrixFromStrings 1181 | # define mxCreateCharMatrixFromStrings mxCreateCharMatrixFromStrings_730 1182 | #endif 1183 | 1184 | #ifndef mxGetString 1185 | # define mxGetString mxGetString_730 1186 | #endif 1187 | 1188 | #ifndef mxGetNumberOfDimensions 1189 | # define mxGetNumberOfDimensions mxGetNumberOfDimensions_730 1190 | #endif 1191 | 1192 | #ifndef mxGetDimensions 1193 | # define mxGetDimensions mxGetDimensions_730 1194 | #endif 1195 | 1196 | #ifndef mxSetDimensions 1197 | # define mxSetDimensions mxSetDimensions_730 1198 | #endif 1199 | 1200 | #ifndef mxSetIr 1201 | # define mxSetIr mxSetIr_730 1202 | #endif 1203 | 1204 | #ifndef mxGetIr 1205 | # define mxGetIr mxGetIr_730 1206 | #endif 1207 | 1208 | #ifndef mxSetJc 1209 | # define mxSetJc mxSetJc_730 1210 | #endif 1211 | 1212 | #ifndef mxGetJc 1213 | # define mxGetJc mxGetJc_730 1214 | #endif 1215 | 1216 | #ifndef mxCreateStructArray 1217 | # define mxCreateStructArray mxCreateStructArray_730 1218 | #endif 1219 | 1220 | #ifndef mxCreateCharArray 1221 | # define mxCreateCharArray mxCreateCharArray_730 1222 | #endif 1223 | 1224 | #ifndef mxCreateNumericArray 1225 | # define mxCreateNumericArray mxCreateNumericArray_730 1226 | #endif 1227 | 1228 | #ifndef mxCreateCellArray 1229 | # define mxCreateCellArray mxCreateCellArray_730 1230 | #endif 1231 | 1232 | #ifndef mxCreateLogicalArray 1233 | # define mxCreateLogicalArray mxCreateLogicalArray_730 1234 | #endif 1235 | 1236 | #ifndef mxGetCell 1237 | # define mxGetCell mxGetCell_730 1238 | #endif 1239 | 1240 | #ifndef mxSetCell 1241 | # define mxSetCell mxSetCell_730 1242 | #endif 1243 | 1244 | #ifndef mxSetNzmax 1245 | # define mxSetNzmax mxSetNzmax_730 1246 | #endif 1247 | 1248 | #ifndef mxSetN 1249 | # define mxSetN mxSetN_730 1250 | #endif 1251 | 1252 | #ifndef mxSetM 1253 | # define mxSetM mxSetM_730 1254 | #endif 1255 | 1256 | #ifndef mxGetNzmax 1257 | # define mxGetNzmax mxGetNzmax_730 1258 | #endif 1259 | 1260 | #ifndef mxCreateDoubleMatrix 1261 | # define mxCreateDoubleMatrix mxCreateDoubleMatrix_730 1262 | #endif 1263 | 1264 | #ifndef mxCreateNumericMatrix 1265 | # define mxCreateNumericMatrix mxCreateNumericMatrix_730 1266 | #endif 1267 | 1268 | #ifndef mxCreateLogicalMatrix 1269 | # define mxCreateLogicalMatrix mxCreateLogicalMatrix_730 1270 | #endif 1271 | 1272 | #ifndef mxCreateSparse 1273 | # define mxCreateSparse mxCreateSparse_730 1274 | #endif 1275 | 1276 | #ifndef mxCreateSparseLogicalMatrix 1277 | # define mxCreateSparseLogicalMatrix mxCreateSparseLogicalMatrix_730 1278 | #endif 1279 | 1280 | #ifndef mxGetNChars 1281 | # define mxGetNChars mxGetNChars_730 1282 | #endif 1283 | 1284 | #ifndef mxCreateStringFromNChars 1285 | # define mxCreateStringFromNChars mxCreateStringFromNChars_730 1286 | #endif 1287 | 1288 | #ifndef mxCalcSingleSubscript 1289 | # define mxCalcSingleSubscript mxCalcSingleSubscript_730 1290 | #endif 1291 | 1292 | #ifndef mxGetDimensions_fcn 1293 | # define mxGetDimensions_fcn mxGetDimensions_730 1294 | #endif 1295 | 1296 | #ifdef __cplusplus 1297 | } 1298 | #endif 1299 | 1300 | #endif /* !MX_COMPAT_32 */ 1301 | 1302 | 1303 | #ifdef MX_COMPAT_32 1304 | 1305 | /* 1306 | * 32-bit compatibility APIs 1307 | */ 1308 | 1309 | #ifdef __cplusplus 1310 | extern "C" { 1311 | #endif 1312 | 1313 | #ifndef mxGetNumberOfDimensions 1314 | #define mxGetNumberOfDimensions mxGetNumberOfDimensions_700 1315 | #endif 1316 | 1317 | #ifndef mxGetDimensions 1318 | #define mxGetDimensions mxGetDimensions_700 1319 | #endif 1320 | 1321 | #ifndef mxGetDimensions_fcn 1322 | # define mxGetDimensions_fcn mxGetDimensions_700 1323 | #endif 1324 | 1325 | #ifndef mxGetIr 1326 | #define mxGetIr mxGetIr_700 1327 | #endif 1328 | 1329 | #ifndef mxGetJc 1330 | #define mxGetJc mxGetJc_700 1331 | #endif 1332 | 1333 | #ifndef mxGetCell 1334 | #define mxGetCell mxGetCell_700 1335 | #endif 1336 | 1337 | #ifndef mxGetNzmax 1338 | #define mxGetNzmax mxGetNzmax_700 1339 | #endif 1340 | 1341 | #ifndef mxSetNzmax 1342 | #define mxSetNzmax mxSetNzmax_700 1343 | #endif 1344 | 1345 | #ifndef mxGetFieldByNumber 1346 | #define mxGetFieldByNumber mxGetFieldByNumber_700 1347 | #endif 1348 | 1349 | #ifndef mxSetProperty 1350 | #define mxSetProperty mxSetProperty_700 1351 | #endif 1352 | 1353 | #ifndef mxGetProperty 1354 | #define mxGetProperty mxGetProperty_700 1355 | #endif 1356 | 1357 | #ifndef mxSetField 1358 | #define mxSetField mxSetField_700 1359 | #endif 1360 | 1361 | #ifndef mxSetFieldByNumber 1362 | #define mxSetFieldByNumber mxSetFieldByNumber_700 1363 | #endif 1364 | 1365 | #ifndef mxGetField 1366 | #define mxGetField mxGetField_700 1367 | #endif 1368 | 1369 | #ifndef mxCreateStructMatrix 1370 | #define mxCreateStructMatrix mxCreateStructMatrix_700 1371 | #endif 1372 | 1373 | #ifndef mxCreateCellMatrix 1374 | #define mxCreateCellMatrix mxCreateCellMatrix_700 1375 | #endif 1376 | 1377 | #ifndef mxCreateCharMatrixFromStrings 1378 | #define mxCreateCharMatrixFromStrings mxCreateCharMatrixFromStrings_700 1379 | #endif 1380 | 1381 | #ifndef mxGetString 1382 | #define mxGetString mxGetString_700 1383 | #endif 1384 | 1385 | #ifndef mxSetDimensions 1386 | #define mxSetDimensions mxSetDimensions_700 1387 | #endif 1388 | 1389 | #ifndef mxSetIr 1390 | #define mxSetIr mxSetIr_700 1391 | #endif 1392 | 1393 | #ifndef mxSetJc 1394 | #define mxSetJc mxSetJc_700 1395 | #endif 1396 | 1397 | #ifndef mxCreateStructArray 1398 | #define mxCreateStructArray mxCreateStructArray_700 1399 | #endif 1400 | 1401 | #ifndef mxCreateCharArray 1402 | #define mxCreateCharArray mxCreateCharArray_700 1403 | #endif 1404 | 1405 | #ifndef mxCreateNumericArray 1406 | #define mxCreateNumericArray mxCreateNumericArray_700 1407 | #endif 1408 | 1409 | #ifndef mxCreateCellArray 1410 | #define mxCreateCellArray mxCreateCellArray_700 1411 | #endif 1412 | 1413 | #ifndef mxCreateLogicalArray 1414 | #define mxCreateLogicalArray mxCreateLogicalArray_700 1415 | #endif 1416 | 1417 | #ifndef mxSetCell 1418 | #define mxSetCell mxSetCell_700 1419 | #endif 1420 | 1421 | #ifndef mxSetN 1422 | #define mxSetN mxSetN_700 1423 | #endif 1424 | 1425 | #ifndef mxSetM 1426 | #define mxSetM mxSetM_700 1427 | #endif 1428 | 1429 | #ifndef mxCreateDoubleMatrix 1430 | #define mxCreateDoubleMatrix mxCreateDoubleMatrix_700 1431 | #endif 1432 | 1433 | #ifndef mxCreateNumericMatrix 1434 | #define mxCreateNumericMatrix mxCreateNumericMatrix_700 1435 | #endif 1436 | 1437 | #ifndef mxCreateLogicalMatrix 1438 | #define mxCreateLogicalMatrix mxCreateLogicalMatrix_700 1439 | #endif 1440 | 1441 | #ifndef mxCreateSparse 1442 | #define mxCreateSparse mxCreateSparse_700 1443 | #endif 1444 | 1445 | #ifndef mxCreateSparseLogicalMatrix 1446 | #define mxCreateSparseLogicalMatrix mxCreateSparseLogicalMatrix_700 1447 | #endif 1448 | 1449 | #ifndef mxGetNChars 1450 | #define mxGetNChars mxGetNChars_700 1451 | #endif 1452 | 1453 | #ifndef mxCreateStringFromNChars 1454 | #define mxCreateStringFromNChars mxCreateStringFromNChars_700 1455 | #endif 1456 | 1457 | #ifndef mxCalcSingleSubscript 1458 | #define mxCalcSingleSubscript mxCalcSingleSubscript_700 1459 | #endif 1460 | 1461 | #ifdef __cplusplus 1462 | } 1463 | #endif 1464 | 1465 | #endif /* #ifdef MX_COMPAT_32 */ 1466 | #endif /* !defined(BUILDING_LIBMX) && !defined(PUBLISHED_API_CPP) */ 1467 | #endif /* matrix_h */ 1468 | #endif /* MATRIX_DEVELOPER_API_HPP */ 1469 | -------------------------------------------------------------------------------- /TextureTransfer/for_testing/mccExcludedFiles.log: -------------------------------------------------------------------------------- 1 | The List of Excluded Files 2 | Excluded files Exclusion Message ID Reason For Exclusion Exclusion Rule 3 | /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/local/+matlab/+internal/+toolboxes/addInstalledToolboxesToPath.m MATLAB:Completion:ExcludedBy Cannot be packaged for use in the target environment MCR. Removed from the parts list by license Compiler. /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/local/[+]matlab/[+]internal/[+]toolboxes/addInstalledToolboxesToPath[.]m 4 | /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/local/+matlab/+internal/+zipAddOns/addInstalledZipAddOnsToPath.m MATLAB:Completion:ExcludedBy Cannot be packaged for use in the target environment MCR. Removed from the parts list by license Compiler. /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/local/[+]matlab/[+]internal/[+]zipAddOns/addInstalledZipAddOnsToPath[.]m 5 | /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/local/pathdef.m MATLAB:Completion:ExcludedBy Cannot be packaged for use in the target environment MCR. Removed from the parts list by license Compiler. /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/local/pathdef[.]m 6 | /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/matlab/codetools/initdesktoputils.m MATLAB:Completion:ExcludedBy Cannot be packaged for use in the target environment MCR. Removed from the parts list by license Compiler. /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/matlab/codetools 7 | -------------------------------------------------------------------------------- /TextureTransfer/for_testing/mclbase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PUBLISHed header for libmclbase, the mclbase library. 3 | * 4 | * Copyright 1984-2013 The MathWorks, Inc. 5 | */ 6 | 7 | #if defined(_MSC_VER) 8 | # pragma once 9 | #endif 10 | #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) 11 | # pragma once 12 | #endif 13 | 14 | #ifndef mclbase_published_api_h 15 | #define mclbase_published_api_h 16 | 17 | /* SWIG can't see these definitions, which are stored in package.h, so we 18 | duplicate them here. */ 19 | #ifdef _MSC_VER 20 | #define DLL_EXPORT_SYM __declspec(dllexport) 21 | #define DLL_IMPORT_SYM __declspec(dllimport) 22 | #elif __GNUC__ >= 4 23 | #define DLL_EXPORT_SYM __attribute__ ((visibility("default"))) 24 | #define DLL_IMPORT_SYM __attribute__ ((visibility("default"))) 25 | #else 26 | #define DLL_EXPORT_SYM 27 | #define DLL_IMPORT_SYM 28 | #endif 29 | 30 | 31 | #ifndef EXTERN_C 32 | # ifdef __cplusplus 33 | # define EXTERN_C extern "C" 34 | # else 35 | # define EXTERN_C extern 36 | # endif 37 | #endif 38 | 39 | #ifndef LIBMWMCLBASE_API 40 | # define LIBMWMCLBASE_API DLL_IMPORT_SYM 41 | #endif 42 | 43 | #ifndef LIBMWMCLBASE_API_EXTERN_C 44 | # define LIBMWMCLBASE_API_EXTERN_C EXTERN_C LIBMWMCLBASE_API 45 | #endif 46 | 47 | LIBMWMCLBASE_API_EXTERN_C void mclSetLastErrIdAndMsg(const char* newid, const char* newmsg); 48 | 49 | 50 | LIBMWMCLBASE_API_EXTERN_C const char* mclGetLastErrorMessage(); 51 | 52 | 53 | /* Get stack trace string when error happens 54 | */ 55 | LIBMWMCLBASE_API_EXTERN_C int mclGetStackTrace(char*** stack); 56 | 57 | 58 | /* Free the stack trace string allocated earlier 59 | */ 60 | LIBMWMCLBASE_API_EXTERN_C int mclFreeStackTrace(char*** stack, int nStackDepth); 61 | 62 | 63 | #include 64 | #include 65 | #include 66 | #include "tmwtypes.h" 67 | 68 | /* Use cases for mcl runtime libraries. 69 | * Used to configure MVM use. 70 | */ 71 | #define mclUndefined 0 72 | #define mclNoMvm 1 73 | #define mclStandaloneApp 2 74 | #define mclStandaloneContainer 3 75 | #define mclJavaBuilder 4 76 | #define mclMcc 5 77 | 78 | 79 | 80 | LIBMWMCLBASE_API_EXTERN_C void mclAcquireMutex(void); 81 | 82 | 83 | LIBMWMCLBASE_API_EXTERN_C void mclReleaseMutex(void); 84 | 85 | 86 | LIBMWMCLBASE_API_EXTERN_C bool mclIsMCRInitialized(); 87 | 88 | 89 | LIBMWMCLBASE_API_EXTERN_C bool mclIsJVMEnabled(); 90 | 91 | 92 | LIBMWMCLBASE_API_EXTERN_C const char* mclGetLogFileName(); 93 | 94 | 95 | LIBMWMCLBASE_API_EXTERN_C bool mclIsNoDisplaySet(); 96 | 97 | 98 | LIBMWMCLBASE_API_EXTERN_C bool mclInitializeApplication(const char** options, size_t count); 99 | 100 | 101 | LIBMWMCLBASE_API_EXTERN_C bool mclTerminateApplication(void); 102 | 103 | 104 | LIBMWMCLBASE_API_EXTERN_C bool mclIsMcc(); 105 | 106 | 107 | typedef int (*mclOutputHandlerFcn)(const char *s); 108 | 109 | 110 | #include 111 | 112 | 113 | /* Extract the path from a file name specified by either absolute or 114 | * relative path. For example: 115 | * 116 | * /home/foo/bar.exe -> /home/foo 117 | * ./bar.exe -> /bar.exe 118 | * bar.exe -> 119 | * 120 | * Returns a pointer to the memory passed in by the caller. 121 | */ 122 | LIBMWMCLBASE_API_EXTERN_C void separatePathName(const char *fullname, char *buf, size_t bufLen); 123 | 124 | 125 | typedef void* HMCRINSTANCE; 126 | 127 | 128 | LIBMWMCLBASE_API_EXTERN_C bool mclFreeStrArray(char **array, size_t elements); 129 | 130 | 131 | #include "matrix.h" 132 | 133 | 134 | LIBMWMCLBASE_API_EXTERN_C void mclFreeArrayList(int nargs, mxArray** ppxArgs); 135 | 136 | 137 | LIBMWMCLBASE_API_EXTERN_C mxArray *mclCreateCellArrayFromArrayList(int narray, mxArray *parray[]); 138 | 139 | 140 | LIBMWMCLBASE_API_EXTERN_C mxArray* mclCreateSharedCopy(mxArray* px); 141 | 142 | 143 | LIBMWMCLBASE_API_EXTERN_C mxArray* mclCreateEmptyArray(void); 144 | 145 | 146 | LIBMWMCLBASE_API_EXTERN_C mxArray* mclCreateSimpleFunctionHandle(mxFunctionPtr fcn); 147 | 148 | 149 | LIBMWMCLBASE_API_EXTERN_C mxArray* mclMxSerialize(const mxArray * pa); 150 | 151 | 152 | LIBMWMCLBASE_API_EXTERN_C mxArray* mclMxDeserialize(const void* ps, size_t len); 153 | 154 | 155 | LIBMWMCLBASE_API_EXTERN_C void mclMxDestroyArray(mxArray* pa, bool onInterpreterThread); 156 | 157 | 158 | LIBMWMCLBASE_API_EXTERN_C bool mclMxIsA(mxArray* pa, const char *cname); 159 | 160 | 161 | LIBMWMCLBASE_API_EXTERN_C int mclMxEnterNewArrayListContext(void); 162 | 163 | 164 | #ifdef __cplusplus 165 | extern "C" { 166 | #endif 167 | typedef void (*mclMxArrayApplyFcn)(mxArray *); 168 | #ifdef __cplusplus 169 | } 170 | #endif 171 | 172 | 173 | LIBMWMCLBASE_API_EXTERN_C void mclMxApplyToAllArraysOnArrayList(mclMxArrayApplyFcn pfcn); 174 | 175 | 176 | LIBMWMCLBASE_API_EXTERN_C void mclMxExitArrayListContext(int prev_context_offset, mxArray **foldList, int listLength, bool bIgnored); 177 | 178 | 179 | LIBMWMCLBASE_API_EXTERN_C void mclMakeMxArrayLocalScope(mxArray *p); 180 | 181 | 182 | /* Main functions passed to mclRunMain must be of this type. This typedef 183 | * must be placed OUTSIDE of an extern "C" block to ensure that it has the 184 | * right linkage in the automatically generated MCLMCRRT proxy API. See 185 | * mclmcrrt/GenLibProxyAPI.pl for more details. 186 | */ 187 | typedef int (*mclMainFcnType)(int, const char **); 188 | 189 | 190 | LIBMWMCLBASE_API_EXTERN_C int mclRunMain(mclMainFcnType run_main, 191 | int argc, 192 | const char **argv); 193 | 194 | #endif /* mclbase_h */ 195 | -------------------------------------------------------------------------------- /TextureTransfer/for_testing/mclmcr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PUBLISHed header for libmclmcr, the mclmcr library. 3 | * 4 | * Copyright 1984-2013 The MathWorks, Inc. 5 | * All Rights Reserved. 6 | */ 7 | 8 | #if defined(_MSC_VER) 9 | # pragma once 10 | #endif 11 | #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) 12 | # pragma once 13 | #endif 14 | 15 | #ifndef mclmcr_published_api_hpp 16 | #define mclmcr_published_api_hpp 17 | 18 | 19 | #ifndef LIBMWMCLMCR_API_EXTERN_C 20 | # ifdef __cplusplus 21 | # define LIBMWMCLMCR_API_EXTERN_C extern "C" 22 | # else 23 | # define LIBMWMCLMCR_API_EXTERN_C extern 24 | # endif 25 | #endif 26 | 27 | #ifndef LIBMWMCLMCR_API 28 | # define LIBMWMCLMCR_API 29 | #endif 30 | 31 | #ifndef LIBMWMCLMCR_API_LIBMWMCLMCR_API_EXTERN_C 32 | # define LIBMWMCLMCR_API_LIBMWMCLMCR_API_EXTERN_C LIBMWMCLMCR_API_EXTERN_C LIBMWMCLMCR_API 33 | #endif 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | typedef int (*mclReadCtfStreamFcn)(char* s, int n); 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | 44 | 45 | 46 | /* All the types of components we can generate code for. These values 47 | * determine how the component initializes itself. 48 | */ 49 | typedef enum 50 | { 51 | NoObjectType, 52 | COMObject, 53 | JavaObject, 54 | DotNetObject 55 | } mccComponentType; 56 | 57 | typedef enum { 58 | ExeTarget, 59 | LibTarget, 60 | MexTarget, 61 | SfunTarget, 62 | AnyTarget 63 | } mccTargetType; 64 | 65 | 66 | typedef struct mclCtfStream_tag { 67 | /*This field is only here to prevent an 68 | empty struct warning for some compilers. */ 69 | char unused; 70 | } mclCtfStream_tag; 71 | 72 | typedef mclCtfStream_tag* mclCtfStream; 73 | #include 74 | 75 | 76 | LIBMWMCLMCR_API_EXTERN_C mclCtfStream mclGetStreamFromArraySrc(char *buffer, int bufferSize); 77 | 78 | 79 | LIBMWMCLMCR_API_EXTERN_C void mclDestroyStream(mclCtfStream pStream); 80 | 81 | 82 | LIBMWMCLMCR_API_EXTERN_C mclCtfStream mclGetEmbeddedCtfStream(void* handle); 83 | 84 | 85 | #include "mclbase.h" /*for mclOutputHandler MCRInstanceProxy*/ 86 | 87 | 88 | LIBMWMCLMCR_API_EXTERN_C bool mclInitializeComponentInstanceNonEmbeddedStandalone( HMCRINSTANCE* inst, 89 | const char* path_to_component, 90 | const char* component_name, 91 | mccTargetType ttype, 92 | mclOutputHandlerFcn error_handler, 93 | mclOutputHandlerFcn print_handler); 94 | 95 | 96 | LIBMWMCLMCR_API_EXTERN_C bool mclInitializeInstanceWithoutComponent( HMCRINSTANCE* inst, 97 | const char** options, 98 | size_t count, 99 | mclOutputHandlerFcn error_handler, 100 | mclOutputHandlerFcn print_handler); 101 | 102 | 103 | LIBMWMCLMCR_API_EXTERN_C bool mclInitializeComponentInstanceCtfFileToCache( HMCRINSTANCE* inst, 104 | mclOutputHandlerFcn error_handler, 105 | mclOutputHandlerFcn print_handler, 106 | const char* ctfFileLocation); 107 | 108 | 109 | LIBMWMCLMCR_API_EXTERN_C bool mclInitializeComponentInstanceEmbedded(HMCRINSTANCE* inst, 110 | mclOutputHandlerFcn error_handler, 111 | mclOutputHandlerFcn print_handler, 112 | mclCtfStream ctfStream); 113 | 114 | 115 | LIBMWMCLMCR_API_EXTERN_C bool mclInitializeComponentInstanceWithCallbk(HMCRINSTANCE* inst, 116 | mclOutputHandlerFcn error_handler, 117 | mclOutputHandlerFcn print_handler, 118 | mclReadCtfStreamFcn readCtfStream_handler, 119 | size_t ctfStreamSize); 120 | 121 | 122 | LIBMWMCLMCR_API_EXTERN_C bool mclInitializeComponentInstanceFromExtractedComponent( HMCRINSTANCE* inst, 123 | mclOutputHandlerFcn error_handler, 124 | mclOutputHandlerFcn print_handler, 125 | const char* component_id); 126 | 127 | 128 | LIBMWMCLMCR_API_EXTERN_C bool mclInitializeComponentInstanceFromExtractedLocation( HMCRINSTANCE* inst, 129 | mclOutputHandlerFcn error_handler, 130 | mclOutputHandlerFcn print_handler, 131 | const char* extractedLoc); 132 | 133 | 134 | LIBMWMCLMCR_API_EXTERN_C int mclGetDotNetComponentType(void); 135 | 136 | 137 | LIBMWMCLMCR_API_EXTERN_C int mclGetMCCTargetType(bool isLibrary); 138 | 139 | 140 | LIBMWMCLMCR_API_EXTERN_C const char * getStandaloneFileName(const char* path_to_ctf, const char* component_name); 141 | 142 | 143 | LIBMWMCLMCR_API_EXTERN_C bool mclStandaloneGenericMain( size_t argc, 144 | const char ** argv, 145 | const char* ctfFileName, 146 | bool ExtractToComponentCache, 147 | void* ctfSettings); 148 | 149 | 150 | LIBMWMCLMCR_API_EXTERN_C bool mclStandaloneCtfxMain( size_t argc, 151 | const char** argv); 152 | 153 | 154 | LIBMWMCLMCR_API_EXTERN_C void mclWaitForFiguresToDie(HMCRINSTANCE inst); 155 | 156 | 157 | 158 | #include 159 | 160 | typedef real64_T mxDouble; 161 | typedef real32_T mxSingle; 162 | typedef int8_T mxInt8; 163 | typedef uint8_T mxUint8; 164 | typedef int16_T mxInt16; 165 | typedef uint16_T mxUint16; 166 | typedef int32_T mxInt32; 167 | typedef uint32_T mxUint32; 168 | #if !defined(__MW_STDINT_H__) 169 | # if defined( linux ) || defined( __linux ) || defined( __linux__ ) 170 | # include 171 | typedef int64_t mxInt64; 172 | typedef uint64_t mxUint64; 173 | # elif defined( macintosh ) || defined( __APPLE__ ) || defined( __APPLE_CC__ ) 174 | # if defined( __GNUC__ ) 175 | # include 176 | typedef int64_t mxInt64; 177 | typedef uint64_t mxUint64; 178 | # endif 179 | # elif defined( sun ) || defined( __sun ) 180 | # include 181 | typedef int64_t mxInt64; 182 | typedef uint64_t mxUint64; 183 | # elif defined( __hpux ) 184 | # include 185 | typedef int64_t mxInt64; 186 | typedef uint64_t mxUint64; 187 | # elif defined(_MSC_VER) 188 | typedef __int64 mxInt64; 189 | typedef unsigned __int64 mxUint64; 190 | # elif defined(__BORLANDC__) 191 | typedef __int64 mxInt64; 192 | typedef unsigned __int64 mxUint64; 193 | # elif defined(__WATCOMC__) 194 | typedef __int64 mxInt64; 195 | typedef unsigned __int64 mxUint64; 196 | # elif defined(__LCC__) 197 | typedef __int64 mxInt64; 198 | typedef unsigned __int64 mxUint64; 199 | # endif 200 | #else 201 | typedef int64_T mxInt64; 202 | typedef uint64_T mxUint64; 203 | #endif 204 | 205 | 206 | 207 | #include "matrix.h" 208 | 209 | 210 | #ifdef __cplusplus 211 | 212 | /* Forward declarations */ 213 | class ref_count_obj; 214 | class char_buffer; 215 | class array_ref; 216 | class array_buffer; 217 | class error_info; 218 | 219 | /* Class declarations */ 220 | 221 | class ref_count_obj 222 | { 223 | public: 224 | /* Virtual destructor required to avoid compiler warnings. */ 225 | virtual ~ref_count_obj() {} 226 | virtual int addref() = 0; 227 | virtual int release() = 0; 228 | }; 229 | 230 | class char_buffer: public ref_count_obj 231 | { 232 | public: 233 | /* Virtual destructor required to avoid compiler warnings. */ 234 | virtual ~char_buffer() {} 235 | virtual size_t size() = 0; 236 | virtual const char* get_buffer() = 0; 237 | virtual int set_buffer(const char* str) = 0; 238 | virtual int compare_to(char_buffer* p) = 0; 239 | }; 240 | 241 | class array_ref: public ref_count_obj 242 | { 243 | public: 244 | /* Virtual destructor required to avoid compiler warnings. */ 245 | virtual ~array_ref() {} 246 | virtual mxClassID classID() = 0; 247 | virtual array_ref* deep_copy() = 0; 248 | virtual void detach() = 0; 249 | virtual array_ref* shared_copy() = 0; 250 | virtual array_ref* serialize() = 0; 251 | virtual size_t element_size() = 0; 252 | virtual mwSize number_of_elements() = 0; 253 | virtual mwSize number_of_nonzeros() = 0; 254 | virtual mwSize maximum_nonzeros() = 0; 255 | virtual mwSize number_of_dimensions() = 0; 256 | virtual array_ref* get_dimensions() = 0; 257 | virtual int number_of_fields() = 0; 258 | virtual char_buffer* get_field_name(int i) = 0; 259 | virtual bool is_empty() = 0; 260 | virtual bool is_sparse() = 0; 261 | virtual bool is_numeric() = 0; 262 | virtual bool is_complex() = 0; 263 | virtual int make_complex() = 0; 264 | virtual bool equals(array_ref* p) = 0; 265 | virtual int compare_to(array_ref* p) = 0; 266 | virtual int hash_code() = 0; 267 | virtual char_buffer* to_string() = 0; 268 | virtual array_ref* row_index() = 0; 269 | virtual array_ref* column_index() = 0; 270 | virtual array_ref* get(mwSize num_indices, const mwIndex* index) = 0; 271 | virtual array_ref* get(const char* name, mwSize num_indices, const mwIndex* index) = 0; 272 | virtual array_ref* getV(mwSize num_indices, va_list vargs) = 0; 273 | virtual array_ref* getV(const char* name, mwSize num_indices, va_list vargs) = 0; 274 | virtual int set(array_ref* p) = 0; 275 | virtual array_ref* real() = 0; 276 | virtual array_ref* imag() = 0; 277 | virtual int get_numeric(mxDouble* x, mwSize len) = 0; 278 | virtual int get_numeric(mxSingle* x, mwSize len) = 0; 279 | virtual int get_numeric(mxInt8* x, mwSize len) = 0; 280 | virtual int get_numeric(mxUint8* x, mwSize len) = 0; 281 | virtual int get_numeric(mxInt16* x, mwSize len) = 0; 282 | virtual int get_numeric(mxUint16* x, mwSize len) = 0; 283 | virtual int get_numeric(mxInt32* x, mwSize len) = 0; 284 | virtual int get_numeric(mxUint32* x, mwSize len) = 0; 285 | virtual int get_numeric(mxInt64* x, mwSize len) = 0; 286 | virtual int get_numeric(mxUint64* x, mwSize len) = 0; 287 | virtual int get_char(mxChar* x, mwSize len) = 0; 288 | virtual int get_logical(mxLogical* x, mwSize len) = 0; 289 | virtual int set_numeric(const mxDouble* x, mwSize len) = 0; 290 | virtual int set_numeric(const mxSingle* x, mwSize len) = 0; 291 | virtual int set_numeric(const mxInt8* x, mwSize len) = 0; 292 | virtual int set_numeric(const mxUint8* x, mwSize len) = 0; 293 | virtual int set_numeric(const mxInt16* x, mwSize len) = 0; 294 | virtual int set_numeric(const mxUint16* x, mwSize len) = 0; 295 | virtual int set_numeric(const mxInt32* x, mwSize len) = 0; 296 | virtual int set_numeric(const mxUint32* x, mwSize len) = 0; 297 | virtual int set_numeric(const mxInt64* x, mwSize len) = 0; 298 | virtual int set_numeric(const mxUint64* x, mwSize len) = 0; 299 | virtual int set_char(const mxChar* x, mwSize len) = 0; 300 | virtual int set_logical(const mxLogical* x, mwSize len) = 0; 301 | }; 302 | 303 | class array_buffer: public ref_count_obj 304 | { 305 | public: 306 | /* Virtual destructor required to avoid compiler warnings. */ 307 | virtual ~array_buffer() {} 308 | virtual mwSize size() = 0; 309 | virtual array_ref* get(mwIndex offset) = 0; 310 | virtual int set(mwIndex offset, array_ref* p) = 0; 311 | virtual int add(array_ref* pa) = 0; 312 | virtual int remove(mwIndex offset) = 0; 313 | virtual int clear() = 0; 314 | virtual array_ref* to_cell(mwIndex offset, mwSize len) = 0; 315 | }; 316 | 317 | class error_info: public ref_count_obj 318 | { 319 | public: 320 | /* Virtual destructor required to avoid compiler warnings. */ 321 | virtual ~error_info() {} 322 | virtual const char* get_message() = 0; 323 | virtual size_t get_stack_trace(char*** stack) = 0; 324 | }; 325 | 326 | #endif /* #ifdef __cplusplus */ 327 | 328 | 329 | #include "matrix.h" 330 | 331 | 332 | #ifdef __cplusplus 333 | /* This is an extern "C" API exclusively for use by C++ programs. It 334 | * exists solely to work around binary incompatibilities between different 335 | * C++ compilers. For example, a Borland C++ program cannot invoke a method 336 | * on an array_ref object created by a library compiled with Microsoft Visual 337 | * C++. The mwArray API, therefore, invokes array_ref methods indirectly, by 338 | * passing the array_ref object to one of these extern "C" routines, which 339 | * are implemented in the MCLMCR module. Since this module is part of the 340 | * MCR, it can invoke array_ref methods with impunity. 341 | * 342 | * This API needs to be protected by #ifdef __cplusplus because some of the 343 | * input arguments to the functions it contains are pointers to objects. 344 | * Translating all of these to void *'s is overly complex and unnecessary, 345 | * as this API is always going to be called from a C++ program. 346 | */ 347 | 348 | 349 | 350 | 351 | LIBMWMCLMCR_API_EXTERN_C int ref_count_obj_addref(ref_count_obj *obj); 352 | 353 | 354 | LIBMWMCLMCR_API_EXTERN_C int ref_count_obj_release(ref_count_obj *obj); 355 | 356 | 357 | LIBMWMCLMCR_API_EXTERN_C size_t char_buffer_size(char_buffer *obj); 358 | 359 | 360 | LIBMWMCLMCR_API_EXTERN_C const char* char_buffer_get_buffer(char_buffer *obj); 361 | 362 | 363 | LIBMWMCLMCR_API_EXTERN_C int char_buffer_set_buffer(char_buffer *obj, const char* str); 364 | 365 | 366 | LIBMWMCLMCR_API_EXTERN_C int char_buffer_compare_to(char_buffer *obj, char_buffer* p); 367 | 368 | 369 | LIBMWMCLMCR_API_EXTERN_C mxClassID array_ref_classID(array_ref *obj); 370 | 371 | 372 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_deep_copy(array_ref *obj); 373 | 374 | 375 | LIBMWMCLMCR_API_EXTERN_C void array_ref_detach(array_ref *obj); 376 | 377 | 378 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_shared_copy(array_ref *obj); 379 | 380 | 381 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_serialize(array_ref *obj); 382 | 383 | 384 | LIBMWMCLMCR_API_EXTERN_C size_t array_ref_element_size(array_ref *obj); 385 | 386 | 387 | LIBMWMCLMCR_API_EXTERN_C mwSize array_ref_number_of_elements(array_ref *obj); 388 | 389 | 390 | LIBMWMCLMCR_API_EXTERN_C mwSize array_ref_number_of_nonzeros(array_ref *obj); 391 | 392 | 393 | LIBMWMCLMCR_API_EXTERN_C mwSize array_ref_maximum_nonzeros(array_ref *obj); 394 | 395 | 396 | LIBMWMCLMCR_API_EXTERN_C mwSize array_ref_number_of_dimensions(array_ref *obj); 397 | 398 | 399 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_get_dimensions(array_ref *obj); 400 | 401 | 402 | LIBMWMCLMCR_API_EXTERN_C int array_ref_number_of_fields(array_ref *obj); 403 | 404 | 405 | LIBMWMCLMCR_API_EXTERN_C char_buffer* array_ref_get_field_name(array_ref *obj, int i); 406 | 407 | 408 | LIBMWMCLMCR_API_EXTERN_C bool array_ref_is_empty(array_ref *obj); 409 | 410 | 411 | LIBMWMCLMCR_API_EXTERN_C bool array_ref_is_sparse(array_ref *obj); 412 | 413 | 414 | LIBMWMCLMCR_API_EXTERN_C bool array_ref_is_numeric(array_ref *obj); 415 | 416 | 417 | LIBMWMCLMCR_API_EXTERN_C bool array_ref_is_complex(array_ref *obj); 418 | 419 | 420 | LIBMWMCLMCR_API_EXTERN_C int array_ref_make_complex(array_ref *obj); 421 | 422 | 423 | LIBMWMCLMCR_API_EXTERN_C bool array_ref_equals(array_ref *obj, array_ref* p); 424 | 425 | 426 | LIBMWMCLMCR_API_EXTERN_C int array_ref_compare_to(array_ref *obj, array_ref* p); 427 | 428 | 429 | LIBMWMCLMCR_API_EXTERN_C int array_ref_hash_code(array_ref *obj); 430 | 431 | 432 | LIBMWMCLMCR_API_EXTERN_C char_buffer* array_ref_to_string(array_ref *obj); 433 | 434 | 435 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_row_index(array_ref *obj); 436 | 437 | 438 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_column_index(array_ref *obj); 439 | 440 | 441 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_get_int(array_ref *obj, mwSize num_indices, const mwIndex* index); 442 | 443 | 444 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_get_const_char(array_ref *obj, const char* name, mwSize num_indices, const mwIndex* index); 445 | 446 | 447 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_getV_int(array_ref *obj, mwSize num_indices, va_list vargs); 448 | 449 | 450 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_getV_const_char(array_ref *obj, const char* name, mwSize num_indices, va_list vargs); 451 | 452 | 453 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set(array_ref *obj, array_ref* p); 454 | 455 | 456 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_real(array_ref *obj); 457 | 458 | 459 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_ref_imag(array_ref *obj); 460 | 461 | 462 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_numeric_mxDouble(array_ref *obj, mxDouble* x, mwSize len); 463 | 464 | 465 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_numeric_mxSingle(array_ref *obj, mxSingle* x, mwSize len); 466 | 467 | 468 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_numeric_mxInt8(array_ref *obj, mxInt8* x, mwSize len); 469 | 470 | 471 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_numeric_mxUint8(array_ref *obj, mxUint8* x, mwSize len); 472 | 473 | 474 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_numeric_mxInt16(array_ref *obj, mxInt16* x, mwSize len); 475 | 476 | 477 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_numeric_mxUint16(array_ref *obj, mxUint16* x, mwSize len); 478 | 479 | 480 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_numeric_mxInt32(array_ref *obj, mxInt32* x, mwSize len); 481 | 482 | 483 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_numeric_mxUint32(array_ref *obj, mxUint32* x, mwSize len); 484 | 485 | 486 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_numeric_mxInt64(array_ref *obj, mxInt64* x, mwSize len); 487 | 488 | 489 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_numeric_mxUint64(array_ref *obj, mxUint64* x, mwSize len); 490 | 491 | 492 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_char(array_ref *obj, mxChar* x, mwSize len); 493 | 494 | 495 | LIBMWMCLMCR_API_EXTERN_C int array_ref_get_logical(array_ref *obj, mxLogical* x, mwSize len); 496 | 497 | 498 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_numeric_mxDouble(array_ref *obj, const mxDouble* x, mwSize len); 499 | 500 | 501 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_numeric_mxSingle(array_ref *obj, const mxSingle* x, mwSize len); 502 | 503 | 504 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_numeric_mxInt8(array_ref *obj, const mxInt8* x, mwSize len); 505 | 506 | 507 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_numeric_mxUint8(array_ref *obj, const mxUint8* x, mwSize len); 508 | 509 | 510 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_numeric_mxInt16(array_ref *obj, const mxInt16* x, mwSize len); 511 | 512 | 513 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_numeric_mxUint16(array_ref *obj, const mxUint16* x, mwSize len); 514 | 515 | 516 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_numeric_mxInt32(array_ref *obj, const mxInt32* x, mwSize len); 517 | 518 | 519 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_numeric_mxUint32(array_ref *obj, const mxUint32* x, mwSize len); 520 | 521 | 522 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_numeric_mxInt64(array_ref *obj, const mxInt64* x, mwSize len); 523 | 524 | 525 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_numeric_mxUint64(array_ref *obj, const mxUint64* x, mwSize len); 526 | 527 | 528 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_char(array_ref *obj, const mxChar* x, mwSize len); 529 | 530 | 531 | LIBMWMCLMCR_API_EXTERN_C int array_ref_set_logical(array_ref *obj, const mxLogical* x, mwSize len); 532 | 533 | 534 | LIBMWMCLMCR_API_EXTERN_C mwSize array_buffer_size(array_buffer *obj); 535 | 536 | 537 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_buffer_get(array_buffer *obj, mwIndex offset); 538 | 539 | 540 | LIBMWMCLMCR_API_EXTERN_C int array_buffer_set(array_buffer *obj, mwIndex offset, array_ref* p); 541 | 542 | 543 | LIBMWMCLMCR_API_EXTERN_C int array_buffer_add(array_buffer *obj, array_ref* pa); 544 | 545 | 546 | LIBMWMCLMCR_API_EXTERN_C int array_buffer_remove(array_buffer *obj, mwIndex offset); 547 | 548 | 549 | LIBMWMCLMCR_API_EXTERN_C int array_buffer_clear(array_buffer *obj); 550 | 551 | 552 | LIBMWMCLMCR_API_EXTERN_C array_ref* array_buffer_to_cell(array_buffer *obj, mwIndex offset, mwSize len); 553 | 554 | 555 | LIBMWMCLMCR_API_EXTERN_C const char* error_info_get_message(error_info *obj); 556 | 557 | 558 | LIBMWMCLMCR_API_EXTERN_C size_t error_info_get_stack_trace(error_info *obj, char*** stack); 559 | 560 | 561 | #endif /* #ifdef __cplusplus */ 562 | 563 | 564 | #define MCLCPP_OK 0 565 | #define MCLCPP_ERR -1 566 | 567 | 568 | LIBMWMCLMCR_API_EXTERN_C int mclcppGetLastError(void** ppv); 569 | 570 | 571 | LIBMWMCLMCR_API_EXTERN_C int mclcppCreateError(void** ppv, const char* msg); 572 | 573 | 574 | LIBMWMCLMCR_API_EXTERN_C void mclcppSetLastError(const char* msg); 575 | 576 | 577 | LIBMWMCLMCR_API_EXTERN_C int mclcppErrorCheck(void); 578 | 579 | 580 | 581 | #ifdef __cplusplus 582 | 583 | #include 584 | #include 585 | 586 | class mwException : public std::exception 587 | { 588 | public: 589 | mwException() : std::exception() 590 | { 591 | m_err = 0; 592 | mclcppCreateError((void**)&m_err, "Unspecified error"); 593 | } 594 | mwException(const char* msg) : std::exception() 595 | { 596 | m_err = 0; 597 | mclcppCreateError((void**)&m_err, (msg ? msg : "Unspecified error")); 598 | } 599 | mwException(const mwException& e) : std::exception() 600 | { 601 | m_err = e.m_err; 602 | if (m_err) 603 | ref_count_obj_addref(m_err); 604 | } 605 | mwException(error_info* pe) 606 | { 607 | m_err = 0; 608 | if (pe) 609 | { 610 | m_err = pe; 611 | ref_count_obj_addref(m_err); 612 | } 613 | else 614 | { 615 | mclcppCreateError((void**)&m_err, "Unspecified error"); 616 | } 617 | } 618 | mwException(error_info* pe, bool bAddRef) 619 | { 620 | m_err = 0; 621 | if (pe) 622 | { 623 | m_err = pe; 624 | if (bAddRef) 625 | ref_count_obj_addref(m_err); 626 | } 627 | else 628 | { 629 | mclcppCreateError((void**)&m_err, "Unspecified error"); 630 | } 631 | } 632 | mwException(const std::exception& e) : std::exception() 633 | { 634 | m_err = 0; 635 | mclcppCreateError((void**)&m_err, e.what()); 636 | } 637 | virtual ~mwException() throw() 638 | { 639 | if (m_err) 640 | ref_count_obj_release(m_err); 641 | } 642 | mwException& operator=(const std::exception& e) 643 | { 644 | if (m_err) 645 | ref_count_obj_release(m_err); 646 | mclcppCreateError((void**)&m_err, e.what()); 647 | return *this; 648 | } 649 | mwException& operator=(const mwException& e) 650 | { 651 | if (m_err) 652 | ref_count_obj_release(m_err); 653 | m_err = e.m_err; 654 | if (m_err) 655 | ref_count_obj_addref(m_err); 656 | return *this; 657 | } 658 | const char *what() const throw() 659 | { 660 | return (m_err ? error_info_get_message(m_err) : NULL); 661 | } 662 | static void raise_error() 663 | { 664 | error_info* pe = 0; 665 | if (mclcppGetLastError((void**)&pe) == MCLCPP_ERR) 666 | { 667 | throw mwException(); 668 | } 669 | throw mwException(pe, false); 670 | } 671 | void print_stack_trace() 672 | { 673 | char** stack; 674 | size_t stackDepth; 675 | 676 | stackDepth = get_stack_trace(&stack); 677 | if(stackDepth > 0) 678 | { 679 | std::cerr << "... Matlab M-code Stack Trace ..." << std::endl; 680 | for(size_t i=0; i 711 | class mw_auto_ptr_t 712 | { 713 | public: 714 | mw_auto_ptr_t() 715 | { 716 | m_p = 0; 717 | } 718 | explicit mw_auto_ptr_t(T* p) 719 | { 720 | m_p = p; 721 | addref(); 722 | } 723 | mw_auto_ptr_t(T*p, bool bAddRef) 724 | { 725 | m_p = p; 726 | if (bAddRef) 727 | addref(); 728 | } 729 | virtual ~mw_auto_ptr_t() 730 | { 731 | if (m_p) 732 | ref_count_obj_release(m_p); 733 | } 734 | void addref() 735 | { 736 | if (m_p) 737 | ref_count_obj_addref(m_p); 738 | } 739 | void release() 740 | { 741 | if (m_p) 742 | { 743 | ref_count_obj_release(m_p); 744 | m_p = 0; 745 | } 746 | } 747 | void attach(T* p, bool bAddRef) 748 | { 749 | release(); 750 | m_p = p; 751 | if (bAddRef) 752 | addref(); 753 | } 754 | T* detach() 755 | { 756 | T* p = m_p; 757 | m_p = 0; 758 | return p; 759 | } 760 | T* operator->(void) const 761 | { 762 | if (!m_p) 763 | throw mwException("Null pointer"); 764 | return m_p; 765 | } 766 | T** operator&(void) 767 | { 768 | release(); 769 | return &m_p; 770 | } 771 | operator T*() const 772 | { 773 | return m_p; 774 | } 775 | mw_auto_ptr_t& operator=(T* p) 776 | { 777 | release(); 778 | m_p = p; 779 | addref(); 780 | return *this; 781 | } 782 | mw_auto_ptr_t& operator=(const mw_auto_ptr_t& ptr) 783 | { 784 | release(); 785 | m_p = ptr.m_p; 786 | addref(); 787 | return *this; 788 | } 789 | bool operator!() const 790 | { 791 | return (m_p == 0); 792 | } 793 | operator bool() const 794 | { 795 | return (m_p != 0); 796 | } 797 | bool operator==(const mw_auto_ptr_t& ptr) 798 | { 799 | return (m_p == (T*)ptr); 800 | } 801 | bool operator!=(const mw_auto_ptr_t& ptr) 802 | { 803 | return (m_p != (T*)ptr); 804 | } 805 | protected: 806 | T* m_p; 807 | }; 808 | 809 | #endif /* ifdef __cplusplus */ 810 | 811 | 812 | 813 | LIBMWMCLMCR_API_EXTERN_C int mclCreateCharBuffer(void** ppv, const char* str); 814 | 815 | 816 | 817 | #ifdef __cplusplus 818 | 819 | //#include 820 | 821 | 822 | class mwString 823 | { 824 | public: 825 | mwString() 826 | { 827 | if (mclCreateCharBuffer((void**)&m_str, "") == MCLCPP_ERR) 828 | mwException::raise_error(); 829 | } 830 | mwString(const char* str) 831 | { 832 | if (mclCreateCharBuffer((void**)&m_str, str) == MCLCPP_ERR) 833 | mwException::raise_error(); 834 | } 835 | mwString(char_buffer* buff, bool bAddref) 836 | { 837 | m_str.attach(buff, bAddref); 838 | } 839 | mwString(const mwString& str) 840 | { 841 | if (mclCreateCharBuffer((void**)&m_str, str) == MCLCPP_ERR) 842 | mwException::raise_error(); 843 | if (char_buffer_set_buffer(m_str, (const char*)str) == MCLCPP_ERR) 844 | mwException::raise_error(); 845 | } 846 | virtual ~mwString(){} 847 | public: 848 | mwSize Length() const 849 | { 850 | return char_buffer_size(m_str); 851 | } 852 | operator const char* () const 853 | { 854 | return char_buffer_get_buffer(m_str); 855 | } 856 | mwString& operator=(const mwString& str) 857 | { 858 | if (&str == this) 859 | return *this; 860 | if (char_buffer_set_buffer(m_str, (const char*)str) == MCLCPP_ERR) 861 | mwException::raise_error(); 862 | return *this; 863 | } 864 | mwString& operator=(const char* str) 865 | { 866 | if (char_buffer_set_buffer(m_str, str) == MCLCPP_ERR) 867 | mwException::raise_error(); 868 | return *this; 869 | } 870 | bool operator==(const mwString& str) const 871 | { 872 | return (char_buffer_compare_to(m_str, str.m_str) == 0); 873 | } 874 | bool operator!=(const mwString& str) const 875 | { 876 | return (char_buffer_compare_to(m_str, str.m_str) != 0); 877 | } 878 | bool operator<(const mwString& str) const 879 | { 880 | return (char_buffer_compare_to(m_str, str.m_str) < 0); 881 | } 882 | bool operator<=(const mwString& str) const 883 | { 884 | return (char_buffer_compare_to(m_str, str.m_str) <= 0); 885 | } 886 | bool operator>(const mwString& str) const 887 | { 888 | return (char_buffer_compare_to(m_str, str.m_str) > 0); 889 | } 890 | bool operator>=(const mwString& str) const 891 | { 892 | return (char_buffer_compare_to(m_str, str.m_str) >= 0); 893 | } 894 | friend std::ostream& operator<<(std::ostream& os, const mwString& str) 895 | { 896 | os << (const char*)str; 897 | return os; 898 | } 899 | private: 900 | mw_auto_ptr_t m_str; 901 | }; 902 | 903 | #endif 904 | 905 | 906 | 907 | LIBMWMCLMCR_API_EXTERN_C double mclGetEps(void); 908 | 909 | 910 | LIBMWMCLMCR_API_EXTERN_C double mclGetInf(void); 911 | 912 | 913 | LIBMWMCLMCR_API_EXTERN_C double mclGetNaN(void); 914 | 915 | 916 | LIBMWMCLMCR_API_EXTERN_C bool mclIsFinite(double x); 917 | 918 | 919 | LIBMWMCLMCR_API_EXTERN_C bool mclIsInf(double x); 920 | 921 | 922 | LIBMWMCLMCR_API_EXTERN_C bool mclIsNaN(double x); 923 | 924 | 925 | LIBMWMCLMCR_API_EXTERN_C bool mclIsIdentical(mxArray* pArray1, mxArray* pArray2); 926 | 927 | 928 | LIBMWMCLMCR_API_EXTERN_C int mclGetEmptyArray(void** ppv, mxClassID classid); 929 | 930 | 931 | LIBMWMCLMCR_API_EXTERN_C int mclGetMatrix(void** ppv, mwSize num_rows, mwSize num_cols, mxClassID classid, mxComplexity cmplx); 932 | 933 | 934 | LIBMWMCLMCR_API_EXTERN_C int mclGetArray(void** ppv, mwSize num_dims, const mwSize* dims, mxClassID classid, mxComplexity cmplx); 935 | 936 | 937 | LIBMWMCLMCR_API_EXTERN_C int mclGetNumericMatrix(void** ppv, mwSize num_rows, mwSize num_cols, mxClassID mxID, mxComplexity cmplx); 938 | 939 | 940 | LIBMWMCLMCR_API_EXTERN_C int mclGetNumericArray(void** ppv, mwSize num_dims, const mwSize* dims, mxClassID mxID, mxComplexity cmplx); 941 | 942 | 943 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarDouble(void** ppv, mxDouble re, mxDouble im, mxComplexity cmplx); 944 | 945 | 946 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarSingle(void** ppv, mxSingle re, mxSingle im, mxComplexity cmplx); 947 | 948 | 949 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarInt8(void** ppv, mxInt8 re, mxInt8 im, mxComplexity cmplx); 950 | 951 | 952 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarUint8(void** ppv, mxUint8 re, mxUint8 im, mxComplexity cmplx); 953 | 954 | 955 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarInt16(void** ppv, mxInt16 re, mxInt16 im, mxComplexity cmplx); 956 | 957 | 958 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarUint16(void** ppv, mxUint16 re, mxUint16 im, mxComplexity cmplx); 959 | 960 | 961 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarInt32(void** ppv, mxInt32 re, mxInt32 im, mxComplexity cmplx); 962 | 963 | 964 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarUint32(void** ppv, mxUint32 re, mxUint32 im, mxComplexity cmplx); 965 | 966 | 967 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarInt64(void** ppv, mxInt64 re, mxInt64 im, mxComplexity cmplx); 968 | 969 | 970 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarUint64(void** ppv, mxUint64 re, mxUint64 im, mxComplexity cmplx); 971 | 972 | 973 | LIBMWMCLMCR_API_EXTERN_C int mclGetCharMatrix(void** ppv, mwSize num_rows, mwSize num_cols); 974 | 975 | 976 | LIBMWMCLMCR_API_EXTERN_C int mclGetCharArray(void** ppv, mwSize num_dims, const mwSize* dims); 977 | 978 | 979 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarChar(void** ppv, mxChar x); 980 | 981 | 982 | LIBMWMCLMCR_API_EXTERN_C int mclGetString(void** ppv, const char* str); 983 | 984 | 985 | LIBMWMCLMCR_API_EXTERN_C int mclGetCharMatrixFromStrings(void** ppv, mwSize m, const char** str); 986 | 987 | 988 | LIBMWMCLMCR_API_EXTERN_C int mclGetLogicalMatrix(void** ppv, mwSize num_rows, mwSize num_cols); 989 | 990 | 991 | LIBMWMCLMCR_API_EXTERN_C int mclGetLogicalArray(void** ppv, mwSize num_dims, const mwSize* dims); 992 | 993 | 994 | LIBMWMCLMCR_API_EXTERN_C int mclGetScalarLogical(void** ppv, mxLogical x); 995 | 996 | 997 | LIBMWMCLMCR_API_EXTERN_C int mclGetCellMatrix(void** ppv, mwSize num_rows, mwSize num_cols); 998 | 999 | 1000 | LIBMWMCLMCR_API_EXTERN_C int mclGetCellArray(void** ppv, mwSize num_dims, const mwSize* dims); 1001 | 1002 | 1003 | LIBMWMCLMCR_API_EXTERN_C int mclGetStructMatrix(void** ppv, mwSize num_rows, mwSize num_cols, int nFields, const char** fieldnames); 1004 | 1005 | 1006 | LIBMWMCLMCR_API_EXTERN_C int mclGetStructArray(void** ppv, mwSize num_dims, const mwSize* dims, int nFields, const char** fieldnames); 1007 | 1008 | 1009 | LIBMWMCLMCR_API_EXTERN_C int mclGetNumericSparse( 1010 | void** ppv, 1011 | mwSize rowindex_size, 1012 | const mwSize* rowindex, 1013 | mwSize colindex_size, 1014 | const mwSize* colindex, 1015 | mwSize data_size, 1016 | const void* rData, 1017 | const void* iData, 1018 | mwSize num_rows, 1019 | mwSize num_cols, 1020 | mwSize nzmax, 1021 | mxClassID mxType, 1022 | mxComplexity cmplx 1023 | ); 1024 | 1025 | 1026 | LIBMWMCLMCR_API_EXTERN_C int mclGetNumericSparseInferRowsCols( 1027 | void** ppv, 1028 | mwSize rowindex_size, 1029 | const mwSize* rowindex, 1030 | mwSize colindex_size, 1031 | const mwSize* colindex, 1032 | mwSize data_size, 1033 | const void* rData, 1034 | const void* iData, 1035 | mwSize nzmax, 1036 | mxClassID mxType, 1037 | mxComplexity cmplx 1038 | ); 1039 | 1040 | 1041 | LIBMWMCLMCR_API_EXTERN_C int mclGetLogicalSparse( 1042 | void** ppv, 1043 | mwSize rowindex_size, 1044 | const mwIndex* rowindex, 1045 | mwSize colindex_size, 1046 | const mwIndex* colindex, 1047 | mwSize data_size, 1048 | const mxLogical* rData, 1049 | mwSize num_rows, 1050 | mwSize num_cols, 1051 | mwSize nzmax 1052 | ); 1053 | 1054 | 1055 | LIBMWMCLMCR_API_EXTERN_C int mclGetLogicalSparseInferRowsCols( 1056 | void** ppv, 1057 | mwSize rowindex_size, 1058 | const mwIndex* rowindex, 1059 | mwSize colindex_size, 1060 | const mwIndex* colindex, 1061 | mwSize data_size, 1062 | const mxLogical* rData, 1063 | mwSize nzmax 1064 | ); 1065 | 1066 | 1067 | LIBMWMCLMCR_API_EXTERN_C int mclDeserializeArray(void** ppv, void** ppa); 1068 | 1069 | 1070 | LIBMWMCLMCR_API_EXTERN_C int mclcppGetArrayBuffer(void** ppv, mwSize size); 1071 | 1072 | 1073 | LIBMWMCLMCR_API_EXTERN_C int mclcppFeval(HMCRINSTANCE inst, const char* name, int nargout, void** lhs, void* rhs); 1074 | 1075 | 1076 | LIBMWMCLMCR_API_EXTERN_C int mclcppArrayToString(const mxArray* parray, char** ppstr); 1077 | 1078 | 1079 | LIBMWMCLMCR_API_EXTERN_C void mclcppFreeString(char* pstr); 1080 | 1081 | 1082 | LIBMWMCLMCR_API_EXTERN_C int mclmxArray2ArrayHandle(void** pphArray, mxArray* pmxArray); 1083 | 1084 | 1085 | LIBMWMCLMCR_API_EXTERN_C int mclArrayHandle2mxArray(mxArray** ppArrayImpl, void* phArray); 1086 | 1087 | 1088 | LIBMWMCLMCR_API_EXTERN_C int mclMXArrayGetIndexArrays(mxArray** ppRows, mxArray** ppColumns, mxArray* pSrcArray); 1089 | 1090 | 1091 | LIBMWMCLMCR_API_EXTERN_C int mclMXArrayGet(mxArray** ppSrcElem, mxArray* pSrcArray, mwSize num_indices, const mwIndex* index); 1092 | 1093 | 1094 | LIBMWMCLMCR_API_EXTERN_C int mclMXArrayGetReal(mxArray** ppSrcElem, mxArray* pSrcArray, mwSize num_indices, const mwIndex* index); 1095 | 1096 | 1097 | LIBMWMCLMCR_API_EXTERN_C int mclMXArrayGetImag(mxArray** ppSrcElem, mxArray* pSrcArray, mwSize num_indices, const mwIndex* index); 1098 | 1099 | 1100 | LIBMWMCLMCR_API_EXTERN_C int mclMXArraySet(mxArray* pTrgArray, mxArray* pSrcElem, mwSize num_indices, const mwIndex* index); 1101 | 1102 | 1103 | LIBMWMCLMCR_API_EXTERN_C int mclMXArraySetReal(mxArray* pTrgArray, mxArray* pSrcElem, mwSize num_indices, const mwIndex* index); 1104 | 1105 | 1106 | LIBMWMCLMCR_API_EXTERN_C int mclMXArraySetImag(mxArray* pTrgArray, mxArray* pSrcElem, mwSize num_indices, const mwIndex* index); 1107 | 1108 | 1109 | LIBMWMCLMCR_API_EXTERN_C int mclMXArraySetLogical(mxArray* pTrgArray, mxArray* pSrcElem, mwSize num_indices, const mwIndex* index); 1110 | 1111 | 1112 | LIBMWMCLMCR_API_EXTERN_C size_t mclHashNBytes (size_t u, size_t n, const char * pb); 1113 | 1114 | 1115 | #include "matrix.h" 1116 | 1117 | 1118 | #ifdef __cplusplus 1119 | /* This public extern "C" API provides functions to create and manipulate 1120 | * arrays. The API represents arrays as oqaque objects (void *'s, to be 1121 | * precise). 1122 | * 1123 | * The MATLAB Compiler and related Builder products use this API to insulate 1124 | * the generated code from changes in the underlying matrix data structure. 1125 | */ 1126 | 1127 | 1128 | 1129 | /* Opaque handle type definition. */ 1130 | typedef void * array_handle; 1131 | 1132 | 1133 | LIBMWMCLMCR_API_EXTERN_C mxClassID array_handle_classID(array_handle handle); 1134 | 1135 | 1136 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_deep_copy(array_handle handle); 1137 | 1138 | 1139 | LIBMWMCLMCR_API_EXTERN_C void array_handle_detach(array_handle handle); 1140 | 1141 | 1142 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_shared_copy(array_handle handle); 1143 | 1144 | 1145 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_serialize(array_handle handle); 1146 | 1147 | 1148 | LIBMWMCLMCR_API_EXTERN_C size_t array_handle_element_size(array_handle handle); 1149 | 1150 | 1151 | LIBMWMCLMCR_API_EXTERN_C mwSize array_handle_number_of_elements(array_handle handle); 1152 | 1153 | 1154 | LIBMWMCLMCR_API_EXTERN_C mwSize array_handle_number_of_nonzeros(array_handle handle); 1155 | 1156 | 1157 | LIBMWMCLMCR_API_EXTERN_C mwSize array_handle_maximum_nonzeros(array_handle handle); 1158 | 1159 | 1160 | LIBMWMCLMCR_API_EXTERN_C mwSize array_handle_number_of_dimensions(array_handle handle); 1161 | 1162 | 1163 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_get_dimensions(array_handle handle); 1164 | 1165 | 1166 | LIBMWMCLMCR_API_EXTERN_C int array_handle_number_of_fields(array_handle handle); 1167 | 1168 | 1169 | LIBMWMCLMCR_API_EXTERN_C char_buffer* array_handle_get_field_name(array_handle handle, int i); 1170 | 1171 | 1172 | LIBMWMCLMCR_API_EXTERN_C bool array_handle_is_empty(array_handle handle); 1173 | 1174 | 1175 | LIBMWMCLMCR_API_EXTERN_C bool array_handle_is_sparse(array_handle handle); 1176 | 1177 | 1178 | LIBMWMCLMCR_API_EXTERN_C bool array_handle_is_numeric(array_handle handle); 1179 | 1180 | 1181 | LIBMWMCLMCR_API_EXTERN_C bool array_handle_is_complex(array_handle handle); 1182 | 1183 | 1184 | LIBMWMCLMCR_API_EXTERN_C int array_handle_make_complex(array_handle handle); 1185 | 1186 | 1187 | LIBMWMCLMCR_API_EXTERN_C bool array_handle_equals(array_handle handle, array_handle p); 1188 | 1189 | 1190 | LIBMWMCLMCR_API_EXTERN_C int array_handle_compare_to(array_handle handle, array_handle p); 1191 | 1192 | 1193 | LIBMWMCLMCR_API_EXTERN_C int array_handle_hash_code(array_handle handle); 1194 | 1195 | 1196 | LIBMWMCLMCR_API_EXTERN_C char_buffer* array_handle_to_string(array_handle handle); 1197 | 1198 | 1199 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_row_index(array_handle handle); 1200 | 1201 | 1202 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_column_index(array_handle handle); 1203 | 1204 | 1205 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_get_int(array_handle handle, mwSize num_indices, const mwIndex* index); 1206 | 1207 | 1208 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_get_const_char(array_handle handle, const char* name, mwSize num_indices, const mwIndex* index); 1209 | 1210 | 1211 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_getV_int(array_handle handle, mwSize num_indices, va_list vargs); 1212 | 1213 | 1214 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_getV_const_char(array_handle handle, const char* name, mwSize num_indices, va_list vargs); 1215 | 1216 | 1217 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set(array_handle handle, array_handle p); 1218 | 1219 | 1220 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_real(array_handle handle); 1221 | 1222 | 1223 | LIBMWMCLMCR_API_EXTERN_C array_handle array_handle_imag(array_handle handle); 1224 | 1225 | 1226 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_numeric_mxDouble(array_handle handle, mxDouble* x, mwSize len); 1227 | 1228 | 1229 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_numeric_mxSingle(array_handle handle, mxSingle* x, mwSize len); 1230 | 1231 | 1232 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_numeric_mxInt8(array_handle handle, mxInt8* x, mwSize len); 1233 | 1234 | 1235 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_numeric_mxUint8(array_handle handle, mxUint8* x, mwSize len); 1236 | 1237 | 1238 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_numeric_mxInt16(array_handle handle, mxInt16* x, mwSize len); 1239 | 1240 | 1241 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_numeric_mxUint16(array_handle handle, mxUint16* x, mwSize len); 1242 | 1243 | 1244 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_numeric_mxInt32(array_handle handle, mxInt32* x, mwSize len); 1245 | 1246 | 1247 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_numeric_mxUint32(array_handle handle, mxUint32* x, mwSize len); 1248 | 1249 | 1250 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_numeric_mxInt64(array_handle handle, mxInt64* x, mwSize len); 1251 | 1252 | 1253 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_numeric_mxUint64(array_handle handle, mxUint64* x, mwSize len); 1254 | 1255 | 1256 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_char(array_handle handle, mxChar* x, mwSize len); 1257 | 1258 | 1259 | LIBMWMCLMCR_API_EXTERN_C int array_handle_get_logical(array_handle handle, mxLogical* x, mwSize len); 1260 | 1261 | 1262 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_numeric_mxDouble(array_handle handle, const mxDouble* x, mwSize len); 1263 | 1264 | 1265 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_numeric_mxSingle(array_handle handle, const mxSingle* x, mwSize len); 1266 | 1267 | 1268 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_numeric_mxInt8(array_handle handle, const mxInt8* x, mwSize len); 1269 | 1270 | 1271 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_numeric_mxUint8(array_handle handle, const mxUint8* x, mwSize len); 1272 | 1273 | 1274 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_numeric_mxInt16(array_handle handle, const mxInt16* x, mwSize len); 1275 | 1276 | 1277 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_numeric_mxUint16(array_handle handle, const mxUint16* x, mwSize len); 1278 | 1279 | 1280 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_numeric_mxInt32(array_handle handle, const mxInt32* x, mwSize len); 1281 | 1282 | 1283 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_numeric_mxUint32(array_handle handle, const mxUint32* x, mwSize len); 1284 | 1285 | 1286 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_numeric_mxInt64(array_handle handle, const mxInt64* x, mwSize len); 1287 | 1288 | 1289 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_numeric_mxUint64(array_handle handle, const mxUint64* x, mwSize len); 1290 | 1291 | 1292 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_char(array_handle handle, const mxChar* x, mwSize len); 1293 | 1294 | 1295 | LIBMWMCLMCR_API_EXTERN_C int array_handle_set_logical(array_handle handle, const mxLogical* x, mwSize len); 1296 | 1297 | 1298 | #endif /* #ifdef __cplusplus */ 1299 | 1300 | 1301 | #include 1302 | #include 1303 | #include 1304 | 1305 | 1306 | #ifdef __cplusplus 1307 | class MclMcr {}; 1308 | #endif 1309 | 1310 | 1311 | LIBMWMCLMCR_API_EXTERN_C int mclWrite(int fd, const void *ptr, size_t count); 1312 | 1313 | 1314 | 1315 | /* define MW_CALL_CONV to __cdecl if building on windows */ 1316 | #ifndef MW_CALL_CONV 1317 | #if defined( _MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__LCC__) 1318 | #define MW_CALL_CONV __cdecl 1319 | #else 1320 | #define MW_CALL_CONV 1321 | #endif /* using some PC compiler */ 1322 | #endif /* MW_CALL_CONV */ 1323 | 1324 | 1325 | 1326 | #ifdef __cplusplus 1327 | extern "C" { 1328 | #endif 1329 | typedef void (*mclErrorCallbackFcnPtr)(void); 1330 | #ifdef __cplusplus 1331 | } 1332 | #endif 1333 | 1334 | 1335 | LIBMWMCLMCR_API_EXTERN_C void mclAddCanonicalPathMacro(const char* macro, const char* expansion); 1336 | 1337 | LIBMWMCLMCR_API_EXTERN_C bool mclFeval(HMCRINSTANCE inst, const char* name, int nlhs, mxArray** plhs, int nrhs, mxArray** prhs); 1338 | 1339 | 1340 | LIBMWMCLMCR_API_EXTERN_C int mclGetMaxPathLen(void); 1341 | 1342 | 1343 | LIBMWMCLMCR_API_EXTERN_C bool mclmcrInitialize2(int primaryMode); 1344 | 1345 | 1346 | LIBMWMCLMCR_API_EXTERN_C bool mclmcrInitialize(void); 1347 | 1348 | 1349 | 1350 | /* 1351 | * in LCC, int32_t is defined as a long since it does not 1352 | * contain a definition for __int32, this is MSVC specific. 1353 | */ 1354 | #ifdef _WIN32 1355 | #ifdef __LCC__ 1356 | typedef long int32_t; 1357 | #else 1358 | typedef __int32 int32_t; 1359 | #endif 1360 | #endif 1361 | 1362 | #define MAX_FIELD_NAME_SIZE 1024 1363 | 1364 | typedef struct _wcsStackPointer 1365 | { 1366 | CHAR16_T * hPtr; 1367 | CHAR16_T sPtr[MAX_FIELD_NAME_SIZE]; 1368 | int32_t buffLen; 1369 | } *pwcsStackPointer; 1370 | 1371 | 1372 | LIBMWMCLMCR_API_EXTERN_C void deleteWcsStackPointer_hPtr(pwcsStackPointer ptr); 1373 | 1374 | 1375 | LIBMWMCLMCR_API_EXTERN_C void initializeWcsStackPointer(pwcsStackPointer *ptr); 1376 | 1377 | 1378 | LIBMWMCLMCR_API_EXTERN_C void deleteWcsStackPointer(pwcsStackPointer ptr); 1379 | 1380 | 1381 | LIBMWMCLMCR_API_EXTERN_C bool allocWcsStackPointer(pwcsStackPointer *ptr, int newLen); 1382 | 1383 | 1384 | LIBMWMCLMCR_API_EXTERN_C int mwMbstowcs(pwcsStackPointer sp, const char *sourceString); 1385 | 1386 | 1387 | LIBMWMCLMCR_API_EXTERN_C void utf16_to_lcp_n_fcn(char * target, int32_t * targetSize, 1388 | CHAR16_T const * source, int32_t sourceSize); 1389 | 1390 | 1391 | LIBMWMCLMCR_API_EXTERN_C int32_t utf16_strlen_fcn(CHAR16_T const * s); 1392 | 1393 | 1394 | LIBMWMCLMCR_API_EXTERN_C CHAR16_T * utf16_strncpy_fcn(CHAR16_T * dst, CHAR16_T const * src, int32_t n); 1395 | 1396 | 1397 | LIBMWMCLMCR_API_EXTERN_C CHAR16_T * utf16_strdup_fcn(const CHAR16_T * sl); 1398 | 1399 | 1400 | 1401 | /* PATH_MAX is the maximum number of characters that can appear in a full 1402 | * path specification. Define it, if it isn't already defined. 1403 | */ 1404 | 1405 | #if !defined(PATH_MAX) || (defined(PATH_MAX) && PATH_MAX<1024) 1406 | #undef PATH_MAX 1407 | 1408 | /* _WIN32 is always defined, for both Win32 and Win64 platforms */ 1409 | #ifdef _WIN32 1410 | #ifdef _MAX_PATH 1411 | #define PATH_MAX _MAX_PATH 1412 | #endif 1413 | #endif 1414 | 1415 | /* Windows platforms on which _MAX_PATH is not defined, and all UNIX 1416 | * platforms that don't define PATH_MAX. (Most UNIX platforms should 1417 | * define PATH_MAX in ) 1418 | */ 1419 | #ifndef PATH_MAX 1420 | #define PATH_MAX 1024 1421 | #endif 1422 | 1423 | #endif 1424 | 1425 | LIBMWMCLMCR_API_EXTERN_C bool mclFeval(HMCRINSTANCE inst, const char* name, int nlhs, mxArray** plhs, int nrhs, mxArray** prhs); 1426 | 1427 | LIBMWMCLMCR_API_EXTERN_C bool mclSetGlobal(HMCRINSTANCE inst, const char* name, mxArray* px); 1428 | 1429 | 1430 | LIBMWMCLMCR_API_EXTERN_C bool mclIsStandaloneMode(); 1431 | 1432 | 1433 | LIBMWMCLMCR_API_EXTERN_C bool mclImpersonationFeval(HMCRINSTANCE inst, const char* name, int nlhs, mxArray** plhs, int nrhs, mxArray** prhs, void* impersonationToken); 1434 | 1435 | 1436 | LIBMWMCLMCR_API_EXTERN_C bool mclFeval(HMCRINSTANCE inst, const char* name, int nlhs, mxArray** plhs, int nrhs, mxArray** prhs); 1437 | 1438 | 1439 | LIBMWMCLMCR_API_EXTERN_C bool mclGetGlobal(HMCRINSTANCE inst, const char* name, mxArray** ppx); 1440 | 1441 | 1442 | LIBMWMCLMCR_API_EXTERN_C long mclGetID(HMCRINSTANCE inst); 1443 | 1444 | 1445 | LIBMWMCLMCR_API_EXTERN_C int mclMain(HMCRINSTANCE inst, int argc, const char* argv[], 1446 | const char* name, int nlhs); 1447 | 1448 | 1449 | LIBMWMCLMCR_API_EXTERN_C bool mclMlfVFeval(HMCRINSTANCE inst, const char* name, int nargout, int fnout, int fnin, va_list ap); 1450 | 1451 | 1452 | typedef void (*mclEventFunctionPtr) (void * context, int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]); 1453 | 1454 | 1455 | LIBMWMCLMCR_API_EXTERN_C bool mclRegisterEventFunction(HMCRINSTANCE inst, const char* varname, mclEventFunctionPtr fcn); 1456 | 1457 | 1458 | LIBMWMCLMCR_API_EXTERN_C bool mclRegisterExternalFunction(HMCRINSTANCE inst, const char* varname, mxFunctionPtr fcn); 1459 | 1460 | 1461 | LIBMWMCLMCR_API_EXTERN_C bool mclSetGlobal(HMCRINSTANCE inst, const char* name, mxArray* px); 1462 | 1463 | 1464 | LIBMWMCLMCR_API_EXTERN_C bool mclGetMCRVersion(const char **version); 1465 | 1466 | 1467 | LIBMWMCLMCR_API_EXTERN_C size_t mclGetActiveID(void); 1468 | 1469 | 1470 | typedef int (*mclOutputFcnCpp)(const char *); 1471 | 1472 | 1473 | LIBMWMCLMCR_API_EXTERN_C char* mclGetTempFileName(char* tempFileName); 1474 | 1475 | 1476 | LIBMWMCLMCR_API_EXTERN_C bool mclTerminateInstance(HMCRINSTANCE* inst); 1477 | 1478 | LIBMWMCLMCR_API_EXTERN_C void stopImpersonationOnMCRThread(); 1479 | 1480 | 1481 | LIBMWMCLMCR_API_EXTERN_C void stopImpersonationOnMCRThread(); 1482 | 1483 | #endif /* mclmcr_published_api_hpp */ 1484 | -------------------------------------------------------------------------------- /TextureTransfer/for_testing/readme.txt: -------------------------------------------------------------------------------- 1 | MATLAB Compiler SDK 2 | 3 | 1. Prerequisites for Deployment 4 | 5 | . Verify the MATLAB runtime is installed and ensure you 6 | have installed version 8.5 (R2015a). 7 | 8 | . If the MATLAB runtime is not installed, do the following: 9 | (1) enter 10 | 11 | >>mcrinstaller 12 | 13 | at MATLAB prompt. The MCRINSTALLER command displays the 14 | location of the MATLAB runtime installer. 15 | 16 | (2) run the MATLAB runtime installer. 17 | 18 | Or download the Linux 64-bit version of the MATLAB runtime for R2015a 19 | from the MathWorks Web site by navigating to 20 | 21 | http://www.mathworks.com/products/compiler/mcr/index.html 22 | 23 | 24 | For more information about the MATLAB runtime and the MATLAB runtime installer, see 25 | Package and Distribute in the MATLAB Compiler SDK documentation 26 | in the MathWorks Documentation Center. 27 | 28 | 29 | 2. Files to Deploy and Package 30 | 31 | Files to package for Shared Libraries 32 | ===================================== 33 | -TextureTransfer.so 34 | -TextureTransfer.h 35 | -MCRInstaller.zip 36 | -if end users are unable to download the MATLAB runtime using the above 37 | link, include it when building your component by clicking 38 | the "Runtime downloaded from web" link in the Deployment Tool 39 | -This readme file 40 | 41 | 3. Definitions 42 | 43 | For information on deployment terminology, go to 44 | http://www.mathworks.com/help. Select MATLAB Compiler > 45 | Getting Started > About Application Deployment > 46 | Application Deployment Terms in the MathWorks Documentation 47 | Center. 48 | 49 | 50 | 4. Appendix 51 | 52 | A. Linux x86-64 systems: 53 | On the target machine, add the MATLAB runtime directory to the environment variable 54 | LD_LIBRARY_PATH by issuing the following commands: 55 | 56 | NOTE: is the directory where MATLAB runtime is installed 57 | on the target machine. 58 | 59 | setenv LD_LIBRARY_PATH 60 | $LD_LIBRARY_PATH: 61 | /v85/runtime/glnxa64: 62 | /v85/bin/glnxa64: 63 | /v85/sys/os/glnxa64: 64 | /v85/sys/opengl/lib/glnxa64 65 | setenv XAPPLRESDIR /v85/X11/app-defaults 66 | 67 | For more detail information about setting the MATLAB runtime paths, see Package and 68 | Distribute in the MATLAB Compiler SDK documentation in the MathWorks Documentation 69 | Center. 70 | 71 | 72 | 73 | NOTE: To make these changes persistent after logout on Linux 74 | or Mac machines, modify the .cshrc file to include this 75 | setenv command. 76 | NOTE: The environment variable syntax utilizes forward 77 | slashes (/), delimited by colons (:). 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /TextureTransfer/for_testing/requiredMCRProducts.txt: -------------------------------------------------------------------------------- 1 | 35000 35010 -------------------------------------------------------------------------------- /TextureTransfer/for_testing/tmwtypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1984-2014 The MathWorks, Inc. 3 | * All Rights Reserved. 4 | */ 5 | 6 | /* Copyright 1995-2014 The MathWorks, Inc. */ 7 | #if defined(_MSC_VER) 8 | # pragma once 9 | #endif 10 | #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) 11 | # pragma once 12 | #endif 13 | 14 | #ifndef tmwtypes_h 15 | #define tmwtypes_h 16 | 17 | #ifndef __TMWTYPES__ 18 | #define __TMWTYPES__ 19 | /* 20 | * File : tmwtypes.h 21 | * Abstract: 22 | * Data types for use with MATLAB/SIMULINK and the Real-Time Workshop. 23 | * 24 | * When compiling stand-alone model code, data types can be overridden 25 | * via compiler switches. 26 | * 27 | * Define NO_FLOATS to eliminate reference to real_T, etc. 28 | */ 29 | 30 | #include 31 | 32 | #ifdef __APPLE_CC__ 33 | #include 34 | #endif 35 | 36 | #define LOGICAL_IS_A_TYPE 37 | #define SPARSE_GENERALIZATION 38 | 39 | #ifdef NO_FLOATS 40 | # define double double_not_allowed 41 | # define float float_not_allowed 42 | #endif /*NO_FLOATS*/ 43 | 44 | #ifndef NO_FLOATS 45 | 46 | #ifndef __MWERKS__ 47 | # ifdef __STDC__ 48 | # include 49 | # else 50 | # define FLT_MANT_DIG 24 51 | # define DBL_MANT_DIG 53 52 | # endif 53 | #endif 54 | 55 | #endif /*NO_FLOATS*/ 56 | 57 | /* 58 | * The following data types cannot be overridden when building MEX files. 59 | */ 60 | #ifdef MATLAB_MEX_FILE 61 | # undef CHARACTER_T 62 | # undef INTEGER_T 63 | # undef BOOLEAN_T 64 | # undef REAL_T 65 | # undef TIME_T 66 | #endif 67 | 68 | /* 69 | * The uchar_T, ushort_T and ulong_T types are needed for compilers which do 70 | * not allow defines to be specified, at the command line, with spaces in them. 71 | */ 72 | 73 | typedef unsigned char uchar_T; 74 | typedef unsigned short ushort_T; 75 | typedef unsigned long ulong_T; 76 | 77 | #if (defined(_MSC_VER) && _MSC_VER >= 1500) \ 78 | || defined(__x86_64__) || defined(__LP64__) \ 79 | || defined(__LCC64__) 80 | 81 | typedef unsigned long long ulonglong_T; 82 | #endif 83 | 84 | 85 | 86 | /*=======================================================================* 87 | * Fixed width word size data types: * 88 | * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers * 89 | * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers * 90 | * real32_T, real64_T - 32 and 64 bit floating point numbers * 91 | *=======================================================================*/ 92 | 93 | /* When used with Real Time Workshop generated code, this 94 | * header file can be used with a variety of compilers. 95 | * 96 | * The compiler could be for an 8 bit embedded processor that 97 | * only had 8 bits per integer and 16 bits per long. 98 | * In that example, a 32 bit integer size is not even available. 99 | * This header file should be robust to that. 100 | * 101 | * For the case of an 8 bit processor, the preprocessor 102 | * may be limited to 16 bit math like its target. That limitation 103 | * would mean that 32 bit comparisons can't be done accurately. 104 | * To increase robustness to this, comparisons are done against 105 | * smaller values first. An inaccurate 32 bit comparison isn't 106 | * attempted if the 16 bit comparison has already succeeded. 107 | * 108 | * Limitations on preprocessor math can also be stricter than 109 | * for the target. There are known cases where a compiler 110 | * targeting processors with 64 bit longs can't do accurate 111 | * preprocessor comparisons on more than 32 bits. 112 | */ 113 | 114 | /* Determine the number of bits for int, long, short, and char. 115 | * If one fails to be determined, set the number of bits to -1 116 | */ 117 | 118 | #ifndef TMW_BITS_PER_INT 119 | # if INT_MAX == 0x7FL 120 | # define TMW_BITS_PER_INT 8 121 | # elif INT_MAX == 0x7FFFL 122 | # define TMW_BITS_PER_INT 16 123 | # elif INT_MAX == 0x7FFFFFFFL 124 | # define TMW_BITS_PER_INT 32 125 | # else 126 | # define TMW_BITS_PER_INT -1 127 | # endif 128 | #endif 129 | 130 | #ifndef TMW_BITS_PER_LONG 131 | # if LONG_MAX == 0x7FL 132 | # define TMW_BITS_PER_LONG 8 133 | # elif LONG_MAX == 0x7FFFL 134 | # define TMW_BITS_PER_LONG 16 135 | # elif LONG_MAX == 0x7FFFFFFFL 136 | # define TMW_BITS_PER_LONG 32 137 | # else 138 | # define TMW_BITS_PER_LONG -1 139 | # endif 140 | #endif 141 | 142 | #ifndef TMW_BITS_PER_SHRT 143 | # if SHRT_MAX == 0x7FL 144 | # define TMW_BITS_PER_SHRT 8 145 | # elif SHRT_MAX == 0x7FFFL 146 | # define TMW_BITS_PER_SHRT 16 147 | # elif SHRT_MAX == 0x7FFFFFFFL 148 | # define TMW_BITS_PER_SHRT 32 149 | # else 150 | # define TMW_BITS_PER_SHRT -1 151 | # endif 152 | #endif 153 | 154 | #ifndef TMW_BITS_PER_SCHAR 155 | # if SCHAR_MAX == 0x7FL 156 | # define TMW_BITS_PER_SCHAR 8 157 | # elif SCHAR_MAX == 0x7FFFL 158 | # define TMW_BITS_PER_SCHAR 16 159 | # elif SCHAR_MAX == 0x7FFFFFFFL 160 | # define TMW_BITS_PER_SCHAR 32 161 | # else 162 | # define TMW_BITS_PER_SCHAR -1 163 | # endif 164 | #endif 165 | 166 | #ifndef TMW_CHAR_SIGNED 167 | # if SCHAR_MAX == CHAR_MAX 168 | # define TMW_CHAR_SIGNED 1 169 | # else 170 | # define TMW_CHAR_SIGNED 0 171 | # endif 172 | #endif 173 | 174 | /* It is common for one or more of the integer types 175 | * to be the same size. For example, on many embedded 176 | * processors, both shorts and ints are 16 bits. On 177 | * processors used for workstations, it is quite common 178 | * for both int and long to be 32 bits. 179 | * When there is more than one choice for typdef'ing 180 | * a portable type like int16_T or uint32_T, in 181 | * concept, it should not matter which choice is made. 182 | * However, some style guides and some code checking 183 | * tools do identify and complain about seemingly 184 | * irrelevant differences. For example, a code 185 | * checking tool may complain about an implicit 186 | * conversion from int to short even though both 187 | * are 16 bits. To reduce these types of 188 | * complaints, it is best to make int the 189 | * preferred choice when more than one is available. 190 | */ 191 | 192 | #ifndef INT8_T 193 | # if TMW_BITS_PER_INT == 8 194 | # define INT8_T int 195 | # elif TMW_BITS_PER_LONG == 8 196 | # define INT8_T long 197 | # elif TMW_BITS_PER_SCHAR == 8 198 | # define INT8_T signed char 199 | # elif TMW_BITS_PER_SHRT == 8 200 | # define INT8_T short 201 | # endif 202 | #endif 203 | #ifdef INT8_T 204 | typedef INT8_T int8_T; 205 | #endif 206 | 207 | #ifndef UINT8_T 208 | # if TMW_BITS_PER_INT == 8 209 | # define UINT8_T unsigned int 210 | # elif TMW_BITS_PER_LONG == 8 211 | # define UINT8_T unsigned long 212 | # elif TMW_BITS_PER_SCHAR == 8 213 | # define UINT8_T unsigned char 214 | # elif TMW_BITS_PER_SHRT == 8 215 | # define UINT8_T unsigned short 216 | # endif 217 | #endif 218 | #ifdef UINT8_T 219 | typedef UINT8_T uint8_T; 220 | #endif 221 | 222 | 223 | #ifndef INT16_T 224 | # if TMW_BITS_PER_INT == 16 225 | # define INT16_T int 226 | # elif TMW_BITS_PER_LONG == 16 227 | # define INT16_T long 228 | # elif TMW_BITS_PER_SCHAR == 16 229 | # define INT16_T signed char 230 | # elif TMW_BITS_PER_SHRT == 16 231 | # define INT16_T short 232 | # endif 233 | #endif 234 | #ifdef INT16_T 235 | typedef INT16_T int16_T; 236 | #endif 237 | 238 | 239 | #ifndef UINT16_T 240 | # if TMW_BITS_PER_INT == 16 241 | # define UINT16_T unsigned int 242 | # elif TMW_BITS_PER_LONG == 16 243 | # define UINT16_T unsigned long 244 | # elif TMW_BITS_PER_SCHAR == 16 245 | # define UINT16_T unsigned char 246 | # elif TMW_BITS_PER_SHRT == 16 247 | # define UINT16_T unsigned short 248 | # endif 249 | #endif 250 | #ifdef UINT16_T 251 | typedef UINT16_T uint16_T; 252 | #endif 253 | 254 | 255 | #ifndef INT32_T 256 | # if TMW_BITS_PER_INT == 32 257 | # define INT32_T int 258 | # elif TMW_BITS_PER_LONG == 32 259 | # define INT32_T long 260 | # elif TMW_BITS_PER_SCHAR == 32 261 | # define INT32_T signed char 262 | # elif TMW_BITS_PER_SHRT == 32 263 | # define INT32_T short 264 | # endif 265 | #endif 266 | #ifdef INT32_T 267 | typedef INT32_T int32_T; 268 | #endif 269 | 270 | 271 | #ifndef UINT32_T 272 | # if TMW_BITS_PER_INT == 32 273 | # define UINT32_T unsigned int 274 | # elif TMW_BITS_PER_LONG == 32 275 | # define UINT32_T unsigned long 276 | # elif TMW_BITS_PER_SCHAR == 32 277 | # define UINT32_T unsigned char 278 | # elif TMW_BITS_PER_SHRT == 32 279 | # define UINT32_T unsigned short 280 | # endif 281 | #endif 282 | #ifdef UINT32_T 283 | typedef UINT32_T uint32_T; 284 | #endif 285 | 286 | /* The following is used to emulate smaller integer types when only 287 | * larger types are available. For example, compilers for TI C3x/C4x DSPs 288 | * define char and short to be 32 bits, so 8 and 16 bits are not directly 289 | * available. This target is commonly used with RTW rapid prototyping. 290 | * Other DSPs define char to be 16 bits, so 8 bits is not directly 291 | * available. 292 | */ 293 | #ifndef INT8_T 294 | # ifdef INT16_T 295 | # define INT8_T INT16_T 296 | typedef INT8_T int8_T; 297 | # else 298 | # ifdef INT32_T 299 | # define INT8_T INT32_T 300 | typedef INT8_T int8_T; 301 | # endif 302 | # endif 303 | #endif 304 | 305 | #ifndef UINT8_T 306 | # ifdef UINT16_T 307 | # define UINT8_T UINT16_T 308 | typedef UINT8_T uint8_T; 309 | # else 310 | # ifdef UINT32_T 311 | # define UINT8_T UINT32_T 312 | typedef UINT8_T uint8_T; 313 | # endif 314 | # endif 315 | #endif 316 | 317 | #ifndef INT16_T 318 | # ifdef INT32_T 319 | # define INT16_T INT32_T 320 | typedef INT16_T int16_T; 321 | # endif 322 | #endif 323 | 324 | #ifndef UINT16_T 325 | # ifdef UINT32_T 326 | # define UINT16_T UINT32_T 327 | typedef UINT16_T uint16_T; 328 | # endif 329 | #endif 330 | 331 | 332 | #ifndef NO_FLOATS 333 | 334 | #ifndef REAL32_T 335 | # ifndef __MWERKS__ 336 | # if FLT_MANT_DIG >= 23 337 | # define REAL32_T float 338 | # endif 339 | # else 340 | # define REAL32_T float 341 | # endif 342 | #endif 343 | #ifdef REAL32_T 344 | typedef REAL32_T real32_T; 345 | #endif 346 | 347 | 348 | #ifndef REAL64_T 349 | # ifndef __MWERKS__ 350 | # if DBL_MANT_DIG >= 52 351 | # define REAL64_T double 352 | # endif 353 | # else 354 | # define REAL64_T double 355 | # endif 356 | #endif 357 | #ifdef REAL64_T 358 | typedef REAL64_T real64_T; 359 | #endif 360 | 361 | #endif /* NO_FLOATS*/ 362 | 363 | /*=======================================================================* 364 | * Fixed width word size data types: * 365 | * int64_T - signed 64 bit integers * 366 | * uint64_T - unsigned 64 bit integers * 367 | *=======================================================================*/ 368 | 369 | 370 | 371 | #ifndef INT64_T 372 | # if defined(__APPLE__) 373 | # define INT64_T long long 374 | # define FMT64 "ll" 375 | # if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG) 376 | # define INT_TYPE_64_IS_LONG 377 | # endif 378 | # elif defined(__x86_64__) || defined(__LP64__) 379 | # define INT64_T long 380 | # define FMT64 "l" 381 | # if !defined(INT_TYPE_64_IS_LONG) 382 | # define INT_TYPE_64_IS_LONG 383 | # endif 384 | # elif defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \ 385 | || (defined(__WATCOMC__) && __WATCOMC__ >= 1100) 386 | # define INT64_T __int64 387 | # define FMT64 "I64" 388 | # elif defined(__GNUC__) || defined(TMW_ENABLE_INT64) \ 389 | || defined(__LCC64__) 390 | # define INT64_T long long 391 | # define FMT64 "ll" 392 | # endif 393 | #endif 394 | 395 | 396 | 397 | #if defined(INT64_T) 398 | # if defined(__GNUC__) && \ 399 | ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9))) 400 | __extension__ 401 | # endif 402 | typedef INT64_T int64_T; 403 | #endif 404 | 405 | 406 | 407 | #ifndef UINT64_T 408 | # if defined(__APPLE__) 409 | # define UINT64_T unsigned long long 410 | # define FMT64 "ll" 411 | # if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG) 412 | # define INT_TYPE_64_IS_LONG 413 | # endif 414 | # elif defined(__x86_64__) || defined(__LP64__) 415 | # define UINT64_T unsigned long 416 | # define FMT64 "l" 417 | # if !defined(INT_TYPE_64_IS_LONG) 418 | # define INT_TYPE_64_IS_LONG 419 | # endif 420 | # elif defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \ 421 | || (defined(__WATCOMC__) && __WATCOMC__ >= 1100) 422 | # define UINT64_T unsigned __int64 423 | # define FMT64 "I64" 424 | # elif defined(__GNUC__) || defined(TMW_ENABLE_INT64) \ 425 | || defined(__LCC64__) 426 | # define UINT64_T unsigned long long 427 | # define FMT64 "ll" 428 | # endif 429 | #endif 430 | 431 | #if defined(_WIN64) || (defined(__APPLE__) && defined(__LP64__)) \ 432 | || defined(__x86_64__) \ 433 | || defined(__LP64__) 434 | # define INT_TYPE_64_IS_SUPPORTED 435 | #endif 436 | 437 | #if defined(UINT64_T) 438 | # if defined(__GNUC__) && \ 439 | ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9))) 440 | __extension__ 441 | # endif 442 | typedef UINT64_T uint64_T; 443 | #endif 444 | 445 | /*===========================================================================* 446 | * Format string modifiers for using size_t variables in printf statements. * 447 | *===========================================================================*/ 448 | 449 | #ifndef FMT_SIZE_T 450 | # if defined( __GNUC__ ) || defined(_STDC_C99) 451 | # define FMT_SIZE_T "z" 452 | # elif defined (__WATCOMC__) 453 | # define FMT_SIZE_T "l" 454 | # elif defined (_WIN32 ) 455 | # define FMT_SIZE_T "I" 456 | # else 457 | # define FMT_SIZE_T "l" 458 | # endif 459 | #endif 460 | 461 | #ifndef FMT_PTRDIFF_T 462 | # if defined(__APPLE__) 463 | # define FMT_PTRDIFF_T "l" 464 | # elif defined( __GNUC__ ) || defined(_STDC_C99) 465 | # define FMT_PTRDIFF_T "t" 466 | # elif defined (__WATCOMC__) 467 | # define FMT_PTRDIFF_T "l" 468 | # elif defined (_WIN32 ) 469 | # define FMT_PTRDIFF_T "I" 470 | # else 471 | # define FMT_PTRDIFF_T "l" 472 | # endif 473 | #endif 474 | 475 | /*===========================================================================* 476 | * General or logical data types where the word size is not guaranteed. * 477 | * real_T - possible settings include real32_T or real64_T * 478 | * time_T - possible settings include real64_T or uint32_T * 479 | * boolean_T * 480 | * char_T * 481 | * int_T * 482 | * uint_T * 483 | * byte_T * 484 | *===========================================================================*/ 485 | 486 | #ifndef NO_FLOATS 487 | 488 | #ifndef REAL_T 489 | # ifdef REAL64_T 490 | # define REAL_T real64_T 491 | # else 492 | # ifdef REAL32_T 493 | # define REAL_T real32_T 494 | # endif 495 | # endif 496 | #endif 497 | #ifdef REAL_T 498 | typedef REAL_T real_T; 499 | #endif 500 | 501 | #ifndef TIME_T 502 | # ifdef REAL_T 503 | # define TIME_T real_T 504 | # endif 505 | #endif 506 | #ifdef TIME_T 507 | typedef TIME_T time_T; 508 | #endif 509 | 510 | #endif /* NO_FLOATS */ 511 | 512 | #ifndef BOOLEAN_T 513 | # if defined(UINT8_T) 514 | # define BOOLEAN_T UINT8_T 515 | # else 516 | # define BOOLEAN_T unsigned int 517 | # endif 518 | #endif 519 | typedef BOOLEAN_T boolean_T; 520 | 521 | 522 | #ifndef CHARACTER_T 523 | # define CHARACTER_T char 524 | #endif 525 | typedef CHARACTER_T char_T; 526 | 527 | 528 | #ifndef INTEGER_T 529 | # define INTEGER_T int 530 | #endif 531 | typedef INTEGER_T int_T; 532 | 533 | 534 | #ifndef UINTEGER_T 535 | # define UINTEGER_T unsigned 536 | #endif 537 | typedef UINTEGER_T uint_T; 538 | 539 | 540 | #ifndef BYTE_T 541 | # define BYTE_T unsigned char 542 | #endif 543 | typedef BYTE_T byte_T; 544 | 545 | 546 | /*===========================================================================* 547 | * Define Complex Structures * 548 | *===========================================================================*/ 549 | #ifndef NO_FLOATS 550 | 551 | #ifndef CREAL32_T 552 | # ifdef REAL32_T 553 | typedef struct { 554 | real32_T re, im; 555 | } creal32_T; 556 | # define CREAL32_T creal32_T 557 | # endif 558 | #endif 559 | 560 | #ifndef CREAL64_T 561 | # ifdef REAL64_T 562 | typedef struct { 563 | real64_T re, im; 564 | } creal64_T; 565 | # define CREAL64_T creal64_T 566 | # endif 567 | #endif 568 | 569 | #ifndef CREAL_T 570 | # ifdef REAL_T 571 | typedef struct { 572 | real_T re, im; 573 | } creal_T; 574 | # define CREAL_T creal_T 575 | # endif 576 | #endif 577 | 578 | #endif /* NO_FLOATS */ 579 | 580 | #ifndef CINT8_T 581 | # ifdef INT8_T 582 | typedef struct { 583 | int8_T re, im; 584 | } cint8_T; 585 | # define CINT8_T cint8_T 586 | # endif 587 | #endif 588 | 589 | #ifndef CUINT8_T 590 | # ifdef UINT8_T 591 | typedef struct { 592 | uint8_T re, im; 593 | } cuint8_T; 594 | # define CUINT8_T cuint8_T 595 | # endif 596 | #endif 597 | 598 | #ifndef CINT16_T 599 | # ifdef INT16_T 600 | typedef struct { 601 | int16_T re, im; 602 | } cint16_T; 603 | # define CINT16_T cint16_T 604 | # endif 605 | #endif 606 | 607 | #ifndef CUINT16_T 608 | # ifdef UINT16_T 609 | typedef struct { 610 | uint16_T re, im; 611 | } cuint16_T; 612 | # define CUINT16_T cuint16_T 613 | # endif 614 | #endif 615 | 616 | #ifndef CINT32_T 617 | # ifdef INT32_T 618 | typedef struct { 619 | int32_T re, im; 620 | } cint32_T; 621 | # define CINT32_T cint32_T 622 | # endif 623 | #endif 624 | 625 | #ifndef CUINT32_T 626 | # ifdef UINT32_T 627 | typedef struct { 628 | uint32_T re, im; 629 | } cuint32_T; 630 | # define CUINT32_T cuint32_T 631 | # endif 632 | #endif 633 | 634 | #ifndef CINT64_T 635 | # ifdef INT64_T 636 | typedef struct { 637 | int64_T re, im; 638 | } cint64_T; 639 | # define CINT64_T cint64_T 640 | # endif 641 | #endif 642 | 643 | #ifndef CUINT64_T 644 | # ifdef UINT64_T 645 | typedef struct { 646 | uint64_T re, im; 647 | } cuint64_T; 648 | # define CUINT64_T cuint64_T 649 | # endif 650 | #endif 651 | 652 | /*=======================================================================* 653 | * Min and Max: * 654 | * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers * 655 | * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers * 656 | *=======================================================================*/ 657 | 658 | #define MAX_int8_T ((int8_T)(127)) /* 127 */ 659 | #define MIN_int8_T ((int8_T)(-128)) /* -128 */ 660 | #define MAX_uint8_T ((uint8_T)(255)) /* 255 */ 661 | #define MIN_uint8_T ((uint8_T)(0)) 662 | 663 | #define MAX_int16_T ((int16_T)(32767)) /* 32767 */ 664 | #define MIN_int16_T ((int16_T)(-32768)) /* -32768 */ 665 | #define MAX_uint16_T ((uint16_T)(65535)) /* 65535 */ 666 | #define MIN_uint16_T ((uint16_T)(0)) 667 | 668 | #define MAX_int32_T ((int32_T)(2147483647)) /* 2147483647 */ 669 | #define MIN_int32_T ((int32_T)(-2147483647-1)) /* -2147483648 */ 670 | #define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU)) /* 4294967295 */ 671 | #define MIN_uint32_T ((uint32_T)(0)) 672 | 673 | #if defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \ 674 | || (defined(__WATCOMC__) && __WATCOMC__ >= 1100) \ 675 | || defined(__LCC64__) 676 | # ifdef INT64_T 677 | # define MAX_int64_T ((int64_T)(9223372036854775807LL)) 678 | # define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL)) 679 | # endif 680 | # ifdef UINT64_T 681 | # define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL)) 682 | # define MIN_uint64_T ((uint64_T)(0)) 683 | # endif 684 | #else 685 | # ifdef INT64_T 686 | # ifdef INT_TYPE_64_IS_LONG 687 | # define MAX_int64_T ((int64_T)(9223372036854775807L)) 688 | # define MIN_int64_T ((int64_T)(-9223372036854775807L-1L)) 689 | # else 690 | # define MAX_int64_T ((int64_T)(9223372036854775807LL)) 691 | # define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL)) 692 | # endif 693 | # endif 694 | # ifdef UINT64_T 695 | # ifdef INT_TYPE_64_IS_LONG 696 | # define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFUL)) 697 | # define MIN_uint64_T ((uint64_T)(0)) 698 | # else 699 | # define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL)) 700 | # define MIN_uint64_T ((uint64_T)(0)) 701 | # endif 702 | # endif 703 | #endif 704 | 705 | #ifdef _MSC_VER 706 | /* Conversion from unsigned __int64 to double is not implemented in windows 707 | * and results in a compile error, thus the value must first be cast to 708 | * signed __int64, and then to double. 709 | * 710 | * If the 64 bit int value is greater than 2^63-1, which is the signed int64 max, 711 | * the macro below provides a workaround for casting a uint64 value to a double 712 | * in windows. 713 | */ 714 | # define uint64_to_double(u) ( ((u) > _I64_MAX) ? \ 715 | (double)(__int64)((u) - _I64_MAX - 1) + (double)_I64_MAX + 1: \ 716 | (double)(__int64)(u) ) 717 | 718 | /* The following inline function should only be used in the macro double_to_uint64, 719 | * as it only handles the specfic range of double between 2^63 and 2^64-1 */ 720 | __forceinline 721 | uint64_T double_to_uint64_helper(double d) { 722 | union double_to_uint64_union_type { 723 | double dd; 724 | uint64_T i64; 725 | } di; 726 | di.dd = d; 727 | return (((di.i64 & 0x000fffffffffffff) | 0x0010000000000000) << 11); 728 | } 729 | 730 | /* The largest double value that can be cast to uint64 in windows is the 731 | * signed int64 max, which is 2^63-1. The macro below provides 732 | * a workaround for casting large double values to uint64 in windows. 733 | */ 734 | /* The magic number 18446744073709551616.0 is 2^64 */ 735 | /* The magic number 9223372036854775808.0 is 2^63 */ 736 | # define double_to_uint64(d) ( ((d) >= 18446744073709551616.0) ? \ 737 | 0xffffffffffffffffULL : \ 738 | ((d) < 0.0) ? 0ULL : \ 739 | ((d) >= 9223372036854775808.0) ? \ 740 | double_to_uint64_helper(d) : \ 741 | (unsigned __int64)(d) ) 742 | #else 743 | # define uint64_to_double(u) ((double)(u)) 744 | # if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__TICCSC__) 745 | /* double_to_uint64 defined only for MSVC and UNIX */ 746 | # else 747 | # define double_to_uint64(d) ( ((d) > 0xffffffffffffffffULL) ? \ 748 | (unsigned long long) 0xffffffffffffffffULL : \ 749 | ((d) < 0) ? (unsigned long long) 0 : (unsigned long long)(d) ) 750 | # endif 751 | #endif 752 | 753 | #if !defined(__cplusplus) && !defined(__bool_true_false_are_defined) 754 | 755 | #ifndef _bool_T 756 | #define _bool_T 757 | 758 | typedef boolean_T bool; 759 | 760 | #ifndef false 761 | #define false (0) 762 | #endif 763 | #ifndef true 764 | #define true (1) 765 | #endif 766 | 767 | #endif /* _bool_T */ 768 | 769 | #endif /* !__cplusplus */ 770 | 771 | /* 772 | * This software assumes that the code is being compiled on a target using a 773 | * 2's complement representation for signed integer values. 774 | */ 775 | #if ((SCHAR_MIN + 1) != -SCHAR_MAX) 776 | #error "This code must be compiled using a 2's complement representation for signed integer values" 777 | #endif 778 | 779 | /* 780 | * Maximum length of a MATLAB identifier (function/variable/model) 781 | * including the null-termination character. 782 | */ 783 | #define TMW_NAME_LENGTH_MAX 64 784 | 785 | /* 786 | * Maximum values for indices and dimensions 787 | */ 788 | #include 789 | 790 | #ifdef MX_COMPAT_32 791 | typedef int mwSize; 792 | typedef int mwIndex; 793 | typedef int mwSignedIndex; 794 | #else 795 | typedef size_t mwSize; /* unsigned pointer-width integer */ 796 | typedef size_t mwIndex; /* unsigned pointer-width integer */ 797 | typedef ptrdiff_t mwSignedIndex; /* a signed pointer-width integer */ 798 | #endif 799 | 800 | #if (defined(_LP64) || defined(_WIN64)) && !defined(MX_COMPAT_32) 801 | /* Currently 2^48 based on hardware limitations */ 802 | # define MWSIZE_MAX 281474976710655UL 803 | # define MWINDEX_MAX 281474976710655UL 804 | # define MWSINDEX_MAX 281474976710655L 805 | # define MWSINDEX_MIN -281474976710655L 806 | #else 807 | # define MWSIZE_MAX 2147483647UL 808 | # define MWINDEX_MAX 2147483647UL 809 | # define MWSINDEX_MAX 2147483647L 810 | # define MWSINDEX_MIN -2147483647L 811 | #endif 812 | #define MWSIZE_MIN 0UL 813 | #define MWINDEX_MIN 0UL 814 | 815 | /** UTF-16 character type */ 816 | 817 | #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT) 818 | typedef char16_t CHAR16_T; 819 | #define U16_STRING_LITERAL_PREFIX u 820 | #elif defined(_MSC_VER) 821 | typedef wchar_t CHAR16_T; 822 | #define U16_STRING_LITERAL_PREFIX L 823 | #else 824 | typedef UINT16_T CHAR16_T; 825 | #endif 826 | 827 | #endif /* __TMWTYPES__ */ 828 | 829 | #endif /* tmwtypes_h */ 830 | -------------------------------------------------------------------------------- /cut.py: -------------------------------------------------------------------------------- 1 | from smop.core import * 2 | import numpy as np 3 | import cv2 4 | import scipy 5 | import math 6 | from scipy import ndimage 7 | 8 | 9 | @function 10 | def cut(sample,patchsize,overlap,imout,samplepos,imoutpos): 11 | 12 | samplesz=size(sample) 13 | sampledms=length(samplesz) 14 | 15 | 16 | line15junk = sample[samplepos[1] + overlap-1:samplepos[1] + patchsize - 2,samplepos[2] + overlap-1:samplepos[2] + patchsize - 2,:] 17 | 18 | imout[imoutpos[0] + overlap-1:imoutpos[0] + patchsize - 2,imoutpos[1] + overlap-1:imoutpos[1] + patchsize - 2,:] = line15junk 19 | 20 | imoutsz=size(imout) 21 | 22 | imoutdms=length(imoutsz) 23 | 24 | samplet=np.zeros((patchsize,overlap)) 25 | 26 | imoutt=np.zeros((patchsize,overlap)) 27 | 28 | delta=np.zeros((patchsize,overlap)) 29 | 30 | 31 | if sampledms == 2: 32 | samplet[:,:]=sample[samplepos[1]-1:samplepos[1] + patchsize - 1,samplepos[2]-1:samplepos[2] + overlap - 1] 33 | 34 | else: 35 | for k in xrange(0,samplesz[3]): 36 | samplet[:,:]=samplet[:,:] + sample[samplepos[1]-1:samplepos[1] + patchsize - 1,samplepos[2]-1:samplepos[2] + overlap - 1,k] 37 | 38 | 39 | if imoutdms == 2: 40 | imoutt[:,:]=imout[imoutpos[0]-1:imoutpos[0] + patchsize - 1,imoutpos[1]-1:imoutpos[1] + overlap - 1] 41 | 42 | else: 43 | for p in xrange(0,imoutsz[3]): 44 | imoutt[:,:]=imoutt[:,:] + imout[imoutpos[0]:imoutpos[0] + patchsize ,imoutpos[1]:imoutpos[1] + overlap,p] 45 | 46 | 47 | delta[:,:]=samplet[:,:] - imoutt[:,:] 48 | 49 | delta[:,:]=abs(delta[:,:]) 50 | 51 | ddelta=np.zeros((patchsize,overlap)) 52 | 53 | ddelta[1,:]=delta[1,:] 54 | 55 | for i in xrange(1,patchsize): 56 | for j in xrange(0,overlap): 57 | if j == 1: 58 | ddelta[i,1]=delta[i,0] + numpy.minimum( delta[i - 1,1], delta[i - 1,1]) 59 | 60 | else: 61 | if j == overlap-1: 62 | ddelta[i,overlap-1]=delta[i,overlap-1] + numpy.minimum(delta[i - 1,overlap - 2],delta[i - 1,overlap-1]) 63 | 64 | else: 65 | ddelta[i,j]=delta[i,j] + numpy.minimum(numpy.minimum(delta[i - 1,j - 1],delta[i - 1,j]),delta[i - 1,j + 1]) 66 | 67 | 68 | cutarr=np.zeros((patchsize,1)) 69 | 70 | 71 | cutarr[patchsize-1]=find(ddelta[patchsize-1,:] == np.amin(ddelta[patchsize-1,:]),0) 72 | 73 | for i in xrange(patchsize-1,0,-1): 74 | if cutarr[i,0] == 1: 75 | temp=matlabarray(ddelta[i - 1,0],ddelta[i - 1,1]) 76 | 77 | cutarr[i - 1]=find(temp == np.amin(temp),0) 78 | 79 | else: 80 | if cutarr[i] == overlap-1: 81 | temp=matlabarray(ddelta[i - 1,overlap-1],ddelta[i - 1,overlap - 2]) 82 | 83 | cutarr[i - 1]=overlap + 1 - find(temp == np.amin(temp),0) 84 | 85 | else: 86 | temp=matlabarray(ddelta[i - 1, int(cutarr[i]) - 3], ddelta[i - 1,int(cutarr[i])-2]) 87 | cutarr[i - 1]=cutarr[i] - 2 + find(temp == np.amin(temp),0) 88 | 89 | 90 | for i in xrange(0,patchsize): 91 | imout[imoutpos[0] + i-1,imoutpos[1] + cutarr[i] - 1:imoutpos[1] + overlap - 1,:]=sample[samplepos[1] + i-1,samplepos[2] + cutarr[i] - 1:samplepos[2] + overlap - 1,:] 92 | 93 | 94 | samplet=np.zeros((overlap,patchsize)) 95 | 96 | imoutt=np.zeros((overlap,patchsize)) 97 | 98 | delta=np.zeros((overlap,patchsize)) 99 | 100 | if sampledms == 2: 101 | samplet[:,:]=sample[samplepos[1]-1:samplepos[1] + overlap - 1,samplepos[2]-1:samplepos[2] + patchsize - 1] 102 | 103 | else: 104 | for k in xrange(0,samplesz[3]): 105 | samplet[:,:]=samplet[:,:] + sample[samplepos[1]-1:samplepos[1] + overlap - 1,samplepos[2]-1:samplepos[2] + patchsize - 1,k] 106 | 107 | 108 | if imoutdms == 2: 109 | imoutt[:,:]=imout[imoutpos[0]:imoutpos[0] + overlap - 1,imoutpos[1]:imoutpos[1] + patchsize - 1] 110 | 111 | else: 112 | for p in xrange(0,imoutsz[3]): 113 | imoutt[:,:]=imoutt[:,:] + imout[imoutpos[0]:imoutpos[0] + overlap ,imoutpos[1]:imoutpos[1] + patchsize,p] 114 | 115 | 116 | delta[:,:]=samplet[:,:] - imoutt[:,:] 117 | 118 | delta[:,:]=abs(delta[:,:]) 119 | 120 | ddelta=np.zeros((overlap,patchsize)) 121 | 122 | ddelta[:,1]=delta[:,1] 123 | 124 | for i in xrange(1,patchsize): 125 | for j in xrange(0,overlap): 126 | if j == 1: 127 | ddelta[1,i]=delta[1,i] + numpy.minimum(delta[1,i - 1],delta[2,i - 1]) 128 | 129 | else: 130 | if j == overlap-1: 131 | ddelta[overlap-1,i]=delta[overlap-1,i] + numpy.minimum(delta[overlap - 2,i - 1],delta[overlap-1,i - 1]) 132 | 133 | else: 134 | ddelta[j,i]=delta[j,i] + numpy.minimum(numpy.minimum(delta[j - 1,i - 1],delta[j,i - 1]),delta[j + 1,i - 1]) 135 | 136 | 137 | cutarr=np.zeros((patchsize,1)) 138 | 139 | cutarr[patchsize-1]=find(ddelta[:,patchsize-1] == np.amin(ddelta[:,patchsize-1]),0) 140 | 141 | for i in xrange(patchsize-1,0,-1): 142 | if cutarr[i] == 1: 143 | temp=matlabarray(ddelta[1,i - 1],ddelta[2,i - 1]) 144 | 145 | cutarr[i - 1]=find(temp == np.amin(temp),0) 146 | 147 | else: 148 | if cutarr[i] == overlap-1: 149 | temp=matlabarray(ddelta[overlap-1,i - 1],ddelta[overlap - 2,i - 1]) 150 | 151 | cutarr[i - 1]=overlap + 1 - find(temp == np.amin(temp),0) 152 | 153 | else: 154 | temp=matlabarray(ddelta[int(cutarr[i]) - 2,i - 1],ddelta[int(cutarr[i])-1,i - 1]) 155 | 156 | cutarr[i - 1]=cutarr[i] - 2 + find(temp == np.amin(temp),0) 157 | 158 | 159 | for i in xrange(0,patchsize-1): 160 | imout[imoutpos[0] + cutarr[i] - 1:imoutpos[0] + overlap - 1,imoutpos[1] + i,:]=sample[samplepos[1] + cutarr[i] - 1:samplepos[1] + overlap - 1,samplepos[2] + i,:] 161 | 162 | return imout -------------------------------------------------------------------------------- /find_mindelta.py: -------------------------------------------------------------------------------- 1 | from smop.core import * 2 | import numpy as np 3 | import cv2 4 | import scipy 5 | import math 6 | from scipy import ndimage 7 | from random import randint 8 | 9 | @function 10 | def find_mindelta(texture=None,target=None,targetpos=None,patchsize=None,tol=None): 11 | 12 | sizetexture=size(texture) 13 | sizetexture=sizetexture[1:2] 14 | 15 | ssdarr=zeros(sizetexture[1] - patchsize + 1,sizetexture[2] - patchsize + 1) 16 | 17 | targetposnew = target[targetpos[0]:targetpos[0]+patchsize-1, targetpos[1]:targetpos[1]+patchsize-1, :] 18 | 19 | if (size(targetposnew)[2] != patchsize-1): 20 | temptargetposnew = np.zeros((patchsize-1,patchsize-1,3)) 21 | temptargetposnew[0:size(targetposnew)[1],0:size(targetposnew)[2],:] = targetposnew 22 | targetposnew = temptargetposnew 23 | 24 | if (size(targetposnew)[1] != patchsize-1): 25 | temptargetposnew = np.zeros((patchsize-1,patchsize-1,3)) 26 | temptargetposnew[0:size(targetposnew)[1],0:size(targetposnew)[2],:] = targetposnew 27 | targetposnew = temptargetposnew 28 | 29 | for i in xrange(0,sizetexture[1] - patchsize + 1): 30 | for j in xrange(0,sizetexture[2] - patchsize + 1): 31 | 32 | temparr=texture[i:i + patchsize-1,j:j + patchsize-1,:] - targetposnew 33 | temparr=multiply(temparr[:,:,:],temparr[:,:,:]) 34 | cost=sum(sum(sum(temparr))) 35 | 36 | 37 | if cost == 0: 38 | ssdarr[i,j]=10000000000 39 | 40 | else: 41 | ssdarr[i,j]=cost 42 | 43 | 44 | sizessd = size(ssdarr) 45 | sizessd = [int(x) for x in np.nditer(sizessd)] 46 | 47 | minssd=min(min(ssdarr)) 48 | 49 | min_mat=np.tile(minssd,sizessd) 50 | 51 | d_mat=dot(min_mat,(1 + tol)) - ssdarr 52 | 53 | temp_x,temp_y=find(d_mat > 0,nargout=2) 54 | 55 | randindex= randint(1,int(size(temp_x)[1])) 56 | 57 | return matlabarray(cat(temp_x[randindex],temp_y[randindex])) 58 | -------------------------------------------------------------------------------- /get_ssd.py: -------------------------------------------------------------------------------- 1 | from smop.core import * 2 | 3 | 4 | @function 5 | def get_ssd(texture=None,texturepos1=None,texturepos2=None,targetposnew=None,patchsize=None,*args,**kwargs): 6 | varargin = get_ssd.varargin 7 | nargin = get_ssd.nargin 8 | 9 | temparr=texture[texturepos1:texturepos1 + patchsize - 1,texturepos2:texturepos2 + patchsize - 1,:] - targetposnew 10 | # ../../ImageQuilting/get_ssd.m:3 11 | temparr=multiply(temparr[:,:,:],temparr[:,:,:]) 12 | # ../../ImageQuilting/get_ssd.m:4 13 | cost=sum(sum(sum(temparr))) 14 | # ../../ImageQuilting/get_ssd.m:6 -------------------------------------------------------------------------------- /texture_transfer.py: -------------------------------------------------------------------------------- 1 | from smop.core import * 2 | import numpy as np 3 | import cv2 4 | import scipy 5 | import math 6 | from scipy import ndimage 7 | from find_mindelta import find_mindelta 8 | from cut import cut 9 | 10 | 11 | @function 12 | def texture_transfer(texture,target,patchsize,overlap,tol): 13 | 14 | outsize= size(target) 15 | outsize= [outsize[1],outsize[2]] 16 | 17 | xtrim = patchsize - ( outsize[1] - ((patchsize-overlap) * math.floor((outsize[1]-patchsize)/(patchsize-overlap)) + 1 + patchsize-overlap) ); 18 | ytrim = patchsize - ( outsize[0] - ((patchsize-overlap) * math.floor((outsize[0]-patchsize)/(patchsize-overlap)) + 1 + patchsize-overlap) ); 19 | 20 | 21 | outsize_ = outsize 22 | outsize_[0] = outsize_[0] + ytrim ; outsize_[1] = outsize_[1] + xtrim; 23 | 24 | if (size(target)[3] == 1): 25 | imout = np.zeros((outsize_)) 26 | 27 | else: 28 | imout= np.zeros((int(outsize_[0]),int(outsize_[1]),int(size(target)[3]))) 29 | 30 | for i in xrange(0, outsize_[0]-patchsize+1 ,patchsize-overlap): 31 | print i 32 | for j in xrange(0, outsize_[1]-patchsize+1 ,patchsize-overlap): 33 | if (i == 0 and j == 0): 34 | pos=find_mindelta(texture,target,[0,0],patchsize,tol) 35 | imout[i:i + patchsize - 1,j:j + patchsize - 1,:] = texture[int(pos[1]):int(pos[1]) + patchsize - 1,int(pos[2]):int(pos[2]) + patchsize - 1,:] 36 | 37 | else: 38 | if (i > outsize[0] - patchsize + 1): 39 | i_new=outsize[0] - patchsize + 1 40 | 41 | else: 42 | i_new=copy(i) 43 | 44 | if (j > outsize[1] - patchsize + 1): 45 | j_new=outsize[1] - patchsize + 1 46 | 47 | else: 48 | j_new=copy(j) 49 | 50 | currentpos=[i_new,j_new] 51 | 52 | patchpos=find_mindelta(texture,target,currentpos,patchsize,tol) 53 | 54 | imout=cut(texture,patchsize,overlap,imout,patchpos,currentpos) 55 | 56 | # imout=imout[1:outsize[1],1:outsize[2],:] 57 | return imout --------------------------------------------------------------------------------