fix some gcc 4.9 valid warnings
[scilab.git] / scilab / modules / elementary_functions / includes / elem_func_gw.hxx
1 /*
2 *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 *  Copyright (C) 2008-2008 - DIGITEO - Antoine ELIAS
4 *  Copyright (C) 2010-2011 - DIGITEO - Bruno JOFRET
5 *
6 *  This file must be used under the terms of the CeCILL.
7 *  This source file is licensed as described in the file COPYING, which
8 *  you should have received as part of this distribution.  The terms
9 *  are also available at
10 *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11 *
12 */
13
14 #ifndef __ELEM_FUNC_GW_HXX__
15 #define __ELEM_FUNC_GW_HXX__
16
17 #include "cpp_gateway_prototype.hxx"
18 #include "double.hxx"
19 #include "complex"
20
21 extern "C"
22 {
23 #include "dynlib_elementary_functions_gw.h"
24 }
25
26 class ElemFuncModule
27 {
28 private :
29     ElemFuncModule() {};
30     ~ElemFuncModule() {};
31 public :
32     EXTERN_EF_GW static int Load();
33     EXTERN_EF_GW static int Unload()
34     {
35         return 1;
36     }
37 };
38
39 CPP_GATEWAY_PROTOTYPE(sci_isequal);
40 CPP_GATEWAY_PROTOTYPE(sci_size);
41 CPP_GATEWAY_PROTOTYPE(sci_eye);
42 CPP_GATEWAY_PROTOTYPE(sci_zeros);
43 CPP_GATEWAY_PROTOTYPE(sci_ones);
44 CPP_GATEWAY_PROTOTYPE(sci_rand);
45 CPP_GATEWAY_PROTOTYPE(sci_prod);
46 CPP_GATEWAY_PROTOTYPE(sci_sum);
47 CPP_GATEWAY_PROTOTYPE(sci_matrix);
48 CPP_GATEWAY_PROTOTYPE(sci_abs);
49 CPP_GATEWAY_PROTOTYPE(sci_acos);
50 CPP_GATEWAY_PROTOTYPE(sci_asin);
51 CPP_GATEWAY_PROTOTYPE(sci_atan);
52 CPP_GATEWAY_PROTOTYPE(sci_ceil);
53 CPP_GATEWAY_PROTOTYPE(sci_clean);
54 CPP_GATEWAY_PROTOTYPE(sci_conj);
55 CPP_GATEWAY_PROTOTYPE(sci_cos);
56 CPP_GATEWAY_PROTOTYPE(sci_sin);
57 CPP_GATEWAY_PROTOTYPE(sci_tan);
58 CPP_GATEWAY_PROTOTYPE(sci_cumprod);
59 CPP_GATEWAY_PROTOTYPE(sci_cumsum);
60 CPP_GATEWAY_PROTOTYPE(sci_diag);
61 CPP_GATEWAY_PROTOTYPE(sci_dsearch);
62 CPP_GATEWAY_PROTOTYPE(sci_exp);
63 CPP_GATEWAY_PROTOTYPE(sci_expm);
64 CPP_GATEWAY_PROTOTYPE(sci_floor);
65 CPP_GATEWAY_PROTOTYPE(sci_frexp);
66 CPP_GATEWAY_PROTOTYPE(sci_gsort);
67 CPP_GATEWAY_PROTOTYPE(sci_imag);
68 CPP_GATEWAY_PROTOTYPE(sci_imult);
69 CPP_GATEWAY_PROTOTYPE(sci_int);
70 CPP_GATEWAY_PROTOTYPE(sci_isreal);
71 CPP_GATEWAY_PROTOTYPE(sci_real);
72 CPP_GATEWAY_PROTOTYPE(sci_kron);
73 CPP_GATEWAY_PROTOTYPE(sci_log);
74 CPP_GATEWAY_PROTOTYPE(sci_log1p);
75 CPP_GATEWAY_PROTOTYPE(sci_max); // Old name sci_maxi
76 CPP_GATEWAY_PROTOTYPE(sci_min); // Old name sci_mini
77 CPP_GATEWAY_PROTOTYPE(sci_rat);
78 CPP_GATEWAY_PROTOTYPE(sci_triu);
79 CPP_GATEWAY_PROTOTYPE(sci_tril);
80 CPP_GATEWAY_PROTOTYPE(sci_round);
81 CPP_GATEWAY_PROTOTYPE(sci_sign);
82 CPP_GATEWAY_PROTOTYPE(sci_cosh);
83 CPP_GATEWAY_PROTOTYPE(sci_sinh);
84 CPP_GATEWAY_PROTOTYPE(sci_tanh);
85 CPP_GATEWAY_PROTOTYPE(sci_acosh);
86 CPP_GATEWAY_PROTOTYPE(sci_asinh);
87 CPP_GATEWAY_PROTOTYPE(sci_atanh);
88
89 bool getDimsFromArguments(types::typed_list& in, const std::string& _pstName, int* _iDims, int** _piDims, bool* _alloc);
90
91 template <class T>
92 types::Double* getAsDouble(T* _val)
93 {
94     types::Double* dbl = new types::Double(_val->getDims(), _val->getDimsArray());
95     double* pOut = dbl->get();
96     typename T::type* pIn = _val->get();
97     int size = dbl->getSize();
98     for (int i = 0; i < size; i++)
99     {
100         pOut[i] = static_cast<double>(pIn[i]);
101     }
102
103     return dbl;
104 }
105
106 template <class T>
107 T* toInt(types::Double* _dbl)
108 {
109     T* pI = new T(_dbl->getDims(), _dbl->getDimsArray());
110     typename T::type* p = pI->get();
111     double* pdbl = _dbl->get();
112     int size = _dbl->getSize();
113     for (int i = 0; i < size; i++)
114     {
115         p[i] = static_cast<typename T::type>(pdbl[i]);
116     }
117
118     return pI;
119 }
120
121 typedef double(*func_real)(double);
122 typedef std::complex<double>(*func_complex)(const std::complex<double>&);
123
124 types::Double* trigo(types::Double* in, func_real func_r, func_complex func_c, bool forceComplex = false);
125
126 #endif /* __ELEM_FUNC_GW_HXX__ */