#include "../include/lass.h"

/**
 *
 * 	@file ddss_dnpgetrf.c
 *
 * 	@brief LASs-DDSs ddss_dnpgetrf routine.
 *
 * 	LASs-DDSs is a software package provided by:
 * 	Barcelona Supercomputing Center - Centro Nacional de Supercomputacion
 *
 * 	@author Pedro Valero-Lara pedro.valero@bsc.es
 * 	@author Boro Sofranac boro.sofranac@bsc.es
 * 	@date 2018-04-06
 * 	@reviewer 
 * 	@modified 
 *
 **/

/**
 *  
 *	@ingroup DDSS
 *   
 *	Performs the LU factorization without pivoting of a general M-by-N matrix A:
 *
 *		A = L * U
 *
 *	where L is a lower triangular ( lower trapezoidal if M > N ) matrix with
 *	unit diagonal elements and U is an upper triangular ( upper trapezoidal 
 *	if M < N ) matrix.
 *
**/

/**
 *	
 *	@param[in]
 *	M       int.
 *          M specifies the number of rows of the matrix A. M >= 0.
 *	
 *	@param[in]
 *	N       int.
 *          N specifies the number of columns of the matrix A. N >= 0.
 *
 *	@param[in,out]
 *  A  		double *.
 *	    	A is a pointer to a regular matrix of dimension M-by-N.
 *          On exit, if return value is Success, the matrix A is overwriten by 
 *          the factors L and U. The unit diagonal elements of L are not stored.
 *   
 *	@param[in]
 *  LDA     int.
 * 	    	LDA specifies the number of columns of A ( row-major order ).
 * 	    	LDA must be at least max( 1, N ).
 * 	    	
 **/

/**
 *
 *	@retval Success successful exit
 *	@retval NoSuccess unsuccessful exit
 *
 **/

/**
 *
 *	@sa knpdgetrf
 *
 **/

int ddss_dnpgetrf( int M, int N, double *A, int LDA )
{

	// Argument checking
	if ( M < 0 )
	{
		fprintf( stderr, "Illegal value of M, in ddss_dnpgetrf code\n" );
		return NoSuccess;
	}

	if ( N < 0 )
	{
		fprintf( stderr, "Illegal value of N, in ddss_dnpgetrf code\n" );
		return NoSuccess;
	}

	if ( LDA < MAX( 1, N ) )
	{
		fprintf( stderr, "Illegal value of LDA, in ddss_dnpgetrf code\n" );
		return NoSuccess;
	}

	// Qick return
	if ( MIN( M, N ) == 0 )
	{
		return Success;
	}

	return kdnpgetrf( M, N, A, LDA );

} 
