English 中文(简体)
C# Vectorized Array Add
原标题:C# Vectorized Array Addition

是否在以“千年发展目标”的方式增加各阵列的内容方面有任何进展?

例如,我要谈谈:

var a = new[] { 1, 2, 3, 4 };
var b = new[] { 1, 2, 3, 4 };
var c = new[] { 1, 2, 3, 4 };
var d = new[] { 1, 2, 3, 4 };

var e = new int[4];

for (int i = 0; i < a.Length; i++)
{
    e[i] = a[i] + b[i] + c[i] + d[i];
}

// e should equal { 4, 8, 12, 16 }

等等:

var e = VectorAdd(a,b,c,d);

我知道C++/XNA图书馆可能有一些东西,但我不知道我们是否达到了标准。 图书馆网。

感谢!

最佳回答

你们想看莫诺。 Simd:

rel=“noreferer”>http://tirania.org/blog/archive/2008/Nov-03.html

它支持在C#中的SIMD。

using Mono.Simd;


//...
var a = new Vector4f( 1, 2, 3, 4 );
var b = new Vector4f( 1, 2, 3, 4 );
var c = new Vector4f( 1, 2, 3, 4 );
var d = new Vector4f( 1, 2, 3, 4 );

var e = a+b+c+d;
问题回答

Mono提供了一种相对体面的SIMD AP(如 se指的),但如果Mono不是一种选择,我也许会写出一个C++/CLI接口图书馆来做重提。 C#在大多数问题组中运作良好,但如果你开始采用高性能法,则最好采用一种能让你真正获得业绩的过错的语文。

在此工作中,我们利用P/Invoke在C++上用C#.P/Invoke书写的图像处理例行程序,但如果你很少打电话,而且在当地做大量处理,则可以这样做。

I guess it all depends on what you are doing, but if you are worried about vectorizing vector sums, you might want to take a look at a library such as Math.NET which provide optimized numerical computations.

网址:

It targets Microsoft .Net 4.0, Mono and Silverlight 4, and in addition to a purely managed implementation will also support native hardware optimization (MKL, ATLAS).





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签