diff options
Diffstat (limited to 'matlab/mex')
-rw-r--r-- | matlab/mex/astra_mex_algorithm_c.cpp | 4 | ||||
-rw-r--r-- | matlab/mex/astra_mex_data3d_c.cpp | 2 | ||||
-rw-r--r-- | matlab/mex/mexCopyDataHelpFunctions.cpp | 42 | ||||
-rw-r--r-- | matlab/mex/mexDataManagerHelpFunctions.cpp | 12 | ||||
-rw-r--r-- | matlab/mex/mexDataManagerHelpFunctions.h | 10 | ||||
-rw-r--r-- | matlab/mex/mexHelpFunctions.h | 10 |
6 files changed, 55 insertions, 25 deletions
diff --git a/matlab/mex/astra_mex_algorithm_c.cpp b/matlab/mex/astra_mex_algorithm_c.cpp index f719a6b..be1c89f 100644 --- a/matlab/mex/astra_mex_algorithm_c.cpp +++ b/matlab/mex/astra_mex_algorithm_c.cpp @@ -32,13 +32,14 @@ $Id$ */ #include <mex.h> #include "mexHelpFunctions.h" +#include "astra/Globals.h" #define USE_MATLAB_UNDOCUMENTED #ifdef USE_MATLAB_UNDOCUMENTED extern "C" { bool utIsInterruptPending(); } -#ifdef __linux__ +#ifdef USE_PTHREADS #define USE_PTHREADS_CTRLC #include <pthread.h> #else @@ -49,7 +50,6 @@ extern "C" { bool utIsInterruptPending(); } -#include "astra/Globals.h" #include "astra/AstraObjectManager.h" #include "astra/AstraObjectFactory.h" diff --git a/matlab/mex/astra_mex_data3d_c.cpp b/matlab/mex/astra_mex_data3d_c.cpp index db81519..35a7512 100644 --- a/matlab/mex/astra_mex_data3d_c.cpp +++ b/matlab/mex/astra_mex_data3d_c.cpp @@ -79,7 +79,7 @@ void astra_mex_data3d_create(int& nlhs, mxArray* plhs[], int& nrhs, const mxArra } if (data && !checkDataType(data)) { - mexErrMsgTxt("Data must be single or double."); + mexErrMsgTxt("Data must be single, double or logical."); return; } diff --git a/matlab/mex/mexCopyDataHelpFunctions.cpp b/matlab/mex/mexCopyDataHelpFunctions.cpp index bbcad30..6dfd4a6 100644 --- a/matlab/mex/mexCopyDataHelpFunctions.cpp +++ b/matlab/mex/mexCopyDataHelpFunctions.cpp @@ -1,13 +1,13 @@ /* ----------------------------------------------------------------------- -Copyright 2013 iMinds-Vision Lab, University of Antwerp +Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp + 2014-2015, CWI, Amsterdam -Contact: astra@ua.ac.be -Website: http://astra.ua.ac.be +Contact: astra@uantwerpen.be +Website: http://sf.net/projects/astra-toolbox +This file is part of the ASTRA Toolbox. -This file is part of the -All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). The ASTRA Toolbox is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,7 +40,6 @@ $Id$ #if defined(__SSE2__) # include <emmintrin.h> - # define STORE_32F_64F_CORE8(in, out, count, base) \ {\ const __m128 inV0 = *((const __m128 *) &in[count + 0 + base]);\ @@ -108,6 +107,17 @@ $Id$ out[count + 7 + base] = in[count + 7 + base];\ } #endif +#define STORE_8F_32F_CORE8(in, out, count, base) \ + {\ + out[count + 0 + base] = (float)in[count + 0 + base];\ + out[count + 1 + base] = (float)in[count + 1 + base];\ + out[count + 2 + base] = (float)in[count + 2 + base];\ + out[count + 3 + base] = (float)in[count + 3 + base];\ + out[count + 4 + base] = (float)in[count + 4 + base];\ + out[count + 5 + base] = (float)in[count + 5 + base];\ + out[count + 6 + base] = (float)in[count + 6 + base];\ + out[count + 7 + base] = (float)in[count + 7 + base];\ + } const char * warnDataTypeNotSupported = "Data type not supported: nothing was copied"; @@ -118,6 +128,7 @@ _copyMexToCFloat32Array(const mxArray * const inArray, astra::float32 * const ou const long long block = 32; const long long totRoundedPixels = ROUND_DOWN(tot_size, block); + // Array of doubles if (mxIsDouble(inArray)) { const double * const pdMatlabData = mxGetPr(inArray); @@ -133,6 +144,8 @@ _copyMexToCFloat32Array(const mxArray * const inArray, astra::float32 * const ou out[count] = pdMatlabData[count]; } } + + // Array of floats else if (mxIsSingle(inArray)) { const float * const pfMatlabData = (const float *)mxGetData(inArray); @@ -148,6 +161,23 @@ _copyMexToCFloat32Array(const mxArray * const inArray, astra::float32 * const ou out[count] = pfMatlabData[count]; } } + + // Array of logicals + else if (mxIsLogical(inArray)) { + const mxLogical * const pfMatlabData = (const mxLogical *)mxGetLogicals(inArray); + +#pragma omp for nowait + for (long long count = 0; count < totRoundedPixels; count += block) { + STORE_8F_32F_CORE8(pfMatlabData, out, count, 0); + STORE_8F_32F_CORE8(pfMatlabData, out, count, 8); + STORE_8F_32F_CORE8(pfMatlabData, out, count, 16); + STORE_8F_32F_CORE8(pfMatlabData, out, count, 24); + } +#pragma omp for nowait + for (long long count = totRoundedPixels; count < tot_size; count++) { + out[count] = pfMatlabData[count]; + } + } else { #pragma omp single nowait mexWarnMsgIdAndTxt("ASTRA_MEX:wrong_datatype", warnDataTypeNotSupported); diff --git a/matlab/mex/mexDataManagerHelpFunctions.cpp b/matlab/mex/mexDataManagerHelpFunctions.cpp index 5e6020b..f9d971c 100644 --- a/matlab/mex/mexDataManagerHelpFunctions.cpp +++ b/matlab/mex/mexDataManagerHelpFunctions.cpp @@ -1,13 +1,13 @@ /* ----------------------------------------------------------------------- -Copyright 2013 iMinds-Vision Lab, University of Antwerp +Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp + 2014-2015, CWI, Amsterdam -Contact: astra@ua.ac.be -Website: http://astra.ua.ac.be +Contact: astra@uantwerpen.be +Website: http://sf.net/projects/astra-toolbox +This file is part of the ASTRA Toolbox. -This file is part of the -All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). The ASTRA Toolbox is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -105,7 +105,7 @@ checkID(const astra::int32 & id, astra::CFloat32Data3DMemory *& pDataObj) bool checkDataType(const mxArray * const in) { - return (mex_is_scalar(in) || mxIsDouble(in) || mxIsSingle(in)); + return (mex_is_scalar(in) || mxIsDouble(in) || mxIsSingle(in) || mxIsLogical(in)); } //----------------------------------------------------------------------------------------- diff --git a/matlab/mex/mexDataManagerHelpFunctions.h b/matlab/mex/mexDataManagerHelpFunctions.h index 36b74d8..0614e05 100644 --- a/matlab/mex/mexDataManagerHelpFunctions.h +++ b/matlab/mex/mexDataManagerHelpFunctions.h @@ -1,13 +1,13 @@ /* ----------------------------------------------------------------------- -Copyright 2013 iMinds-Vision Lab, University of Antwerp +Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp + 2014-2015, CWI, Amsterdam -Contact: astra@ua.ac.be -Website: http://astra.ua.ac.be +Contact: astra@uantwerpen.be +Website: http://sf.net/projects/astra-toolbox +This file is part of the ASTRA Toolbox. -This file is part of the -All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). The ASTRA Toolbox is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/matlab/mex/mexHelpFunctions.h b/matlab/mex/mexHelpFunctions.h index 425b4ef..84372ba 100644 --- a/matlab/mex/mexHelpFunctions.h +++ b/matlab/mex/mexHelpFunctions.h @@ -1,13 +1,13 @@ /* ----------------------------------------------------------------------- -Copyright 2012 iMinds-Vision Lab, University of Antwerp +Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp + 2014-2015, CWI, Amsterdam -Contact: astra@ua.ac.be -Website: http://astra.ua.ac.be +Contact: astra@uantwerpen.be +Website: http://sf.net/projects/astra-toolbox +This file is part of the ASTRA Toolbox. -This file is part of the -All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox"). The ASTRA Toolbox is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by |