Luna Moon <lunamoonmoon@gmail.com> wrote: <snip> > If vectorized computation is not facilitated, then I have to call this > function millions of times. > > But if vectorized computation is okay, then I can send in just a u > vector with batch elements a time. > > I have many such code in Matlab need to be converted into C++ with > vectorization. > > Any thoughts? > > Thank you! > > double t5, t6, t7, t9, t11, t13, t16, t20, t23, t27, t32, t34, t36, > t37, t38, t42, > t44, t47, t48, t51, t52, t54, t59, t60, t61, t66, t67, t69, t74, > t75, t76, t81, > t82, t84, t87, t105, t106, t110, t112; > > t5 = exp(-t * l1 - t * l2 - t * l3); > t6 = t * u; > t7 = mu1 * mu1; > t9 = u * u; > t11 = kappa * kappa; > t13 = 0.1e1 / (t9 * t7 + t11); This is out of my element, but I have written some vector code in GCC, just for my own edification. I'm not sure how you would translate the above code... I don't exactly see the vectors, unless I'm misinterpreting. Anyhow: http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Vector-Extensions.html#Vector-Extensions It's exceedingly simple. ICC and MSC support similar, though incompatible syntax. With GCC, make sure to manually specify -march, otherwise the generator won't have access to SSE instructions (or whatever your platform has). The biggest initial syntax gotcha I encountered was initializing the vector; the vector can be treated like an array, IIRC, but I encountered some hangups. Second, GCC has to load all the SSE registers, and other sourcery I wasn't acquainted with. There just seems like there'd be lots of headaches keeping the pipeline chugging along, depending on your data set, and where it comes from. Also, I have no idea if the syntax carriers over to C++. And perhaps GCC can already accomplish similar optimizations with valarrays. Either way, you'll definitely want to use the latest GCC 4.3 version, which AFAIK is at the moment king of the hill regarding auto-vectorization.

0 |

7/27/2008 1:29:16 AM

Is it possible to read C/C++ code in matlab and the other way around too? Hi, as long as C or C++ are written in text files you can edit them in the matlab editor. To see the special character of C or C++ coding language, in the editor go to menus: file>preferences>Edito/Debugger>language and on popup "Language" select "C/C++". This does not allow you to run the C/C++ code, just to view it i nicer way... regards, chris saneman <asdfsdf@asd.com> wrote in message <frl846 $f8i$2@news.net.uni-c.dk>... > Is it possible to read C/C...

Hi, I am reading the help documents about how to program matlab and C C++ together and my questions are a little bit general. It seems that are several ways to call matlab in C C++ and another several ways to call C C++ in matlab. Please correct me if I am wrong or missing something when I try to list them. To call matlab code in C C++, are there two methods available? The first one is Matlab engine and the second one is to use MATLAB Compiler mcc to create C or C++ shared libraries from your MATLAB code. To call C C++ in matlab, are there also two methods? The first one is to call funct...

I'm relatively new to the world of Matlab. I want to call my matlab own code from a C/C++ program on a machine with matlab installed. Do I need to compile the matlab code using matlab compiler tool or the matlab engine is enough for this? Thanks a lot for your help On Nov 28, 10:03 am, "Paeo Campigotto" <campigo...@dit.unitn.it> wrote: > I'm relatively new to the world of Matlab. > I want to call my matlab own code from a C/C++ program on a > machine with matlab installed. > Do I need to compile the matlab code using matlab compiler > tool or the matla...

Hi I've been asking on the net how to use MEX properly so that I can use C/C++ in MATLAB, but information is not forthcoming. There seems to be a lot on using MATLAB in C/C++ but not the other way around. I understand Mathworks is trying very hard to sell the Matlab Compiler, but even so, why is it SO hard to get information about MEX? Or is it that I've missed something very fundamental, meaning that I'm struggling over something that is actually quite easy? Any thoughts and info would be great. Thanks BullDog BullDog wrote: > Hi > > I've been asking on the net ...

I am working on conversion of .m files to c/c++. I am using the MATLAB compiler version 3.0 and MATLAB version 6.5.1. There seem to be a few functions which do not seem to get converted. The error i got while using functions like TRAIN, NETWORK and INIT (all neural-networks related functions used in the general neural network programs, newpnn.m etc) is The MATLAB compiler does not currently support MATLAB object oriented programming and the functions TRAIN , NETWORK and INIT would produce a run-time error. Could anyone please tell me as to how i can circumnavigate this problem or solve this...

