Library/ManagedCuda/CudaSolve/Refactorization.cs
/// <summary>
/// This routine extracts lower (L) and upper (U) triangular factors from the
/// cuSolverRF library handle into the host memory. It is assumed that a prior call to the
/// cusolverRfRefactor() was done in order to generate these triangular factors.
/// </summary>
/// <param name="n">Size of Matrix M (n x n)</param>
/// <param name="h_nnzL">the number of non-zero elements of matrix L.</param>
/// <param name="h_csrRowPtrL">the array of offsets corresponding to the start of each row in the arrays h_Li and
/// h_Lx. This array has also an extra entry at the end that stores the number of nonzero elements in the matrix L. The array size is n+1.</param>
/// <param name="h_csrColIndL">the array of column indices corresponding to the non-zero elements in the matrix L. It is assumed that this array is sorted by
/// row and by column within each row. The array size is h_nnzL.</param>
/// <param name="h_csrValL">the array of values corresponding to the non-zero elements in the matrix L. It is assumed that this array is sorted by row
/// and by column within each row. The array size is h_nnzL.</param>
/// <param name="h_nnzU">the number of non-zero elements of matrix U.</param>
/// <param name="h_csrRowPtrU">the array of offsets corresponding to the start of each row in the arrays h_Ui and h_Ux. This array has also an extra entry
/// at the end that stores the number of nonzero elements in the matrix U. The array size is n+1.</param>
/// <param name="h_csrColIndU">the array of column indices corresponding to the non-zero elements in the matrix U. It is assumed that this array is sorted by
/// row and by column within each row. The array size is h_nnzU.</param>
/// <param name="h_csrValU">the array of values corresponding to the non-zero elements in the matrix U. It is assumed that this array is sorted by row
/// and by column within each row. The array size is h_nnzU.</param>
This routine extracts lower (L) and upper (U) triangular factors from the
cuSolverRF library handle into the host memory. It is assumed that a prior call to the
cusolverRfRefactor() was done in order to generate these triangular factors.
This routine extracts lower ( L ) and upper ( U ) triangular factors from the cuSolverRF library handle into the host memory . It is assumed that a prior call to the cusolverRfRefactor () was done in order to generate these triangular factors .
public void ExtractSplitFactorsHost(int n, out int h_nnzL, out int[] h_csrRowPtrL, out int[] h_csrColIndL, out double[] h_csrValL, out int h_nnzU, out int[] h_csrRowPtrU, out int[] h_csrColIndU, out double[] h_csrValU)
		{
			h_nnzL = 0;
			h_nnzU = 0;
			IntPtr RowPtrL = new IntPtr();
			IntPtr ColIndL = new IntPtr();
			IntPtr ValL = new IntPtr();
			IntPtr RowPtrU = new IntPtr();
			IntPtr ColIndU = new IntPtr();
			IntPtr ValU = new IntPtr();
			res = CudaSolveNativeMethods.Refactorization.cusolverRfExtractSplitFactorsHost(_handle, ref h_nnzL, ref RowPtrL, ref ColIndL, ref ValL, ref h_nnzU, ref RowPtrU, ref ColIndU, ref ValU);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cusolverRfExtractSplitFactorsHost", res));
			if (res != cusolverStatus.Success) throw new CudaSolveException(res);
			if (h_nnzL == 0)
			{
				h_csrRowPtrL = null;
				h_csrColIndL = null;
				h_csrValL = null;
			}
			else
			{
				h_csrRowPtrL = new int[n + 1];
				h_csrColIndL = new int[h_nnzL];
				h_csrValL = new double[h_nnzL];
				Marshal.Copy(RowPtrL, h_csrRowPtrL, 0, n + 1);
				Marshal.Copy(ColIndL, h_csrColIndL, 0, h_nnzL);
				Marshal.Copy(ValL, h_csrValL, 0, h_nnzL);
			}
			if (h_nnzU == 0)
			{
				h_csrRowPtrU = null;
				h_csrColIndU = null;
				h_csrValU = null;
			}
			else
			{
				h_csrRowPtrU = new int[n + 1];
				h_csrColIndU = new int[h_nnzU];
				h_csrValU = new double[h_nnzU];
				Marshal.Copy(RowPtrU, h_csrRowPtrU, 0, n + 1);
				Marshal.Copy(ColIndU, h_csrColIndU, 0, h_nnzU);
				Marshal.Copy(ValU, h_csrValU, 0, h_nnzU);
			}
		}
