执行矩阵运算在C复数 [英] Performing matrix operations with complex numbers in C

查看:211
本文介绍了执行矩阵运算在C复数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图执行涉及矩阵运算和复杂的数学计算 - 有时在一起,在C.我很熟悉Matlab和我知道这些类型的计算可以简单,高效地进行。例如,相同的大小,A和B的两个矩阵,复数值的每个具有元件可以很容易地通过前pression A + B相加。有没有可以推荐采用C或目标C编程这些类型的前pressions的任何软件包或技术?我知道complex.h它允许对复数执行操作的,但我不知道如何在复杂的矩阵,这是我真正追求的是执行操作。同样的,我知道这包允许在矩阵操作,但不认为他们将在复杂基质中的工作是有用的。

I'm trying to perform computations involving matrix operations and complex math - sometimes together, in C. I'm very familiar with Matlab and I know these types of computations could be performed simply and efficiently. For example, two matrices of the same size, A and B, each having elements of complex values can be summed easily through the expression A+B. Are there any packages or techniques that can be recommended to employ programming these types of expressions in C or Objective C? I am aware of complex.h which allows for performing operations on complex numbers, but am unaware of how to perform operations on complex matrices, which is what I'm really after. Similarly, I'm aware of packages which allow for operations on matrices, but don't think they will be useful in working on complex matrices.

推荐答案

您想使用 BLAS 基本线性代数运算,如求和或相乘两个矩阵,以及LAPACK的计算密集型算法,如保矩阵。

You want to use BLAS for basic linear algebra operations, like summing or multiplying two matrices, and LAPACK for more computational intensive algorithms, like factoring matrices.

BLAS例程有好笑的名字,看起来像字母汤。这是因为对函数名的长度旧的Fortran限制。名称的第一个字母表示BLAS例行操作的数据类型。由于您感兴趣的复数要看看开始程序ç(对于复杂的单precision)或以Z (对于zouble复杂的双precision)。例如,BLAS例行乘复杂基质中的 A B CGEMM ZGEMM (这里 GEMM 表示通用矩阵矩阵乘法。)

BLAS routines have funny names, that look like alphabet soup. This is because of old Fortran restrictions on the length of the function name. The first letter of the name indicates the data type the BLAS routine operates on. Since your interested in complex numbers you want to look at routines beginning in c (for complex single precision) or z (for zouble complex double precision). For example the BLAS routine to multiply complex matrices A and B is CGEMM or ZGEMM (here GEMM stands for general matrix matrix multiply.)

它看起来像在Objective C,BLAS可通过<一个href=\"http://developer.apple.com/library/mac/#documentation/Accelerate/Reference/BLAS_Ref/Reference/reference.html#//apple_ref/doc/uid/TP40009457\">Accelerate框架。命名约定是prePEND cblas _ 原来的BLAS名称。例如这里是<一个href=\"http://developer.apple.com/library/mac/documentation/Accelerate/Reference/BLAS_Ref/Reference/reference.html#//apple_ref/c/func/cblas_zgemm\">documentation为 cblas_zgemm

It looks like in Objective C, BLAS is available through the Accelerate framework. The naming convention is to prepend cblas_ to the original BLAS name. For example here is the documentation for cblas_zgemm.

通常情况下,供应商为他们的平台提供的BLAS的优化版本。这些例程
往往可以比这些矩阵运算的天真实现显著更快。经常
一台机器的峰值浮点性能可以达到或几乎达到,这些
例程。事实上LINPACK基准测试(LINPACK是predecessor到LAPACK)使用这些
例程基准和等级的超级计算机。

Normally, vendors provided optimized versions of the BLAS for their platform. These routines can often be significantly faster than naive implementations of these matrix operations. Often the peak floating-point performance of a machine can be achieved, or nearly achieved, with these routines. In fact the LINPACK benchmark (LINPACK was the predecessor to LAPACK) uses these routines to benchmark and rank supercomputers.

这篇关于执行矩阵运算在C复数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