/// <summary> /// Solves a system of linear equations, Ax = b. /// </summary> /// <param name="input">Right hand side vector b.</param> /// <param name="result">Solution vector x.</param> public void Solve(T[] input, T[] result) { if (!factorized) { Factorize(); } var handles = new List <GCHandle>(); try { var h_b = InteropHelper.Pin(input, handles); var h_x = InteropHelper.Pin(result, handles); int rows = input.Length; int columns = result.Length; Cuda.CopyToDevice(d_b, h_b, sizeT * rows); // Solve A*x = b. Check(Solve(rows, columns)); Cuda.CopyToHost(h_x, d_x, sizeT * columns); } finally { InteropHelper.Free(handles); } }