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