1 /*
3 BLIS
4 An object-based framework for developing high-performance BLAS-like
5 libraries.
7 Copyright (C) 2014, The University of Texas at Austin
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are
11 met:
12 - Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14 - Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the following disclaimer in the
16 documentation and/or other materials provided with the distribution.
17 - Neither the name of The University of Texas at Austin nor the names
18 of its contributors may be used to endorse or promote products
19 derived from this software without specific prior written permission.
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
35 #include "blis.h"
37 #define FUNCPTR_T normfsc_fp
39 typedef void (*FUNCPTR_T)(
40 void* chi,
41 void* norm
42 );
44 static FUNCPTR_T GENARRAY(ftypes,normfsc_unb_var1);
47 void bli_normfsc_unb_var1( obj_t* chi,
48 obj_t* norm )
49 {
50 num_t dt_chi;
51 num_t dt_norm_c = bli_obj_datatype_proj_to_complex( *norm );
53 void* buf_chi;
55 void* buf_norm = bli_obj_buffer_at_off( *norm );
57 FUNCPTR_T f;
59 // If chi is a scalar constant, use dt_norm_c to extract the address of the
60 // corresponding constant value; otherwise, use the datatype encoded
61 // within the chi object and extract the buffer at the chi offset.
62 bli_set_scalar_dt_buffer( chi, dt_norm_c, dt_chi, buf_chi );
64 // Index into the type combination array to extract the correct
65 // function pointer.
66 f = ftypes[dt_chi];
68 // Invoke the function.
69 f( buf_chi,
70 buf_norm );
71 }
74 #undef GENTFUNCR
75 #define GENTFUNCR( ctype_x, ctype_xr, chx, chxr, varname ) \
76 \
77 void PASTEMAC(chx,varname)( \
78 void* chi, \
79 void* norm \
80 ) \
81 { \
82 ctype_x* chi_cast = chi; \
83 ctype_xr* norm_cast = norm; \
84 \
85 PASTEMAC2(chx,chxr,abval2s)( *chi_cast, *norm_cast ); \
86 }
88 INSERT_GENTFUNCR_BASIC0( normfsc_unb_var1 )