/// <summary> /// Get i-th row from cache /// </summary> /// <param name="i">i-th row</param> /// <param name="len">block length</param> /// <returns>array with i-th row kernel products</returns> public float[] GetQ(int i, int len) { float[] data = null; int start = 0; //data = new float[problem.ElementsCount]; //for (int j = start; j < len; j++) // data[j] = (y[i] * y[j] * kernel.Product(i, j)); //with cache if ((start = cache.GetData(i, ref data, len)) < len) { kernel.AllProducts(i, data); //System.IO.File.WriteAllLines("kernel.txt", data.Select(d => d.ToString())); // for (j = start; j < len; j++) // data[j] = (y[i] * y[j] * kernel.Product(i, j)); //var data2 = kernel.AllProducts(i); //for (int k = 0; k < len; k++) //{ // if (data[k] != data2[k]) // throw new InvalidOperationException(string.Format("different val on {0} position", k)); //} //var partition = Partitioner.Create(start, len); //Parallel.ForEach(partition, (range) => //{ // for (int k = range.Item1; k < range.Item2; k++) // { // data[k] = (y[i] * y[k] * kernel.Product(i, k)); // } //}); } else { CacheHit++; } //string debStr = i.ToString() + " ->" + string.Join("; ", data); //Debug.WriteLine(debStr); //Debug.WriteLine(i); return(data); }