"James Tursa" wrote in message <jdp3od$esi$
1...@newscl01ah.mathworks.com>...
Ok, understood, I will use mtimesx.
Regarding the formula B = sum_i [ (A*S(:,:,i)*A)^0.5 ], the square root is inside the sum and the dimensions of A are nxn, where n can be 1 or 3 and S is nxnxM, where the value of M depends but it is normally between 2 and 15. So, the space is not as important as the time it takes to do the computations, given that I will need to iterate this formula 20000 times, more specifically, I want to implement:
for j=1:20000
B = sum_i [ (A*S(:,:,i)*A)^0.5 ];
A = B^0.5;
end
For the pow(XX,0.5), is there a fast way of executing it in mex? I was planning to call the mexcallMATLAB, something like:
mxArray * squareRoot( mxArray *Input){
//inputs
mxArray* params[2];
params[0] = Input;
params[1] = mxCreateDoubleScalar(0.5); //power=0.5
mwSize n = mxGetM(Input);
//outputs
mxArray *Output[1];
Output[0] = mxCreateDoubleMatrix(n, n + n - 1, mxCOMPLEX);
/* get the square root */
mexCallMATLAB(1, Output, 2, params, "mpower");
return(Output[0]);
}
and then sum along "i" in the formula and every position using a regular C loop.