Skip to content
Snippets Groups Projects
Commit f20928b0 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

C++/mex: cleanup old unused code

parent 795b7ea0
No related branches found
No related tags found
No related merge requests found
/*
* gt6DBlobsToSingleSino_c.cpp
*
* Created on: Oct 30, 2014
* Author: vigano
*/
#include "gt6DBlobsSinogramsTransforms.h"
void mexFunction( int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[] )
{
if (nrhs < 3) {
mexErrMsgIdAndTxt(GT6D::transforms_error_id,
"Not enough arguments!");
return;
}
const mxArray * const blobs = prhs[1];
const mxArray * const coeffs = prhs[2];
if (!GT6D::check_coeffs(coeffs))
{
return;
}
if (!mxIsNumeric(prhs[0])) {
mexErrMsgIdAndTxt(GT6D::transforms_error_id,
"The first argument should be an array (Sinogram sizes)");
return;
}
if (!mxIsCell(blobs)) {
mexErrMsgIdAndTxt(GT6D::transforms_error_id,
"The second argument should be a Cell array (Blobs)");
return;
}
const mxClassID class_id = getMxClassOfCell(blobs);
if (class_id == mxUNKNOWN_CLASS)
{
mexErrMsgIdAndTxt(GT6D::transforms_error_id,
"The blobs need to be a non empty Cell array of coherent floating point types");
return;
}
if (nrhs >= 4)
{
initialize_multithreading(mxGetScalar(prhs[3]));
}
else
{
initialize_multithreading();
}
mxArray * const sino = GT6D::allocate_sino_from_dims(prhs[0], class_id);
if (!sino)
{
return;
}
plhs[0] = sino;
if (!GT6D::check_blobs_and_single_sinogram(sino, blobs, coeffs))
{
return;
}
switch (class_id)
{
case mxDOUBLE_CLASS:
{
{
GT6D::do_blobs_to_single_sinogram<double>(sino, blobs, coeffs);
}
break;
}
case mxSINGLE_CLASS:
{
{
GT6D::do_blobs_to_single_sinogram<float>(sino, blobs, coeffs);
}
break;
}
default:
{
mexErrMsgIdAndTxt(GT6D::transforms_error_id,
"The argument needs to be a Cell array of floating point numbers");
return;
}
}
}
/*
* gt6DCheckSinoBlobsCoeffs_c.cpp
*
* Created on: Oct 30, 2014
* Author: vigano
*/
#include "gt6DBlobsSinogramsTransforms.h"
void mexFunction( int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[] )
{
GT6D::check_full_incoming_args_blobs_and_sino(nrhs, prhs);
}
/*
* gt6DSingleSinoToBlobs_c.cpp
*
* Created on: Oct 31, 2014
* Author: vigano
*/
#include "gt6DBlobsSinogramsTransforms.h"
void mexFunction( int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[] )
{
if (nrhs < 3) {
mexErrMsgIdAndTxt(GT6D::transforms_error_id,
"Not enough arguments!");
return;
}
const mxArray * const in_blobs = prhs[0];
const mxArray * const sino = prhs[1];
const mxArray * const coeffs = prhs[2];
if (!GT6D::check_coeffs(coeffs))
{
return;
}
if (!mxIsCell(in_blobs)) {
mexErrMsgIdAndTxt(GT6D::transforms_error_id,
"The first argument should be a Cell array (Blobs)");
return;
}
if (!mxIsNumeric(sino)) {
mexErrMsgIdAndTxt(GT6D::transforms_error_id,
"The second argument should be an array (Sinogram)");
return;
}
if (nrhs >= 4)
{
initialize_multithreading(mxGetScalar(prhs[3]));
}
else
{
initialize_multithreading();
}
if (!GT6D::check_blobs_and_single_sinogram(sino, in_blobs, coeffs))
{
return;
}
plhs[0] = mxCreateSharedDataCopy(in_blobs);
const mxClassID class_id = getMxClassOfCell(in_blobs);
if (class_id != mxGetClassID(sino))
{
mexErrMsgIdAndTxt(GT6D::transforms_error_id,
"The sinogram needs to be an array of coherent floating point type, with the arrays in the Blob cell");
return;
}
switch (class_id)
{
case mxDOUBLE_CLASS:
{
{
GT6D::do_single_sinogram_to_blobs<double>(plhs[0], sino, coeffs);
}
break;
}
case mxSINGLE_CLASS:
{
{
GT6D::do_single_sinogram_to_blobs<float>(plhs[0], sino, coeffs);
}
break;
}
case mxUNKNOWN_CLASS:
{
mexErrMsgIdAndTxt(GT6D::transforms_error_id,
"The argument needs to be a non empty Cell array of coherent floating point types");
return;
}
default:
{
mexErrMsgIdAndTxt(GT6D::transforms_error_id,
"The argument needs to be a Cell array of floating point numbers");
return;
}
}
}
This diff is collapsed.
This diff is collapsed.
/*
* parallelization.h
*
* Created on: Jan 24, 2017
* Author: vigano
*/
#ifndef ZUTIL_CXX_INCLUDE_PARALLELIZATION_OMP_H_
#define ZUTIL_CXX_INCLUDE_PARALLELIZATION_OMP_H_
#include <omp.h>
void
initialize_multithreading(const double & suggested_num_threads = 0)
{
#ifndef DEBUG
if (suggested_num_threads > 0)
{
int num_threads = (const int)suggested_num_threads;
num_threads = std::min(num_threads, omp_get_num_procs());
num_threads = std::max(num_threads, 1);
omp_set_num_threads(num_threads);
}
else
{
omp_set_num_threads(std::max(omp_get_num_procs()/4*3, 1));
}
#endif
}
#endif /* ZUTIL_CXX_INCLUDE_PARALLELIZATION_OMP_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment