1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef LE_FX_ENGINE_DSP_CORE_BASIC_H_
18#define LE_FX_ENGINE_DSP_CORE_BASIC_H_
19
20#include <limits.h>
21#include "common/core/math.h"
22#include "common/core/types.h"
23
24namespace le_fx {
25
26namespace sigmod {
27
28// Searchs for the interval that contains <x> using a divide-and-conquer
29// algorithm.
30// X[]: a vector of sorted values (X[i+1] > X[i])
31// x:   a value
32// StartIndex: the minimum searched index
33// EndIndex: the maximum searched index
34// returns: the index <i> that satisfies: X[i] <= x <= X[i+1] &&
35//          StartIndex <= i <= (EndIndex-1)
36template <typename T>
37int SearchIndex(const T x_data[],
38                T x,
39                int start_index,
40                int end_index);
41
42}  // namespace sigmod
43
44}  // namespace le_fx
45
46#include "dsp/core/basic-inl.h"
47
48#endif  // LE_FX_ENGINE_DSP_CORE_BASIC_H_
49