I'm relatively new to the world of Matlab. I want to call my matlab own code from a C/C++ program on a machine with matlab installed. Do I need to compile the matlab code using matlab compiler tool or the matlab engine is enough for this? Thanks a lot for your help ...

I'm trying to create an object inside C++ and then pass it to Matlab via en= gPutVariable. It seems I can create a struct // Create a float array mxArray *acq_data =3D mxCreateNumericMatrix(0, 0, mxSINGLE_CLASS); float *data =3D (float *)mxCalloc(M*N, sizeof(float)); mxSetData(acq_data, data); mxSetM(acq_data, M); mxSetN(acq_data, N); // Convert to struct const char *fieldname =3D "data"; mxArray *acq_struct =3D mxCreateStructMatrix(1,1,1, &fieldname); mxSetField(acq_struct,i,"data",acq_data); // Convert to class ?? Does it work? if (j=3D=3D1...

I am trying to call and debug matlab code via C/C++. i am able to run the engdemo.c program but I cannot stop the debugger in a test MatLab file to see if this can be done. I would like the C/C++ program to spawn the MatLab environment so that I may have access to all the MatLab debugging tools but be able to read any inputs from the C/C++ calling function and return any modifications to those values back to the C/C++ function as well. I am running MatLab 6.5.1.199709 v 13. Does MatLab 7 have any added capability that I would need to do this? Reginald Robertson wrote: > > > I am tr...

Hello, I have a code. I need to change that code for matlab. I am wandering if there is an article so I can read before start. Thank you "Ongun Palaoglu" <ongun@mac.com> wrote in message <hae0r2$erv$1@fred.mathworks.com>... > Hello, I have a code. I need to change that code for matlab. I am wandering if there is an article so I can read before start. Thank you check matlab help and read mex file creation. its pretty simple to call c from matlab. "Maya " <priyaravi_22@yahoo.co.in> wrote in message <hae4mr$nf6$1@fred.mathworks.com>... > "Ongun Palaoglu" <ongun@mac.com> wrote in message <hae0r2$erv$1@fred.mathworks.com>... > > Hello, I have a code. I need to change that code for matlab. I am wandering if there is an article so I can read before start. Thank you > > check matlab help and read mex file creation. its pretty simple to call c from matlab. Dear Maya, I do not want to call the function. I want to change the language to Matlabs own language . "Ongun Palaoglu" <ongun@mac.com> wrote in message <hae5r1$59l$1@fred.mathworks.com>... > "Maya " <priyaravi_22@yahoo.co.in> wrote in message <hae4mr$nf6$1@fred.mathworks.com>... > > "Ongun Palaoglu" <ongun@mac.com> wrote in message <hae0r2$erv$1@fred.mathworks.com>... > > > Hello, I have a code. I need to change that code for matlab. I am wandering if th...

I was wondering if there is a way to control Matlab event loop? Is there a way to make Matlab be able to respond to key presses in Matlab GUI or call from C (via engine) and to either pause or stop its execution. I know that Matlab can execute items on its 'event queue' when pause() or drawnow() etc are called, but that means that I have to explicitly put those in the code. Is there some way that would be more elegant? Second question is about the 'event queue.' How does one add things to the event queue? How can I add a call from, say, C engine such as evalString() to the ev...

I know that this has probably been asked before but I desperately need to do this. I have simple scripts in Matlab and I would like to see what they look like in C language. Can anyone help me with this? I'm not a great C programer so this would help me immensly if I could see various examples of things that I have written in Matlab in C Thank you. Hi finiteguy, check the MATLAB help for the MATLAB Compiler, if you have. Regards, Stefan Hi Stefan, I tried that and got no help. Nothing about Matlab compiler. I kew that years ago there was a simple command but I lost it. On Mon, 30...

Is it possible to call MatLab or a MatLab function in C or C++? If so, where can I find info on how to do that? Mike On Feb 11, 8:57 am, "Michael Stachowsky" <mstachow...@gmail.com> wrote: > Is it possible to call MatLab or a MatLab function in C or > C++? If so, where can I find info on how to do that? > > Mike See the Matlab engine http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f38569.html Chris "Michael Stachowsky" <mstachowsky@gmail.com> wrote in message <fopk7d$bs2$1@fred.mathworks.com>... > Is it possibl...

well i attended the seminar this morning and found it really useful. so i decided to try the stuff out myself. I am using the same program that is provided in the slides of the seminar as below. #include "C:\MATLAB7\extern\include\engine.h" void main() { Engine *ep; double data_c[10] = {8,1,2,3,2,5,-1,7,8,3}; mxArray *data_ml; data_ml = mxCreateDoubleMatrix(1,10,mxREAL); memcpy((char *)mxGetPr(data_ml),(char *)data_c,10*sizeof(double)); ep = engOpen(NULL); // Transfer to MATLAB engPutVariable(ep,"data",data_ml); } everything seems to be working fine except th...

SUBJECT : Using matlab Engine. (Or Calling matlab from C). I have a problem in Calling matlab from C. Did any body used it before. I'm getting problem while Linking at Runtime.(During Build.. not while compiling). It Shows The Following Error Message. Error LNK2001 unresolved External Symbol. Even I couldn't Run the example program given by matlab. I tried engdemo.c and engwindemo.c given in $matlab/extern/examples/eng_mat/ I will truely, apprieciate all your help in this regard. Thanks, Kiran Chintal. hello, which compiler do you use? I tried BloodShed, and it didn't co...

Hi. I would like to convert a short .m file to C or C++ code. I have MATLAB compiler version 4.6. I used the following commands: mbuild -setup mcc -c MyFunction.m I recived the following error messages: "??? Unable to determine application type, since no wrapper function was specified. Please use the -W switch or specify application type via - m or -l. Type 'mcc -?' for further assistance." "Error: File "MyFunction" is a script M-file and cannot be compiled with the current Compiler. You may be able to correct this by converting this script into a fu...

Good day everyone, i'm already developed a system in matlab's fuzzy environment and i wrote the Mfile.Which i later compiled using the matlab compiler into both c and c++ codes..after setting the linker options in the visual c++ environment, i get the error below ------ Build started: Project: Bio, Configuration: Debug Win32 ------ Linking... LINK : fatal error LNK1104: cannot open file 'C:\Bio\Bio.obj' Build log was saved at "file://c:\Bio\Bio\Bio\Debug\BuildLog.htm" Bio - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ====...

Hi, I have installed MATLAB7 which includes MATLAB Compiler. It's mentioned that the MATLAB Compiler now includes MATLAB C/C++ Math and Graphics Libraries. In my case, there is no directory called "cmath" and "cppmath" in $MATLAB/extern/examples/. That means it is not installed. Should I need a License for it or same license is applicable. Where to get these libraries? Any idea. Thanks & Regards, Ardhendu Hi Ardhendu, MATLAB Compiler 4 dosen't include MATLAB C/C++ Math Library. To know what version you have, type command in MATLAB Command Workspace: >&...

Hi, I'm student and i'm working on wavelet foveation, my first version of m filles takes more than 4 hours to calculate results using 512*512 image, i tried to use matlab c ++ compiler in order to optimise time calculation (making full or partial stend alone application), problem : i had a lot of warnings and errors ! my question is about efficient manuals or books about making stand alone applications using matlab compiler (with visual interfaces if its posible, generating mex files under linux or dll's under windows). Thanks. Marie. On Sat, 15 Nov 2003 11:49:24 +0...

We have a signal processing application for doing frequency analysis of acoustic signals. The original signal is captured in a C struct: -------------------------------------------- typedef struct _sig { unsigned long length; float *data; } Sig; -------------------------------------------- Typical length is 10M, so the size of the data is 10M*sizeof(float)=40M. We want to apply FIR filter on this signal using Matlab MCR. I have built a Matlab DLL using the deploytool from the Compiler toolbox. In the Matlab DLL there is Filt.m that includes somethin...

I am currently trying to create a C++ - Matlab function call(on a Windows platform) where I am able to debug the Matlab function via the edit/debugger. Yes, I have used the MatLab Engine calls and the COM interface. However when i attempt to debug via the edit/debugger, I get the following error message sent to STDOUT: buffer 0x0012fda4 "Warning: Debug commands not available when using MATLAB as Engine. > In <a href="error:c:\matlab7\bin\win32\cMatlabTest.m,4,1">cMatlabTest at 4</a> Checked all 17 cache memory tables. Found no corrupted tables. We also at...

Hello, I have a problem calling C code from Matlab. The mex file compilation is ok. When I run the program Matlab (7.3) crashes. Below is the mexFunction code. Any idea is welcome. (I think the main part of the code (middle part) is not useful for the crash problem, but I put it anyway). //########################################################### #include "math.h" #include "mex.h" void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Standard variables int p,r,h,i,j,f,w; // Indices for loop int MAX_NBM = 1000; int MAX_DIM = 10; int MAX_NB_CLUST = 20; double *SF, *km, *new_data; int size, dim, K, nbm, aux_size, count_bis, count_aux; double diam_max, diam, vec1_p, vec2_p, dist_min, dis; int combi[1000000][2]; int dist_aux[1000000][2]; /* Check for proper number of arguments. */ if (nrhs != 5) { mexErrMsgTxt("5 input required."); } else if (nlhs > 1) { mexErrMsgTxt("Too many output arguments"); } // Input parameter (MATLAB) new_data = mxGetPr(prhs[0]); size = (int)mxGetScalar(prhs[1]); dim = (int)mxGetScalar(prhs[2]); K = (int)mxGetScalar(prhs[3]); km = mxGetPr(prhs[4]); // Output parameter (MATLAB) plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); SF = mxGetPr(plhs[0]); // Other variables nbm = size/dim; // Number of points printf("Taille: %d\n",nbm); printf("Dimension: %d\n",dim); //#############################...

hallo firends, Can any body help me write this below code into MATLAB object oriented code or C code form please? M=50; % total number of periods. (choose for 1s duration) f0 = 50; % fundamental AC frequency T0 = 1/f0; %fundamental AC period T = M*T0; %Time for M periods (integer M) N=30; % sample points per period. dt = T0/N; % Sample at N points per period (integer N > 20) t = dt*[1:M*N-1]; % Sampling time array A0=120/2; % amplitude of AC signal. Divide by 2 or maybe sqrt (2) ? AC=A0*sin(f0*t*2*pi); % create AC signal. DC0=50; % DC amplitude DC=DC0*ones(1,length(t)); % create a DC signal that is constant of length t S=AC+DC; % total signal is AC signal + DC signal figure(1); plot(t,S); % plot signal. xlabel('time');ylabel('Signal'); title('Total Signal'); % filter components fAC=S-mean(S); % here is the AC component fDC=mean(S); % here is the DC component figure(2); plot(t,fAC,'r',t,fDC,'b'); % plot AC and DC signals legend('AC','DC'); xlabel('time');ylabel('Signal'); title('Signal with only AC component'); figure(3); plot(t,fDC,'b'); % plot DC signal legend('DC'); xlabel('time');ylabel('Signal'); title('Signal with only DC component'); figure(4); % best to plot in Fourier domain u=abs(fftshift(fft(S))); NumPoints=length(t); freq=(1/dt)*[1:NumPoints]/NumPoints; % create frequency axis freq=fre...

Hello All, Please can I get some guidance on how to Convert a structure from Matlab code to C code using Matlab Compiler. Kind regards Sammy ...

I wanna use matlab C++ math library into VC++6.0, but my matlab is 7.1. if i wanna use matlab C++ math library to programme, how can i setup my VC link?? why matlab7.1 doesn't have "extern->include->cpp" file??? In using matlab C++ math library , what difference between matlab 6.X and matlab7.1??? ...

that follows a well-defined model understood and expressed as, for example, an algorithm , or a protocol . The study of computation is paramount ...

In computer science , evolutionary computation is a subfield of artificial intelligence (more particularly computational intelligence ) that ...

In a few days bit-player will celebrate its seventh birthday. (The first published post was dated January 9, 2006.) The original design for the ...

Get Bubble Math – Place Value Computation Tactics Educational Game for kids on the App Store. See screenshots and ratings, and read customer ...

Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to ...

Jonathan Koomey [Stanford University] Abstract: This talk will describe long-term trends in the electrical efficiency of computation that enabled ...

Curtin University has opened the Curtin Institute for Computation (CIC) in Western Australia to focus on computation and data analytics research. ...

Calculation compensates for fiber imperfection, may increase data rates.

MacArthur Fellow Luis von Ahn's programs harness human abilities to solve large-scale, complex problems The New York Times (NYT) has published ...

A lot of brain power missed the connection. Wolfram Research, Inc. has lost a Uniform Rapid Suspension (URS) case for mathematica.guru and wolfram.ceo, ...

Resources last updated: 3/15/2016 10:06:55 AM