C语言实现复数矩阵乘法(不使用complex.h) ,转置 和求逆应该如何实现,如果使用二维 数组的 方法该怎么构造 结构体?
1.矩阵与自身转置相乘之后得到是对称矩阵 ,如何分配 内存空间 ?
![](https://profile-avatar.csdnimg.cn/default.jpg!4)
C语言实现复数矩阵乘法(不使用complex.h) ,转置 和求逆应该如何实现,如果使用二维 数组的 方法该怎么构造 结构体
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
关注
/* NAME */ /* DSPF_dp_mat_mul_cplx -- Complex matrix multiplication */ /* */ /* USAGE */ /* */ /* This routine has the following C prototype: */ /* */ /* void DSPF_dp_mat_mul_cplx( */ /* const double* x, */ /* int r1, */ /* int c1, */ /* const double* y, */ /* int c2, */ /* double* restrict r */ /* ) */ /* */ /* x[2*r1*c1]: Input matrix containing r1*c1 complex */ /* floating point numbers having r1 rows and c1 */ /* columns of complex numbers. */ /* r1 : No. of rows in matrix x. */ /* c1 : No. of columns in matrix x. */ /* Also no. of rows in matrix y. */ /* y[2*c1*c2]: Input matrix containing c1*c2 complex */ /* floating point numbers having c1 rows and c2 */ /* columns of complex numbers. */ /* c2 : No. of columns in matrix y. */ /* r[2*r1*c2]: Output matrix of c1*c2 complex floating */ /* point numbers having c1 rows and c2 columns of */ /* complex numbers. */ /* */ /* Complex numbers are stored consecutively with */ /* real values stored in even positions and */ /* imaginary values in odd positions. */ /* */ /* DESCRIPTION */ /* */ /* This function computes the expression "r = x * y" for the */ /* matrices x and y. The columnar dimension of x must match the row */ /* dimension of y. The resulting matrix has the same number of rows */ /* as x and the same number of columns as y. */ /* */ /* Each element of the matrix is assumed to be complex numbers with */ /* Real values are stored in even positions and imaginary */ /* values in odd positions. */ /* */ /* TECHNIQUES */ /* */ /* 1. Innermost loop is unrolled twice. */ /* 2. Outermost loop is executed in parallel with innner loops. */ /* */ /* ASSUMPTIONS */ /* */ /* 1. r1,r2>=1,c1 should be a multiple of 2 and >=2. */ /* 2. x should be padded with 6 words */ /* */ /* */ /* C CODE */ /* */ void DSPF_dp_mat_mul_cplx(const double* x, int r1, int c1, const double* y, int c2, double* r) { double real, imag; int i, j, k; for(i = 0; i < r1; i++) { for(j = 0; j < c2; j++) { real=0; imag=0; for(k = 0; k < c1; k++) { real += (x[i*2*c1 + 2*k]*y[k*2*c2 + 2*j] -x[i*2*c1 + 2*k + 1] * y[k*2*c2 + 2*j + 1]); imag+=(x[i*2*c1 + 2*k] * y[k*2*c2 + 2*j + 1] + x[i*2*c1 + 2*k + 1] * y[k*2*c2 + 2*j]); } r[i*2*c2 + 2*j] = real; r[i*2*c2 + 2*j + 1] = imag; } } } /* NOTES */ /* */ /* 1. Real values are stored in even word positions and imaginary */ /* values in odd positions. */ /* 2. Endian: This code is LITTLE ENDIAN. */ /* 3. Interruptibility: This code is interrupt tolerant but not */ /* interruptible. */ /* */ /* CYCLES */ /* */ /* 8*r1*c1*c2'+ 18*(r1*c2)+40 WHERE c2'=2*ceil(c2/2) */ /* When r1=3, c1=4, c2=4, cycles = 640 */ /* When r1=4, c1=4, c2=5, cycles = 1040 */ /* */ /* CODESIZE */ /* */ /* 832 bytes */ /* ------------------------------------------------------------------------ */ /* Copyright (c) 2004 Texas Instruments, Incorporated. */ /* All Rights Reserved. */ /* ======================================================================== */ #ifndef DSPF_DP_MAT_MUL_CPLX_H_ #define DSPF_DP_MAT_MUL_CPLX_H_ 1 void DSPF_dp_mat_mul_cplx( const double* x, int r1, int c1, const double* y, int c2, double* restrict r ); #endif /* ======================================================================== */ /* End of file: DSPF_dp_mat_mul_cplx.h */ /* ------------------------------------------------------------------------ */
解决评论 打赏 举报无用 3
悬赏问题
- ¥15 关于stm32hal库驱动ft6336触摸屏遇到的问题
- ¥15 需要手写数字信号处理Dsp三个简单题 不用太复杂
- ¥15 数字信号处理考试111
- ¥100 关于#audobe audition#的问题,如何解决?
- ¥15 allegro17.2生成bom表是空白的
- ¥15 请问一下怎么打通CAN通讯
- ¥20 如何在 rocky9.4 部署 CDH6.3.2?
- ¥35 navicat将excel中的数据导入mysql出错
- ¥15 rt-thread线程切换的问题
- ¥15 高通uboot 打印ubi init err 22