我一直在审查算法,这是Anany Levitin的算法书中的问题。
您在实线上有n个打开间隔(a1,b1),...,(an,bn)的列表。(一个开放区间(a,b)严格包含其端点a和b之间的所有点,即(a,b)=(xi a <x <b}。)找出这些区间中具有共同点的最大数目例如,对于时间间隔(1、4),(0、3),(-1.5、2),(3.6、5),此最大数为3。为此问题设计一种算法,其算法优于二次方程时间效率。
任何人都可以帮助我为它形成算法或在互联网上建议任何资源。
谢谢,哈琳德拉
$$
在 NASM 中定义为当前段地址。但它的真正含义是什么?我写了两个asm
文件来测试它:
a.asm
extern another
[section .text]
global _start
_start:
mov ebx, $$
call another
Run Code Online (Sandbox Code Playgroud)
b.asm
[section .text]
global another
another:
mov eax, $$
ret
Run Code Online (Sandbox Code Playgroud)
编译
nasm -f elf a.asm -g
nasm -f elf b.asm -g
ld -o test a.o b.o
Run Code Online (Sandbox Code Playgroud)
使用gdb调试最终文件test
,我发现虽然我定义了两个同名的section,但$$
两个文件中的不同。所以我猜:
$$
就是该段的起始地址。与$$
所谓的段寄存器(cs、ss、fs、gs、.etc)无关。如果我在其他文件中定义了同名的另一个部分,它会被解释为不同的部分。但是如果在同一个文件中定义了两个同名段,无论它们之间是否存在其他段定义,它总是被解释为同一个段,具有相同的$$
值。如下,这两个.text
部分是一样的。
[section .text]
global _start
_start:
mov ebx, $$
[section .d]
d:
mov ecx, $$
[section .text]
another:
mov eax, …
Run Code Online (Sandbox Code Playgroud)我正在尝试基于两个给定点和描述圆弧段的给定高度绘制弧.为了实现这一点,我将使用java.awt.Graphics中的以下方法.
drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Run Code Online (Sandbox Code Playgroud)
首先,我观察到x,y,width和height值描述了一个包含圆的矩形.
弧的中心是矩形的中心,其原点是(x,y),其大小由width和height参数指定.(http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html)
首先,我首先计算x,y,width和height值.下图描述了我将如何做到这一点.
第一张照片显示了我已经获得的价值.第一张照片中的弧线正是我想要绘制的.在图片二中,我计算了两点之间一条线的长度.我执行此步骤的代码如下所示:
int dx = p1.x- p2.x;
int dy = p1.y - p2.y;
double len = Math.sqrt(Math.pow((double)dx, 2) + Math.pow((double)dy, 2));
Run Code Online (Sandbox Code Playgroud)
如图3所示,我现在可以使用以下函数计算圆的半径.
radius = h/2 + len^2 / 8h
Run Code Online (Sandbox Code Playgroud)
我遇到的第一个问题是计算圆的中心点.这部分是我需要帮助的地方.
如果我要计算中心点,我可以很容易地找到x,y,whith和height坐标.
x = centerPoint.x - radius;
y = centerPoint.y - radius;
width = radius * 2;
height = radius * 2;
Run Code Online (Sandbox Code Playgroud)
最后一部分是根据我们已经计算过的值计算startAngle和arcAngle.
TL; DR我需要帮助计算角度和中心点.
提前致谢!
如果MPD文件没有任何段URL列表,如何确定DASH介质的段数?它只有一个段模板,因此我不知道与该MPD关联的媒体有多少段.这是我正在谈论的MPD:
<MPD type="static" xmlns="urn:mpeg:DASH:schema:MPD:2011" profiles="urn:mpeg:dash:profile:full:2011" minBufferTime="PT1.5S" mediaPresentationDuration="PT0H1M59.89S">
<ProgramInformation moreInformationURL="http://gpac.sourceforge.net">
<Title>Media Presentation Description for file hdworld_0696kbps_ffmpeg_track1.mp4 generated with GPAC </Title>
</ProgramInformation>
<Period start="PT0S" duration="PT0H1M59.89S">
<AdaptationSet>
<ContentComponent id="1" contentType="video"/>
<SegmentTemplate initialization="/$Bandwidth$/hdworld_ffmpeg_track1_dash.mp4" timescale="1000" duration="4920" media="/$Bandwidth$/hdworld_ffmpeg_track1_$Number$.m4s" startNumber="1"/>
<Representation id="1" mimeType="video/mp4" codecs="avc1.64001f" width="1280" height="720" startWithSAP="1" bandwidth="534343"/>
<Representation id="2" mimeType="video/mp4" codecs="avc1.64001f" width="1280" height="720" startWithSAP="1" bandwidth="812553"/>
<Representation id="3" mimeType="video/mp4" codecs="avc1.64001f" width="1280" height="720" startWithSAP="1" bandwidth="1607692"/>
</AdaptationSet>
<AdaptationSet>
<ContentComponent id="2" contentType="audio" lang="und"/>
<SegmentTemplate initialization="/audio/HDWorld_audio_init.mp4"/>
<Representation id="6" mimeType="audio/mp4" codecs="mp4a.40.02" sampleRate="44100" numChannels="2" lang="und" startWithSAP="1" bandwidth="257141">
<SegmentTemplate timescale="1000" duration="9980" media="/audio/hdworld_seg_audio$Number$.m4s" startNumber="1"/>
</Representation> …
Run Code Online (Sandbox Code Playgroud) 我正在使用tf.unsorted_segment_sum
TensorFlow的方法,当我作为数据给出的张量只有一行时,它工作正常。例如:
tf.unsorted_segment_sum(tf.constant([0.2, 0.1, 0.5, 0.7, 0.8]),
tf.constant([0, 0, 1, 2, 2]), 3)
Run Code Online (Sandbox Code Playgroud)
给出正确的结果:
array([ 0.3, 0.5 , 1.5 ], dtype=float32)
Run Code Online (Sandbox Code Playgroud)
问题是,如果我使用多行的张量,我怎样才能得到每一行的结果?例如,如果我尝试使用两行张量:
tf.unsorted_segment_sum(tf.constant([[0.2, 0.1, 0.5, 0.7, 0.8],
[0.2, 0.2, 0.5, 0.7, 0.8]]),
tf.constant([[0, 0, 1, 2, 2],
[0, 0, 1, 2, 2]]), 3)
Run Code Online (Sandbox Code Playgroud)
我期望的结果是:
array([ [ 0.3, 0.5 , 1.5 ], [ 0.4, 0.5, 1.5 ] ], dtype=float32)
Run Code Online (Sandbox Code Playgroud)
但我得到的是:
array([ 0.7, 1. , 3. ], dtype=float32)
Run Code Online (Sandbox Code Playgroud)
我想知道是否有人知道如何在不使用 for 循环的情况下获取每一行的结果?
提前致谢
我需要在Android中使用分段控件.是否有相同的默认控件?什么是最好和最有效的方法呢?
我试图在 Python 3 中使用 OpenCV4 库中的 FastLineDetector 来检测图像中的线条和段,但似乎没有办法让它工作。我在这里阅读了文档:https : //docs.opencv.org/3.4/df/d4c/classcv_1_1ximgproc_1_1FastLineDetector.html对我来说仍然没有什么清楚。我已经安装了 OpenCV 4.1.0,并且在 Ubuntu 18.0.4 中运行 Python 3.6。
这是我单独尝试过的代码:
img = cv2.imread('/tmp/output0.png', cv2.CV_8UC1)
fld = cv2.ximgproc_FastLineDetector.detect(img)
Run Code Online (Sandbox Code Playgroud)
fld = cv2.ximgproc_FastLineDetector.detect(cv2.ximgproc_FastLineDetector(img))
fld.detect(img)
Run Code Online (Sandbox Code Playgroud)
以下是输出错误:
fld = cv2.ximgproc_FastLineDetector.detect(img)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: descriptor 'detect' requires a 'cv2.ximgproc_FastLineDetector' object but received a 'numpy.ndarray'
Run Code Online (Sandbox Code Playgroud)
fld = cv2.ximgproc_FastLineDetector.detect(cv2.ximgproc_FastLineDetector(img))
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: Incorrect type of self (must be 'ximgproc_FastLineDetector' or …
Run Code Online (Sandbox Code Playgroud) 我正在开发 Flutter 应用程序并尝试向我的应用程序添加一个段。是否可以在 Flutter 中实现它。所以我想为 2 个按钮使用 2 个不同的小部件。类似于 Flutter 中的 TabBar 或原生应用中的 Segment
众所周知,当elasticsearch中更新或删除文档内容时,该段并不会立即删除,而是重新创建。
之后,我们知道片段是通过时间表合并的。
我知道它之所以这样工作是因为它很昂贵。
但我不知道段不可变并且不立即合并的确切原因。
即使我搜索文档也找不到确切的原因,但如果有人知道这一点,请评论。
谢谢。