612 {
613 int i_ret = 1;
614
615 if (x < xmin) {
616 i_ret = 0;
617 n1 = 0;
618 n2 = 1;
619 b1 = xmin;
620#ifndef TLINE_REDUCE_TO_RAW_ARR
621 b2 = (*amesh)[1];
622#else
623 b2 = amesh[1];
624#endif
625 } else if (x >= xmax) {
626 i_ret = 2;
627 n1 = q - 2;
628 n2 = q - 1;
629#ifndef TLINE_REDUCE_TO_RAW_ARR
630 b1 = (*amesh)[q - 2];
631#else
632 b1 = amesh[q - 2];
633#endif
634 b2 = xmax;
635 } else {
636#ifndef TLINE_REDUCE_TO_RAW_ARR
637 if (n_old >= 0 && x_old <= x) {
638 n1 = t_find_interval_end<T, D>(x, q, *amesh, n_old);
639 } else {
640 n1 = t_find_interval<T, D>(x, q, *amesh);
641 }
642
643#else
644 if (n_old >= 0 && x_old <= x) {
645 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
646 } else {
647 n1 = t_find_interval<T, T*>(x, q, amesh);
648 }
649
650#endif
651 n2 = n1 + 1;
652#ifndef TLINE_REDUCE_TO_RAW_ARR
653 b1 = (*amesh)[n1];
654 b2 = (*amesh)[n2];
655#else
656 b1 = amesh[n1];
657 b2 = amesh[n2];
658#endif
659 if (n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax ||
660 b2 < xmin || b2 > xmax) {
661 mcerr <<
"ERROR in PointCoorMesh<T,D>::get_interval:\n"
662 << "n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > "
663 "xmax || b2 < xmin || b2 > xmax\n";
667 }
668 n_old = n1;
670 }
671 return i_ret;
672}