我还没有达到我拥有工具(或者知道如何开发或使用它们)的水平,用于测试和分析看似简单的事情,比如我的问题,所以我转向你.
我有一个检查条件的函数,并根据该条件选择最好的数学工具(不同的模块)但这个函数应用于数组的窗口,因此循环.从一个窗口到另一个窗口可能会发生不同的导入,但这让我想知道导入是否实际上是循环的,如果这是一个性能问题.
以下是matplotlib源代码的示例
def pause(interval):
"""
Pause for *interval* seconds.
If there is an active figure it will be updated and displayed,
and the GUI event loop will run during the pause.
If there is no active figure, or if a non-interactive backend
is in use, this executes time.sleep(interval).
This can be used for crude animation. For more complex
animation, see :mod:`matplotlib.animation`.
This function is experimental; its behavior may be changed
or extended in a future release.
"""
backend = …Run Code Online (Sandbox Code Playgroud) 标题可能含糊不清,不知道怎么说出来.
我使用numpy和matplotlib在python中使用我的粒子模拟器有点远,我已经设法实现coloumb,重力和风,现在我只想添加温度和压力但我有一个预优化问题(所有邪恶的根源) ).我想看看粒子崩溃的时候:
问:基于bool条件,是否可以将数组与每个自己的元素区分开来?我想避免循环.
例如:(x - any element in x) < a
应该返回类似的东西
[True, True, False, True]
Run Code Online (Sandbox Code Playgroud)
如果x中的元素0,1和3满足条件.
编辑:
循环等价将是:
for i in len(x):
for j in in len(x):
#!= not so important
##earlier question I asked lets me figure that one out
if i!=j:
if x[j] - x[i] < a:
True
Run Code Online (Sandbox Code Playgroud)
我注意到numpy操作比测试快得多,这有助于我加速ALOT.
这是一个示例代码,如果有人想玩它.
#Simple circular box simulator, part of part_sim
#Restructure to import into gravity() or coloumb () or wind() or pressure()
#Or to use all forces: …Run Code Online (Sandbox Code Playgroud) 做一个类型的数学函数def.
def integral_error(integral,f):
------stufff-------
print integral
Run Code Online (Sandbox Code Playgroud)
给出类似的东西: '<function simpsons at 0xb7370a74>'
有没有办法让辛普森一家没有字符串操作?即只是功能名称?
问题出在一条线上.图书馆清楚地说随机有一个类型mt19337.
#include <random>
class Util{
std::mt19337 generator;
};
Run Code Online (Sandbox Code Playgroud)
用g ++ -std = c ++ 11 -c util.cpp编译
输出是
util.cpp:4:7: error: ‘mt19337’ in namespace ‘std’ does not name a type
std::mt19337 generator;
^
Run Code Online (Sandbox Code Playgroud)
G ++配置
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.9.2-0ubuntu1~14.04' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 …Run Code Online (Sandbox Code Playgroud)