There is a code on *C # *, and I need to remake it so that everything is considered on the video card:

```
public static double [] satl (double [] DATA)
{
Double [] Matrix = {0.0982862174, ..., -0.0229204861, ..., 0.0161380976};
int datalength = data.length;
int matrixlength = Matrix.Length;
INT START = Matrixlength + 1;
Var NewData = New Double [DataLength];
If (DataLength & Lt; = Matrixlength)
{
RETURN NULL;
}
for (int i = matrixlength; i & lt; datalength; i ++)
{
INT Counter = I - Matrixlength;
For (int j = 0; j & lt; matrixlength; j ++)
{
NewData [i] + = Matrix [j] * Data [Counter ++];
}
}
Return NewData;
}
```

The problem is that I can not understand how to run through the second array. I do not understand how the indexing occurs in *Cudafy *. That’s what I did, but it works not correctly:

```
public static double [] fatlcuda (double [] data, double [] matrix)
{
Cudafymodule km = cudafytranslator.cudafy ();
Gpgpu gpu = cudafyhost.getdevice (cudabymodes.target, cudabymodes.deviceid);
GPU.LoadModule (KM);
...
gpu.launch (). Add (dev_data, dev_matrix, dev_newdata);
}
[Cudafy]
Public Static Void Add (GThread Thread, Double [] Data, Double [] Matrix, Double [] NewData)
{
int tid = thread.blockidx.x;
If (TID & LT; Data.Length)
{
int jid = 0;
INT Counter = Tid - Matrix.Length;
If (JID & LT; Matrix.Length)
{
NEWDATA [TID] + = Matrix [JID] * Data [Counter ++];
JID ++;
}
Tid ++;
}
}
```

## Answer 1, Authority 100%

Not so long ago in .NET added support for SIMD . This namespace allows you to use hardware acceleration. To use, you need to have Ryujit Compiler, .NET 4.6 and System.Numerics.Vectors, which is put through Nuget.

Example of the simplest program using this namespace:

```
using system;
using System.Numerics;
Class Program
{
Static Void Main (String [] Args)
{
Const int32 n = 8;
Single [] A = {41982.0F, 81.5091F, 3.14F, 42.666F, 54776.45F, 342.4556F, 6756.2344F, 4563.789F};
Single [] B = {85989/111F, 156.5091F, 3.14F, 42.666F, 1006.45F, 9999.4546F, 0.2344F, 7893.789F};
Single [] C = New Single [N];
For (int i = 0; i & lt; n; i + = vector & lt; Single & gt ;count) // count Returns 16 for char, 4 for Float, 2 for Double, etc.
{
var asimd = new vector & lt; single & gt; (a, i); // Create an instance with displacement I
var bsimd = new vector & lt; single & gt; (b, i);
Vector & lt; Single & GT; csimd = asimd + bsimd; // or so vector & lt; single & gt; c_simd = vector.add (b_simd, a_simd);
csimd.copyto (C, I); // Copy into an array with displacement
}
for (int i = 0; i & lt; a.length; i ++)
{
CONSOLE.WRITELINE (C [I]);
}
Console.ReadKey ();
}
}
```

In other words, using this namespace, you can do everything much easier and more beautiful.