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_Inv_scal_elemwise(FLA_Trans trans,FLA_Obj A,FLA_Obj B)13 FLA_Error FLA_Inv_scal_elemwise( FLA_Trans trans, FLA_Obj A, FLA_Obj B )
14 {
15   FLA_Datatype datatype;
16   int          m_B, n_B;
17   int          rs_A, cs_A;
18   int          rs_B, cs_B;
19   trans1_t      blis_trans;
20 
21   if ( FLA_Check_error_level() == FLA_FULL_ERROR_CHECKING )
22     FLA_Inv_scal_elemwise_check( trans, A, B );
23 
24   if ( FLA_Obj_has_zero_dim( A ) ) return FLA_SUCCESS;
25 
26   datatype = FLA_Obj_datatype( A );
27 
28   rs_A     = FLA_Obj_row_stride( A );
29   cs_A     = FLA_Obj_col_stride( A );
30 
31   m_B      = FLA_Obj_length( B );
32   n_B      = FLA_Obj_width( B );
33   rs_B     = FLA_Obj_row_stride( B );
34   cs_B     = FLA_Obj_col_stride( B );
35 
36   FLA_Param_map_flame_to_blis_trans( trans, &blis_trans );
37 
38   switch ( datatype ){
39 
40   case FLA_FLOAT:
41   {
42     float *buff_A     = ( float * ) FLA_FLOAT_PTR( A );
43     float *buff_B     = ( float * ) FLA_FLOAT_PTR( B );
44 
45     bl1_sewinvscalmt( blis_trans,
46                       m_B,
47                       n_B,
48                       buff_A, rs_A, cs_A,
49                       buff_B, rs_B, cs_B );
50 
51     break;
52   }
53 
54   case FLA_DOUBLE:
55   {
56     double *buff_A     = ( double * ) FLA_DOUBLE_PTR( A );
57     double *buff_B     = ( double * ) FLA_DOUBLE_PTR( B );
58 
59     bl1_dewinvscalmt( blis_trans,
60                       m_B,
61                       n_B,
62                       buff_A, rs_A, cs_A,
63                       buff_B, rs_B, cs_B );
64 
65     break;
66   }
67 
68   case FLA_COMPLEX:
69   {
70     scomplex *buff_A =     ( scomplex * ) FLA_COMPLEX_PTR( A );
71     scomplex *buff_B =     ( scomplex * ) FLA_COMPLEX_PTR( B );
72 
73     bl1_cewinvscalmt( blis_trans,
74                       m_B,
75                       n_B,
76                       buff_A, rs_A, cs_A,
77                       buff_B, rs_B, cs_B );
78 
79     break;
80   }
81 
82   case FLA_DOUBLE_COMPLEX:
83   {
84     dcomplex *buff_A     = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );
85     dcomplex *buff_B     = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( B );
86 
87     bl1_zewinvscalmt( blis_trans,
88                       m_B,
89                       n_B,
90                       buff_A, rs_A, cs_A,
91                       buff_B, rs_B, cs_B );
92 
93     break;
94   }
95 
96   }
97 
98   return FLA_SUCCESS;
99 }
100 
101