1 /*
2 
3     Copyright (C) 2014, The University of Texas at Austin
4 
5     This file is part of libflame and is available under the 3-Clause
6     BSD license, which can be found in the LICENSE file at the top-level
7     directory, or at http://opensource.org/licenses/BSD-3-Clause
8 
9 */
10 
11 #include "FLAME.h"
12 
13 extern fla_sylv_t* flash_sylv_cntl;
14 extern fla_sylv_t* fla_sylv_cntl_leaf;
15 
FLA_Sylv_internal(FLA_Trans transa,FLA_Trans transb,FLA_Obj isgn,FLA_Obj A,FLA_Obj B,FLA_Obj C,FLA_Obj scale,fla_sylv_t * cntl)16 FLA_Error FLA_Sylv_internal( FLA_Trans transa, FLA_Trans transb, FLA_Obj isgn, FLA_Obj A, FLA_Obj B, FLA_Obj C, FLA_Obj scale, fla_sylv_t* cntl )
17 {
18 	FLA_Error r_val = FLA_SUCCESS;
19 
20 	if ( FLA_Check_error_level() == FLA_FULL_ERROR_CHECKING )
21 		FLA_Sylv_internal_check( transa, transb, isgn, A, B, C, scale, cntl );
22 
23 	if      ( FLA_Cntl_matrix_type( cntl ) == FLA_HIER &&
24 	          FLA_Obj_elemtype( A ) == FLA_MATRIX &&
25 	          FLA_Cntl_variant( cntl ) == FLA_SUBPROBLEM )
26 	{
27 		// Recurse
28 		r_val = FLA_Sylv_internal( transa,
29 		                           transb,
30 		                           isgn,
31 		                           *FLASH_OBJ_PTR_AT( A ),
32 		                           *FLASH_OBJ_PTR_AT( B ),
33 		                           *FLASH_OBJ_PTR_AT( C ),
34 		                           scale,
35 		                           flash_sylv_cntl );
36 	}
37 	else if ( FLA_Cntl_matrix_type( cntl ) == FLA_HIER &&
38 	          FLA_Obj_elemtype( A ) == FLA_SCALAR &&
39 	          FLASH_Queue_get_enabled( ) )
40 	{
41 		// Enqueue
42 		ENQUEUE_FLASH_Sylv( transa, transb, isgn, A, B, C, scale, cntl );
43 	}
44 	else
45 	{
46 		if ( FLA_Cntl_matrix_type( cntl ) == FLA_HIER &&
47 		     FLA_Obj_elemtype( A ) == FLA_SCALAR &&
48 		     !FLASH_Queue_get_enabled( ) )
49 		{
50 			// Execute leaf
51 			cntl = fla_sylv_cntl_leaf;
52 		}
53 
54 		// Parameter combinations
55 		if      ( transa == FLA_NO_TRANSPOSE )
56 		{
57 			if      ( transb == FLA_NO_TRANSPOSE )
58 				r_val = FLA_Sylv_nn( isgn, A, B, C, scale, cntl );
59 			else if ( transb == FLA_TRANSPOSE || transb == FLA_CONJ_TRANSPOSE )
60 				r_val = FLA_Sylv_nh( isgn, A, B, C, scale, cntl );
61 		}
62 		else if ( transa == FLA_TRANSPOSE || transa == FLA_CONJ_TRANSPOSE )
63 		{
64 			if      ( transb == FLA_NO_TRANSPOSE )
65 				r_val = FLA_Sylv_hn( isgn, A, B, C, scale, cntl );
66 			else if ( transb == FLA_TRANSPOSE || transb == FLA_CONJ_TRANSPOSE )
67 				r_val = FLA_Sylv_hh( isgn, A, B, C, scale, cntl );
68 		}
69 	}
70 
71 	return r_val;
72 }
73 
74