Edinburgh Speech Tools
2.4-release
All
Classes
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Pages
EST_inline_utils.h
1
/************************************************************************/
2
/* */
3
/* Centre for Speech Technology Research */
4
/* University of Edinburgh, UK */
5
/* Copyright (c) 1996,1997 */
6
/* All Rights Reserved. */
7
/* */
8
/* Permission is hereby granted, free of charge, to use and distribute */
9
/* this software and its documentation without restriction, including */
10
/* without limitation the rights to use, copy, modify, merge, publish, */
11
/* distribute, sublicense, and/or sell copies of this work, and to */
12
/* permit persons to whom this work is furnished to do so, subject to */
13
/* the following conditions: */
14
/* 1. The code must retain the above copyright notice, this list of */
15
/* conditions and the following disclaimer. */
16
/* 2. Any modifications must be clearly marked as such. */
17
/* 3. Original authors' names are not deleted. */
18
/* 4. The authors' names are not used to endorse or promote products */
19
/* derived from this software without specific prior written */
20
/* permission. */
21
/* */
22
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30
/* THIS SOFTWARE. */
31
/* */
32
/************************************************************************/
33
34
/**@name EST_inline_utils.h
35
* Some simple inline functions gathered together in one place.
36
* <p>
37
* @author Richard Caley <rjc@cstr.ed.ac.uk>
38
* @version $Id: EST_inline_utils.h,v 1.3 2004/05/04 00:00:17 awb Exp $
39
*/
40
41
//@{
42
43
#ifndef __EST_INLINE_UTILS_H__
44
#define __EST_INLINE_UTILS_H__
45
46
/// Round to nearest integer
47
static
inline
int
irint(
float
f) {
return
(
int
)(f+0.5); }
48
/// Round to nearest integer
49
static
inline
int
irint(
double
f) {
return
(
int
)(f+0.5); }
50
/// Round to nearest integer
51
static
inline
int
srint(
float
f) {
return
(
short
)(f+0.5); }
52
/// Round to nearest integer
53
static
inline
int
srint(
double
f) {
return
(
short
)(f+0.5); }
54
/// Round down
55
static
inline
int
ifloor(
float
f) {
return
(
int
)(f); }
56
/// Round up
57
static
inline
int
iceil(
float
f) {
return
(
int
)(f+0.9999999); }
58
59
/// Smaller of two ints
60
static
inline
int
min(
int
a,
int
b) {
return
(a<b)?a:b; }
61
/// Larger of two ints
62
static
inline
int
max(
int
a,
int
b) {
return
(a>b)?a:b; }
63
/// Smaller of two floats
64
static
inline
float
min(
float
a,
float
b) {
return
(a<b)?a:b; }
65
/// Larger of two floats
66
static
inline
float
max(
float
a,
float
b) {
return
(a>b)?a:b; }
67
/// Smaller of two doubles
68
static
inline
double
min(
double
a,
double
b) {
return
(a<b)?a:b; }
69
/// Larger of two doubles
70
static
inline
double
max(
double
a,
double
b) {
return
(a>b)?a:b; }
71
72
/// Absolute value.
73
static
inline
short
absval(
short
n) {
return
n<0?-n:n; }
74
/// Absolute value.
75
static
inline
int
absval(
int
n) {
return
n<0?-n:n; }
76
/// Absolute value.
77
static
inline
float
absval(
float
n) {
return
n<0.0?-n:n; }
78
/// Absolute value.
79
static
inline
double
absval(
double
n) {
return
n<0.0?-n:n; }
80
81
#endif
82
//@}
include
EST_inline_utils.h
Generated on Wed Dec 24 2014 09:16:35 for Edinburgh Speech Tools by
1.8.3.1