我想尝试PyCharm进行鼠尾草数学开发.通常我运行eclipse来进行sage开发,但现在我想用PyCharm尝试它.
要使用sage环境变量启动eclipse,在命令行中我通常会执行以下操作:
sage -sh
cd /path/to/eclipse
./eclipse
Run Code Online (Sandbox Code Playgroud)
第一行加载sage环境变量,其余部分启动eclipse.我怎么能为pyCharm做同样的事情?(注意我使用Mac和Ubuntu进行sage开发;上面的命令对两个操作系统都是不可知的)
创建一个总和为X的随机向量(例如X = 1000)非常简单:
import random
def RunFloat():
Scalar = 1000
VectorSize = 30
RandomVector = [random.random() for i in range(VectorSize)]
RandomVectorSum = sum(RandomVector)
RandomVector = [Scalar*i/RandomVectorSum for i in RandomVector]
return RandomVector
RunFloat()
Run Code Online (Sandbox Code Playgroud)
上面的代码创建了一个向量,其值为浮点数,sum为1000.
我很难创建一个简单的函数来创建一个值为整数且和为X的向量(例如X = 1000*30)
import random
def RunInt():
LowerBound = 600
UpperBound = 1200
VectorSize = 30
RandomVector = [random.randint(LowerBound,UpperBound) for i in range(VectorSize)]
RandomVectorSum = 1000*30
#Sanity check that our RandomVectorSum is sensible/feasible
if LowerBound*VectorSize <= RandomVectorSum and RandomVectorSum <= UpperBound*VectorSum:
if sum(RandomVector) == RandomVectorSum:
return …
Run Code Online (Sandbox Code Playgroud) 为了不重写开源库,我想将一串文本视为python 3中的文件.
假设我将文件内容作为字符串:
not_a_file = 'there is a lot of blah blah in this so-called file'
Run Code Online (Sandbox Code Playgroud)
我想把这个变量,即文件的内容,作为一个 类似路径的对象,我可以在python的open()
函数中使用它.
这是一个显示我的困境的简单例子:
not_a_file = 'there is a lot of blah blah in this so-called file'
file_ptr = open(not_a_file, 'r')
Run Code Online (Sandbox Code Playgroud)
显然,该示例不起作用,因为not_a_file
它不是类似路径的对象.我不想编写文件,也不想为了可移植性目的创建任何临时目录.
话虽如此,我需要解决这个谜团:
not_a_file = 'there is a lot of blah blah in this so-called file'
... Something goes here ...
file_ptr = open(also_not_a_file, 'r')
Run Code Online (Sandbox Code Playgroud)
我已经研究过StringIO并尝试将其用作路径式对象并且没有骰子:
import StringIO
output = StringIO.StringIO()
output.write('First line.\n')
file_ptr = open(output,'r') …
我希望能够计算
g^x = g * g * g * ... * g (x times)
Run Code Online (Sandbox Code Playgroud)
其中 g 位于有限域 GF(2^m) 中。这里 m 相当大,m = 256、384、512 等,因此查找表不是解决方案。我知道有类似想法的快速算法,modpow for Z/nZ(参见HAC第 619-620 页)。
备注:这是我在 math.stackoverflow.com 上的帖子,我认为这是提出这个问题的最佳社区。
multiplication polynomial-math exponentiation galois-field finite-field
我一直在寻找解决方案。当然,这些链接可以暗示一件事或另一件事:
致命错误:sys / socket.h:32位上没有此类文件或目录
和其他类似的链接。
让我给你错误,相关的Makefile语句,并告诉我我的包含目录结构。
错误
gcc -o obj/nmlflpth.o -std=c99 -Ilarc/include -Ilarc/modules/include -Ilarc/milesup -Ilarc/pftk -Ilarc/npsol -Ilarc/src -Ilarc/uih -Ilarc/util -Ilarc/uopt -Ilarc/pgm -Ilarc/navlrc -Ilarc/modules/production/common -Ilarc/src_test -Ilarc/gtest/include -c -O2 larc/uih/nmlflpth.c
larc/uih/nmlflpth.c:48:23: fatal error: sys\types.h: No such file or directory
#include <sys\types.h>
Run Code Online (Sandbox Code Playgroud)
相关的Makefile语句
# list of all dirs with compilable C, C++ and F77 code
dirs := larc/milesup \
larc/pftk \
larc/npsol \
larc/src \
larc/uih \
larc/util \
larc/uopt \
larc/pgm \
larc/navlrc \
larc/modules/production/common
# …
Run Code Online (Sandbox Code Playgroud) python ×3
c ×1
command-line ×1
compilation ×1
finite-field ×1
galois-field ×1
io ×1
list ×1
makefile ×1
pycharm ×1
random ×1
sage ×1
string ×1