Could you please compile this as mex for windows 64 bit ? I can not run the compiler. Faster exp function with reduced accuracy.

1 回表示 (過去 30 日間)
Code for Exp function with reduced accuracy. I can not compile it.
Code from
#include <stddef.h>
#include <math.h>
#include "mex.h"
#ifndef mwSize
#define mwSize int
#endif
/* these 2 #define lines help make the later code more
readable */
/* Input Arguments */
#define PARAMETER_IN prhs[0]
/* Output Arguments */
#define RESULT_OUT plhs[0]
#define LITTLE_ENDIAN 1
static union
{
double d;
struct {
#ifdef LITTLE_ENDIAN
int j,i;
#else
int i,j;
#endif
} n;
} _eco;
#define EXP_A (1048576/0.69314718055994530942)
#define EXP_C 60801
#define EXP(y) (_eco.n.i = EXP_A*(y) + (1072693248 - EXP_C), _eco.d)
void mexexp(double*y, double*yp, mwSize m) {
while(m--) {
*yp++ = EXP(*y++);
}
}
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray*prhs[] )
{
mwSize numel;
mwSize ndim;
mwSize *dims;
/* Check for proper number of arguments */
if (nrhs != 1) {
mexErrMsgTxt("One input argument required.");
} else if (nlhs > 1) {
mexErrMsgTxt("Too many output arguments.");
} else if ( !mxIsDouble(PARAMETER_IN) ) {
mexErrMsgTxt("Input must be double.");
} else if ( mxIsComplex(PARAMETER_IN) ) {
mexErrMsgTxt("Input cannot be complex.");
}
ndim = mxGetNumberOfDimensions(PARAMETER_IN);
dims = mxGetDimensions(PARAMETER_IN);
numel = mxGetNumberOfElements(PARAMETER_IN);
/* Create a matrix for the return argument */
RESULT_OUT = mxCreateNumericArray(ndim, dims,
mxDOUBLE_CLASS, mxREAL);
/* Do the actual computation*/
mexexp(mxGetPr(PARAMETER_IN),mxGetPr(RESULT_OUT),numel);
return;
}
  4 件のコメント
Ole
Ole 2015 年 3 月 14 日
>> mex -setup Error using mex No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2015a/win64.html.
I can not install SDK for some reason.
>> gcc -o fastexp fastexp.c -lm Undefined function or variable 'gcc'.
Jan
Jan 2015 年 3 月 15 日
GCC is a compiler under Linux. Before you can activate the compiler from the SDK for Windows, you have to download and install the SDK at first. Did you follow the instructions at http://www.mathworks.com/support/compilers/R2015a/win64.html carefully?

サインインしてコメントする。

採用された回答

Jan
Jan 2015 年 3 月 14 日
編集済み: Jan 2015 年 3 月 14 日
Here is a compiled version: RoughExp.mex
You might need the MSVC 2010 runtime libs, if you did not install them before: http://www.microsoft.com/en-us/download/details.aspx?id=14632

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTroubleshooting in MATLAB Compiler SDK についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by