完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我的程序里面用到cos函数进行计算,如果单纯的用math.c计算一次大概将近2ms,用arm_math.c可以提升到0.5ms,同时我用STM32f1测试,用math.c大概就0.115ms,请问一下差别真有这么大吗,或者是我自己那块搞错了...
|
|
相关推荐
6个回答
|
|
关键NUC支持DSP指令和浮点运算单元
|
|
|
|
你开启浮点运算了吗?是不是需要进行设置
|
|
|
|
一个就是系统初始化 再就是配置,计算结果是正确的 所以..........
|
|
|
|
你要调用DSP的库操作才行。
|
|
|
|
#include
#include "arm_math.h" /* ---------------------------------------------------------------------- * Defines each of the tests performed * ------------------------------------------------------------------- */ #define MAX_BLOCKSIZE 32 #define DELTA (0.000001f) /* ---------------------------------------------------------------------- * Test input data for Floating point sin_cos example for 32-blockSize * Generated by the MATLAB randn() function * ------------------------------------------------------------------- */ const float32_t testInput_f32[MAX_BLOCKSIZE] = { -1.244916875853235400, -4.793533929171324800, 0.360705030233248850, 0.827929644170887320, -3.299532218312426900, 3.427441903227623800, 3.422401784294607700, -0.108308165334010680, 0.941943896490312180, 0.502609575000365850, -0.537345278736373500, 2.088817392965764500, -1.693168684143455700, 6.283185307179590700, -0.392545884746175080, 0.327893095115825040, 3.070147440456292300, 0.170611405884662230, -0.275275082396073010, -2.395492805446796300, 0.847311163536506600, -3.845517018083148800, 2.055818378415868300, 4.672594161978930800, -1.990923030266425800, 2.469305197656249500, 3.609002606064021000, -4.586736582331667500, -4.147080139136136300, 1.643756718868359500, -1.150866392366494800, 1.985805026477433800 }; const float32_t testRefOutput_f32 = 1.000000000; /* ---------------------------------------------------------------------- * Declare Global variables * ------------------------------------------------------------------- */ uint32_t blockSize = 32; float32_t testOutput; float32_t cosOutput; float32_t sinOutput; float32_t cosSquareOutput; float32_t sinSquareOutput; /* ---------------------------------------------------------------------- * Max magnitude FFT Bin test * ------------------------------------------------------------------- */ arm_status status; int32_t main(void) { float32_t diff; uint32_t i; for(i=0; i< blockSize; i++) { cosOutput = arm_cos_f32(testInput_f32[i]); sinOutput = arm_sin_f32(testInput_f32[i]); arm_mult_f32(&cosOutput, &cosOutput, &cosSquareOutput, 1); arm_mult_f32(&sinOutput, &sinOutput, &sinSquareOutput, 1); arm_add_f32(&cosSquareOutput, &sinSquareOutput, &testOutput, 1); /* absolute value of difference between ref and test */ diff = fabsf(testRefOutput_f32 - testOutput); /* Comparison of sin_cos value with reference */ if(diff > DELTA) { status = ARM_MATH_TEST_FAILURE; } if( status == ARM_MATH_TEST_FAILURE) { while(1); } } while(1); /* main function does not return */ } /** endlink */ |
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
298 浏览 1 评论
《DNESP32S3使用指南-IDF版_V1.6》第二十六章 INFRARED_RECEPTION实验
309 浏览 0 评论
826 浏览 0 评论
求助一下关于51系列单片机的Timer0的计时问题,TH0、TL0+1的时间是怎么算的?
1911 浏览 2 评论
【RA-Eco-RA4E2-64PIN-V1.0开发板试用】开箱+Keil环境搭建+点灯+点亮OLED
1427 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
12031 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 21:42 , Processed in 0.826170 second(s), Total 85, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号