python - 如何在python中对LCSS使用递归
问题描述
长CSS
我的代码
def Distance(P1,P2,R=6378137):#
lon1=P1[1];lon2=P2[1]
lat1=P1[0];lat2=P2[0]
dist = R*math.acos(1-(math.pow((math.sin((90-lat1)*math.pi/180)*math.cos(lon1*math.pi/180)-math.sin((90-lat2)*math.pi/180)*math.cos(lon2*math.pi/180)),2)\
+math.pow((math.sin((90-lat1)*math.pi/180)*math.sin(lon1*math.pi/180)-math.sin((90-lat2)*math.pi/180)*math.sin(lon2*math.pi/180)),2)\
+math.pow((math.cos((90-lat1)*math.pi/180)-math.cos((90-lat2)*math.pi/180)),2))/2)
return round(dist,2)
def LCSS(A,B,e=500,f=5):
if len(A)*len(B)==0:
return 0
elif Disance(A[-1],B[-1)<e and abs(len(A)-len(B))<f:
return LCSS()+1
else:
return max(LCSS(A[:-1],B),LCSS(A,B[:-1]))
问题
我不知道 LCSS 的功能,因为该功能一直在我的代码中运行,而不是返回 N(int) < max(len(A),len(B))。
谢谢!
解决方案
推荐阅读
- c++ - 打印每个 c++ 对象
- c++ - Qt3D:如何给线条上色?
- google-apps-script - 在 Google Apps 脚本中运行多个函数
- oracle - 在 Oracle 中运行存储过程时出错 - 无法打印游标
- postgresql - 在 postgres dockerfile 上运行 psql
- apache-kafka - Kafka Streams - 为什么没有 GlobalKStream?
- javascript - vueJs中如何获取vue元素调用方法
- javascript - 通过 Javascript 和 EWS 在 Outlook 缓存模式下设置 HTML
- security - Maximo 7.6 隐藏或屏蔽两个特定用户的多个安全组
- if-statement - 事件触发器根据 2 列中的值将行移动到另外两个工作表之一