public void ExtractSplitFactorsHost ( int n , out int h_nnzL , out int [ ] h_csrRowPtrL , out int [ ] h_csrColIndL , out double [ ] h_csrValL , out int h_nnzU , out int [ ] h_csrRowPtrU , out int [ ] h_csrColIndU , out double [ ] h_csrValU ) { h_nnzL = 0 ; h_nnzU = 0 ; IntPtr RowPtrL = new IntPtr ( ) ; IntPtr ColIndL = new IntPtr ( ) ; IntPtr ValL = new IntPtr ( ) ; IntPtr RowPtrU = new IntPtr ( ) ; IntPtr ColIndU = new IntPtr ( ) ; IntPtr ValU = new IntPtr ( ) ; res = CudaSolveNativeMethods . Refactorization . cusolverRfExtractSplitFactorsHost ( _handle , ref h_nnzL , ref RowPtrL , ref ColIndL , ref ValL , ref h_nnzU , ref RowPtrU , ref ColIndU , ref ValU ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != cusolverStatus . Success ) throw new CudaSolveException ( res ) ; if ( h_nnzL == 0 ) { h_csrRowPtrL = null ; h_csrColIndL = null ; h_csrValL = null ; } else { h_csrRowPtrL = new int [ n + 1 ] ; h_csrColIndL = new int [ h_nnzL ] ; h_csrValL = new double [ h_nnzL ] ; Marshal . Copy ( RowPtrL , h_csrRowPtrL , 0 , n + 1 ) ; Marshal . Copy ( ColIndL , h_csrColIndL , 0 , h_nnzL ) ; Marshal . Copy ( ValL , h_csrValL , 0 , h_nnzL ) ; } if ( h_nnzU == 0 ) { h_csrRowPtrU = null ; h_csrColIndU = null ; h_csrValU = null ; } else { h_csrRowPtrU = new int [ n + 1 ] ; h_csrColIndU = new int [ h_nnzU ] ; h_csrValU = new double [ h_nnzU ] ; Marshal . Copy ( RowPtrU , h_csrRowPtrU , 0 , n + 1 ) ; Marshal . Copy ( ColIndU , h_csrColIndU , 0 , h_nnzU ) ; Marshal . Copy ( ValU , h_csrValU , 0 , h_nnzU ) ; } }
This routine extracts lower (L) and upper (U) triangular factors from the
cuSolverRF library handle into the host memory.
This routine extracts lower ( L ) and upper ( U ) triangular factors from the cuSolverRF library handle into the host memory .
n
int
Size of Matrix M (n x n)
Size of Matrix M ( n x n )
int
out
int[]
out
double[]
out
h_nnzL
the number of non-zero elements of matrix L.
the number of non - zero elements of matrix L .
h_csrRowPtrL
the array of offsets corresponding to the start of each row in the arrays h_Li and
h_Lx. This array has also an extra entry at the end that stores the number of nonzero elements in the matrix L. The array size is n+1.
the array of offsets corresponding to the start of each row in the arrays h_Li and h_Lx . This array has also an extra entry at the end that stores the number of nonzero elements in the matrix L . The array size is n + 1 .
h_csrColIndL
the array of column indices corresponding to the non-zero elements in the matrix L. It is assumed that this array is sorted by
row and by column within each row. The array size is h_nnzL.
the array of column indices corresponding to the non - zero elements in the matrix L . It is assumed that this array is sorted by row and by column within each row . The array size is h_nnzL .
h_csrValL
the array of values corresponding to the non-zero elements in the matrix L. It is assumed that this array is sorted by row
and by column within each row. The array size is h_nnzL.
the array of values corresponding to the non - zero elements in the matrix L . It is assumed that this array is sorted by row and by column within each row . The array size is h_nnzL .
h_nnzU
the number of non-zero elements of matrix U.
the number of non - zero elements of matrix U .
h_csrRowPtrU
the array of offsets corresponding to the start of each row in the arrays h_Ui and h_Ux. This array has also an extra entry
at the end that stores the number of nonzero elements in the matrix U. The array size is n+1.
the array of offsets corresponding to the start of each row in the arrays h_Ui and h_Ux . This array has also an extra entry at the end that stores the number of nonzero elements in the matrix U . The array size is n + 1 .
h_csrColIndU
the array of column indices corresponding to the non-zero elements in the matrix U. It is assumed that this array is sorted by
row and by column within each row. The array size is h_nnzU.
the array of column indices corresponding to the non - zero elements in the matrix U . It is assumed that this array is sorted by row and by column within each row . The array size is h_nnzU .
h_csrValU
the array of values corresponding to the non-zero elements in the matrix U. It is assumed that this array is sorted by row
and by column within each row. The array size is h_nnzU.
the array of values corresponding to the non - zero elements in the matrix U . It is assumed that this array is sorted by row and by column within each row . The array size is h_nnzU .