我正在使用python进行天文图像处理,并且numpy.std(a)正在消耗过多的内存.一些搜索显示了Luis Pedro的ncreduce软件包,但是我很难构建here软件包的下载.ActiveState似乎表明该软件包不能在Windows上构建.我正在使用Win...

我正在使用python进行天文图像处理,并且numpy.std(a)正在消耗过多的内存.一些搜索显示了Luis Pedro的ncreduce软件包,但是我很难构建here软件包的下载.ActiveState似乎表明该软件包不能在Windows上构建.我正在使用Windows 7和Python 2.7.
是否可以在Windows上使用ncreduce?如果不是,是否有替代的快速算法来计算标准偏差或方差,而不像numpy.std(a)那样耗费内存?
解决方法:
该软件包需要一些小的更改才能使用msvc构建.它已经很老了,没有测试,所以使用后果自负.
--- ncreduce/reduce.cpp Thu Aug 14 13:02:50 2008
+++ ncreduce/reduce.cpp Thu Sep 26 11:56:04 2013
@@ -6,6 +6,7 @@
#include <iterator>
#include <vector>
#include <cmath>
+#include <limits>
extern "C" {
#include <Python.h>
#include <numpy/ndarrayobject.h>
@@ -98,7 +99,7 @@
}
*result /= N;
if (extra.is_std) {
- *result = std::sqrt(*result);
+ *result = std::sqrt((double)(*result));
}
}
@@ -142,7 +143,7 @@
for (unsigned i = 0; i != result.diameter(); ++i) {
first_result[i] = divide(first_result[i],ArrSize/result.diameter());
if (extra.is_std) {
- first_result[i] = sqrt(first_result[i]);
+ first_result[i] = sqrt((double)first_result[i]);
}
}
--- setup.py Thu Aug 14 13:54:48 2008
+++ setup.py Thu Sep 26 12:03:16 2013
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from numpy.distutils.core import setup, Extension
-ncreduce = Extension('ncreduce', sources = ['ncreduce/reduce.cpp', 'ncreduce/numpy_utils.hpp'], extra_compile_args=['-Wno-sign-compare'])
+ncreduce = Extension('ncreduce', sources = ['ncreduce/reduce.cpp', 'ncreduce/numpy_utils.hpp'], extra_compile_args=['/EHsc'])
classifiers = [
'Development Status :: 4 - Beta',
我把二进制数设为http://www.lfd.uci.edu/~gohlke/pythonlibs/.搜索ncreduce.
沃梦达教程
本文标题为:c-适用于Windows的python ncreduce


基础教程推荐
猜你喜欢
- Python随机采样及概率分布(二) 2023-08-11
- 用Python每天自动给女友免费发短信 2023-08-09
- Python爬取当网书籍数据并数据可视化展示 2023-08-11
- Python遗传算法Geatpy工具箱使用介绍 2022-10-20
- Python实现字符串匹配算法代码示例_python_脚本之家 2023-09-04
- Ubuntu18.04安装Python虚拟环境 2023-09-03
- Python中最神秘missing()函数介绍 2023-08-09
- 通过OpenCV实现对指定颜色的物体追踪 2023-08-11
- Python中并发、进程、线程的总结 2023-09-03
- Windows 下update pip 报错:Cannot remove entries from nonexistent file c:\intelpython3\lib\site-packa 2023-09-04