[英]On finding the index of the first >= element
Given an ordered list A
of integers, and an integer q <= A[-1]
, I want to find the smallest non-negative index i
such that A[i] >= q
. 给定整数的有序列表A
和整数q <= A[-1]
,我想找到最小的非负索引i
,使得A[i] >= q
。
I can think of ways to do this efficiently (eg with some form of binary search), but I'd like to know if there's anything in either Python's standard library or in numpy/scipy that I can use to implement this. 我可以考虑有效地执行此操作的方法 (例如,使用某种形式的二进制搜索),但是我想知道Python的标准库或numpy / scipy中是否有任何可用于实现此功能的内容。
(For example, something analogous to MATLAB's interp1
function.) (例如,类似于MATLAB的interp1
函数。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.