Prev: Dynamically allocate space for mxArray (C Mex)
Next: Fitting Pareto distribution CDF to ECDF of data
From: Matt J on 26 Jul 2010 17:22 "Avinash " <avinash_varna_remove_this(a)yahoo.com> wrote in message <i2knm1$s2v$1(a)fred.mathworks.com>... > > @Matt, > While I understand that bsxfun is designed to operate element-wise, it can still be used for functions that do not operate element-wise, but produce an output of the same size as the input. In the above example, if I change fun to: > ----------------- > function out = fun1(in1, in2) > out = sum(in1+in2)*ones(size(in1)); > ----------------- > then bsxfun(@fun1, A, v) is still (slightly) faster than the for loop. ========== But even in this case, bsxfun can infer what the output data size will be, whereas your proposed colfun cannot. Also, even if bsxfun allows you to do this, it might be bit unpredictable to do so. As far as I can see in the bsxfun documentation, you never know a priori what chunk of data in A gets passed as in1. Will bsxfun operate row-by-row on A or column-by-column? If the operation is not element-wise or order-independent, you could get different results for each case. Regardless, if you're going to avoid these dangers in your proposed colfun, the user will need to be given control of the processing order, so it won't be a straightforward extension of bsxfun...
First
|
Prev
|
Pages: 1 2 Prev: Dynamically allocate space for mxArray (C Mex) Next: Fitting Pareto distribution CDF to ECDF of data |