您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 电子设计/PCB > 第20章ARM官方DSP库的MatrixFunctions的使用(二)
安安富富莱莱UUMM440033DDSSPP教教程程SSTTMM3322--VV55开开发发板板系系统统篇篇手手册册22001155年年0011月月1155日日版版本本::11..00第第11页页共共1144页页第第2200章章MMaattrriixxFFuunnccttiioonnss的的使使用用((二二))本期教程主要讲解矩阵运算中的放缩,乘法和转置。20.1矩阵放缩MatScale20.2矩阵乘法MatMult20.3转置矩阵MatTrans20.4总结2200..11矩矩阵阵放放缩缩MMaattSSccaallee2200..11..11aarrmm__mmaatt__ssccaallee__ff3322公式描述:函数定义如下:arm_statusarm_mat_scale_f32(constarm_matrix_instance_f32*pSrc,float32_tscale,arm_matrix_instance_f32*pDst)参数定义:[in]*pSrcpointstoinputmatrixstructure[in]scalescalefactortobeapplied[out]*pDstpointstooutputmatrixstructurereturnThefunctionreturnseithercodeARM_MATH_SIZE_MISMATCH/code2200..11..22aarrmm__mmaatt__ssccaallee__qq3311函数定义如下:arm_statusarm_mat_scale_q31(安安富富莱莱UUMM440033DDSSPP教教程程SSTTMM3322--VV55开开发发板板系系统统篇篇手手册册22001155年年0011月月1155日日版版本本::11..00第第22页页共共1144页页constarm_matrix_instance_q31*pSrc,q31_tscaleFract,int32_tshift,arm_matrix_instance_q31*pDst)参数定义:[in]*pSrcpointstoinputmatrix[in]scaleFractfractionalportionofthescalefactor[in]shiftnumberofbitstoshifttheresultby[out]*pDstpointstooutputmatrixstructurereturnThefunctionreturnseither注意事项:1.两个1.31格式的数据相乘产生2.62格式的数据,最终结果要做偏移和饱和运算产生1.31格式数据。2.定点数的最终放缩比例计算是:scale=scaleFract*2^shift.2200..11..33aarrmm__mmaatt__ssccaallee__qq1155函数定义如下:arm_statusarm_mat_scale_q15(constarm_matrix_instance_q15*pSrc,q15_tscaleFract,int32_tshift,arm_matrix_instance_q15*pDst)参数定义:[in,out]*Spointstoaninstanceofthefloating-pointmatrixstructure.[in]nRowsnumberofrowsinthematrix.[in]nColumnsnumberofcolumnsinthematrix.[in]*pDatapointstothematrixdataarray.注意事项:1.两个1.15格式的数据相乘产生2.30格式的数据,最终结果要做偏移和饱和运算产生1.15格式数据。2.定点数的最终放缩比例计算是:scale=scaleFract*2^shift.2200..11..44实实例例讲讲解解实验目的:1.学习MatrixFunctions中矩阵的放缩实验内容:1.按下按键K1,串口打印函数DSP_MatScale的输出结果安安富富莱莱UUMM440033DDSSPP教教程程SSTTMM3322--VV55开开发发板板系系统统篇篇手手册册22001155年年0011月月1155日日版版本本::11..00第第33页页共共1144页页实验现象:通过窗口上位机软件SecureCRT(V5光盘里面有此软件)查看打印信息现象如下:程序设计:/***********************************************************************************************************函数名:DSP_MatScale*功能说明:矩阵放缩*形参:无*返回值:无**********************************************************************************************************/staticvoidDSP_MatScale(void){uint8_ti;/****浮点数数组******************************************************************/float32_tpDataA[9]={1.1f,1.1f,2.1f,2.1f,3.1f,3.1f,4.1f,4.1f,5.1f};float32_tscale=1.1f;float32_tpDataDst[9];arm_matrix_instance_f32pSrcA;//3行3列数据arm_matrix_instance_f32pDst;/****定点数Q31数组******************************************************************/q31_tpDataA1[9]={1,1,2,2,3,3,4,4,5};q31_tscaleFract=10;int32_tshift=0;q31_tpDataDst1[9];arm_matrix_instance_q31pSrcA1;//3行3列数据arm_matrix_instance_q31pDst1;/****定点数Q15数组******************************************************************/安安富富莱莱UUMM440033DDSSPP教教程程SSTTMM3322--VV55开开发发板板系系统统篇篇手手册册22001155年年0011月月1155日日版版本本::11..00第第44页页共共1144页页q15_tpDataA2[9]={1,1,2,2,3,3,4,4,5};q15_tscaleFract1=10;int32_tshift1=0;q15_tpDataDst2[9];arm_matrix_instance_q15pSrcA2;//3行3列数据arm_matrix_instance_q15pDst2;/****浮点数***********************************************************************/pSrcA.numCols=3;pSrcA.numRows=3;pSrcA.pData=pDataA;pDst.numCols=3;pDst.numRows=3;pDst.pData=pDataDst;printf(****浮点数******************************************\r\n);arm_mat_scale_f32(&pSrcA,scale,&pDst);for(i=0;i9;i++){printf(pDataDst[%d]=%f\r\n,i,pDataDst[i]);}/****定点数Q31***********************************************************************/pSrcA1.numCols=3;pSrcA1.numRows=3;pSrcA1.pData=pDataA1;pDst1.numCols=3;pDst1.numRows=3;pDst1.pData=pDataDst1;printf(****定点数Q31******************************************\r\n);arm_mat_scale_q31(&pSrcA1,scaleFract,shift,&pDst1);for(i=0;i9;i++){printf(pDataDst1[%d]=%d\r\n,i,pDataDst1[i]);}/****定点数Q15***********************************************************************/pSrcA2.numCols=3;pSrcA2.numRows=3;pSrcA2.pData=pDataA2;pDst2.numCols=3;pDst2.numRows=3;pDst2.pData=pDataDst2;printf(****定点数Q15******************************************\r\n);arm_mat_scale_q15(&pSrcA2,scaleFract1,shift1,&pDst2);for(i=0;i9;i++){printf(pDataDst2[%d]=%d\r\n,i,pDataDst2[i]);}}1.下面通过matlab来实现矩阵的放缩:安安富富莱莱UUMM440033DDSSPP教教程程SSTTMM3322--VV55开开发发板板系系统统篇篇手手册册22001155年年0011月月1155日日版版本本::11..00第第55页页共共1144页页2200..22矩矩阵阵乘乘法法MMaattMMuulltt2200..22..22aarrmm__mmaatt__mmuulltt__ff3322公式描述:函数定义如下:arm_statusarm_mat_mult_f32(constarm_matrix_instance_f32*pSrcA,constarm_matrix_instance_f32*pSrcB,arm_matrix_instance_f32*pDst)参数定义:[in]*pSrcApointstothefirstinputmatrixstructure[in]*pSrcBpointstothesecondinputmatrixstructure[out]*pDstpointstooutputmatrixstructurereturnThefunctionreturnseither注意事项:1.两个矩阵MxN和NxP相乘的结果是MxP.(必须保证一个矩形的列数等于另一个矩阵的行数)。2200..22..33aarrmm__mmaatt__mmuulltt__qq3311函数定义如下:arm_statusarm_mat_mult_q31(constarm_matrix_instance_q31*pSrcA,安安富富莱莱UUMM440033DDSSPP教教程程SSTTMM3322--VV55开开发发板板系系统统篇篇手手册册22001155年年0011月月1155日日版版本本::11..00第第66页页共共1144页页constarm_matrix_instance_q31*pSrcB,arm_matrix_instance_q31*pDst)参数定义:[in]*pSrcApointstothefirstinputmatrixstructure[in]*pSrcBpointstothesecondinputmatrixstructure
本文标题:第20章ARM官方DSP库的MatrixFunctions的使用(二)
链接地址:https://www.777doc.com/doc-5071627 .html