OpenCL中的矩阵求逆 [英] Matrix inversion in OpenCL

查看:212
本文介绍了OpenCL中的矩阵求逆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用OpenCL加速某些计算,算法的一部分包括对矩阵求逆.是否有任何开放源代码库或免费可用的代码来计算用OpenCL或CUDA编写的矩阵的lu分解(lapack dgetrf和dgetri)或通用反演?矩阵是实数和正方形,但除此之外没有任何其他特殊属性.到目前为止,我设法在gpu上仅找到基本的blas矩阵矢量运算实现.

I am trying to accelerate some computations using OpenCL and part of the algorithm consists of inverting a matrix. Is there any open-source library or freely available code to compute lu factorization (lapack dgetrf and dgetri) of matrix or general inversion written in OpenCL or CUDA? The matrix is real and square but doesn't have any other special properties besides that. So far, I've managed to find only basic blas matrix-vector operations implementations on gpu.

矩阵很小,只有大约60-100行和列,因此可以在cpu上更快地进行计算,但是它在算法中间使用,所以我必须将其传输到主机,计算取反,然后将结果传回设备,然后再用于更大的计算中.

The matrix is rather small, only about 60-100 rows and cols, so it could be computed faster on cpu, but it's used kinda in the middle of the algorithm, so I would have to transfer it to host, calculate the inverse, and then transfer the result back on the device where it's then used in much larger computations.

推荐答案

我在Open CL中没有实现,但是两个和Gil Strang的应用数学入门" 有很好的解释,很容易编写代码. "NR"具有您可以适应的C代码.

I don't have an implementation in Open CL, but both "Numerical Recipes" and Gil Strang's "Into to Applied Math" have wonderful explanations that would be easy to code. "NR" has C code that you could adapt.

计算逆数

这是不正确的.您不是在用LU分解计算逆,而是在分解矩阵.如果需要逆运算,则必须使用一系列单位向量进行正向反向替换.这是一个很小但很重要的区别.

This is incorrect. You aren't calculating an inverse with LU decomposition, you're decomposing the matrix. If you wanted the inverse, you'd have to do forward back substitution with a series of unit vectors. It's a small but important difference.

这篇关于OpenCL中的矩阵求逆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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