27 const google::protobuf::RepeatedField<double>& input_vector,
28 const google::protobuf::RepeatedField<double>& output_vector) {
29 int input_size = input_vector.size();
30 int output_size = output_vector.size();
32 ADEBUG <<
"input_size is " << input_size <<
", output_size is " << output_size;
33 if (input_size < 1 || output_size < 1) {
34 AERROR <<
"1d interpolation: vector size is 0";
36 }
else if (input_size != output_size) {
37 AERROR <<
"1d interpolation: vector size is wrong"
38 <<
", input_size: " << input_size <<
", output_size: " << output_size;
42 if (value <= input_vector.Get(0)) {
43 ADEBUG <<
"return the output_vector.Get(0)";
44 return output_vector.Get(0);
45 }
else if (value >= input_vector.Get(input_size - 1)) {
46 ADEBUG <<
"return the output_vector.Get(input_size - 1)";
47 return output_vector.Get(input_size - 1);
50 for (
int i = 1; i < input_size; ++i) {
51 if (value >= input_vector.Get(i - 1) && value < input_vector.Get(i)) {
52 ADEBUG <<
"return the interpolation_1d";
53 return output_vector.Get(i - 1)
54 + (output_vector.Get(i) - output_vector.Get(i - 1)) * (value - input_vector.Get(i - 1))
55 / (input_vector.Get(i) - input_vector.Get(i - 1));
59 AERROR <<
"1d interpolation: something is wrong";