Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab matalb中幂函数的快速逼近与实现_Matlab - Fatal编程技术网

Matlab matalb中幂函数的快速逼近与实现

Matlab matalb中幂函数的快速逼近与实现,matlab,Matlab,我可以在以下问题中找到C/C++的类似答案: 根据分析器,我的代码的瓶颈类似于以下代码: a=rand(100,1); % a is an array of doubles b=1.2; % power can be double instead of only integers. temp=power(a,b); % this line is taking maximum time 根据我的要求,只有前3-4位是有效的,所以任何快速的幂近似对我都非常有用。有什么建议可以这样做吗 更多信息:

我可以在以下问题中找到C/C++的类似答案:

根据分析器,我的代码的瓶颈类似于以下代码:

a=rand(100,1); % a is an array of doubles
b=1.2; % power can be double instead of only integers.
temp=power(a,b); % this line is taking maximum time
根据我的要求,只有前3-4位是有效的,所以任何快速的幂近似对我都非常有用。有什么建议可以这样做吗

更多信息: 这就是我使用exp和log计算功率的方法。这大约提高了50%。现在我需要找到log和exp的近似函数,并检查这是否更快

      a=rand(1000,1);

tic;
for i=1:100000
    powA=power(a,1.1);
end
toc;
tic;
for i=1:100000
    powB=exp(1.1*log(a));
end
toc;

Elapsed time is 4.098334 seconds.
Elapsed time is 1.994894 seconds.

从数学上讲,近似值应该知道
a
b
的范围,否则用
timeit
来计算代码的时间就太宽泛了。