651 {
652 int i_ret = 1;
653
654 if (x < xmin) {
655 i_ret = 0;
656 n1 = 0;
657 n2 = 1;
658 b1 = xmin;
659#ifndef TLINE_REDUCE_TO_RAW_ARR
660 b2 = (*amesh)[1];
661#else
662 b2 = amesh[1];
663#endif
664 } else if (x >= xmax) {
665 i_ret = 2;
666 n1 = q - 2;
667 n2 = q - 1;
668#ifndef TLINE_REDUCE_TO_RAW_ARR
669 b1 = (*amesh)[q - 2];
670#else
671 b1 = amesh[q - 2];
672#endif
673 b2 = xmax;
674 } else {
675#ifndef TLINE_REDUCE_TO_RAW_ARR
676 if (n_old >= 0 && x_old <= x) {
677 n1 = t_find_interval_end<T, D>(x, q, *amesh, n_old);
678 } else {
679 n1 = t_find_interval<T, D>(x, q, *amesh);
680 }
681
682#else
683 if (n_old >= 0 && x_old <= x) {
684 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
685 } else {
686 n1 = t_find_interval<T, T*>(x, q, amesh);
687 }
688
689#endif
690 n2 = n1 + 1;
691#ifndef TLINE_REDUCE_TO_RAW_ARR
692 b1 = (*amesh)[n1];
693 b2 = (*amesh)[n2];
694#else
695 b1 = amesh[n1];
696 b2 = amesh[n2];
697#endif
698 if (n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax ||
699 b2 < xmin || b2 > xmax) {
700 mcerr <<
"ERROR in PointCoorMesh<T,D>::get_interval:\n"
701 << "n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > "
702 "xmax || b2 < xmin || b2 > xmax\n";
706 }
707 n_old = n1;
708 x_old = x;
709 }
710 return i_ret;
711
712}