在快速排序实现中,左边的数据用于纯-O2优化代码,右边的数据是-O2带有-fno-optimize-sibling-calls标志的优化代码, 即关闭尾调用优化.这是3次不同运行的平均值,变化似乎可以忽略不计.值的范围为1-1000,时间以毫秒为单位.编译器是MinGW g ++,版本6.3.0.
size of array with TLO(ms) without TLO(ms)
8M 35,083 34,051
4M 8,952 8,627
1M 613 609
Run Code Online (Sandbox Code Playgroud)
以下是我的代码:
#include <bits/stdc++.h>
using namespace std;
int N = 4000000;
void qsort(int* arr,int start=0,int finish=N-1){
if(start>=finish) return ;
int i=start+1,j = finish,temp;
auto pivot = arr[start];
while(i!=j){
while (arr[j]>=pivot && j>i) --j;
while (arr[i]<pivot && i<j) ++i;
if(i==j) break;
temp=arr[i];arr[i]=arr[j];arr[j]=temp; //swap big guy to right side
}
if(arr[i]>=arr[start]) --i;
temp = arr[start];arr[start]=arr[i];arr[i]=temp; //swap pivot …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 SelectionPolygonVolume 对象裁剪 Open3d 点云。在 Open3d 的 github教程上,SelectionPolygonVolume 是通过调用
从json 文件vol = o3d.visualization.read_selection_polygon_volume("../../TestData/Crop/cropped.json")
构建对象来创建的。
我可以让它运行良好,但如果不先从 json 文件加载它,就无法生成 SelectionPolygonVolume。没有json文件怎么实例化类呢?我浏览了所有文档和在线,但找不到任何东西。
到目前为止,这是我尝试过的:
bounding_polygon = np.array([
[ 2.6509309513852526, 0.0, 1.6834473132326844 ],
...
[ 2.6579576128816544, 0.0, 1.6819127849749496 ]]).astype("float64")
vol = o3d.visualization.SelectionPolygonVolume()
vol.orthogonal_axis = "Y"
vol.axis_max = 4.022921085357666
vol.axis_min = -0.76341366767883301
vol.bounding_polygon = bounding_polygon
Run Code Online (Sandbox Code Playgroud)
但它会引发以下错误(调用时vol.bounding_polygon = bounding_polygon):
TypeError: (): incompatible function arguments. The following argument types are supported:
1. (self: open3d.open3d.visualization.SelectionPolygonVolume, arg0: open3d.open3d.utility.Vector3dVector) -> None
Invoked with: visualization::SelectionPolygonVolume, access its …Run Code Online (Sandbox Code Playgroud)