public static void _V_X_M_line_M(Index2 size, ArrayView2D <float> output, ArrayView2D <float> m, ArrayView <float> v) { int x = size.X; int y = size.Y; output[x, y] = v[x] * m[x, y]; }
public static void Frame(Index2 index, ArrayView2D <Vector4> dataView, Index2 canvasSize) { float g = index.X / (float)canvasSize.X; float r = index.Y / (float)canvasSize.Y; dataView[index] = new Vector4(r, g, 0f, 255f); }
public static void MyKernel2(Index1 index, ArrayView2D <byte> dataView) { for (int i = 0; i < dataView.Height; i++) { dataView[new Index2(index.X, i)] = (byte)i; } }
public static void kernel_M_ApplyMask(Index2 pos, ArrayView2D <float> output, ArrayView2D <float> arr, ArrayView2D <byte> mask) { int x = pos.X; int y = pos.Y; output[x, y] = arr[x, y] * mask[x, y]; }
public static void kernel_V_mult_VT(Index2 pos, ArrayView2D <float> output, ArrayView <float> v, ArrayView <float> vt) { int x = pos.X; int y = pos.Y; output[x, y] = v[x] * vt[y]; }
public static void kernel_M_div_C(Index2 pos, ArrayView2D <float> output, ArrayView2D <float> m, float c) { int x = pos.X; int y = pos.Y; output[x, y] = m[x, y] / c; }
public static void kernel_m_Sqrt(Index2 pos, ArrayView2D <float> output, ArrayView2D <float> arr) { int x = pos.X; int y = pos.Y; output[x, y] = GPUMath.Sqrt(arr[x, y]); }
public static void M_sub_M(Index2 pos, ArrayView2D <float> output, ArrayView2D <float> m0, ArrayView2D <float> m1) { int x = pos.X; int y = pos.Y; output[x, y] = m0[x, y] - m1[x, y]; }
public static void M_mult_VT(Index2 pos, ArrayView2D <float> output, ArrayView2D <float> m, ArrayView <float> vt) { int x = pos.X; int y = pos.Y; output[x, y] = m[x, y] * vt[y]; }
private static void strategyPerLine(Index1 index, ArrayView2D <int> same) { for (int i = 1; i < same.Extent.Y; i++) { same[index, 0] = same[index, 0] & same[index, i]; } }
private static void strategy(Index2 index, ArrayView2D <int> bp, Index2 offT1, Index2 offT2, Index2 tileExtent, ArrayView2D <int> same) { int x = index.X; int fx = tileExtent.X - 1 - x; int y = index.Y; int fy = tileExtent.Y - 1 - y; same[x, y] = 0; int c = bp[x + offT1.X, y + offT1.Y]; if (c == bp[x + offT2.X, y + offT2.Y]) { same[x, y]++; } if (c == bp[fx + offT2.X, y + offT2.Y]) { same[x, y] += 2; } if (c == bp[x + offT2.X, fy + offT2.Y]) { same[x, y] += 4; } if (c == bp[fx + offT2.X, fy + offT2.Y]) { same[x, y] += 8; } }
private static void strategyResume(Index1 index, ArrayView2D <int> same) { for (int i = 1; i < same.Extent.Y; i++) { same[0, 0] = same[0, 0] & same[i, 0]; } }
private static void PaintKernel( Index i, Template template, ArrayView <float> series, ArrayView2D <float> clusters, ArrayView <int> outPutHeatMap, float error) { //TODO: refactor this peace of vector creation for (int i5 = template.Distance1 + template.Distance2 + template.Distance3 + template.Distance4, i4 = i5 - template.Distance4, i3 = i5 - template.Distance4 - template.Distance3, i2 = i5 - template.Distance4 - template.Distance3 - template.Distance2, i1 = i5 - template.Distance4 - template.Distance3 - template.Distance2 - template.Distance1; i5 < series.Length - 1; i5++, i4++, i3++, i2++, i1++) { if (Math.Abs(series[i5] - clusters[i, 4]) < 0.1) { var vector = new float[] { series[i1], series[i2], series[i3], series[i4], series[i5] }; var cluster = new float[] { clusters[i, 0], clusters[i, 1], clusters[i, 2], clusters[i, 3], clusters[i, 4] }; double distance = DistanceCalculator.Distance(vector, cluster); if (distance <= error) { outPutHeatMap[i1]++; outPutHeatMap[i2]++; outPutHeatMap[i3]++; outPutHeatMap[i4]++; } } } }
public static void CalculateSliceBand(Index2 index, ArrayView2D <uint> result, ArrayView3D <short> input, int band) { var ind = new Index2(index.X, index.Y + input.Depth); uint val = (uint)(input[index.X, index.Y, band] / 9000f * 255); result[ind] = (uint)((val) + (val << 8) + (val << 16) + (255 << 24)); }
public static void kernel_M_add_M(Index2 pos, ArrayView2D <float> output, ArrayView2D <float> m0, ArrayView2D <float> m1) { int x = pos.X; int y = pos.Y; output[x, y] = m0[x, y] + m1[x, y]; }
public static void M_add_C(Index2 pos, ArrayView2D <float> output, ArrayView2D <float> m, float c) { int x = pos.X; int y = pos.Y; output[x, y] = m[x, y] + c; }
public static void kernel_V_mult_M(Index2 pos, ArrayView2D <float> output, ArrayView <float> v, ArrayView2D <float> m) { int x = pos.X; int y = pos.Y; output[x, y] = m[x, y] * v[x]; }
public static void M_mult_MT(Index2 pos, ArrayView2D <float> output, ArrayView2D <float> m, ArrayView2D <float> mt) { int x = pos.X; int y = pos.Y; output[x, y] = m[x, y] * mt[y, x]; }
public static void kernel_IC_div_M(Index2 pos, ArrayView2D <float> output, ArrayView2D <float> m, int c) { int x = pos.X; int y = pos.Y; output[x, y] = c / m[x, y]; }
public static void M_SumLine(Index2 pos, ArrayView2D <float> m, int r, int boxSize) { var x = pos.X; var y = pos.Y; m[x, y] = m[x, y] + m[x, y + r + boxSize]; }
public static void kernel_MT_mult_M(Index2 pos, ArrayView2D <float> output, ArrayView2D <float> mt, ArrayView2D <float> m) { int x = pos.X; int y = pos.Y; output[x, y] = mt[y, x] * m[x, y]; }
public static void VT_mult_V(Index2 pos, ArrayView2D <float> output, ArrayView <float> vt, ArrayView <float> v) { int x = pos.X; int y = pos.Y; output[x, y] = vt[y] * v[x]; }
public static void kernel_M_SumColumn(Index2 pos, ArrayView2D <float> m, int r, int boxSize) { var x = pos.X; var y = pos.Y; m[x, y] = m[x, y] + m[x + r + boxSize, y]; }
private static void Product(Index index, ArrayView2D <double> layer, ArrayView2D <double> layerNext) { //for (int n = 0; n < layerNext.Height; ++n) int n = index; { double sum = 0; if (layerNext[1, n] == 1 && layerNext[1, n] == 2) // connected bias { for (int p = 0; p < layer.Height; ++p) { sum += layer[1, p] == 1 ? layer[0, p] * layer[3 + n, p] : 0; } } if (layerNext[1, n] == 0) // not bias { for (int p = 0; p < layer.Height; ++p) { sum += layer[0, p] * layer[3 + n, p]; } } layerNext[0, n] = sum; } }
static void ProcessResultsKernelFunction(Index1 individualIndex, ArrayView2D <double> results2D, ArrayView <double> results1D) { for (int rowIndex = 0; rowIndex < results2D.Height; rowIndex++) { results1D[individualIndex] += results2D[individualIndex, rowIndex]; } }
public DeviceData(ArrayView2D <Vec3> canvas, ParticleSystemStructOfArrays particles, int width, int height) { this.canvas = canvas; this.width = width; this.height = height; this.particles = particles; }
public static void CosineSimilarityKernel( Index index, ArrayView2D <int> dataset, ArrayView2D <double> distances) { int rows = dataset.Rows; int i = index / rows; int j = index % rows; if (i < j) { return; } double dotProduct = 0; double magnitudeOne = 0; double magnitudeTwo = 0; for (int k = 0; k < dataset.Columns; k++) { dotProduct += (dataset[i, k] * dataset[j, k]); magnitudeOne += (dataset[i, k] * dataset[i, k]); magnitudeTwo += (dataset[j, k] * dataset[j, k]); } double distance = double.NaN; double divisor = GPUMath.Sqrt(magnitudeOne * magnitudeTwo); if (divisor != 0) { distance = GPUMath.Max(0, 1 - (dotProduct / divisor)); } distances[i, j] = distance; distances[j, i] = distance; }
public static void Kernel(Index2 index, ArrayView2D <Vector3> dataView, Scene scene, ArrayView <Geometry> sceneGeometry, ArrayView <Light> sceneLights, int seed) { Vector3 outputColor = Vector3.Zero; scene.SceneGeometry = sceneGeometry; scene.SceneLights = sceneLights; //Models.Random random = new Models.Random((uint) (index.X * index.Y + seed)); XorShift64Star random = new XorShift64Star((ulong)index.X + (ulong)scene.Camera.ScreenWidth * (ulong)index.Y + (ulong)seed); float xOffset = random.NextFloat(); random.NextFloat(); float yOffset = random.NextFloat(); Ray ray = scene.Camera.GetRaySimple(index.X + (xOffset * 2f - 1f) * 0.5f, index.Y + (yOffset * 2f - 1f) * 0.5f); Intersection intersection = scene.TraceScene(ray); if (intersection.Hit) { outputColor = intersection.HitObject.Material.GetShaded(random, scene, intersection.HitPosition, ray.Direction, intersection.HitNormal); } else if (intersection.HitLight) { outputColor = intersection.HitLightObject.GetColor(ray.Direction); } dataView[index] += outputColor; }
public CanvasData(ArrayView2D <Vec3> canvas, ArrayView <byte> bitmapData, int width, int height) { this.canvas = canvas; this.bitmapData = bitmapData; this.width = width; this.height = height; }
public static void _M_sum_lines(Index2 size, int r, ArrayView2D <float> m, int boxSize) { int x = size.X; int y = size.Y; m[x, y] = m[x, y] + m[x, y + r + boxSize]; }