复数的乘积c语言,复数矩阵乘法C语言实现

本文介绍了一个用于计算两个复数矩阵乘积的C语言函数DSPF_dp_mat_mul_cplx。该函数接受两个输入矩阵x和y,并返回它们的乘积矩阵r。矩阵中的每个元素都是复数,实部存储在偶数位置,虚部存储在奇数位置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/* 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                                                                  */

/*                                                                          */

voidDSPF_dp_mat_mul_cplx(constdouble* x,intr1,intc1,

constdouble* y,intc2,double* r)

{

doublereal, imag;

inti, j, k;

for(i = 0; i 

{

for(j = 0; j 

{

real=0;

imag=0;

for(k = 0; 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

voidDSPF_dp_mat_mul_cplx(

constdouble* x,

intr1,

intc1,

constdouble* y,

intc2,

double* restrict r

);

#endif

/* ======================================================================== */

/*  End of file:  DSPF_dp_mat_mul_cplx.h                                         */

/* ------------------------------------------------------------------------ */

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值