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 
FLA_Amax_external(FLA_Obj x,FLA_Obj index)13 FLA_Error FLA_Amax_external( FLA_Obj x, FLA_Obj index )
14 {
15   FLA_Datatype datatype;
16   int          num_elem;
17   int          inc_x;
18   int         *buff_index;
19 
20   if ( FLA_Check_error_level() == FLA_FULL_ERROR_CHECKING )
21     FLA_Amax_check( x, index );
22 
23   buff_index = ( int * ) FLA_INT_PTR( index );
24 
25   if ( FLA_Obj_has_zero_dim( x ) )
26   {
27     *buff_index = 0;
28     return FLA_SUCCESS;
29   }
30 
31   datatype = FLA_Obj_datatype( x );
32 
33   inc_x    = FLA_Obj_vector_inc( x );
34   num_elem = FLA_Obj_vector_dim( x );
35 
36 
37   switch ( datatype ){
38 
39   case FLA_FLOAT:
40   {
41     float* buff_x = ( float * ) FLA_FLOAT_PTR( x );
42 
43     bl1_samax( num_elem,
44                buff_x, inc_x,
45                buff_index );
46 
47     break;
48   }
49 
50   case FLA_DOUBLE:
51   {
52     double* buff_x = ( double * ) FLA_DOUBLE_PTR( x );
53 
54     bl1_damax( num_elem,
55                buff_x, inc_x,
56                buff_index );
57 
58     break;
59   }
60 
61   case FLA_COMPLEX:
62   {
63     scomplex* buff_x = ( scomplex * ) FLA_COMPLEX_PTR( x );
64 
65     bl1_camax( num_elem,
66                buff_x, inc_x,
67                buff_index );
68 
69     break;
70   }
71 
72   case FLA_DOUBLE_COMPLEX:
73   {
74     dcomplex* buff_x = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( x );
75 
76     bl1_zamax( num_elem,
77                buff_x, inc_x,
78                buff_index );
79 
80     break;
81   }
82 
83   }
84 
85   return FLA_SUCCESS;
86 }
87 
88