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