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

Cell operations: added sqrt and another variant of exponential


Signed-off-by: default avatarNicola Vigano <nicola.vigano@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@663 4c865b51-4357-4376-afb4-474e03ccb993
parent 2af16018
No related branches found
No related tags found
No related merge requests found
/*
* internal_cell_exponent.cpp
*
* Created on: Jul 10, 2012
*
* Nicola Vigano', 2012, ID11 @ ESRF vigano@esrf.eu
*/
#include "internal_cell_defs.h"
void mexFunction( int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[] )
{
if (nrhs != 2) {
mexErrMsgIdAndTxt("C_FUN:cell_exponent_wrong_argument",
"Not enough arguments! you need to provide a cell array and a double");
}
if (!mxIsCell(prhs[0])) {
mexErrMsgIdAndTxt("C_FUN:cell_exponent_wrong_argument",
"The first argument should be a Cell array");
}
if (!mxIsDouble(prhs[1])) {
mexErrMsgIdAndTxt("C_FUN:cell_exponent_wrong_argument",
"The second argument should be a double containing the exponent");
}
const double exponent = *mxGetPr(prhs[1]);
plhs[0] = (mxArray *) prhs[0];
inner_pow<const double, const double> func(exponent);
cell_iteration<false>(plhs[0], prhs[0], func);
}
/*
* internal_cell_exponent.cpp
*
* Created on: Jul 10, 2012
*
* Nicola Vigano', 2012, ID11 @ ESRF vigano@esrf.eu
*/
#include "internal_cell_defs.h"
void mexFunction( int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[] )
{
if (nrhs != 1) {
mexErrMsgIdAndTxt("C_FUN:cell_exponent_wrong_argument",
"Not enough arguments! you need to provide a cell array and a double");
}
if (!mxIsCell(prhs[0])) {
mexErrMsgIdAndTxt("C_FUN:cell_exponent_wrong_argument",
"The first argument should be a Cell array");
}
plhs[0] = (mxArray *) prhs[0];
inner_sqrt<const double, const double> funcNonVect;
#if defined(__SSE2__) || defined(__SSE2_MATH__)
inner_sqrt<const v2df, const v2df> func;
cell_iteration_sse<false>(plhs[0], prhs[0], func, funcNonVect);
#else
cell_iteration<false>(plhs[0], prhs[0], funcNonVect);
#endif
}
/*
* internal_cell_exponent.cpp
*
* Created on: Jul 10, 2012
*
* Nicola Vigano', 2012, ID11 @ ESRF vigano@esrf.eu
*/
#include "internal_cell_defs.h"
void mexFunction( int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[] )
{
if (nrhs != 1) {
mexErrMsgIdAndTxt("C_FUN:cell_exponent_wrong_argument",
"Not enough arguments! you need to provide a cell array and a double");
}
if (!mxIsCell(prhs[0])) {
mexErrMsgIdAndTxt("C_FUN:cell_exponent_wrong_argument",
"The first argument should be a Cell array");
}
inner_sqrt<const double, const double> funcNonVect;
#if defined(__SSE2__) || defined(__SSE2_MATH__)
inner_sqrt<const v2df, const v2df> func;
cell_iteration_sse<true>(plhs[0], prhs[0], func, funcNonVect);
#else
cell_iteration<true>(plhs[0], prhs[0], funcNonVect);
#endif
}
......@@ -41,6 +41,28 @@ public:
}
};
template<typename Type1, typename Type2>
class inner_sqrt {
public:
const Type2
operator()(Type1 & inData1, Type2 & inData2) const throw()
{
return sqrt(inData2); // __builtin_ia32_sqrtpd
}
};
#if defined(__SSE2__) || defined(__SSE2_MATH__)
template<>
class inner_sqrt<const v2df, const v2df> {
public:
const v2df
operator()(const v2df & inData1, const v2df & inData2) const throw()
{
return __builtin_ia32_sqrtpd(inData2);
}
};
#endif
template<typename Type1, typename Type2>
class inner_sum {
public:
......
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