1 /*
2 Copyright (C) 2016-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: dk4maai16.ctr
12 */
13 
14 #ifndef DK4MAAI16_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4MAAI16_H_INCLUDED 1
17 
18 
19 /**	@file	dk4maai16.h	Operations on int16_t data.
20 
21 	CRT on Windows: Optional.
22 */
23 
24 
25 #ifndef DK4CONF_H_INCLUDED
26 #if DK4_BUILDING_DKTOOLS4
27 #include "dk4conf.h"
28 #else
29 #include <dktools-4/dk4conf.h>
30 #endif
31 #endif
32 
33 #ifndef DK4ERROR_H_INCLUDED
34 #if DK4_BUILDING_DKTOOLS4
35 #include <libdk4base/dk4error.h>
36 #else
37 #include <dktools-4/dk4error.h>
38 #endif
39 #endif
40 
41 #if DK4_HAVE_STDLIB_H
42 #ifndef	DK4_STDLIB_H_INCLUDED
43 #include <stdlib.h>
44 #define	DK4_STDLIB_H_INCLUDED 1
45 #endif
46 #endif
47 
48 #if DK4_HAVE_SYS_TYPES_H
49 #ifndef	DK4_SYS_TYPES_H_INCLUDED
50 #include <sys/types.h>
51 #define	DK4_SYS_TYPES_H_INCLUDED 1
52 #endif
53 #endif
54 
55 #if DK4_HAVE_STDINT_H
56 #ifndef	DK4_STDINT_H_INCLUDED
57 #include <stdint.h>
58 #define	DK4_STDINT_H_INCLUDED 1
59 #endif
60 #endif
61 
62 #ifndef	INT16_MAX
63 #define	INT16_MAX	((int16_t)32767)
64 #endif
65 
66 #ifndef	INT16_MIN
67 #define	INT16_MIN	(((int16_t)(-32767)) - ((int16_t)1))
68 #endif
69 
70 #ifdef	__cplusplus
71 extern "C" {
72 #endif
73 
74 /**	Addition of int16_t.
75 	@param	a	Left operand.
76 	@param	b	Right operand.
77 	@param	erp	Error report, may be NULL.
78 	@return	Operation result.
79 
80 	Error codes:
81 	- DK4_E_INVALID_ARGUMENTS<br>
82 	  if a or b is out of range
83 	- DK4_E_MATH_OVERFLOW<br>
84 	  if a mathematical overfow occured.
85 */
86 int16_t
87 dk4ma_int16_t_add(int16_t a, int16_t b, dk4_er_t *erp);
88 
89 /**	Substraction of int16_t.
90 	@param	a	Left operand.
91 	@param	b	Right operand.
92 	@param	erp	Error report, may be NULL.
93 	@return	Operation result.
94 
95 	Error codes:
96 	- DK4_E_INVALID_ARGUMENTS<br>
97 	  if a or b is out of range
98 	- DK4_E_MATH_OVERFLOW<br>
99 	  if a mathematical overfow occured.
100 */
101 int16_t
102 dk4ma_int16_t_sub(int16_t a, int16_t b, dk4_er_t *erp);
103 
104 /**	Multiplication of int16_t.
105 	@param	a	Left operand.
106 	@param	b	Right operand.
107 	@param	erp	Error report, may be NULL.
108 	@return	Operation result.
109 
110 	Error codes:
111 	- DK4_E_INVALID_ARGUMENTS<br>
112 	  if a or b is out of range
113 	- DK4_E_MATH_OVERFLOW<br>
114 	  if a mathematical overfow occured.
115 */
116 int16_t
117 dk4ma_int16_t_mul(int16_t a, int16_t b, dk4_er_t *erp);
118 
119 /**	Division of int16_t.
120 	@param	a	Left operand.
121 	@param	b	Right operand.
122 	@param	erp	Error report, may be NULL.
123 	@return	Operation result.
124 
125 	Error codes:
126 	- DK4_E_INVALID_ARGUMENTS<br>
127 	  if a or b is out of range
128 	- DK4_E_MATH_OVERFLOW<br>
129 	  if a mathematical overfow occured,
130 	- DK4_E_MATH_DIVZERO<br>
131 	  if b is 0.
132 */
133 int16_t
134 dk4ma_int16_t_div(int16_t a, int16_t b, dk4_er_t *erp);
135 
136 /**	Absolute value.
137 	@param	a	Argument.
138 	@param	erp	Error report, may be NULL.
139 	@return	Absolute value of a.
140 
141 	Error codes:
142 	- DK4_E_INVALID_ARGUMENTS<br>
143 	  if a or b is out of range
144 	- DK4_E_MATH_OVERFLOW<br>
145 	  if a mathematical overfow occured.
146 */
147 int16_t
148 dk4ma_int16_t_abs(int16_t a, dk4_er_t *erp);
149 
150 /**	Convert dk4_im_t value to int16_t.
151 	@param	i	Value to convert.
152 	@param	erp	Error report, may be NULL.
153 	@return	Conversion result.
154 
155 	Error codes: DK4_E_MATH_OVERFLOW.
156 */
157 int16_t
158 dk4ma_int16_from(dk4_im_t i, dk4_er_t *erp);
159 
160 /**	Convert double to int16_t.
161 	@param	d	Value to convert.
162 	@param	erp	Error report, may be NULL.
163 	@return	Conversion result.
164 
165 	Error codes: DK4_E_OVERFLOW.
166 */
167 int16_t
168 dk4ma_int16_from_double(double d, dk4_er_t *erp);
169 
170 #ifdef	__cplusplus
171 }
172 #endif
173 
174 
175 
176 #endif
177